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

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: Use newer dartfmt 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 | « pkg/compiler/lib/src/resolution/members.dart ('k') | no next file » | 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) 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 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 2093
2094 /// A constant constructor invocation that couldn't be determined fully during 2094 /// A constant constructor invocation that couldn't be determined fully during
2095 /// resolution. 2095 /// resolution.
2096 // TODO(johnniwinther): Remove this when all constants are computed during 2096 // TODO(johnniwinther): Remove this when all constants are computed during
2097 // resolution. 2097 // resolution.
2098 class LateConstInvokeStructure<R, A> extends NewStructure<R, A> { 2098 class LateConstInvokeStructure<R, A> extends NewStructure<R, A> {
2099 final TreeElements elements; 2099 final TreeElements elements;
2100 2100
2101 LateConstInvokeStructure(this.elements); 2101 LateConstInvokeStructure(this.elements);
2102 2102
2103 /// Convert this new structure into a regular new structure using the data
2104 /// available in [elements].
2105 NewStructure resolve(NewExpression node) {
2106 Element element = elements[node.send];
2107 Selector selector = elements.getSelector(node.send);
2108 DartType type = elements.getType(node);
2109 ConstantExpression constant = elements.getConstant(node);
2110 if (element.isMalformed ||
2111 constant == null ||
2112 constant.kind == ConstantExpressionKind.ERRONEOUS) {
2113 // This is a non-constant constant constructor invocation, like
2114 // `const Const(method())`.
2115 return new NewInvokeStructure(
2116 new ConstructorAccessSemantics(
2117 ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR, element, type),
2118 selector);
2119 } else {
2120 ConstantInvokeKind kind;
2121 switch (constant.kind) {
2122 case ConstantExpressionKind.CONSTRUCTED:
2123 kind = ConstantInvokeKind.CONSTRUCTED;
2124 break;
2125 case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT:
2126 kind = ConstantInvokeKind.BOOL_FROM_ENVIRONMENT;
2127 break;
2128 case ConstantExpressionKind.INT_FROM_ENVIRONMENT:
2129 kind = ConstantInvokeKind.INT_FROM_ENVIRONMENT;
2130 break;
2131 case ConstantExpressionKind.STRING_FROM_ENVIRONMENT:
2132 kind = ConstantInvokeKind.STRING_FROM_ENVIRONMENT;
2133 break;
2134 default:
2135 throw new SpannableAssertionFailure(
2136 node, "Unexpected constant kind $kind: ${constant.getText()}");
2137 }
2138 return new ConstInvokeStructure(kind, constant);
2139 }
2140 }
2141
2103 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) { 2142 R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
2104 Element element = elements[node.send]; 2143 Element element = elements[node.send];
2105 Selector selector = elements.getSelector(node.send); 2144 Selector selector = elements.getSelector(node.send);
2106 DartType type = elements.getType(node); 2145 DartType type = elements.getType(node);
2107 ConstantExpression constant = elements.getConstant(node); 2146 ConstantExpression constant = elements.getConstant(node);
2108 if (element.isMalformed || 2147 if (element.isMalformed ||
2109 constant == null || 2148 constant == null ||
2110 constant.kind == ConstantExpressionKind.ERRONEOUS) { 2149 constant.kind == ConstantExpressionKind.ERRONEOUS) {
2111 // This is a non-constant constant constructor invocation, like 2150 // This is a non-constant constant constructor invocation, like
2112 // `const Const(method())`. 2151 // `const Const(method())`.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 ThisConstructorInvokeStructure( 2380 ThisConstructorInvokeStructure(
2342 this.node, this.constructor, this.callStructure); 2381 this.node, this.constructor, this.callStructure);
2343 2382
2344 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) { 2383 R dispatch(SemanticDeclarationVisitor<R, A> visitor, A arg) {
2345 return visitor.visitThisConstructorInvoke( 2384 return visitor.visitThisConstructorInvoke(
2346 node, constructor, node.argumentsNode, callStructure, arg); 2385 node, constructor, node.argumentsNode, callStructure, arg);
2347 } 2386 }
2348 2387
2349 bool get isConstructorInvoke => true; 2388 bool get isConstructorInvoke => true;
2350 } 2389 }
OLDNEW
« no previous file with comments | « 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