Chromium Code Reviews| Index: tests/compiler/dart2js/closure/closure_test.dart | 
| diff --git a/tests/compiler/dart2js/closure/closure_test.dart b/tests/compiler/dart2js/closure/closure_test.dart | 
| index 00c7c80ff99acaa37757fdcd6df5c5dbe1ffbb74..a206a1102197b4c8246585e8a6160c7db965b492 100644 | 
| --- a/tests/compiler/dart2js/closure/closure_test.dart | 
| +++ b/tests/compiler/dart2js/closure/closure_test.dart | 
| @@ -95,9 +95,11 @@ class ClosureAstComputer extends AstDataExtractor with ComputeValueMixin { | 
| visitFunctionExpression(ast.FunctionExpression node) { | 
| Entity localFunction = resolvedAst.elements.getFunctionDefinition(node); | 
| if (localFunction is LocalFunctionElement) { | 
| + pushMember(localFunction.callMethod); | 
| pushLocalFunction(node); | 
| super.visitFunctionExpression(node); | 
| popLocalFunction(); | 
| + popMember(); | 
| } else { | 
| super.visitFunctionExpression(node); | 
| } | 
| @@ -107,7 +109,8 @@ class ClosureAstComputer extends AstDataExtractor with ComputeValueMixin { | 
| String computeNodeValue(ast.Node node, [AstElement element]) { | 
| if (element != null && element.isLocal) { | 
| if (element.isFunction) { | 
| - return computeObjectValue(element); | 
| + LocalFunctionElement localFunction = element; | 
| + return computeObjectValue(localFunction.callMethod); | 
| } else { | 
| LocalElement local = element; | 
| return computeLocalValue(local); | 
| @@ -118,7 +121,7 @@ class ClosureAstComputer extends AstDataExtractor with ComputeValueMixin { | 
| } | 
| @override | 
| - String computeElementValue(AstElement element) { | 
| + String computeElementValue(covariant MemberElement element) { | 
| // TODO(johnniwinther,efortuna): Collect data for the member | 
| // (has thisLocal, has box, etc.). | 
| return computeObjectValue(element); | 
| @@ -144,27 +147,36 @@ class ClosureIrChecker extends IrDataExtractor with ComputeValueMixin<ir.Node> { | 
| } | 
| visitFunctionExpression(ir.FunctionExpression node) { | 
| + ClosureRepresentationInfo info = closureDataLookup.getClosureInfo(node); | 
| + pushMember(info.callMethod); | 
| pushLocalFunction(node); | 
| super.visitFunctionExpression(node); | 
| popLocalFunction(); | 
| + popMember(); | 
| } | 
| visitFunctionDeclaration(ir.FunctionDeclaration node) { | 
| + ClosureRepresentationInfo info = closureDataLookup.getClosureInfo(node); | 
| + pushMember(info.callMethod); | 
| pushLocalFunction(node); | 
| super.visitFunctionDeclaration(node); | 
| popLocalFunction(); | 
| + popMember(); | 
| } | 
| @override | 
| String computeNodeValue(ir.Node node) { | 
| if (node is ir.VariableDeclaration) { | 
| if (node.parent is ir.FunctionDeclaration) { | 
| - return computeObjectValue(node.parent); | 
| + ClosureRepresentationInfo info = | 
| + closureDataLookup.getClosureInfo(node.parent); | 
| + return computeObjectValue(info.callMethod); | 
| } | 
| Local local = _localsMap.getLocalVariable(node); | 
| return computeLocalValue(local); | 
| } else if (node is ir.FunctionExpression) { | 
| - return computeObjectValue(node); | 
| + ClosureRepresentationInfo info = closureDataLookup.getClosureInfo(node); | 
| + return computeObjectValue(info.callMethod); | 
| } | 
| return null; | 
| } | 
| @@ -177,10 +189,12 @@ class ClosureIrChecker extends IrDataExtractor with ComputeValueMixin<ir.Node> { | 
| abstract class ComputeValueMixin<T> { | 
| bool get verbose; | 
| + Map<BoxLocal, String> boxNames = <BoxLocal, String>{}; | 
| ClosureDataLookup<T> get closureDataLookup; | 
| Link<ScopeInfo> scopeInfoStack = const Link<ScopeInfo>(); | 
| ScopeInfo get scopeInfo => scopeInfoStack.head; | 
| - CapturedScope capturedScope; | 
| + CapturedScope get capturedScope => capturedScopeStack.head; | 
| + Link<CapturedScope> capturedScopeStack = const Link<CapturedScope>(); | 
| Link<ClosureRepresentationInfo> closureRepresentationInfoStack = | 
| const Link<ClosureRepresentationInfo>(); | 
| ClosureRepresentationInfo get closureRepresentationInfo => | 
| @@ -191,12 +205,17 @@ abstract class ComputeValueMixin<T> { | 
| void pushMember(MemberEntity member) { | 
| scopeInfoStack = | 
| scopeInfoStack.prepend(closureDataLookup.getScopeInfo(member)); | 
| - capturedScope = closureDataLookup.getCapturedScope(member); | 
| + capturedScopeStack = | 
| + capturedScopeStack.prepend(closureDataLookup.getCapturedScope(member)); | 
| + if (capturedScope.hasBox) { | 
| + boxNames[capturedScope.box] = 'box${boxNames.length}'; | 
| + } | 
| dump(member); | 
| } | 
| void popMember() { | 
| scopeInfoStack = scopeInfoStack.tail; | 
| + capturedScopeStack = capturedScopeStack.tail; | 
| } | 
| void pushLocalFunction(T node) { | 
| @@ -240,8 +259,9 @@ abstract class ComputeValueMixin<T> { | 
| if (capturedScope.isBoxed(local)) { | 
| features.add('boxed'); | 
| } | 
| - if (capturedScope.context == local) { | 
| - features.add('local'); | 
| + if (capturedScope.box == local) { | 
| + // TODO(johnniwinther): This can't happen! | 
| 
 
Emily Fortuna
2017/08/22 23:47:37
but this is happening? 
if not... throw?
 
Johnni Winther
2017/08/23 07:47:18
I'm still in the process of making this accurate.
 
 | 
| + features.add('box'); | 
| } | 
| if (capturedScope is CapturedLoopScope) { | 
| CapturedLoopScope loopScope = capturedScope; | 
| @@ -253,22 +273,19 @@ abstract class ComputeValueMixin<T> { | 
| if (closureRepresentationInfo.createdFieldEntities.contains(local)) { | 
| features.add('field'); | 
| } | 
| - if (closureRepresentationInfo.isVariableBoxed(local)) { | 
| - features.add('variable-boxed'); | 
| - } | 
| } | 
| // TODO(johnniwinther,efortuna): Add more info? | 
| return (features.toList()..sort()).join(','); | 
| } | 
| - String computeObjectValue(Object object) { | 
| + String computeObjectValue(MemberEntity member) { | 
| Map<String, String> features = <String, String>{}; | 
| void addLocals(String name, forEach(f(Local local, _))) { | 
| List<String> names = <String>[]; | 
| forEach((Local local, _) { | 
| if (local is BoxLocal) { | 
| - names.add('box'); | 
| + names.add(boxNames[local]); | 
| } else { | 
| names.add(local.name); | 
| } | 
| @@ -276,25 +293,21 @@ abstract class ComputeValueMixin<T> { | 
| String value = names.isEmpty ? null : '[${(names..sort()).join(',')}]'; | 
| if (features.containsKey(name)) { | 
| Expect.equals( | 
| - features[name], value, "Inconsistent values for $name on $object."); | 
| + features[name], value, "Inconsistent values for $name on $member."); | 
| } | 
| features[name] = value; | 
| } | 
| - if (object is MemberEntity) { | 
| - if (scopeInfo.thisLocal != null) { | 
| - features['hasThis'] = ''; | 
| - } | 
| - | 
| - if (capturedScope.requiresContextBox) { | 
| - features['requiresBox'] = ''; | 
| - } | 
| - addLocals('boxed', capturedScope.forEachBoxedVariable); | 
| + if (scopeInfo.thisLocal != null) { | 
| + features['hasThis'] = ''; | 
| + } | 
| + if (capturedScope.hasBox) { | 
| + //print('------------- $object from $capturedScope'); | 
| 
 
Emily Fortuna
2017/08/22 23:47:37
remove commented out line?
 
 | 
| + features['box'] = boxNames[capturedScope.box]; | 
| } | 
| + addLocals('boxed', capturedScope.forEachBoxedVariable); | 
| if (closureRepresentationInfo != null) { | 
| - addLocals('boxed', closureRepresentationInfo.forEachBoxedVariable); | 
| - addLocals('captured', closureRepresentationInfo.forEachCapturedVariable); | 
| addLocals('free', closureRepresentationInfo.forEachFreeVariable); | 
| } |