Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: sdk/lib/_internal/compiler/implementation/closure.dart

Issue 24268002: Fix bug in the closure methods, where iterating over the boxed variable did not return the variable… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/closure.dart
===================================================================
--- sdk/lib/_internal/compiler/implementation/closure.dart (revision 27646)
+++ sdk/lib/_internal/compiler/implementation/closure.dart (working copy)
@@ -247,10 +247,6 @@
final Set<Element> usedVariablesInTry;
- // A map from the parameter element to the variable element that
- // holds the sentinel check.
- final Map<Element, Element> parametersWithSentinel;
-
ClosureClassMap(this.closureElement,
this.closureClassElement,
this.callElement,
@@ -258,18 +254,25 @@
: this.freeVariableMapping = new Map<Element, Element>(),
this.capturedFieldMapping = new Map<Element, Element>(),
this.capturingScopes = new Map<Node, ClosureScope>(),
- this.usedVariablesInTry = new Set<Element>(),
- this.parametersWithSentinel = new Map<Element, Element>();
+ this.usedVariablesInTry = new Set<Element>();
bool isClosure() => closureElement != null;
bool isVariableCaptured(Element element) {
- return freeVariableMapping.containsKey(element);
+ return freeVariableMapping.containsKey(element)
+ || capturingScopesBox(element);
}
+ bool capturingScopesBox(Element element) {
+ return capturingScopes.values.any((scope) {
+ return scope.boxedLoopVariables.contains(element);
+ });
+ }
+
bool isVariableBoxed(Element element) {
Element copy = freeVariableMapping[element];
- return copy != null && !copy.isMember();
+ if (copy != null && !copy.isMember()) return true;
+ return capturingScopesBox(element);
}
void forEachCapturedVariable(void f(Element local, Element field)) {
@@ -277,6 +280,9 @@
if (variable is BoxElement) return;
f(variable, copy);
});
+ capturingScopes.values.forEach((scope) {
+ scope.capturedVariableMapping.forEach(f);
+ });
}
void forEachBoxedVariable(void f(Element local, Element field)) {
@@ -284,6 +290,9 @@
if (!isVariableBoxed(variable)) return;
f(variable, copy);
});
+ capturingScopes.values.forEach((scope) {
+ scope.capturedVariableMapping.forEach(f);
+ });
}
void forEachNonBoxedCapturedVariable(void f(Element local, Element field)) {
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/types/simple_types_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698