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

Side by Side Diff: pkg/kernel/lib/transformations/closure/converter.dart

Issue 2937213002: Remove ContextClass that is not needed since we're using Vectors (Closed)
Patch Set: Merge in latest changes in master (f99509ad42) Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library kernel.transformations.closure.converter; 5 library kernel.transformations.closure.converter;
6 6
7 import '../../ast.dart' 7 import '../../ast.dart'
8 show 8 show
9 Arguments, 9 Arguments,
10 Block, 10 Block,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 import 'clone_without_body.dart' show CloneWithoutBody; 67 import 'clone_without_body.dart' show CloneWithoutBody;
68 68
69 import 'context.dart' show Context, NoContext; 69 import 'context.dart' show Context, NoContext;
70 70
71 import 'info.dart' show ClosureInfo; 71 import 'info.dart' show ClosureInfo;
72 72
73 import 'rewriter.dart' show AstRewriter, BlockRewriter, InitializerRewriter; 73 import 'rewriter.dart' show AstRewriter, BlockRewriter, InitializerRewriter;
74 74
75 class ClosureConverter extends Transformer { 75 class ClosureConverter extends Transformer {
76 final CoreTypes coreTypes; 76 final CoreTypes coreTypes;
77 final Class contextClass;
78 final Set<VariableDeclaration> capturedVariables; 77 final Set<VariableDeclaration> capturedVariables;
79 final Map<FunctionNode, Set<TypeParameter>> capturedTypeVariables; 78 final Map<FunctionNode, Set<TypeParameter>> capturedTypeVariables;
80 final Map<FunctionNode, VariableDeclaration> thisAccess; 79 final Map<FunctionNode, VariableDeclaration> thisAccess;
81 final Map<FunctionNode, String> localNames; 80 final Map<FunctionNode, String> localNames;
82 81
83 /// Records place-holders for cloning contexts. See [visitForStatement]. 82 /// Records place-holders for cloning contexts. See [visitForStatement].
84 final Set<InvalidExpression> contextClonePlaceHolders = 83 final Set<InvalidExpression> contextClonePlaceHolders =
85 new Set<InvalidExpression>(); 84 new Set<InvalidExpression>();
86 85
87 /// Maps the names of all instance methods that may be torn off (aka 86 /// Maps the names of all instance methods that may be torn off (aka
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 /// } 128 /// }
130 /// class Closure#0<T_> implements Function { 129 /// class Closure#0<T_> implements Function {
131 /// call(x) => x is T_; 130 /// call(x) => x is T_;
132 /// } 131 /// }
133 /// 132 ///
134 /// In this example, `typeSubstitution[T].parameter == T_` when transforming 133 /// In this example, `typeSubstitution[T].parameter == T_` when transforming
135 /// the closure in `f`. 134 /// the closure in `f`.
136 Map<TypeParameter, DartType> typeSubstitution = 135 Map<TypeParameter, DartType> typeSubstitution =
137 const <TypeParameter, DartType>{}; 136 const <TypeParameter, DartType>{};
138 137
139 ClosureConverter(this.coreTypes, ClosureInfo info, this.contextClass) 138 ClosureConverter(this.coreTypes, ClosureInfo info)
140 : this.capturedVariables = info.variables, 139 : this.capturedVariables = info.variables,
141 this.capturedTypeVariables = info.typeVariables, 140 this.capturedTypeVariables = info.typeVariables,
142 this.thisAccess = info.thisAccess, 141 this.thisAccess = info.thisAccess,
143 this.localNames = info.localNames, 142 this.localNames = info.localNames,
144 this.tearOffGetterNames = info.tearOffGetterNames; 143 this.tearOffGetterNames = info.tearOffGetterNames;
145 144
146 bool get isOuterMostContext { 145 bool get isOuterMostContext {
147 return currentFunction == null || currentMemberFunction == currentFunction; 146 return currentFunction == null || currentMemberFunction == currentFunction;
148 } 147 }
149 148
(...skipping 10 matching lines...) Expand all
160 try { 159 try {
161 return f(); 160 return f();
162 } finally { 161 } finally {
163 rewriter = old; 162 rewriter = old;
164 context = savedContext; 163 context = savedContext;
165 } 164 }
166 } 165 }
167 166
168 TreeNode visitLibrary(Library node) { 167 TreeNode visitLibrary(Library node) {
169 assert(newLibraryMembers.isEmpty); 168 assert(newLibraryMembers.isEmpty);
170 if (node == contextClass.enclosingLibrary) return node;
171 169
172 currentLibrary = node; 170 currentLibrary = node;
173 node = super.visitLibrary(node); 171 node = super.visitLibrary(node);
174 for (TreeNode member in newLibraryMembers) { 172 for (TreeNode member in newLibraryMembers) {
175 if (member is Class) { 173 if (member is Class) {
176 node.addClass(member); 174 node.addClass(member);
177 } else { 175 } else {
178 node.addMember(member); 176 node.addMember(member);
179 } 177 }
180 } 178 }
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 newClassMembers.add(tearOffMethod); 876 newClassMembers.add(tearOffMethod);
879 877
880 resetContext(); 878 resetContext();
881 }); 879 });
882 } finally { 880 } finally {
883 currentMember = oldCurrentMember; 881 currentMember = oldCurrentMember;
884 currentMemberFunction = oldCurrentMemberFunction; 882 currentMemberFunction = oldCurrentMemberFunction;
885 } 883 }
886 } 884 }
887 } 885 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/transformations/closure/context.dart ('k') | pkg/kernel/lib/transformations/closure/mock.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698