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

Unified Diff: pkg/compiler/lib/src/kernel/element_map_impl.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/kernel/element_map_impl.dart
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index 990970ed9756a34b1e3c4cc267466de172bd6e2e..0663f0b757e46ba26b15c5b98d046a37bbc65c69 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -2299,7 +2299,25 @@ class JsKernelToElementMap extends KernelToElementMapBase
member,
cls,
memberMap,
+ localsMap.getLocalVariable(variable),
variable,
+ variable.isConst,
+ !(variable.isFinal || variable.isConst),
+ boxedCapturedVariables,
+ fieldNumber,
+ info.capturedVariablesAccessor,
+ localsMap);
+ fieldNumber++;
+ }
+ if (info.thisUsedAsFreeVariable) {
+ _constructClosureField(
+ member,
+ cls,
+ memberMap,
+ cls.thisLocal,
+ getMemberDefinition(member).node,
+ true,
+ false,
boxedCapturedVariables,
fieldNumber,
info.capturedVariablesAccessor,
@@ -2327,28 +2345,30 @@ class JsKernelToElementMap extends KernelToElementMapBase
MemberEntity member,
KernelClosureClass cls,
Map<String, MemberEntity> memberMap,
- ir.VariableDeclaration variable,
+ Local capturedLocal,
+ ir.TreeNode sourceNode,
+ bool isConst,
+ bool isAssignable,
Map<Local, JRecordField> boxedCapturedVariables,
int fieldNumber,
NodeBox box,
KernelToLocalsMap localsMap) {
- // NOTE: This construction order may be slightly different than the
+ // NOTE: This construction *order* may be slightly different than the
// old Element version. The old version did all the boxed items and then
// all the others.
- Local capturedLocal = localsMap.getLocalVariable(variable);
JRecordField field = boxedCapturedVariables[capturedLocal];
FieldEntity closureField = new JClosureField(
_getClosureVariableName(capturedLocal.name, fieldNumber),
_memberData.length,
cls,
- variable.isConst,
- variable.isFinal || variable.isConst);
+ isConst,
+ isAssignable);
_memberList.add(closureField);
_memberData.add(new ClosureFieldData(new ClosureMemberDefinition(
cls.localToFieldMap[capturedLocal],
- computeSourceSpanFromTreeNode(variable),
+ computeSourceSpanFromTreeNode(sourceNode),
MemberKind.closureField,
- variable)));
+ sourceNode)));
memberMap[closureField.name] = closureField;
if (boxedCapturedVariables.containsKey(capturedLocal)) {
cls.localToFieldMap[field.box] = closureField;

Powered by Google App Engine
This is Rietveld 408576698