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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java

Issue 113143004: Constant evaluation support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Clean-up Created 7 years 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/hint/DeadCodeVerifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java
index ec682e23341246f3b0e9d7366de5b14274a67093..0b5189be45cf90647d693c4e702dc95151ac328f 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/DeadCodeVerifier.java
@@ -36,6 +36,8 @@ import com.google.dart.engine.element.PropertyInducingElement;
import com.google.dart.engine.error.HintCode;
import com.google.dart.engine.internal.constant.ValidResult;
import com.google.dart.engine.internal.error.ErrorReporter;
+import com.google.dart.engine.internal.object.BoolState;
+import com.google.dart.engine.internal.object.DartObjectImpl;
import com.google.dart.engine.scanner.Token;
import com.google.dart.engine.scanner.TokenType;
import com.google.dart.engine.type.Type;
@@ -74,13 +76,13 @@ public class DeadCodeVerifier extends RecursiveASTVisitor<Void> {
if (!isDebugConstant(lhsCondition)) {
ValidResult lhsResult = getConstantBooleanValue(lhsCondition);
if (lhsResult != null) {
- if (lhsResult == ValidResult.RESULT_TRUE && isBarBar) {
+ if (lhsResult.isTrue() && isBarBar) {
// report error on else block: true || !e!
errorReporter.reportError(HintCode.DEAD_CODE, node.getRightOperand());
// only visit the LHS:
safelyVisit(lhsCondition);
return null;
- } else if (lhsResult == ValidResult.RESULT_FALSE && isAmpAmp) {
+ } else if (lhsResult.isFalse() && isAmpAmp) {
// report error on if block: false && !e!
errorReporter.reportError(HintCode.DEAD_CODE, node.getRightOperand());
// only visit the LHS:
@@ -143,7 +145,7 @@ public class DeadCodeVerifier extends RecursiveASTVisitor<Void> {
if (!isDebugConstant(conditionExpression)) {
ValidResult result = getConstantBooleanValue(conditionExpression);
if (result != null) {
- if (result == ValidResult.RESULT_TRUE) {
+ if (result.isTrue()) {
// report error on else block: true ? 1 : !2!
errorReporter.reportError(HintCode.DEAD_CODE, node.getElseExpression());
safelyVisit(node.getThenExpression());
@@ -183,7 +185,7 @@ public class DeadCodeVerifier extends RecursiveASTVisitor<Void> {
if (!isDebugConstant(conditionExpression)) {
ValidResult result = getConstantBooleanValue(conditionExpression);
if (result != null) {
- if (result == ValidResult.RESULT_TRUE) {
+ if (result.isTrue()) {
// report error on else block: if(true) {} else {!}
Statement elseStatement = node.getElseStatement();
if (elseStatement != null) {
@@ -274,7 +276,7 @@ public class DeadCodeVerifier extends RecursiveASTVisitor<Void> {
if (!isDebugConstant(conditionExpression)) {
ValidResult result = getConstantBooleanValue(conditionExpression);
if (result != null) {
- if (result == ValidResult.RESULT_FALSE) {
+ if (result.isFalse()) {
// report error on if block: while (false) {!}
errorReporter.reportError(HintCode.DEAD_CODE, node.getBody());
return null;
@@ -298,9 +300,9 @@ public class DeadCodeVerifier extends RecursiveASTVisitor<Void> {
private ValidResult getConstantBooleanValue(Expression expression) {
if (expression instanceof BooleanLiteral) {
if (((BooleanLiteral) expression).getValue()) {
- return ValidResult.RESULT_TRUE;
+ return new ValidResult(new DartObjectImpl(null, BoolState.from(true)));
} else {
- return ValidResult.RESULT_FALSE;
+ return new ValidResult(new DartObjectImpl(null, BoolState.from(false)));
}
}
// Don't consider situations where we could evaluate to a constant boolean expression with the

Powered by Google App Engine
This is Rietveld 408576698