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

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

Issue 1842033004: Add *IndexSetIfNull methods to SemanticSendVisitor. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 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/inferrer/simple_types_inferrer.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_task; 5 library dart2js.ir_builder_task;
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 Identifiers, 10 Identifiers,
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 with IrBuilderMixin<ast.Node>, 128 with IrBuilderMixin<ast.Node>,
129 SemanticSendResolvedMixin<ir.Primitive, dynamic>, 129 SemanticSendResolvedMixin<ir.Primitive, dynamic>,
130 ErrorBulkMixin<ir.Primitive, dynamic>, 130 ErrorBulkMixin<ir.Primitive, dynamic>,
131 BaseImplementationOfStaticsMixin<ir.Primitive, dynamic>, 131 BaseImplementationOfStaticsMixin<ir.Primitive, dynamic>,
132 BaseImplementationOfLocalsMixin<ir.Primitive, dynamic>, 132 BaseImplementationOfLocalsMixin<ir.Primitive, dynamic>,
133 BaseImplementationOfDynamicsMixin<ir.Primitive, dynamic>, 133 BaseImplementationOfDynamicsMixin<ir.Primitive, dynamic>,
134 BaseImplementationOfConstantsMixin<ir.Primitive, dynamic>, 134 BaseImplementationOfConstantsMixin<ir.Primitive, dynamic>,
135 BaseImplementationOfNewMixin<ir.Primitive, dynamic>, 135 BaseImplementationOfNewMixin<ir.Primitive, dynamic>,
136 BaseImplementationOfCompoundsMixin<ir.Primitive, dynamic>, 136 BaseImplementationOfCompoundsMixin<ir.Primitive, dynamic>,
137 BaseImplementationOfSetIfNullsMixin<ir.Primitive, dynamic>, 137 BaseImplementationOfSetIfNullsMixin<ir.Primitive, dynamic>,
138 BaseImplementationOfIndexCompoundsMixin<ir.Primitive, dynamic> 138 BaseImplementationOfIndexCompoundsMixin<ir.Primitive, dynamic>,
139 BaseImplementationOfSuperIndexSetIfNullMixin<ir.Primitive, dynamic>
139 implements SemanticSendVisitor<ir.Primitive, dynamic> { 140 implements SemanticSendVisitor<ir.Primitive, dynamic> {
140 final TreeElements elements; 141 final TreeElements elements;
141 final Compiler compiler; 142 final Compiler compiler;
142 final SourceInformationBuilder sourceInformationBuilder; 143 final SourceInformationBuilder sourceInformationBuilder;
143 final TypeMaskSystem typeMaskSystem; 144 final TypeMaskSystem typeMaskSystem;
144 145
145 /// A map from try statements in the source to analysis information about 146 /// A map from try statements in the source to analysis information about
146 /// them. 147 /// them.
147 /// 148 ///
148 /// The analysis information includes the set of variables that must be 149 /// The analysis information includes the set of variables that must be
(...skipping 2561 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 ast.Node index, 2711 ast.Node index,
2711 ast.Node rhs, 2712 ast.Node rhs,
2712 _) { 2713 _) {
2713 return irBuilder.buildSuperIndexSet( 2714 return irBuilder.buildSuperIndexSet(
2714 function, 2715 function,
2715 visit(index), 2716 visit(index),
2716 visit(rhs), 2717 visit(rhs),
2717 sourceInformationBuilder.buildIndexSet(node)); 2718 sourceInformationBuilder.buildIndexSet(node));
2718 } 2719 }
2719 2720
2721 ir.Primitive translateIfNull(
2722 ast.SendSet node,
2723 ir.Primitive getValue(),
2724 ast.Node rhs,
2725 void setValue(ir.Primitive value)) {
2726 ir.Primitive value = getValue();
2727 // Unlike other compound operators if-null conditionally will not do the
2728 // assignment operation.
2729 return irBuilder.buildIfNull(value, nested(() {
2730 ir.Primitive newValue = build(rhs);
2731 setValue(newValue);
2732 return newValue;
2733 }),
2734 sourceInformationBuilder.buildIf(node));
2735 }
2736
2720 ir.Primitive translateCompounds( 2737 ir.Primitive translateCompounds(
2721 ast.SendSet node, 2738 ast.SendSet node,
2722 ir.Primitive getValue(), 2739 ir.Primitive getValue(),
2723 CompoundRhs rhs, 2740 CompoundRhs rhs,
2724 void setValue(ir.Primitive value)) { 2741 void setValue(ir.Primitive value)) {
2725 ir.Primitive value = getValue(); 2742 ir.Primitive value = getValue();
2726 op.BinaryOperator operator = rhs.operator; 2743 op.BinaryOperator operator = rhs.operator;
2727 if (operator.kind == op.BinaryOperatorKind.IF_NULL) { 2744 assert(operator.kind != op.BinaryOperatorKind.IF_NULL);
2728 // Unlike other compound operators if-null conditionally will not do the
2729 // assignment operation.
2730 return irBuilder.buildIfNull(value, nested(() {
2731 ir.Primitive newValue = build(rhs.rhs);
2732 setValue(newValue);
2733 return newValue;
2734 }),
2735 sourceInformationBuilder.buildIf(node));
2736 }
2737 2745
2738 Selector operatorSelector = 2746 Selector operatorSelector =
2739 new Selector.binaryOperator(operator.selectorName); 2747 new Selector.binaryOperator(operator.selectorName);
2740 ir.Primitive rhsValue; 2748 ir.Primitive rhsValue;
2741 if (rhs.kind == CompoundKind.ASSIGNMENT) { 2749 if (rhs.kind == CompoundKind.ASSIGNMENT) {
2742 rhsValue = visit(rhs.rhs); 2750 rhsValue = visit(rhs.rhs);
2743 } else { 2751 } else {
2744 rhsValue = irBuilder.buildIntegerConstant(1); 2752 rhsValue = irBuilder.buildIntegerConstant(1);
2745 } 2753 }
2746 List<ir.Primitive> arguments = <ir.Primitive>[rhsValue]; 2754 List<ir.Primitive> arguments = <ir.Primitive>[rhsValue];
(...skipping 24 matching lines...) Expand all
2771 // assignment operation. 2779 // assignment operation.
2772 return irBuilder.buildIfNull(value, nested(() { 2780 return irBuilder.buildIfNull(value, nested(() {
2773 ir.Primitive newValue = build(rhs); 2781 ir.Primitive newValue = build(rhs);
2774 setValue(newValue); 2782 setValue(newValue);
2775 return newValue; 2783 return newValue;
2776 }), 2784 }),
2777 sourceInformationBuilder.buildIf(node)); 2785 sourceInformationBuilder.buildIf(node));
2778 } 2786 }
2779 2787
2780 @override 2788 @override
2789 ir.Primitive handleSuperIndexSetIfNull(
2790 ast.SendSet node,
2791 Element indexFunction,
2792 Element indexSetFunction,
2793 ast.Node index,
2794 ast.Node rhs,
2795 arg,
2796 {bool isGetterValid,
2797 bool isSetterValid}) {
2798 return translateSetIfNull(node, () {
2799 if (isGetterValid) {
2800 return irBuilder.buildSuperMethodGet(
2801 indexFunction, sourceInformationBuilder.buildIndex(node));
2802 } else {
2803 return buildSuperNoSuchGetter(
2804 indexFunction,
2805 elements.getGetterTypeMaskInComplexSendSet(node),
2806 sourceInformationBuilder.buildIndex(node));
2807 }
2808 }, rhs, (ir.Primitive result) {
2809 if (isSetterValid) {
2810 return irBuilder.buildSuperMethodGet(
2811 indexSetFunction, sourceInformationBuilder.buildIndexSet(node));
2812 } else {
2813 return buildSuperNoSuchSetter(
2814 indexSetFunction, elements.getTypeMask(node), result,
2815 sourceInformationBuilder.buildIndexSet(node));
2816 }
2817 });
2818 }
2819
2820 @override
2821 ir.Primitive visitIndexSetIfNull(
2822 ast.SendSet node,
2823 ast.Node receiver,
2824 ast.Node index,
2825 ast.Node rhs,
2826 arg) {
2827 ir.Primitive target = visit(receiver);
2828 ir.Primitive indexValue = visit(index);
2829 return translateSetIfNull(node, () {
2830 Selector selector = new Selector.index();
2831 List<ir.Primitive> arguments = <ir.Primitive>[indexValue];
2832 CallStructure callStructure =
2833 normalizeDynamicArguments(selector.callStructure, arguments);
2834 return irBuilder.buildDynamicInvocation(
2835 target,
2836 new Selector(selector.kind, selector.memberName, callStructure),
2837 elements.getGetterTypeMaskInComplexSendSet(node),
2838 arguments,
2839 sourceInformationBuilder.buildCall(receiver, node));
2840 }, rhs, (ir.Primitive result) {
2841 irBuilder.buildDynamicIndexSet(
2842 target,
2843 elements.getTypeMask(node),
2844 indexValue,
2845 result,
2846 sourceInformationBuilder.buildIndexSet(node));
2847 });
2848 }
2849
2850 @override
2781 ir.Primitive handleDynamicSet( 2851 ir.Primitive handleDynamicSet(
2782 ast.SendSet node, 2852 ast.SendSet node,
2783 ast.Node receiver, 2853 ast.Node receiver,
2784 Name name, 2854 Name name,
2785 ast.Node rhs, 2855 ast.Node rhs,
2786 _) { 2856 _) {
2787 return irBuilder.buildDynamicSet( 2857 return irBuilder.buildDynamicSet(
2788 translateReceiver(receiver), 2858 translateReceiver(receiver),
2789 new Selector.setter(name), 2859 new Selector.setter(name),
2790 elements.getTypeMask(node), 2860 elements.getTypeMask(node),
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass); 4327 _backend.jsInteropAnalysis.hasAnonymousAnnotation(element.contextClass);
4258 4328
4259 String getJsInteropTargetPath(FunctionElement element) { 4329 String getJsInteropTargetPath(FunctionElement element) {
4260 return '${_backend.namer.fixedBackendPath(element)}.' 4330 return '${_backend.namer.fixedBackendPath(element)}.'
4261 '${_backend.nativeData.getFixedBackendName(element)}'; 4331 '${_backend.nativeData.getFixedBackendName(element)}';
4262 } 4332 }
4263 4333
4264 DartType get jsJavascriptObjectType => 4334 DartType get jsJavascriptObjectType =>
4265 _backend.helpers.jsJavaScriptObjectClass.thisType; 4335 _backend.helpers.jsJavaScriptObjectClass.thisType;
4266 } 4336 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698