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

Side by Side Diff: pkg/compiler/lib/src/resolution/send_structure.dart

Issue 1869383002: Replace LateConstInvokeStructure after analysis. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.resolution.send_structure; 5 library dart2js.resolution.send_structure;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../dart_types.dart'; 9 import '../dart_types.dart';
10 import '../elements/elements.dart'; 10 import '../elements/elements.dart';
(...skipping 2813 matching lines...) Expand 10 before | Expand all | Expand 10 after
2824 2824
2825 /// A constant constructor invocation that couldn't be determined fully during 2825 /// A constant constructor invocation that couldn't be determined fully during
2826 /// resolution. 2826 /// resolution.
2827 // TODO(johnniwinther): Remove this when all constants are computed during 2827 // TODO(johnniwinther): Remove this when all constants are computed during
2828 // resolution. 2828 // resolution.
2829 class LateConstInvokeStructure<R, A> extends NewStructure<R, A> { 2829 class LateConstInvokeStructure<R, A> extends NewStructure<R, A> {
2830 final TreeElements elements; 2830 final TreeElements elements;
2831 2831
2832 LateConstInvokeStructure(this.elements); 2832 LateConstInvokeStructure(this.elements);
2833 2833
2834 /// Convert this new structure into a regular new structure using the data
2835 /// available in [elements].
2836 NewStructure resolve(NewExpression node) {
2837 Element element = elements[node.send];
2838 Selector selector = elements.getSelector(node.send);
2839 DartType type = elements.getType(node);
2840 ConstantExpression constant = elements.getConstant(node);
2841 if (element.isMalformed ||
2842 constant == null ||
2843 constant.kind == ConstantExpressionKind.ERRONEOUS) {
2844 // This is a non-constant constant constructor invocation, like
2845 // `const Const(method())`.
2846 return new NewInvokeStructure(
2847 new ConstructorAccessSemantics(
2848 ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR, element, type),
2849 selector);
2850 } else {
2851 ConstantInvokeKind kind;
2852 switch (constant.kind) {
2853 case ConstantExpressionKind.CONSTRUCTED:
2854 kind = ConstantInvokeKind.CONSTRUCTED;
2855 break;
2856 case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT:
2857 kind = ConstantInvokeKind.BOOL_FROM_ENVIRONMENT;
2858 break;
2859 case ConstantExpressionKind.INT_FROM_ENVIRONMENT:
2860 kind = ConstantInvokeKind.INT_FROM_ENVIRONMENT;
2861 break;
2862 case ConstantExpressionKind.STRING_FROM_ENVIRONMENT:
2863 kind = ConstantInvokeKind.STRING_FROM_ENVIRONMENT;
2864 break;
2865 default:
2866 throw new SpannableAssertionFailure(
2867 node, "Unexpected constant kind $kind: ${constant.getText()}");
2868 }
2869 return new ConstInvokeStructure(kind, constant);
2870 }
2871 }
2872
2834 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { 2873 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
2835 Element element = elements[node.send]; 2874 Element element = elements[node.send];
2836 Selector selector = elements.getSelector(node.send); 2875 Selector selector = elements.getSelector(node.send);
2837 DartType type = elements.getType(node); 2876 DartType type = elements.getType(node);
2838 ConstantExpression constant = elements.getConstant(node); 2877 ConstantExpression constant = elements.getConstant(node);
2839 if (element.isMalformed || 2878 if (element.isMalformed ||
2840 constant == null || 2879 constant == null ||
2841 constant.kind == ConstantExpressionKind.ERRONEOUS) { 2880 constant.kind == ConstantExpressionKind.ERRONEOUS) {
2842 // This is a non-constant constant constructor invocation, like 2881 // This is a non-constant constant constructor invocation, like
2843 // `const Const(method())`. 2882 // `const Const(method())`.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
3092 ThisConstructorInvokeStructure( 3131 ThisConstructorInvokeStructure(
3093 this.node, this.constructor, this.callStructure); 3132 this.node, this.constructor, this.callStructure);
3094 3133
3095 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { 3134 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) {
3096 return visitor.visitThisConstructorInvoke( 3135 return visitor.visitThisConstructorInvoke(
3097 node, constructor, node.argumentsNode, callStructure, arg); 3136 node, constructor, node.argumentsNode, callStructure, arg);
3098 } 3137 }
3099 3138
3100 bool get isConstructorInvoke => true; 3139 bool get isConstructorInvoke => true;
3101 } 3140 }
OLDNEW
« pkg/compiler/lib/src/resolution/members.dart ('K') | « pkg/compiler/lib/src/resolution/members.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698