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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder.dart

Issue 1416723008: dart2js cps: Propagate container types for lists. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unreachable handling of list constructor in type propagation Created 5 years, 1 month 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.ir_builder; 5 library dart2js.ir_builder;
6 6
7 import '../closure.dart' hide ClosureScope; 7 import '../closure.dart' hide ClosureScope;
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart' show 9 import '../common/names.dart' show
10 Names, 10 Names,
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 706 }
707 707
708 /// Create a string constant and add it to the CPS term. 708 /// Create a string constant and add it to the CPS term.
709 ir.Constant buildDartStringConstant(ast.DartString value) { 709 ir.Constant buildDartStringConstant(ast.DartString value) {
710 return buildConstant(state.constantSystem.createString(value)); 710 return buildConstant(state.constantSystem.createString(value));
711 } 711 }
712 712
713 /// Creates a non-constant list literal of the provided [type] and with the 713 /// Creates a non-constant list literal of the provided [type] and with the
714 /// provided [values]. 714 /// provided [values].
715 ir.Primitive buildListLiteral(InterfaceType type, 715 ir.Primitive buildListLiteral(InterfaceType type,
716 Iterable<ir.Primitive> values) { 716 Iterable<ir.Primitive> values,
717 {TypeMask allocationSiteType}) {
717 assert(isOpen); 718 assert(isOpen);
718 return addPrimitive(new ir.LiteralList(type, values.toList())); 719 return addPrimitive(new ir.LiteralList(type, values.toList(),
720 allocationSiteType: allocationSiteType));
719 } 721 }
720 722
721 /// Creates a non-constant map literal of the provided [type] and with the 723 /// Creates a non-constant map literal of the provided [type] and with the
722 /// entries build from the [keys] and [values] using [build]. 724 /// entries build from the [keys] and [values] using [build].
723 ir.Primitive buildMapLiteral(InterfaceType type, 725 ir.Primitive buildMapLiteral(InterfaceType type,
724 Iterable keys, 726 Iterable keys,
725 Iterable values, 727 Iterable values,
726 BuildFunction build) { 728 BuildFunction build) {
727 assert(isOpen); 729 assert(isOpen);
728 List<ir.LiteralMapEntry> entries = <ir.LiteralMapEntry>[]; 730 List<ir.LiteralMapEntry> entries = <ir.LiteralMapEntry>[];
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 } 2601 }
2600 2602
2601 /// Create a constructor invocation of [element] on [type] where the 2603 /// Create a constructor invocation of [element] on [type] where the
2602 /// constructor name and argument structure are defined by [callStructure] and 2604 /// constructor name and argument structure are defined by [callStructure] and
2603 /// the argument values are defined by [arguments]. 2605 /// the argument values are defined by [arguments].
2604 ir.Primitive buildConstructorInvocation( 2606 ir.Primitive buildConstructorInvocation(
2605 ConstructorElement element, 2607 ConstructorElement element,
2606 CallStructure callStructure, 2608 CallStructure callStructure,
2607 DartType type, 2609 DartType type,
2608 List<ir.Primitive> arguments, 2610 List<ir.Primitive> arguments,
2609 SourceInformation sourceInformation) { 2611 SourceInformation sourceInformation,
2612 {TypeMask allocationSiteType}) {
2610 assert(isOpen); 2613 assert(isOpen);
2611 Selector selector = 2614 Selector selector =
2612 new Selector(SelectorKind.CALL, element.memberName, callStructure); 2615 new Selector(SelectorKind.CALL, element.memberName, callStructure);
2613 ClassElement cls = element.enclosingClass; 2616 ClassElement cls = element.enclosingClass;
2614 if (program.requiresRuntimeTypesFor(cls)) { 2617 if (program.requiresRuntimeTypesFor(cls)) {
2615 InterfaceType interface = type; 2618 InterfaceType interface = type;
2616 Iterable<ir.Primitive> typeArguments = 2619 Iterable<ir.Primitive> typeArguments =
2617 interface.typeArguments.map((DartType argument) { 2620 interface.typeArguments.map((DartType argument) {
2618 return type.treatAsRaw 2621 return type.treatAsRaw
2619 ? buildNullConstant() 2622 ? buildNullConstant()
2620 : buildTypeExpression(argument); 2623 : buildTypeExpression(argument);
2621 }); 2624 });
2622 arguments = new List<ir.Primitive>.from(arguments) 2625 arguments = new List<ir.Primitive>.from(arguments)
2623 ..addAll(typeArguments); 2626 ..addAll(typeArguments);
2624 } 2627 }
2625 return _continueWithExpression( 2628 return _continueWithExpression(
2626 (k) => new ir.InvokeConstructor( 2629 (k) => new ir.InvokeConstructor(
2627 type, element, selector, arguments, k, sourceInformation)); 2630 type, element, selector, arguments, k, sourceInformation,
2631 allocationSiteType: allocationSiteType));
2628 } 2632 }
2629 2633
2630 ir.Primitive buildTypeExpression(DartType type) { 2634 ir.Primitive buildTypeExpression(DartType type) {
2631 type = program.unaliasType(type); 2635 type = program.unaliasType(type);
2632 if (type is TypeVariableType) { 2636 if (type is TypeVariableType) {
2633 return buildTypeVariableAccess(type); 2637 return buildTypeVariableAccess(type);
2634 } else if (type is InterfaceType || type is FunctionType) { 2638 } else if (type is InterfaceType || type is FunctionType) {
2635 List<ir.Primitive> arguments = <ir.Primitive>[]; 2639 List<ir.Primitive> arguments = <ir.Primitive>[];
2636 type.forEachTypeVariable((TypeVariableType variable) { 2640 type.forEachTypeVariable((TypeVariableType variable) {
2637 ir.Primitive value = buildTypeVariableAccess(variable); 2641 ir.Primitive value = buildTypeVariableAccess(variable);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 } 2893 }
2890 2894
2891 class SwitchCaseInfo { 2895 class SwitchCaseInfo {
2892 final List<ir.Primitive> constants = <ir.Primitive>[]; 2896 final List<ir.Primitive> constants = <ir.Primitive>[];
2893 final SubbuildFunction buildBody; 2897 final SubbuildFunction buildBody;
2894 2898
2895 SwitchCaseInfo(this.buildBody); 2899 SwitchCaseInfo(this.buildBody);
2896 2900
2897 void addConstant(ir.Primitive constant) => constants.add(constant); 2901 void addConstant(ir.Primitive constant) => constants.add(constant);
2898 } 2902 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/common/names.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698