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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/InstanceCreationExpression.java

Issue 270813004: Evaluate constant instance creation expressions in ConstantValueComputer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/InstanceCreationExpression.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/InstanceCreationExpression.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/InstanceCreationExpression.java
index ef4045c30a823618dd2e9455e390de75b8dd6220..5bc3ff3f60c1ebbea7ad6ec97d1cb18e1e2b0845 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/InstanceCreationExpression.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/ast/InstanceCreationExpression.java
@@ -14,6 +14,7 @@
package com.google.dart.engine.ast;
import com.google.dart.engine.element.ConstructorElement;
+import com.google.dart.engine.internal.constant.EvaluationResultImpl;
import com.google.dart.engine.scanner.Keyword;
import com.google.dart.engine.scanner.KeywordToken;
import com.google.dart.engine.scanner.Token;
@@ -52,6 +53,11 @@ public class InstanceCreationExpression extends Expression {
private ConstructorElement staticElement;
/**
+ * The result of evaluating this expression, if it is constant.
+ */
+ private EvaluationResultImpl result;
+
+ /**
* Initialize a newly created instance creation expression.
*
* @param keyword the keyword used to indicate how an object should be created
@@ -99,6 +105,17 @@ public class InstanceCreationExpression extends Expression {
}
/**
+ * Return the result of evaluating this constant as a compile-time constant expression, or
+ * {@code null} if this variable is not a 'const' expression or an error prevented the result from
+ * being computed.
+ *
+ * @return the result of evaluating this constant
+ */
+ public EvaluationResultImpl getEvaluationResult() {
+ return result;
+ }
+
+ /**
* Return the keyword used to indicate how an object should be created.
*
* @return the keyword used to indicate how an object should be created
@@ -152,6 +169,16 @@ public class InstanceCreationExpression extends Expression {
}
/**
+ * Set the result of evaluating this expression as a compile-time constant expression to the given
+ * result.
+ *
+ * @param result the result of evaluating this expression
+ */
+ public void setEvaluationResult(EvaluationResultImpl result) {
+ this.result = result;
+ }
+
+ /**
* Set the keyword used to indicate how an object should be created to the given keyword.
*
* @param keyword the keyword used to indicate how an object should be created

Powered by Google App Engine
This is Rietveld 408576698