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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder_kernel.dart

Issue 3009803003: dart2js kernel: Handle ir.LocalInitializer (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
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/dart2js_extra.status » ('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) 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 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/codegen.dart' show CodegenRegistry; 9 import '../common/codegen.dart' show CodegenRegistry;
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 SourceInformationBuilder sourceInformationBuilder; 90 SourceInformationBuilder sourceInformationBuilder;
91 final KernelToElementMapForBuilding _elementMap; 91 final KernelToElementMapForBuilding _elementMap;
92 final KernelToTypeInferenceMap _typeInferenceMap; 92 final KernelToTypeInferenceMap _typeInferenceMap;
93 final KernelToLocalsMap localsMap; 93 final KernelToLocalsMap localsMap;
94 LoopHandler<ir.Node> loopHandler; 94 LoopHandler<ir.Node> loopHandler;
95 TypeBuilder typeBuilder; 95 TypeBuilder typeBuilder;
96 96
97 final NativeEmitter nativeEmitter; 97 final NativeEmitter nativeEmitter;
98 98
99 // [ir.Let] and [ir.LocalInitializer] bindings.
99 final Map<ir.VariableDeclaration, HInstruction> letBindings = 100 final Map<ir.VariableDeclaration, HInstruction> letBindings =
100 <ir.VariableDeclaration, HInstruction>{}; 101 <ir.VariableDeclaration, HInstruction>{};
101 102
102 /// True if we are visiting the expression of a throw statement; we assume 103 /// True if we are visiting the expression of a throw statement; we assume
103 /// this is a slow path. 104 /// this is a slow path.
104 bool _inExpressionOfThrow = false; 105 bool _inExpressionOfThrow = false;
105 106
106 KernelSsaGraphBuilder( 107 KernelSsaGraphBuilder(
107 this.targetElement, 108 this.targetElement,
108 ClassEntity contextClass, 109 ClassEntity contextClass,
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 ir.Constructor constructor, 488 ir.Constructor constructor,
488 List<ir.Constructor> constructorChain, 489 List<ir.Constructor> constructorChain,
489 Map<FieldEntity, HInstruction> fieldValues) { 490 Map<FieldEntity, HInstruction> fieldValues) {
490 assert( 491 assert(
491 _elementMap.getConstructor(constructor) == localsMap.currentMember, 492 _elementMap.getConstructor(constructor) == localsMap.currentMember,
492 failedAt( 493 failedAt(
493 localsMap.currentMember, 494 localsMap.currentMember,
494 'Expected ${localsMap.currentMember} ' 495 'Expected ${localsMap.currentMember} '
495 'but found ${_elementMap.getConstructor(constructor)}.')); 496 'but found ${_elementMap.getConstructor(constructor)}.'));
496 constructorChain.add(constructor); 497 constructorChain.add(constructor);
497
498 var foundSuperOrRedirectCall = false; 498 var foundSuperOrRedirectCall = false;
499 for (var initializer in constructor.initializers) { 499 for (var initializer in constructor.initializers) {
500 if (initializer is ir.FieldInitializer) { 500 if (initializer is ir.FieldInitializer) {
501 initializer.value.accept(this); 501 initializer.value.accept(this);
502 fieldValues[_elementMap.getField(initializer.field)] = pop(); 502 fieldValues[_elementMap.getField(initializer.field)] = pop();
503 } else if (initializer is ir.SuperInitializer) { 503 } else if (initializer is ir.SuperInitializer) {
504 assert(!foundSuperOrRedirectCall); 504 assert(!foundSuperOrRedirectCall);
505 foundSuperOrRedirectCall = true; 505 foundSuperOrRedirectCall = true;
506 _inlineSuperInitializer( 506 _inlineSuperInitializer(
507 initializer, constructorChain, fieldValues, constructor); 507 initializer, constructorChain, fieldValues, constructor);
508 } else if (initializer is ir.RedirectingInitializer) { 508 } else if (initializer is ir.RedirectingInitializer) {
509 assert(!foundSuperOrRedirectCall); 509 assert(!foundSuperOrRedirectCall);
510 foundSuperOrRedirectCall = true; 510 foundSuperOrRedirectCall = true;
511 _inlineRedirectingInitializer( 511 _inlineRedirectingInitializer(
512 initializer, constructorChain, fieldValues, constructor); 512 initializer, constructorChain, fieldValues, constructor);
513 } else if (initializer is ir.LocalInitializer) { 513 } else if (initializer is ir.LocalInitializer) {
514 assert(false, 'ir.LocalInitializer not handled'); 514 // LocalInitializer is like a let-expression that is in scope for the
515 // rest of the initializers.
516 ir.VariableDeclaration variable = initializer.variable;
517 assert(variable.isFinal);
518 variable.initializer.accept(this);
519 HInstruction value = pop();
520 // TODO(sra): Apply inferred type information.
521 letBindings[variable] = value;
515 } else if (initializer is ir.InvalidInitializer) { 522 } else if (initializer is ir.InvalidInitializer) {
516 assert(false, 'ir.InvalidInitializer not handled'); 523 assert(false, 'ir.InvalidInitializer not handled');
517 } 524 }
518 } 525 }
519 526
520 if (!foundSuperOrRedirectCall) { 527 if (!foundSuperOrRedirectCall) {
521 assert( 528 assert(
522 _elementMap.getClass(constructor.enclosingClass) == 529 _elementMap.getClass(constructor.enclosingClass) ==
523 _elementMap.commonElements.objectClass, 530 _elementMap.commonElements.objectClass,
524 'All constructors should have super- or redirecting- initializers,' 531 'All constructors should have super- or redirecting- initializers,'
(...skipping 3212 matching lines...) Expand 10 before | Expand all | Expand 10 after
3737 enterBlock.setBlockFlow( 3744 enterBlock.setBlockFlow(
3738 new HTryBlockInformation( 3745 new HTryBlockInformation(
3739 kernelBuilder.wrapStatementGraph(bodyGraph), 3746 kernelBuilder.wrapStatementGraph(bodyGraph),
3740 exception, 3747 exception,
3741 kernelBuilder.wrapStatementGraph(catchGraph), 3748 kernelBuilder.wrapStatementGraph(catchGraph),
3742 kernelBuilder.wrapStatementGraph(finallyGraph)), 3749 kernelBuilder.wrapStatementGraph(finallyGraph)),
3743 exitBlock); 3750 exitBlock);
3744 kernelBuilder.inTryStatement = previouslyInTryStatement; 3751 kernelBuilder.inTryStatement = previouslyInTryStatement;
3745 } 3752 }
3746 } 3753 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/dart2js_extra.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698