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

Unified Diff: frog/leg/ssa/closure.dart

Issue 9351020: Implement try/catch without finally, and without type checks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 10 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 | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/ssa/closure.dart
===================================================================
--- frog/leg/ssa/closure.dart (revision 4024)
+++ frog/leg/ssa/closure.dart (working copy)
@@ -44,10 +44,13 @@
// contain any nested closure.
final Map<Node, ClosureScope> capturingScopes;
+ final Set<Element> usedVariablesInTry;
+
ClosureData(this.globalizedClosureElement, this.callElement)
: this.freeVariableMapping = new Map<Element, Element>(),
this.capturedFieldMapping = new Map<Element, Element>(),
- this.capturingScopes = new Map<Node, ClosureScope>();
+ this.capturingScopes = new Map<Node, ClosureScope>(),
+ this.usedVariablesInTry = new Set<Element>();
}
Map<Node, ClosureData> _closureDataCache;
@@ -62,6 +65,7 @@
final Compiler compiler;
final TreeElements elements;
int boxCounter = 0;
+ bool inTryCatchOrFinally = false;
// Map of captured variables. Initially they will map to themselves. If
// a variable needs to be boxed then the scope declaring the variable
@@ -147,6 +151,9 @@
assert(closureData.freeVariableMapping[element] == null ||
closureData.freeVariableMapping[element] == element);
closureData.freeVariableMapping[element] = element;
+ } else if (inTryCatchOrFinally) {
+ // TODO(ngeoffray): only do this if the variable is mutated.
+ closureData.usedVariablesInTry.add(element);
}
}
@@ -307,4 +314,11 @@
declareLocal(elements[node]);
}
}
+
+ visitTryStatement(TryStatement node) {
+ // TODO(ngeoffray): implement finer grain state.
+ inTryCatchOrFinally = true;
+ node.visitChildren(this);
+ inTryCatchOrFinally = false;
+ }
}
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698