Chromium Code Reviews| Index: pkg/compiler/lib/src/closure.dart |
| diff --git a/pkg/compiler/lib/src/closure.dart b/pkg/compiler/lib/src/closure.dart |
| index 93e7bb2c2b87e60d99bc6d8ac0dcad80f3a7c8c9..b72f6a8e3df831d5ec5cf34b1d76342128af3cab 100644 |
| --- a/pkg/compiler/lib/src/closure.dart |
| +++ b/pkg/compiler/lib/src/closure.dart |
| @@ -272,6 +272,7 @@ class SynthesizedCallMethodElementX extends BaseFunctionElementX { |
| ClosureClassElement enclosing) |
| : expression = other, |
| super(name, other.kind, other.modifiers, enclosing, false) { |
| + asyncMarker = other.asyncMarker; |
| functionSignatureCache = other.functionSignature; |
| } |
| @@ -347,7 +348,7 @@ class ClosureClassMap { |
| // contain any nested closure. |
| final Map<Node, ClosureScope> capturingScopes = new Map<Node, ClosureScope>(); |
| - final Set<Local> usedVariablesInTry = new Set<Local>(); |
| + final Set<Local> variablesUsedInTryOrGenerator = new Set<Local>(); |
|
floitsch
2015/02/02 22:00:06
Add comment.
Not every variable in a generator is
sigurdm
2015/02/03 16:59:27
Done.
|
| ClosureClassMap(this.closureElement, |
| this.closureClassElement, |
| @@ -427,6 +428,7 @@ class ClosureTranslator extends Visitor { |
| int closureFieldCounter = 0; |
| int boxedFieldCounter = 0; |
| bool inTryStatement = false; |
| + |
| final Map<Node, ClosureClassMap> closureMappingCache; |
| // Map of captured variables. Initially they will map to `null`. If |
| @@ -589,8 +591,14 @@ class ClosureTranslator extends Visitor { |
| if (variable != closureData.thisLocal && |
| variable != closureData.closureElement) { |
| // TODO(ngeoffray): only do this if the variable is mutated. |
|
floitsch
2015/02/02 22:00:06
We should have an "isEffectivelyFinal" getter on v
sigurdm
2015/02/03 16:59:27
Done.
|
| - closureData.usedVariablesInTry.add(variable); |
| + closureData.variablesUsedInTryOrGenerator.add(variable); |
| } |
| + } else if (variable is LocalParameterElement && |
| + variable.functionDeclaration.asyncMarker == AsyncMarker.SYNC_STAR) { |
| + // Parameters in a sync* function are shared between each Iterator created |
| + // by the Iterable returned by the function, therefore they must be boxed. |
| + // TODO(sigurdm): only do this if the variable is mutated. |
| + closureData.variablesUsedInTryOrGenerator.add(variable); |
| } |
| } |