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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/ValidResult.java

Issue 29313003: Don't evaluate << because of possible overflow. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/constant/ConstantEvaluatorTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/ValidResult.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/ValidResult.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/ValidResult.java
index 1d3bc3b3a8e18fad0d565362af019b27cbd0997e..c735cafc1623955630e753c485e9c8a95765c206 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/ValidResult.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/ValidResult.java
@@ -41,7 +41,7 @@ public class ValidResult extends EvaluationResultImpl {
* A result object representing the an arbitrary integer on which no further operations can be
* performed.
*/
- public static final ValidResult RESULT_INT = new ValidResult(null);
+ public static final ValidResult RESULT_INT = new ValidResult(0);
/**
* A result object representing the {@code null} value.
@@ -252,6 +252,12 @@ public class ValidResult extends EvaluationResultImpl {
return valueOf(((Double) value).toString());
} else if (value instanceof String) {
return this;
+ } else if (isSomeBool()) {
+ return valueOf("<some bool>");
+ } else if (isSomeInt()) {
+ return valueOf("<some int>");
+ } else if (isSomeNum()) {
+ return valueOf("<some num>");
}
return error(node);
}
@@ -867,7 +873,8 @@ public class ValidResult extends EvaluationResultImpl {
return error(node.getRightOperand());
} else if (leftValue instanceof BigInteger) {
if (value instanceof BigInteger) {
- return valueOf(((BigInteger) leftValue).shiftLeft(((BigInteger) value).intValue()));
+ // we cannot always evaluate "shift left" because of possible overflow
+ return RESULT_INT;
}
return error(node.getRightOperand());
}
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/constant/ConstantEvaluatorTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698