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

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

Issue 1574543003: dart2js: Start creating IR nodes in the IrBuilderVisitor class. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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/cps_ir/cps_ir_builder_task.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) 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' as closure; 7 import '../closure.dart' as closure;
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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 _current = _current.plug(expr); 646 _current = _current.plug(expr);
647 } 647 }
648 } 648 }
649 649
650 /// Create and add a new [LetPrim] for [primitive]. 650 /// Create and add a new [LetPrim] for [primitive].
651 ir.Primitive addPrimitive(ir.Primitive primitive) { 651 ir.Primitive addPrimitive(ir.Primitive primitive) {
652 add(new ir.LetPrim(primitive)); 652 add(new ir.LetPrim(primitive));
653 return primitive; 653 return primitive;
654 } 654 }
655 655
656 ir.Primitive _buildInvokeStatic(Element element, 656 ir.Primitive buildInvokeStatic(Element element,
657 Selector selector, 657 Selector selector,
658 List<ir.Primitive> arguments, 658 List<ir.Primitive> arguments,
659 SourceInformation sourceInformation) { 659 SourceInformation sourceInformation) {
660 assert(!element.isLocal); 660 assert(!element.isLocal);
661 assert(!element.isInstanceMember); 661 assert(!element.isInstanceMember);
662 assert(isOpen); 662 assert(isOpen);
663 return addPrimitive( 663 return addPrimitive(
664 new ir.InvokeStatic(element, selector, arguments, sourceInformation)); 664 new ir.InvokeStatic(element, selector, arguments, sourceInformation));
665 } 665 }
666 666
667 ir.Primitive _buildInvokeSuper(Element target, 667 ir.Primitive _buildInvokeSuper(Element target,
668 Selector selector, 668 Selector selector,
669 List<ir.Primitive> arguments, 669 List<ir.Primitive> arguments,
(...skipping 20 matching lines...) Expand all
690 TypeMask mask, 690 TypeMask mask,
691 List<ir.Definition> arguments, 691 List<ir.Definition> arguments,
692 {SourceInformation sourceInformation}) { 692 {SourceInformation sourceInformation}) {
693 Selector selector = callStructure.callSelector; 693 Selector selector = callStructure.callSelector;
694 return _buildInvokeDynamic( 694 return _buildInvokeDynamic(
695 target, selector, mask, arguments, sourceInformation); 695 target, selector, mask, arguments, sourceInformation);
696 } 696 }
697 697
698 ir.Primitive buildStaticNoSuchMethod(Selector selector, 698 ir.Primitive buildStaticNoSuchMethod(Selector selector,
699 List<ir.Primitive> arguments) { 699 List<ir.Primitive> arguments) {
700 Element thrower = program.throwNoSuchMethod;
701 ir.Primitive receiver = buildStringConstant(''); 700 ir.Primitive receiver = buildStringConstant('');
702 ir.Primitive name = buildStringConstant(selector.name); 701 ir.Primitive name = buildStringConstant(selector.name);
703 ir.Primitive argumentList = buildListLiteral(null, arguments); 702 ir.Primitive argumentList = buildListLiteral(null, arguments);
704 ir.Primitive expectedArgumentNames = buildNullConstant(); 703 ir.Primitive expectedArgumentNames = buildNullConstant();
705 return buildStaticFunctionInvocation( 704 return buildStaticFunctionInvocation(
706 thrower, 705 program.throwNoSuchMethod,
707 new CallStructure.unnamed(4), 706 <ir.Primitive>[receiver, name, argumentList, expectedArgumentNames]);
708 [receiver, name, argumentList, expectedArgumentNames]);
709 } 707 }
710 708
711
712 /// Create a [ir.Constant] from [value] and add it to the CPS term. 709 /// Create a [ir.Constant] from [value] and add it to the CPS term.
713 ir.Constant buildConstant(ConstantValue value, 710 ir.Constant buildConstant(ConstantValue value,
714 {SourceInformation sourceInformation}) { 711 {SourceInformation sourceInformation}) {
715 assert(isOpen); 712 assert(isOpen);
716 return addPrimitive( 713 return addPrimitive(
717 new ir.Constant(value, sourceInformation: sourceInformation)); 714 new ir.Constant(value, sourceInformation: sourceInformation));
718 } 715 }
719 716
720 /// Create an integer constant and add it to the CPS term. 717 /// Create an integer constant and add it to the CPS term.
721 ir.Constant buildIntegerConstant(int value) { 718 ir.Constant buildIntegerConstant(int value) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 LocalFunctionElement function, 1016 LocalFunctionElement function,
1020 CallStructure callStructure, 1017 CallStructure callStructure,
1021 List<ir.Primitive> arguments, 1018 List<ir.Primitive> arguments,
1022 SourceInformation sourceInformation) { 1019 SourceInformation sourceInformation) {
1023 // TODO(johnniwinther): Maybe this should have its own ir node. 1020 // TODO(johnniwinther): Maybe this should have its own ir node.
1024 return buildCallInvocation( 1021 return buildCallInvocation(
1025 buildLocalFunctionGet(function), callStructure, arguments, 1022 buildLocalFunctionGet(function), callStructure, arguments,
1026 sourceInformation: sourceInformation); 1023 sourceInformation: sourceInformation);
1027 } 1024 }
1028 1025
1029 /// Create a static invocation of [function] where argument structure is 1026 /// Create a static invocation of [function].
1030 /// defined by [callStructure] and the argument values are defined by 1027 ///
1031 /// [arguments]. 1028 /// The arguments are not named and their values are defined by [arguments].
1032 ir.Primitive buildStaticFunctionInvocation( 1029 ir.Primitive buildStaticFunctionInvocation(
1033 MethodElement function, 1030 MethodElement function,
1034 CallStructure callStructure,
1035 List<ir.Primitive> arguments, 1031 List<ir.Primitive> arguments,
1036 {SourceInformation sourceInformation}) { 1032 {SourceInformation sourceInformation}) {
1037 Selector selector = 1033 Selector selector = new Selector.call(
1038 new Selector(SelectorKind.CALL, function.memberName, callStructure); 1034 function.memberName, new CallStructure(arguments.length));
1039 return _buildInvokeStatic( 1035 return buildInvokeStatic(function, selector, arguments, sourceInformation);
1040 function, selector, arguments, sourceInformation);
1041 } 1036 }
1042 1037
1043 /// Create a read access of the static [field]. 1038 /// Create a read access of the static [field].
1044 ir.Primitive buildStaticFieldGet(FieldElement field, 1039 ir.Primitive buildStaticFieldGet(FieldElement field,
1045 SourceInformation sourceInformation) { 1040 SourceInformation sourceInformation) {
1046 return addPrimitive(new ir.GetStatic(field, sourceInformation)); 1041 return addPrimitive(new ir.GetStatic(field, sourceInformation));
1047 } 1042 }
1048 1043
1049 /// Create a read access of a static [field] that might not have been 1044 /// Create a read access of a static [field] that might not have been
1050 /// initialized yet. 1045 /// initialized yet.
1051 ir.Primitive buildStaticFieldLazyGet(FieldElement field, 1046 ir.Primitive buildStaticFieldLazyGet(FieldElement field,
1052 SourceInformation sourceInformation) { 1047 SourceInformation sourceInformation) {
1053 return addPrimitive(new ir.GetLazyStatic(field, sourceInformation)); 1048 return addPrimitive(new ir.GetLazyStatic(field, sourceInformation));
1054 } 1049 }
1055 1050
1056 /// Create a getter invocation of the static [getter]. 1051 /// Create a getter invocation of the static [getter].
1057 ir.Primitive buildStaticGetterGet(MethodElement getter, 1052 ir.Primitive buildStaticGetterGet(MethodElement getter,
1058 SourceInformation sourceInformation) { 1053 SourceInformation sourceInformation) {
1059 Selector selector = new Selector.getter(getter.memberName); 1054 Selector selector = new Selector.getter(getter.memberName);
1060 return _buildInvokeStatic( 1055 return buildInvokeStatic(
1061 getter, selector, const <ir.Primitive>[], sourceInformation); 1056 getter, selector, const <ir.Primitive>[], sourceInformation);
1062 } 1057 }
1063 1058
1064 /// Create a read access of the static [function], i.e. a closurization of 1059 /// Create a read access of the static [function], i.e. a closurization of
1065 /// [function]. 1060 /// [function].
1066 ir.Primitive buildStaticFunctionGet(MethodElement function, 1061 ir.Primitive buildStaticFunctionGet(MethodElement function,
1067 {SourceInformation sourceInformation}) { 1062 {SourceInformation sourceInformation}) {
1068 return addPrimitive(new ir.GetStatic(function, sourceInformation)); 1063 return addPrimitive(new ir.GetStatic(function, sourceInformation));
1069 } 1064 }
1070 1065
1071 /// Create a write access to the static [field] with the [value]. 1066 /// Create a write access to the static [field] with the [value].
1072 ir.Primitive buildStaticFieldSet(FieldElement field, 1067 ir.Primitive buildStaticFieldSet(FieldElement field,
1073 ir.Primitive value, 1068 ir.Primitive value,
1074 [SourceInformation sourceInformation]) { 1069 [SourceInformation sourceInformation]) {
1075 addPrimitive(new ir.SetStatic(field, value, sourceInformation)); 1070 addPrimitive(new ir.SetStatic(field, value, sourceInformation));
1076 return value; 1071 return value;
1077 } 1072 }
1078 1073
1079 /// Create a setter invocation of the static [setter] with the [value]. 1074 /// Create a setter invocation of the static [setter] with the [value].
1080 ir.Primitive buildStaticSetterSet(MethodElement setter, 1075 ir.Primitive buildStaticSetterSet(MethodElement setter,
1081 ir.Primitive value, 1076 ir.Primitive value,
1082 {SourceInformation sourceInformation}) { 1077 {SourceInformation sourceInformation}) {
1083 Selector selector = new Selector.setter(setter.memberName); 1078 Selector selector = new Selector.setter(setter.memberName);
1084 _buildInvokeStatic( 1079 buildInvokeStatic(
1085 setter, selector, <ir.Primitive>[value], sourceInformation); 1080 setter, selector, <ir.Primitive>[value], sourceInformation);
1086 return value; 1081 return value;
1087 } 1082 }
1088 1083
1089 /// Create an erroneous invocation where argument structure is defined by 1084 /// Create an erroneous invocation where argument structure is defined by
1090 /// [selector] and the argument values are defined by [arguments]. 1085 /// [selector] and the argument values are defined by [arguments].
1091 // TODO(johnniwinther): Make this more fine-grained. 1086 // TODO(johnniwinther): Make this more fine-grained.
1092 ir.Primitive buildErroneousInvocation( 1087 ir.Primitive buildErroneousInvocation(
1093 Element element, 1088 Element element,
1094 Selector selector, 1089 Selector selector,
1095 List<ir.Primitive> arguments) { 1090 List<ir.Primitive> arguments) {
1096 // TODO(johnniwinther): This should have its own ir node. 1091 // TODO(johnniwinther): This should have its own ir node.
1097 return _buildInvokeStatic(element, selector, arguments, null); 1092 return buildInvokeStatic(element, selector, arguments, null);
1098 } 1093 }
1099 1094
1100 /// Concatenate string values. 1095 /// Concatenate string values. The arguments must be strings.
1101 ///
1102 /// The arguments must be strings; usually a call to [buildStringify] is
1103 /// needed to ensure the proper conversion takes places.
1104 ir.Primitive buildStringConcatenation(List<ir.Primitive> arguments, 1096 ir.Primitive buildStringConcatenation(List<ir.Primitive> arguments,
1105 {SourceInformation sourceInformation}) { 1097 {SourceInformation sourceInformation}) {
1106 assert(isOpen); 1098 assert(isOpen);
1107 return addPrimitive(new ir.ApplyBuiltinOperator( 1099 return addPrimitive(new ir.ApplyBuiltinOperator(
1108 ir.BuiltinOperator.StringConcatenate, 1100 ir.BuiltinOperator.StringConcatenate,
1109 arguments, 1101 arguments,
1110 sourceInformation)); 1102 sourceInformation));
1111 } 1103 }
1112 1104
1113 /// Create an invocation of the `call` method of [functionExpression], where 1105 /// Create an invocation of the `call` method of [functionExpression], where
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
1692 1684
1693 ir.Primitive condition = buildConditionsFrom(0)(casesBuilder); 1685 ir.Primitive condition = buildConditionsFrom(0)(casesBuilder);
1694 IrBuilder thenBuilder = makeDelimitedBuilder(); 1686 IrBuilder thenBuilder = makeDelimitedBuilder();
1695 caseInfo.buildBody(thenBuilder); 1687 caseInfo.buildBody(thenBuilder);
1696 if (thenBuilder.isOpen) { 1688 if (thenBuilder.isOpen) {
1697 // It is a runtime error to reach the end of a switch case, unless 1689 // It is a runtime error to reach the end of a switch case, unless
1698 // it is the last case. 1690 // it is the last case.
1699 if (caseInfo == cases.last && defaultCase == null) { 1691 if (caseInfo == cases.last && defaultCase == null) {
1700 thenBuilder.jumpTo(join); 1692 thenBuilder.jumpTo(join);
1701 } else { 1693 } else {
1702 ir.Primitive exception = thenBuilder._buildInvokeStatic( 1694 ir.Primitive exception = thenBuilder.buildInvokeStatic(
1703 error, 1695 error,
1704 new Selector.fromElement(error), 1696 new Selector.fromElement(error),
1705 <ir.Primitive>[], 1697 <ir.Primitive>[],
1706 sourceInformation); 1698 sourceInformation);
1707 thenBuilder.buildThrow(exception); 1699 thenBuilder.buildThrow(exception);
1708 } 1700 }
1709 } 1701 }
1710 1702
1711 ir.Continuation thenContinuation = new ir.Continuation([]); 1703 ir.Continuation thenContinuation = new ir.Continuation([]);
1712 thenContinuation.body = thenBuilder._root; 1704 thenContinuation.body = thenBuilder._root;
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 // where (C', x) = Build(e, C) 2058 // where (C', x) = Build(e, C)
2067 // 2059 //
2068 // Return without a subexpression is translated as if it were return null. 2060 // Return without a subexpression is translated as if it were return null.
2069 assert(isOpen); 2061 assert(isOpen);
2070 if (value == null) { 2062 if (value == null) {
2071 value = buildNullConstant(); 2063 value = buildNullConstant();
2072 } 2064 }
2073 jumpTo(state.returnCollector, value, sourceInformation); 2065 jumpTo(state.returnCollector, value, sourceInformation);
2074 } 2066 }
2075 2067
2076 /// Build a call to the closure conversion helper for the [Function] typed
2077 /// value in [value].
2078 ir.Primitive _convertDartClosure(ir.Primitive value, FunctionType type) {
2079 ir.Constant arity = buildIntegerConstant(type.computeArity());
2080 return buildStaticFunctionInvocation(
2081 program.closureConverter,
2082 CallStructure.TWO_ARGS,
2083 <ir.Primitive>[value, arity]);
2084 }
2085
2086 /// Generate the body for a native function [function] that is annotated with 2068 /// Generate the body for a native function [function] that is annotated with
2087 /// an implementation in JavaScript (provided as string in [javaScriptCode]). 2069 /// an implementation in JavaScript (provided as string in [javaScriptCode]).
2088 void buildNativeFunctionBody(FunctionElement function, 2070 void buildNativeFunctionBody(FunctionElement function,
2089 String javaScriptCode) { 2071 String javaScriptCode) {
2090 NativeBehavior behavior = new NativeBehavior(); 2072 NativeBehavior behavior = new NativeBehavior();
2091 behavior.sideEffects.setAllSideEffects(); 2073 behavior.sideEffects.setAllSideEffects();
2092 // Generate a [ForeignCode] statement from the given native code. 2074 // Generate a [ForeignCode] statement from the given native code.
2093 buildForeignCode( 2075 buildForeignCode(
2094 js.js.statementTemplateYielding( 2076 js.js.statementTemplateYielding(
2095 new js.LiteralStatement(javaScriptCode)), 2077 new js.LiteralStatement(javaScriptCode)),
(...skipping 21 matching lines...) Expand all
2117 } 2099 }
2118 // Collect all parameters of the function and templates for them to be 2100 // Collect all parameters of the function and templates for them to be
2119 // inserted into the JavaScript code. 2101 // inserted into the JavaScript code.
2120 List<String> argumentTemplates = <String>[]; 2102 List<String> argumentTemplates = <String>[];
2121 function.functionSignature.forEachParameter((ParameterElement parameter) { 2103 function.functionSignature.forEachParameter((ParameterElement parameter) {
2122 ir.Primitive input = environment.lookup(parameter); 2104 ir.Primitive input = environment.lookup(parameter);
2123 DartType type = program.unaliasType(parameter.type); 2105 DartType type = program.unaliasType(parameter.type);
2124 if (type is FunctionType) { 2106 if (type is FunctionType) {
2125 // The parameter type is a function type either directly or through 2107 // The parameter type is a function type either directly or through
2126 // typedef(s). 2108 // typedef(s).
2127 input = _convertDartClosure(input, type); 2109 ir.Constant arity = buildIntegerConstant(type.computeArity());
2110 input = buildStaticFunctionInvocation(
2111 program.closureConverter, <ir.Primitive>[input, arity]);
2128 } 2112 }
2129 arguments.add(input); 2113 arguments.add(input);
2130 argumentTemplates.add('#'); 2114 argumentTemplates.add('#');
2131 }); 2115 });
2132 // Construct the application of parameters for functions and setters. 2116 // Construct the application of parameters for functions and setters.
2133 if (function.kind == ElementKind.FUNCTION) { 2117 if (function.kind == ElementKind.FUNCTION) {
2134 code = "$code(${argumentTemplates.join(', ')})"; 2118 code = "$code(${argumentTemplates.join(', ')})";
2135 } else if (function.kind == ElementKind.SETTER) { 2119 } else if (function.kind == ElementKind.SETTER) {
2136 code = "$code = ${argumentTemplates.single}"; 2120 code = "$code = ${argumentTemplates.single}";
2137 } else { 2121 } else {
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 2578
2595 ir.Primitive buildSuperFieldGet(FieldElement target) { 2579 ir.Primitive buildSuperFieldGet(FieldElement target) {
2596 return addPrimitive(new ir.GetField(buildThis(), target)); 2580 return addPrimitive(new ir.GetField(buildThis(), target));
2597 } 2581 }
2598 2582
2599 ir.Primitive buildSuperFieldSet(FieldElement target, ir.Primitive value) { 2583 ir.Primitive buildSuperFieldSet(FieldElement target, ir.Primitive value) {
2600 addPrimitive(new ir.SetField(buildThis(), target, value)); 2584 addPrimitive(new ir.SetField(buildThis(), target, value));
2601 return value; 2585 return value;
2602 } 2586 }
2603 2587
2604 ir.Primitive buildInvokeDirectly(MethodElement target,
2605 ir.Primitive receiver,
2606 List<ir.Primitive> arguments,
2607 {SourceInformation sourceInformation}) {
2608 assert(isOpen);
2609 Selector selector =
2610 new Selector.call(target.memberName, new CallStructure(arguments.length) );
2611 return addPrimitive(new ir.InvokeMethodDirectly(
2612 receiver, target, selector, arguments, sourceInformation));
2613 }
2614
2615 /// Loads parameters to a constructor body into the environment. 2588 /// Loads parameters to a constructor body into the environment.
2616 /// 2589 ///
2617 /// The header for a constructor body differs from other functions in that 2590 /// The header for a constructor body differs from other functions in that
2618 /// some parameters are already boxed, and the box is passed as an argument 2591 /// some parameters are already boxed, and the box is passed as an argument
2619 /// instead of being created in the header. 2592 /// instead of being created in the header.
2620 void buildConstructorBodyHeader(Iterable<Local> parameters, 2593 void buildConstructorBodyHeader(Iterable<Local> parameters,
2621 ClosureScope closureScope) { 2594 ClosureScope closureScope) {
2622 _createThisParameter(); 2595 _createThisParameter();
2623 for (Local param in parameters) { 2596 for (Local param in parameters) {
2624 ir.Parameter parameter = _createLocalParameter(param); 2597 ir.Parameter parameter = _createLocalParameter(param);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2746 /// Creates a type test or type cast of [value] against [type]. 2719 /// Creates a type test or type cast of [value] against [type].
2747 ir.Primitive buildTypeOperator(ir.Primitive value, 2720 ir.Primitive buildTypeOperator(ir.Primitive value,
2748 DartType type, 2721 DartType type,
2749 {bool isTypeTest}) { 2722 {bool isTypeTest}) {
2750 assert(isOpen); 2723 assert(isOpen);
2751 assert(isTypeTest != null); 2724 assert(isTypeTest != null);
2752 2725
2753 type = program.unaliasType(type); 2726 type = program.unaliasType(type);
2754 2727
2755 if (type.isMalformed) { 2728 if (type.isMalformed) {
2756 FunctionElement helper = program.throwTypeErrorHelper;
2757 ErroneousElement element = type.element; 2729 ErroneousElement element = type.element;
2758 ir.Primitive message = buildStringConstant(element.message); 2730 ir.Primitive message = buildStringConstant(element.message);
2759 return buildStaticFunctionInvocation( 2731 return buildStaticFunctionInvocation(
2760 helper, 2732 program.throwTypeErrorHelper,
2761 CallStructure.ONE_ARG,
2762 <ir.Primitive>[message]); 2733 <ir.Primitive>[message]);
2763 } 2734 }
2764 2735
2765 List<ir.Primitive> typeArguments = const <ir.Primitive>[]; 2736 List<ir.Primitive> typeArguments = const <ir.Primitive>[];
2766 if (type is GenericType && type.typeArguments.isNotEmpty) { 2737 if (type is GenericType && type.typeArguments.isNotEmpty) {
2767 typeArguments = type.typeArguments.map(buildTypeExpression).toList(); 2738 typeArguments = type.typeArguments.map(buildTypeExpression).toList();
2768 } else if (type is TypeVariableType) { 2739 } else if (type is TypeVariableType) {
2769 typeArguments = <ir.Primitive>[buildTypeVariableAccess(type)]; 2740 typeArguments = <ir.Primitive>[buildTypeVariableAccess(type)];
2770 } else if (type is FunctionType) { 2741 } else if (type is FunctionType) {
2771 typeArguments = <ir.Primitive>[buildTypeExpression(type)]; 2742 typeArguments = <ir.Primitive>[buildTypeExpression(type)];
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2817 return buildConditional(condition, (_) => receiver, buildSend); 2788 return buildConditional(condition, (_) => receiver, buildSend);
2818 } 2789 }
2819 2790
2820 /// Creates a type test checking whether [value] is null. 2791 /// Creates a type test checking whether [value] is null.
2821 ir.Primitive _buildCheckNull(ir.Primitive value, 2792 ir.Primitive _buildCheckNull(ir.Primitive value,
2822 {SourceInformation sourceInformation}) { 2793 {SourceInformation sourceInformation}) {
2823 assert(isOpen); 2794 assert(isOpen);
2824 return buildIdentical(value, buildNullConstant(), 2795 return buildIdentical(value, buildNullConstant(),
2825 sourceInformation: sourceInformation); 2796 sourceInformation: sourceInformation);
2826 } 2797 }
2827
2828 /// Convert the given value to a string.
2829 ir.Primitive buildStringify(ir.Primitive value) {
2830 return buildStaticFunctionInvocation(
2831 program.stringifyFunction,
2832 new CallStructure.unnamed(1),
2833 <ir.Primitive>[value]);
2834 }
2835
2836 ir.Primitive buildAwait(ir.Primitive value) {
2837 return addPrimitive(new ir.Await(value));
2838 }
2839
2840 void buildYield(ir.Primitive value, bool hasStar) {
2841 addPrimitive(new ir.Yield(value, hasStar));
2842 }
2843
2844 ir.Primitive buildRefinement(ir.Primitive value, TypeMask type) {
2845 return addPrimitive(new ir.Refinement(value, type));
2846 }
2847 } 2798 }
2848 2799
2849 /// Location of a variable relative to a given closure. 2800 /// Location of a variable relative to a given closure.
2850 class ClosureLocation { 2801 class ClosureLocation {
2851 /// If not `null`, this location is [box].[field]. 2802 /// If not `null`, this location is [box].[field].
2852 /// The location of [box] can be obtained separately from an 2803 /// The location of [box] can be obtained separately from an
2853 /// enclosing [ClosureEnvironment] or [ClosureScope]. 2804 /// enclosing [ClosureEnvironment] or [ClosureScope].
2854 /// If `null`, then the location is [field] on the enclosing function object. 2805 /// If `null`, then the location is [field] on the enclosing function object.
2855 final closure.BoxLocal box; 2806 final closure.BoxLocal box;
2856 2807
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2948 } 2899 }
2949 2900
2950 class SwitchCaseInfo { 2901 class SwitchCaseInfo {
2951 final List<ir.Primitive> constants = <ir.Primitive>[]; 2902 final List<ir.Primitive> constants = <ir.Primitive>[];
2952 final SubbuildFunction buildBody; 2903 final SubbuildFunction buildBody;
2953 2904
2954 SwitchCaseInfo(this.buildBody); 2905 SwitchCaseInfo(this.buildBody);
2955 2906
2956 void addConstant(ir.Primitive constant) => constants.add(constant); 2907 void addConstant(ir.Primitive constant) => constants.add(constant);
2957 } 2908 }
OLDNEW
« no previous file with comments | « no previous file | 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