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

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

Issue 2993603002: Updated test status after fixing closure call generation. (Closed)
Patch Set: dartfmt 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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/element_map_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 /// If no variables are captured, this parameter is null. 124 /// If no variables are captured, this parameter is null.
125 void _produceSyntheticElements(MemberEntity member, ir.FunctionNode node, 125 void _produceSyntheticElements(MemberEntity member, ir.FunctionNode node,
126 KernelScopeInfo info, JsClosedWorld closedWorldRefiner) { 126 KernelScopeInfo info, JsClosedWorld closedWorldRefiner) {
127 KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(member); 127 KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(member);
128 KernelClosureClass closureClass = closedWorldRefiner.buildClosureClass( 128 KernelClosureClass closureClass = closedWorldRefiner.buildClosureClass(
129 member, node, member.library, info, node.location, localsMap); 129 member, node, member.library, info, node.location, localsMap);
130 130
131 // We want the original declaration where that function is used to point 131 // We want the original declaration where that function is used to point
132 // to the correct closure class. 132 // to the correct closure class.
133 _closureRepresentationMap[closureClass.callMethod] = closureClass; 133 _closureRepresentationMap[closureClass.callMethod] = closureClass;
134 Entity entity = localsMap.getLocalFunction(node.parent); 134 Entity entity;
135 if (node.parent is ir.Member) {
136 entity = _elementMap.getMember(node.parent);
137 } else {
138 entity = localsMap.getLocalFunction(node.parent);
139 }
135 assert(entity != null); 140 assert(entity != null);
136 _closureRepresentationMap[entity] = closureClass; 141 _closureRepresentationMap[entity] = closureClass;
137 } 142 }
138 143
139 @override 144 @override
140 ScopeInfo getScopeInfo(Entity entity) { 145 ScopeInfo getScopeInfo(Entity entity) {
141 // TODO(johnniwinther): Remove this check when constructor bodies a created 146 // TODO(johnniwinther): Remove this check when constructor bodies a created
142 // eagerly with the J-model; a constructor body should have it's own 147 // eagerly with the J-model; a constructor body should have it's own
143 // [ClosureRepresentationInfo]. 148 // [ClosureRepresentationInfo].
144 if (entity is ConstructorBodyEntity) { 149 if (entity is ConstructorBodyEntity) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 335
331 final Map<Local, JField> localToFieldMap = new Map<Local, JField>(); 336 final Map<Local, JField> localToFieldMap = new Map<Local, JField>();
332 337
333 KernelClosureClass.fromScopeInfo( 338 KernelClosureClass.fromScopeInfo(
334 ir.FunctionNode closureSourceNode, 339 ir.FunctionNode closureSourceNode,
335 this.name, 340 this.name,
336 this.classIndex, 341 this.classIndex,
337 this.library, 342 this.library,
338 KernelScopeInfo info, 343 KernelScopeInfo info,
339 KernelToLocalsMap localsMap) 344 KernelToLocalsMap localsMap)
340 : closureEntity = localsMap.getLocalFunction(closureSourceNode.parent), 345 : closureEntity = closureSourceNode.parent is ir.Member
346 ? null
347 : localsMap.getLocalFunction(closureSourceNode.parent),
341 super.from(info, localsMap); 348 super.from(info, localsMap);
342 349
343 ClassEntity get closureClassEntity => this; 350 ClassEntity get closureClassEntity => this;
344 351
345 List<Local> get createdFieldEntities => localToFieldMap.keys.toList(); 352 List<Local> get createdFieldEntities => localToFieldMap.keys.toList();
346 353
347 // TODO(efortuna): Implement. 354 // TODO(efortuna): Implement.
348 FieldEntity get thisFieldEntity => null; 355 FieldEntity get thisFieldEntity => null;
349 356
350 void forEachCapturedVariable(f(Local from, JField to)) { 357 void forEachCapturedVariable(f(Local from, JField to)) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 ClosureMemberData(this.definition); 434 ClosureMemberData(this.definition);
428 435
429 @override 436 @override
430 Iterable<ConstantValue> getMetadata(KernelToElementMap elementMap) { 437 Iterable<ConstantValue> getMetadata(KernelToElementMap elementMap) {
431 return const <ConstantValue>[]; 438 return const <ConstantValue>[];
432 } 439 }
433 } 440 }
434 441
435 class ClosureFunctionData extends ClosureMemberData implements FunctionData { 442 class ClosureFunctionData extends ClosureMemberData implements FunctionData {
436 final FunctionType functionType; 443 final FunctionType functionType;
444 final ir.FunctionNode functionNode;
437 445
438 ClosureFunctionData(MemberDefinition definition, this.functionType) 446 ClosureFunctionData(
447 ClosureMemberDefinition definition, this.functionType, this.functionNode)
439 : super(definition); 448 : super(definition);
440 449
441 @override
442 void forEachParameter(KernelToElementMapForBuilding elementMap, 450 void forEachParameter(KernelToElementMapForBuilding elementMap,
443 void f(DartType type, String name, ConstantValue defaultValue)) { 451 void f(DartType type, String name, ConstantValue defaultValue)) {
444 // TODO(johnniwinther,efortuna): Implement this. 452 void handleParameter(ir.VariableDeclaration node, {bool isOptional: true}) {
445 throw new UnimplementedError('ClosureFunctionData.forEachParameter'); 453 DartType type = elementMap.getDartType(node.type);
454 String name = node.name;
455 ConstantValue defaultValue;
456 if (isOptional) {
457 if (node.initializer != null) {
458 defaultValue = elementMap.getConstantValue(node.initializer);
459 } else {
460 defaultValue = new NullConstantValue();
461 }
462 }
463 f(type, name, defaultValue);
464 }
465
466 for (int i = 0; i < functionNode.positionalParameters.length; i++) {
467 handleParameter(functionNode.positionalParameters[i],
468 isOptional: i < functionNode.requiredParameterCount);
469 }
470 functionNode.namedParameters.toList()
471 ..sort(namedOrdering)
472 ..forEach(handleParameter);
446 } 473 }
447 474
448 @override 475 @override
449 FunctionType getFunctionType(KernelToElementMap elementMap) { 476 FunctionType getFunctionType(KernelToElementMap elementMap) {
450 return functionType; 477 return functionType;
451 } 478 }
452 } 479 }
453 480
454 class ClosureFieldData extends ClosureMemberData implements FieldData { 481 class ClosureFieldData extends ClosureMemberData implements FieldData {
455 ClosureFieldData(MemberDefinition definition) : super(definition); 482 ClosureFieldData(MemberDefinition definition) : super(definition);
(...skipping 30 matching lines...) Expand all
486 KernelScopeInfo scopeInfo; 513 KernelScopeInfo scopeInfo;
487 514
488 /// Collected [CapturedScope] data for nodes. 515 /// Collected [CapturedScope] data for nodes.
489 Map<ir.Node, KernelCapturedScope> capturedScopesMap = 516 Map<ir.Node, KernelCapturedScope> capturedScopesMap =
490 <ir.Node, KernelCapturedScope>{}; 517 <ir.Node, KernelCapturedScope>{};
491 518
492 /// Collected [ScopeInfo] data for nodes. 519 /// Collected [ScopeInfo] data for nodes.
493 Map<ir.FunctionNode, KernelScopeInfo> closuresToGenerate = 520 Map<ir.FunctionNode, KernelScopeInfo> closuresToGenerate =
494 <ir.FunctionNode, KernelScopeInfo>{}; 521 <ir.FunctionNode, KernelScopeInfo>{};
495 } 522 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/element_map_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698