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

Unified Diff: pkg/compiler/lib/src/js_model/closure.dart

Issue 3009903002: Pass in `this` as a free variable to the closure class (Closed)
Patch Set: merge with master Created 3 years, 4 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: pkg/compiler/lib/src/js_model/closure.dart
diff --git a/pkg/compiler/lib/src/js_model/closure.dart b/pkg/compiler/lib/src/js_model/closure.dart
index 0d9a9df1764227379ffeda3a30605821a994d4bf..b80c91da0b74833d0717d27551bd243671490004 100644
--- a/pkg/compiler/lib/src/js_model/closure.dart
+++ b/pkg/compiler/lib/src/js_model/closure.dart
@@ -253,6 +253,11 @@ class KernelScopeInfo {
/// this scope.
Set<ir.VariableDeclaration> freeVariables = new Set<ir.VariableDeclaration>();
+ /// If true, `this` is used as a free variable, in this scope. It is stored
+ /// separately from [freeVariables] because there is no single
+ /// `VariableDeclaration` node that represents `this`.
+ bool thisUsedAsFreeVariable = false;
+
KernelScopeInfo(this.hasThisLocal)
: localsUsedInTryOrSync = new Set<ir.VariableDeclaration>(),
boxedVariables = new Set<ir.VariableDeclaration>(),
@@ -294,7 +299,11 @@ class JsScopeInfo extends ScopeInfo {
this.localsUsedInTryOrSync =
info.localsUsedInTryOrSync.map(localsMap.getLocalVariable).toSet(),
this.freeVariables =
- info.freeVariables.map(localsMap.getLocalVariable).toSet();
+ info.freeVariables.map(localsMap.getLocalVariable).toSet() {
+ if (info.thisUsedAsFreeVariable) {
+ this.freeVariables.add(this.thisLocal);
+ }
+ }
void forEachBoxedVariable(f(Local local, FieldEntity field)) {
boxedVariables.forEach((Local l, JRecordField box) {

Powered by Google App Engine
This is Rietveld 408576698