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

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

Issue 2949293002: Add ScopeInfo class for variable information that doesn't actually involve closures. (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
Index: pkg/compiler/lib/src/kernel/closure.dart
diff --git a/pkg/compiler/lib/src/kernel/closure.dart b/pkg/compiler/lib/src/kernel/closure.dart
index 9354ae3c29280f351abcde25a64792e1cb9b5ab2..b8b9467c51177088f2593a1fc92621ed7406c04a 100644
--- a/pkg/compiler/lib/src/kernel/closure.dart
+++ b/pkg/compiler/lib/src/kernel/closure.dart
@@ -44,14 +44,14 @@ class KernelClosureDataBuilder extends ir.Visitor {
@override
visitVariableGet(ir.VariableGet node) {
if (_inTry) {
- info.registerUsedInTryOrSync(_localsMap.getLocal(node.variable));
+ info.variablesUsedInTryOrSync.add(_localsMap.getLocal(node.variable));
}
}
@override
visitVariableSet(ir.VariableSet node) {
if (_inTry) {
- info.registerUsedInTryOrSync(_localsMap.getLocal(node.variable));
+ info.variablesUsedInTryOrSync.add(_localsMap.getLocal(node.variable));
}
node.visitChildren(this);
}
@@ -104,6 +104,12 @@ class KernelClosureConversionTask extends ClosureConversionTask<ir.Node> {
return const LoopClosureRepresentationInfo();
}
+ @override
+ ScopeInfo getScopeInfo(Entity entity) {
+ // TODO(efortuna): Specialize this function from the one below.
+ return getClosureRepresentationInfo(entity);
+ }
+
@override
ClosureRepresentationInfo getClosureRepresentationInfo(Entity entity) {
return _infoMap.putIfAbsent(entity, () {
@@ -129,21 +135,15 @@ class KernelClosureConversionTask extends ClosureConversionTask<ir.Node> {
// [ClosureRepresentationInfo].
class KernelClosureRepresentationInfo extends ClosureRepresentationInfo {
final ThisLocal thisLocal;
- final Set<Local> _localsUsedInTryOrSync = new Set<Local>();
+ final Set<Local> variablesUsedInTryOrSync = new Set<Local>();
KernelClosureRepresentationInfo(this.thisLocal);
- void registerUsedInTryOrSync(Local local) {
- _localsUsedInTryOrSync.add(local);
- }
-
- bool variableIsUsedInTryOrSync(Local variable) =>
- _localsUsedInTryOrSync.contains(variable);
-
String toString() {
StringBuffer sb = new StringBuffer();
sb.write('this=$thisLocal,');
- sb.write('localsUsedInTryOrSync={${_localsUsedInTryOrSync.join(', ')}}');
+ sb.write(
+ 'variablesUsedInTryOrSync={${variablesUsedInTryOrSync.join(', ')}}');
return sb.toString();
}
}

Powered by Google App Engine
This is Rietveld 408576698