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

Side by Side Diff: pkg/compiler/lib/src/js_model/closure.dart

Issue 3011433002: Revert "Reduce use of getClosureInfoForMember and cleanup closure_test" (Closed)
Patch Set: Created 3 years, 3 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/tasks.dart'; 9 import '../common/tasks.dart';
10 import '../constants/expressions.dart'; 10 import '../constants/expressions.dart';
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 @override 158 @override
159 ScopeInfo getScopeInfo(MemberEntity entity) { 159 ScopeInfo getScopeInfo(MemberEntity entity) {
160 // TODO(johnniwinther): Remove this check when constructor bodies a created 160 // TODO(johnniwinther): Remove this check when constructor bodies a created
161 // eagerly with the J-model; a constructor body should have it's own 161 // eagerly with the J-model; a constructor body should have it's own
162 // [ClosureRepresentationInfo]. 162 // [ClosureRepresentationInfo].
163 if (entity is ConstructorBodyEntity) { 163 if (entity is ConstructorBodyEntity) {
164 ConstructorBodyEntity constructorBody = entity; 164 ConstructorBodyEntity constructorBody = entity;
165 entity = constructorBody.constructor; 165 entity = constructorBody.constructor;
166 } 166 }
167 167
168 ScopeInfo scopeInfo = _scopeMap[entity]; 168 return _scopeMap[entity] ?? getClosureInfoForMember(entity);
169 assert(
170 scopeInfo != null, failedAt(entity, "Missing scope info for $entity."));
171 return scopeInfo;
172 } 169 }
173 170
174 // TODO(efortuna): Eventually capturedScopesMap[node] should always 171 // TODO(efortuna): Eventually capturedScopesMap[node] should always
175 // be non-null, and we should just test that with an assert. 172 // be non-null, and we should just test that with an assert.
176 @override 173 @override
177 CapturedScope getCapturedScope(MemberEntity entity) { 174 CapturedScope getCapturedScope(MemberEntity entity) {
178 MemberDefinition definition = _elementMap.getMemberDefinition(entity); 175 MemberDefinition definition = _elementMap.getMemberDefinition(entity);
179 switch (definition.kind) { 176 switch (definition.kind) {
180 case MemberKind.regular: 177 case MemberKind.regular:
181 case MemberKind.constructor: 178 case MemberKind.constructor:
(...skipping 23 matching lines...) Expand all
205 202
206 @override 203 @override
207 ClosureRepresentationInfo getClosureInfo(ir.Node node) { 204 ClosureRepresentationInfo getClosureInfo(ir.Node node) {
208 var closure = _localClosureRepresentationMap[node]; 205 var closure = _localClosureRepresentationMap[node];
209 assert( 206 assert(
210 closure != null, 207 closure != null,
211 "Corresponding closure class not found for $node. " 208 "Corresponding closure class not found for $node. "
212 "Closures found for ${_localClosureRepresentationMap.keys}"); 209 "Closures found for ${_localClosureRepresentationMap.keys}");
213 return closure; 210 return closure;
214 } 211 }
212
213 @override
214 ClosureRepresentationInfo getClosureInfoForMemberTesting(
215 MemberEntity entity) {
216 return _memberClosureRepresentationMap[entity];
217 }
218
219 @override
220 ClosureRepresentationInfo getClosureInfoForTesting(ir.Node node) {
221 return _localClosureRepresentationMap[node];
222 }
215 } 223 }
216 224
217 class KernelScopeInfo { 225 class KernelScopeInfo {
218 final Set<ir.VariableDeclaration> localsUsedInTryOrSync; 226 final Set<ir.VariableDeclaration> localsUsedInTryOrSync;
219 final bool hasThisLocal; 227 final bool hasThisLocal;
220 final Set<ir.VariableDeclaration> boxedVariables; 228 final Set<ir.VariableDeclaration> boxedVariables;
221 // If boxedVariables is empty, this will be null, because no variables will 229 // If boxedVariables is empty, this will be null, because no variables will
222 // need to be boxed. 230 // need to be boxed.
223 final NodeBox capturedVariablesAccessor; 231 final NodeBox capturedVariablesAccessor;
224 232
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 KernelScopeInfo scopeInfo; 590 KernelScopeInfo scopeInfo;
583 591
584 /// Collected [CapturedScope] data for nodes. 592 /// Collected [CapturedScope] data for nodes.
585 Map<ir.Node, KernelCapturedScope> capturedScopesMap = 593 Map<ir.Node, KernelCapturedScope> capturedScopesMap =
586 <ir.Node, KernelCapturedScope>{}; 594 <ir.Node, KernelCapturedScope>{};
587 595
588 /// Collected [ScopeInfo] data for nodes. 596 /// Collected [ScopeInfo] data for nodes.
589 Map<ir.FunctionNode, KernelScopeInfo> closuresToGenerate = 597 Map<ir.FunctionNode, KernelScopeInfo> closuresToGenerate =
590 <ir.FunctionNode, KernelScopeInfo>{}; 598 <ir.FunctionNode, KernelScopeInfo>{};
591 } 599 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart ('k') | pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698