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

Unified Diff: pkg/compiler/lib/src/closure.dart

Issue 2931463002: Revert "Entity-ify some portions of LocalsHandler and Closure." (Closed)
Patch Set: Created 3 years, 6 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 | pkg/compiler/lib/src/ssa/locals_handler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/closure.dart
diff --git a/pkg/compiler/lib/src/closure.dart b/pkg/compiler/lib/src/closure.dart
index 50d827a2591f2d66ab902ce7b82d1d2653ecf4fa..6dacea63154b7b81b3c29e4ce148533d4e327ae1 100644
--- a/pkg/compiler/lib/src/closure.dart
+++ b/pkg/compiler/lib/src/closure.dart
@@ -130,10 +130,15 @@ class ClosureTask extends CompilerTask implements ClosureClassMaps {
}
}
+/// Common interface for [BoxFieldElement] and [ClosureFieldElement] as
+/// non-elements.
+// TODO(johnniwinther): Remove `implements Element`.
+abstract class CapturedVariable implements Element {}
+
// TODO(ahe): These classes continuously cause problems. We need to
// find a more general solution.
class ClosureFieldElement extends ElementX
- implements FieldElement, PrivatelyNamedJSEntity {
+ implements FieldElement, CapturedVariable, PrivatelyNamedJSEntity {
/// The [BoxLocal] or [LocalElement] being accessed through the field.
final Local local;
@@ -290,7 +295,11 @@ class BoxLocal extends Local {
// TODO(ngeoffray, ahe): These classes continuously cause problems. We need to
// find a more general solution.
class BoxFieldElement extends ElementX
- implements TypedElement, FieldElement, PrivatelyNamedJSEntity {
+ implements
+ TypedElement,
+ CapturedVariable,
+ FieldElement,
+ PrivatelyNamedJSEntity {
final BoxLocal box;
BoxFieldElement(String name, this.variableElement, BoxLocal box)
@@ -413,7 +422,7 @@ class ClosureScope {
// If the scope is attached to a [For] contains the variables that are
// declared in the initializer of the [For] and that need to be boxed.
// Otherwise contains the empty List.
- List<Local> boxedLoopVariables = const <Local>[];
+ List<VariableElement> boxedLoopVariables = const <VariableElement>[];
ClosureScope(this.boxElement, this.capturedVariables);
@@ -473,7 +482,8 @@ class ClosureClassMap {
/// Maps free locals, arguments, function elements, and box locals to
/// their locations.
- final Map<Local, FieldEntity> freeVariableMap = new Map<Local, FieldEntity>();
+ final Map<Local, CapturedVariable> freeVariableMap =
+ new Map<Local, CapturedVariable>();
/// Maps [Loop] and [FunctionExpression] nodes to their [ClosureScope] which
/// contains their box and the captured variables that are stored in the box.
@@ -503,7 +513,7 @@ class ClosureClassMap {
return freeVariableMap.containsKey(element);
}
- void forEachFreeVariable(f(Local variable, FieldEntity field)) {
+ void forEachFreeVariable(f(Local variable, CapturedVariable field)) {
freeVariableMap.forEach(f);
}
@@ -520,14 +530,14 @@ class ClosureClassMap {
}
bool isVariableBoxed(Local variable) {
- FieldEntity copy = freeVariableMap[variable];
+ CapturedVariable copy = freeVariableMap[variable];
if (copy is BoxFieldElement) {
return true;
}
return capturingScopesBox(variable);
}
- void forEachCapturedVariable(void f(Local variable, FieldEntity field)) {
+ void forEachCapturedVariable(void f(Local variable, CapturedVariable field)) {
freeVariableMap.forEach((variable, copy) {
if (variable is BoxLocal) return;
f(variable, copy);
« no previous file with comments | « no previous file | pkg/compiler/lib/src/ssa/locals_handler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698