Index: frog/leg/ssa/closure.dart |
=================================================================== |
--- frog/leg/ssa/closure.dart (revision 3986) |
+++ 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; |
floitsch
2012/02/08 10:07:53
we don't care about the try-body. -> inCatchOrFina
ngeoffray
2012/02/08 10:17:17
As discussed, we do care about the try body, becau
|
// 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. |
floitsch
2012/02/08 10:07:53
only do this if the variable is mutated in the try
ngeoffray
2012/02/08 10:17:17
ditto
|
+ closureData.usedVariablesInTry.add(element); |
} |
} |
@@ -307,4 +314,11 @@ |
declareLocal(elements[node]); |
} |
} |
+ |
+ visitTryStatement(TryStatement node) { |
floitsch
2012/02/08 10:07:53
move this code into visitCatch and visitFinally.
ngeoffray
2012/02/08 10:17:17
ditto
|
+ // TODO(ngeoffray): implement finer grain state. |
+ inTryCatchOrFinally = true; |
+ node.visitChildren(this); |
+ inTryCatchOrFinally = false; |
+ } |
} |