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

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

Issue 3005823002: Handle forwarding constructors to unnamed mixin applications (Closed)
Patch Set: Updated cf. comments 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) 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 sourceInformationBuilder = oldSourceInformationBuilder; 455 sourceInformationBuilder = oldSourceInformationBuilder;
456 _targetStack.removeLast(); 456 _targetStack.removeLast();
457 localsMap.leaveInlinedMember(inlinedTarget); 457 localsMap.leaveInlinedMember(inlinedTarget);
458 return result; 458 return result;
459 }); 459 });
460 } 460 }
461 461
462 /// Maps the instance fields of a class to their SSA values. 462 /// Maps the instance fields of a class to their SSA values.
463 Map<FieldEntity, HInstruction> _collectFieldValues(ir.Class clazz) { 463 Map<FieldEntity, HInstruction> _collectFieldValues(ir.Class clazz) {
464 Map<FieldEntity, HInstruction> fieldValues = <FieldEntity, HInstruction>{}; 464 Map<FieldEntity, HInstruction> fieldValues = <FieldEntity, HInstruction>{};
465 465 ClassEntity cls = _elementMap.getClass(clazz);
466 for (ir.Field node in clazz.fields) { 466 _worldBuilder.forEachInstanceField(cls, (_, FieldEntity field) {
467 if (node.isInstanceMember) { 467 MemberDefinition definition = _elementMap.getMemberDefinition(field);
468 FieldEntity field = _elementMap.getField(node); 468 ir.Field node;
469 if (node.initializer == null) { 469 switch (definition.kind) {
470 fieldValues[field] = graph.addConstantNull(closedWorld); 470 case MemberKind.regular:
471 } else { 471 node = definition.node;
472 // Gotta update the resolvedAst when we're looking at field values 472 break;
473 // outside the constructor. 473 default:
474 inlinedFrom(field, () { 474 failedAt(field, "Unexpected member definition $definition.");
475 node.initializer.accept(this);
476 fieldValues[field] = pop();
477 });
478 }
479 } 475 }
480 } 476 if (node.initializer == null) {
481 477 fieldValues[field] = graph.addConstantNull(closedWorld);
478 } else {
479 // Gotta update the current member when we're looking at field values
480 // outside the constructor.
481 inlinedFrom(field, () {
482 node.initializer.accept(this);
483 fieldValues[field] = pop();
484 });
485 }
486 });
482 return fieldValues; 487 return fieldValues;
483 } 488 }
484 489
485 /// Collects field initializers all the way up the inheritance chain. 490 /// Collects field initializers all the way up the inheritance chain.
486 void _buildInitializers( 491 void _buildInitializers(
487 ir.Constructor constructor, 492 ir.Constructor constructor,
488 List<ir.Constructor> constructorChain, 493 List<ir.Constructor> constructorChain,
489 Map<FieldEntity, HInstruction> fieldValues) { 494 Map<FieldEntity, HInstruction> fieldValues) {
490 assert( 495 assert(
491 _elementMap.getConstructor(constructor) == localsMap.currentMember, 496 _elementMap.getConstructor(constructor) == localsMap.currentMember,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 var target = initializer.target; 623 var target = initializer.target;
619 var arguments = 624 var arguments =
620 _normalizeAndBuildArguments(target.function, initializer.arguments); 625 _normalizeAndBuildArguments(target.function, initializer.arguments);
621 626
622 ir.Class callerClass = caller.enclosingClass; 627 ir.Class callerClass = caller.enclosingClass;
623 _bindSupertypeTypeParameters(callerClass.supertype); 628 _bindSupertypeTypeParameters(callerClass.supertype);
624 if (callerClass.mixedInType != null) { 629 if (callerClass.mixedInType != null) {
625 _bindSupertypeTypeParameters(callerClass.mixedInType); 630 _bindSupertypeTypeParameters(callerClass.mixedInType);
626 } 631 }
627 632
628 ir.Class cls = target.enclosingClass;
629
630 inlinedFrom(_elementMap.getConstructor(target), () {
631 fieldValues.addAll(_collectFieldValues(cls));
632 });
633
634 _inlineSuperOrRedirectCommon( 633 _inlineSuperOrRedirectCommon(
635 initializer, target, arguments, constructorChain, fieldValues, caller); 634 initializer, target, arguments, constructorChain, fieldValues, caller);
636 } 635 }
637 636
638 void _inlineSuperOrRedirectCommon( 637 void _inlineSuperOrRedirectCommon(
639 ir.Initializer initializer, 638 ir.Initializer initializer,
640 ir.Constructor constructor, 639 ir.Constructor constructor,
641 List<HInstruction> arguments, 640 List<HInstruction> arguments,
642 List<ir.Constructor> constructorChain, 641 List<ir.Constructor> constructorChain,
643 Map<FieldEntity, HInstruction> fieldValues, 642 Map<FieldEntity, HInstruction> fieldValues,
(...skipping 3093 matching lines...) Expand 10 before | Expand all | Expand 10 after
3737 enterBlock.setBlockFlow( 3736 enterBlock.setBlockFlow(
3738 new HTryBlockInformation( 3737 new HTryBlockInformation(
3739 kernelBuilder.wrapStatementGraph(bodyGraph), 3738 kernelBuilder.wrapStatementGraph(bodyGraph),
3740 exception, 3739 exception,
3741 kernelBuilder.wrapStatementGraph(catchGraph), 3740 kernelBuilder.wrapStatementGraph(catchGraph),
3742 kernelBuilder.wrapStatementGraph(finallyGraph)), 3741 kernelBuilder.wrapStatementGraph(finallyGraph)),
3743 exitBlock); 3742 exitBlock);
3744 kernelBuilder.inTryStatement = previouslyInTryStatement; 3743 kernelBuilder.inTryStatement = previouslyInTryStatement;
3745 } 3744 }
3746 } 3745 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698