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

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: 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') | tests/co19/co19-leg.status » ('J')
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 1d2a16ed5112c41ab394030e28592ae26301e0f0..e2900ef3fbc59dc3788b41696d4de47502d5393c 100644
--- a/frog/leg/ssa/builder.dart
+++ b/frog/leg/ssa/builder.dart
@@ -261,6 +261,18 @@ class LocalsHandler {
// treat as if it was a local.
directLocals[element] = parameter;
});
+ if (closureData.thisElement !== null) {
+ // Note that closures, once they are mapped to classes, might have
+ // instance-members that do *not* have any thisElement.
ngeoffray 2012/02/29 12:22:17 Please explain why.
floitsch 2012/02/29 12:35:28 Done.
+ 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;
ngeoffray 2012/02/29 12:22:17 Why is this commented out?
floitsch 2012/02/29 12:35:28 this one is the correct one...
+ updateLocal(closureData.thisElement, thisInstruction);
ngeoffray 2012/02/29 12:22:17 Why do you call updateLocal, and not use directLoc
floitsch 2012/02/29 12:35:28 debug code...
+ }
enterScope(node);
@@ -275,11 +287,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') | tests/co19/co19-leg.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698