Index: pkg/compiler/lib/src/ssa/locals_handler.dart |
diff --git a/pkg/compiler/lib/src/ssa/locals_handler.dart b/pkg/compiler/lib/src/ssa/locals_handler.dart |
index c521f9cf4e88c663ca2834d80fa544c64cac3600..5bacc12de7d9db656e0077b5830b8848751a877c 100644 |
--- a/pkg/compiler/lib/src/ssa/locals_handler.dart |
+++ b/pkg/compiler/lib/src/ssa/locals_handler.dart |
@@ -139,19 +139,24 @@ class LocalsHandler { |
void enterScope(ast.Node node, {bool forGenerativeConstructorBody: false}) { |
// See if any variable in the top-scope of the function is captured. If yes |
// we need to create a box-object. |
- ClosureScope scopeData = closureData.capturingScopes[node]; |
- if (scopeData == null) return; |
+ CapturedVariableInfo scopeData = |
+ _closureToClassMapper.getCapturedVariableInfo(node); |
+ if (!scopeData.hasCapturedVariables()) return; |
+ Local localExecutableContext = |
+ _closureToClassMapper.getExecutableContext(node); |
+ |
HInstruction box; |
// The scope has captured variables. |
if (forGenerativeConstructorBody) { |
// The box is passed as a parameter to a generative |
// constructor body. |
- box = builder.addParameter(scopeData.boxElement, commonMasks.nonNullType); |
+ box = |
+ builder.addParameter(localExecutableContext, commonMasks.nonNullType); |
} else { |
box = createBox(); |
} |
// Add the box to the known locals. |
- directLocals[scopeData.boxElement] = box; |
+ directLocals[localExecutableContext] = box; |
// Make sure that accesses to the boxed locals go into the box. We also |
// need to make sure that parameters are copied into the box if necessary. |
scopeData.forEachCapturedVariable( |
@@ -178,7 +183,7 @@ class LocalsHandler { |
/// Replaces the current box with a new box and copies over the given list |
/// of elements from the old box into the new box. |
void updateCaptureBox( |
- BoxLocal boxElement, List<LocalVariableElement> toBeCopiedElements) { |
+ Local boxElement, List<LocalVariableElement> toBeCopiedElements) { |
// Create a new box and copy over the values from the old box into the |
// new one. |
HInstruction oldBox = readLocal(boxElement); |
@@ -206,11 +211,11 @@ class LocalsHandler { |
if (element is MethodElement) { |
MethodElement functionElement = element; |
FunctionSignature params = functionElement.functionSignature; |
- ClosureScope scopeData = closureData.capturingScopes[node]; |
params.orderedForEachParameter((ParameterElement parameterElement) { |
if (element.isGenerativeConstructorBody) { |
- if (scopeData != null && |
- scopeData.isCapturedVariable(parameterElement)) { |
+ if (_closureToClassMapper |
+ .getCapturedVariableInfo(node) |
+ .isCaptured(parameterElement)) { |
// The parameter will be a field in the box passed as the |
// last parameter. So no need to have it. |
return; |
@@ -477,8 +482,8 @@ class LocalsHandler { |
/// goto loop-entry; |
/// loop-exit: |
void startLoop(ast.Node node) { |
- ClosureScope scopeData = closureData.capturingScopes[node]; |
- if (scopeData == null) return; |
+ CapturedVariableInfo scopeData = |
+ _closureToClassMapper.getCapturedVariableInfo(node); |
if (scopeData.hasBoxedLoopVariables()) { |
// If there are boxed loop variables then we set up the box and |
// redirections already now. This way the initializer can write its |
@@ -512,8 +517,8 @@ class LocalsHandler { |
} |
void enterLoopBody(ast.Node node) { |
- ClosureScope scopeData = closureData.capturingScopes[node]; |
- if (scopeData == null) return; |
+ CapturedVariableInfo scopeData = |
+ _closureToClassMapper.getCapturedVariableInfo(node); |
// If there are no declared boxed loop variables then we did not create the |
// box before the initializer and we have to create the box now. |
if (!scopeData.hasBoxedLoopVariables()) { |
@@ -527,10 +532,11 @@ class LocalsHandler { |
// updates. |
// In all other cases a new box will be created when entering the body of |
// the next iteration. |
- ClosureScope scopeData = closureData.capturingScopes[node]; |
- if (scopeData == null) return; |
+ CapturedVariableInfo scopeData = |
+ _closureToClassMapper.getCapturedVariableInfo(node); |
if (scopeData.hasBoxedLoopVariables()) { |
- updateCaptureBox(scopeData.boxElement, scopeData.boxedLoopVariables); |
+ updateCaptureBox(_closureToClassMapper.getExecutableContext(node), |
+ scopeData.boxedLoopVariables); |
} |
} |