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

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

Issue 9542001: Fix this capturing in closures. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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 | « no previous file | frog/leg/ssa/closure.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/ssa/builder.dart
diff --git a/frog/leg/ssa/builder.dart b/frog/leg/ssa/builder.dart
index c7da42a91e453aefc16f78f688cbdc7ccefca0b6..a04617bd7dea5271c08f65cb410051d5374aeebf 100644
--- a/frog/leg/ssa/builder.dart
+++ b/frog/leg/ssa/builder.dart
@@ -264,6 +264,18 @@ class LocalsHandler {
// treat as if it was a local.
directLocals[element] = parameter;
});
+ if (closureData.thisElement !== null) {
+ // Once closures have been mapped to classes their instance members might
+ // not have any thisElement if the closure was created inside a static
+ // context.
+ assert(function.isInstanceMember() || function.isGenerativeConstructor());
+ // We have to introduce 'this' before we enter the scope, since it might
+ // need to be copied into a box (if it is captured). This is similar
+ // to all other parameters that are introduced.
+ HInstruction thisInstruction = new HThis();
+ builder.add(thisInstruction);
+ directLocals[closureData.thisElement] = thisInstruction;
+ }
enterScope(node);
@@ -278,11 +290,6 @@ class LocalsHandler {
HInstruction thisInstruction = new HThis();
builder.add(thisInstruction);
updateLocal(closureData.closureElement, thisInstruction);
- } else if (function.isInstanceMember() ||
- function.isGenerativeConstructor()) {
- HInstruction thisInstruction = new HThis();
- builder.add(thisInstruction);
- updateLocal(closureData.thisElement, thisInstruction);
}
}
« no previous file with comments | « no previous file | frog/leg/ssa/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698