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

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

Issue 9378040: Allow self-referencing closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert last update to CL. 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
Index: frog/leg/ssa/builder.dart
diff --git a/frog/leg/ssa/builder.dart b/frog/leg/ssa/builder.dart
index 359e7cd95a50864237fe4af110e85a182d552111..93e5b14216420ed33d3230cb8513db7be0fc0c0f 100644
--- a/frog/leg/ssa/builder.dart
+++ b/frog/leg/ssa/builder.dart
@@ -216,11 +216,10 @@ class LocalsHandler {
new ClosureTranslator(builder.compiler, builder.elements);
closureData = translator.translate(node);
- if (closureData.thisElement !== null &&
- isAccessedDirectly(closureData.thisElement)) {
+ if (closureData.thisElement !== null && !closureData.isClosure()) {
HInstruction thisInstruction = new HThis();
- updateLocal(closureData.thisElement, thisInstruction);
builder.add(thisInstruction);
+ updateLocal(closureData.thisElement, thisInstruction);
}
FunctionParameters params = function.computeParameters(builder.compiler);
@@ -240,6 +239,12 @@ class LocalsHandler {
closureData.freeVariableMapping.forEach((Element from, Element to) {
redirectElement(from, to);
});
+ // Inside closure redirect references to itself to [:this:].
+ if (closureData.isClosure()) {
+ HInstruction thisInstruction = new HThis();
+ builder.add(thisInstruction);
+ updateLocal(closureData.closureElement, thisInstruction);
ngeoffray 2012/02/13 10:13:38 Could you share some code with line 219? It looks
floitsch 2012/02/13 12:03:42 Refactored together.
+ }
}
/**
@@ -1403,8 +1408,7 @@ class SsaBuilder implements Visitor {
visit(node.selector);
closureTarget = pop();
} else {
- assert(element.kind === ElementKind.VARIABLE ||
- element.kind === ElementKind.PARAMETER);
+ assert(Elements.isLocal(element));
closureTarget = localsHandler.readLocal(element);
}
var inputs = <HInstruction>[];

Powered by Google App Engine
This is Rietveld 408576698