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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/InstanceState.java

Issue 581773002: Implement new constant expressions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 6 years, 3 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/internal/object/InstanceState.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/InstanceState.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/InstanceState.java
index 1b5f1bf74e8771ed6ce66709c4326cb104d7f8d7..6e21041afd76d2e4f40138bb9607a83fcffdad5b 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/InstanceState.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/object/InstanceState.java
@@ -29,7 +29,10 @@ public abstract class InstanceState {
* @return the result of invoking the '+' operator on this object with the given argument
* @throws EvaluationException if the operator is not appropriate for an object of this kind
*/
- public NumState add(InstanceState rightOperand) throws EvaluationException {
+ public InstanceState add(InstanceState rightOperand) throws EvaluationException {
+ if (this instanceof StringState || rightOperand instanceof StringState) {
+ return concatenate(rightOperand);
+ }
assertNumOrNull(this);
assertNumOrNull(rightOperand);
throw new EvaluationException(CompileTimeErrorCode.INVALID_CONSTANT);
@@ -93,6 +96,7 @@ public abstract class InstanceState {
* @throws EvaluationException if the operator is not appropriate for an object of this kind
*/
public StringState concatenate(InstanceState rightOperand) throws EvaluationException {
+ assertString(rightOperand);
throw new EvaluationException(CompileTimeErrorCode.INVALID_CONSTANT);
}
@@ -364,6 +368,17 @@ public abstract class InstanceState {
}
/**
+ * Return the result of invoking the 'length' getter on this object.
+ *
+ * @return the result of invoking the 'length' getter on this object
+ * @throws EvaluationException if the operator is not appropriate for an object of this kind
+ */
+ public IntState stringLength() throws EvaluationException {
+ assertString(this);
+ throw new EvaluationException(CompileTimeErrorCode.INVALID_CONSTANT);
+ }
+
+ /**
* Return the result of invoking the '*' operator on this object with the given argument.
*
* @param rightOperand the right-hand operand of the operation

Powered by Google App Engine
This is Rietveld 408576698