Chromium Code Reviews| Index: pkg/analyzer2dart/lib/src/cps_generator.dart |
| diff --git a/pkg/analyzer2dart/lib/src/cps_generator.dart b/pkg/analyzer2dart/lib/src/cps_generator.dart |
| index 60d2335c201499798b7af8265e46b176356cbcec..37afd1cd44ea2216db826b7171bb89a821b5c2af 100644 |
| --- a/pkg/analyzer2dart/lib/src/cps_generator.dart |
| +++ b/pkg/analyzer2dart/lib/src/cps_generator.dart |
| @@ -31,6 +31,8 @@ class CpsGeneratingVisitor extends SemanticVisitor<ir.Node> |
| Source get currentSource => element.source; |
| + analyzer.LibraryElement get currentLibrary => element.library; |
| + |
| ir.Node visit(AstNode node) => node.accept(this); |
| @override |
| @@ -343,4 +345,40 @@ class CpsGeneratingVisitor extends SemanticVisitor<ir.Node> |
| irBuilder.buildWhile(buildCondition: subbuild(node.condition), |
| buildBody: subbuild(node.body)); |
| } |
| + |
| + @override |
| + visitDeclaredIdentifier(DeclaredIdentifier node) { |
| + giveUp(node, "Unexpected node: DeclaredIdentifier"); |
| + } |
| + |
| + @override |
| + visitForEachStatement(ForEachStatement node) { |
| + SubbuildFunction buildVariableDeclaration; |
| + dart2js.Element variableElement; |
| + Selector variableSelector; |
| + if (node.identifier != null) { |
| + AccessSemantics accessSemantics = |
| + node.identifier.accept(ACCESS_SEMANTICS_VISITOR); |
| + if (accessSemantics.kind == AccessKind.DYNAMIC) { |
| + variableSelector = new Selector.getter( |
| + node.identifier.name, converter.convertElement(currentLibrary)); |
|
Paul Berry
2014/11/03 15:05:56
I'm confused. The only situation in which accessS
Johnni Winther
2014/11/04 12:58:53
The selector should have been a setter. Nice catch
|
| + } else { |
| + variableElement = converter.convertElement(accessSemantics.element); |
|
Paul Berry
2014/11/03 15:05:56
This seems like it will break if the variable in t
Johnni Winther
2014/11/04 12:58:53
Yes. We seem to be missing a statically unresolved
|
| + } |
| + } else { |
| + assert(invariant( |
| + node, node.loopVariable != null, "Loop variable expected")); |
| + variableElement = converter.convertElement(node.loopVariable.element); |
| + buildVariableDeclaration = (IrBuilder builder) { |
| + builder.declareLocalVariable(variableElement); |
| + }; |
| + } |
| + // TODO(johnniwinther): Support `for-in` as a jump target. |
| + irBuilder.buildForIn( |
| + buildExpression: subbuild(node.iterable), |
| + buildVariableDeclaration: buildVariableDeclaration, |
| + variableElement: variableElement, |
| + variableSelector: variableSelector, |
| + buildBody: subbuild(node.body)); |
| + } |
| } |