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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/send_structure.dart
diff --git a/pkg/compiler/lib/src/resolution/send_structure.dart b/pkg/compiler/lib/src/resolution/send_structure.dart
index 15e5d500f44034a8b561d1aed7fd7954cf47bbee..bdf8762cb77ce4ae6931b1632f0b71811e871559 100644
--- a/pkg/compiler/lib/src/resolution/send_structure.dart
+++ b/pkg/compiler/lib/src/resolution/send_structure.dart
@@ -2100,6 +2100,45 @@ class LateConstInvokeStructure<R, A> extends NewStructure<R, A> {
LateConstInvokeStructure(this.elements);
+ /// Convert this new structure into a regular new structure using the data
+ /// available in [elements].
+ NewStructure resolve(NewExpression node) {
+ Element element = elements[node.send];
+ Selector selector = elements.getSelector(node.send);
+ DartType type = elements.getType(node);
+ ConstantExpression constant = elements.getConstant(node);
+ if (element.isMalformed ||
+ constant == null ||
+ constant.kind == ConstantExpressionKind.ERRONEOUS) {
+ // This is a non-constant constant constructor invocation, like
+ // `const Const(method())`.
+ return new NewInvokeStructure(
+ new ConstructorAccessSemantics(
+ ConstructorAccessKind.NON_CONSTANT_CONSTRUCTOR, element, type),
+ selector);
+ } else {
+ ConstantInvokeKind kind;
+ switch (constant.kind) {
+ case ConstantExpressionKind.CONSTRUCTED:
+ kind = ConstantInvokeKind.CONSTRUCTED;
+ break;
+ case ConstantExpressionKind.BOOL_FROM_ENVIRONMENT:
+ kind = ConstantInvokeKind.BOOL_FROM_ENVIRONMENT;
+ break;
+ case ConstantExpressionKind.INT_FROM_ENVIRONMENT:
+ kind = ConstantInvokeKind.INT_FROM_ENVIRONMENT;
+ break;
+ case ConstantExpressionKind.STRING_FROM_ENVIRONMENT:
+ kind = ConstantInvokeKind.STRING_FROM_ENVIRONMENT;
+ break;
+ default:
+ throw new SpannableAssertionFailure(
+ node, "Unexpected constant kind $kind: ${constant.getText()}");
+ }
+ return new ConstInvokeStructure(kind, constant);
+ }
+ }
+
R dispatch(SemanticSendVisitor<R, A> visitor, NewExpression node, A arg) {
Element element = elements[node.send];
Selector selector = elements.getSelector(node.send);
« 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