diff --git a/src/com/google/dart/compiler/backend/js/ast/CanBooleanEval.java b/src/com/google/dart/compiler/backend/js/ast/CanBooleanEval.java deleted file mode 100644 index 4213394da22..00000000000 --- a/src/com/google/dart/compiler/backend/js/ast/CanBooleanEval.java +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -package com.google.dart.compiler.backend.js.ast; - -/** - * An interface that describes the boolean evaluation of an expression. - */ -public interface CanBooleanEval { - boolean isBooleanFalse(); - boolean isBooleanTrue(); -} diff --git a/src/com/google/dart/compiler/backend/js/ast/ChameleonJsExpression.java b/src/com/google/dart/compiler/backend/js/ast/ChameleonJsExpression.java index e3c0a06c85a..4229c344dd0 100644 --- a/src/com/google/dart/compiler/backend/js/ast/ChameleonJsExpression.java +++ b/src/com/google/dart/compiler/backend/js/ast/ChameleonJsExpression.java @@ -14,21 +14,6 @@ public class ChameleonJsExpression implements JsExpression { this.expression = expression; } - @Override - public boolean hasSideEffects() { - return expression.hasSideEffects(); - } - - @Override - public boolean isDefinitelyNotNull() { - return expression.isDefinitelyNotNull(); - } - - @Override - public boolean isDefinitelyNull() { - return expression.isDefinitelyNull(); - } - @Override public boolean isLeaf() { return expression.isLeaf(); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsArrayAccess.java b/src/com/google/dart/compiler/backend/js/ast/JsArrayAccess.java index 7b53b3f5351..94e7470095c 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsArrayAccess.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsArrayAccess.java @@ -28,21 +28,6 @@ public final class JsArrayAccess extends JsExpressionImpl { return indexExpression; } - @Override - public boolean hasSideEffects() { - return arrayExpression.hasSideEffects() || indexExpression.hasSideEffects(); - } - - @Override - public boolean isDefinitelyNotNull() { - return false; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - public void setArrayExpression(JsExpression arrayExpression) { this.arrayExpression = arrayExpression; } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.java b/src/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.java index 6358d3c34e7..8d43ed05758 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsArrayLiteral.java @@ -26,36 +26,6 @@ public final class JsArrayLiteral extends JsLiteral { return expressions; } - @Override - public boolean hasSideEffects() { - for (JsExpression expr : expressions) { - if (expr.hasSideEffects()) { - return true; - } - } - return false; - } - - @Override - public boolean isBooleanFalse() { - return false; - } - - @Override - public boolean isBooleanTrue() { - return true; - } - - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitArray(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.java b/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.java index d29fffc5808..e0e0405da4e 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsBinaryOperation.java @@ -33,38 +33,6 @@ public final class JsBinaryOperation extends JsExpressionImpl { return op; } - @Override - public boolean hasSideEffects() { - return op.isAssignment() || arg1.hasSideEffects() || arg2.hasSideEffects(); - } - - @Override - public boolean isDefinitelyNotNull() { - // Precarious coding, but none of these can have null results. - if (op.getPrecedence() > 5) { - return true; - } - if (op == JsBinaryOperator.OR) { - if (arg1 instanceof CanBooleanEval) { - if (((CanBooleanEval) arg1).isBooleanTrue()) { - assert arg1.isDefinitelyNotNull(); - return true; - } - } - } - // AND and OR can return nulls - if (op.isAssignment()) { - return op != JsBinaryOperator.ASG || arg2.isDefinitelyNotNull(); - } - - return op == JsBinaryOperator.COMMA && arg2.isDefinitelyNotNull(); - } - - @Override - public boolean isDefinitelyNull() { - return op == JsBinaryOperator.AND && arg1.isDefinitelyNull(); - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitBinaryExpression(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsConditional.java b/src/com/google/dart/compiler/backend/js/ast/JsConditional.java index bbf013065a4..97695c35b8d 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsConditional.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsConditional.java @@ -30,21 +30,6 @@ public final class JsConditional extends JsExpressionImpl { return thenExpression; } - @Override - public boolean hasSideEffects() { - return testExpression.hasSideEffects() || thenExpression.hasSideEffects() || elseExpression.hasSideEffects(); - } - - @Override - public boolean isDefinitelyNotNull() { - return thenExpression.isDefinitelyNotNull() && elseExpression.isDefinitelyNotNull(); - } - - @Override - public boolean isDefinitelyNull() { - return thenExpression.isDefinitelyNull() && elseExpression.isDefinitelyNull(); - } - public void setElseExpression(JsExpression elseExpression) { this.elseExpression = elseExpression; } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsDocComment.java b/src/com/google/dart/compiler/backend/js/ast/JsDocComment.java index da90d894862..60f83d394f8 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsDocComment.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsDocComment.java @@ -26,19 +26,4 @@ public class JsDocComment extends JsExpressionImpl { public void accept(JsVisitor v, JsContext context) { v.visitDocComment(this, context); } - - @Override - public boolean hasSideEffects() { - return false; - } - - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsExpression.java b/src/com/google/dart/compiler/backend/js/ast/JsExpression.java index 5cbc2bd4284..b4f8828c751 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsExpression.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsExpression.java @@ -3,21 +3,6 @@ package com.google.dart.compiler.backend.js.ast; import com.google.dart.compiler.common.HasSourceInfo; public interface JsExpression extends JsNode, HasSourceInfo { - /** - * Determines whether the expression can cause side effects. - */ - boolean hasSideEffects(); - - /** - * True if the target expression is definitely not null. - */ - boolean isDefinitelyNotNull(); - - /** - * True if the target expression is definitely null. - */ - boolean isDefinitelyNull(); - boolean isLeaf(); JsStatement makeStmt(); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsFunction.java b/src/com/google/dart/compiler/backend/js/ast/JsFunction.java index 12ac1d58e34..d9a60fc4e4a 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsFunction.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsFunction.java @@ -55,32 +55,6 @@ public final class JsFunction extends JsLiteral implements HasName { return scope; } - @Override - public boolean hasSideEffects() { - // If there's a name, the name is assigned to. - return name != null; - } - - @Override - public boolean isBooleanFalse() { - return false; - } - - @Override - public boolean isBooleanTrue() { - return true; - } - - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - public void setBody(JsBlock body) { this.body = body; } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsInvocation.java b/src/com/google/dart/compiler/backend/js/ast/JsInvocation.java index 08ad8f77df0..234f7b16e11 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsInvocation.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsInvocation.java @@ -47,21 +47,6 @@ public final class JsInvocation extends JsExpressionImpl.JsExpressionHasArgument return qualifier; } - @Override - public boolean hasSideEffects() { - return true; - } - - @Override - public boolean isDefinitelyNotNull() { - return false; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - public void setQualifier(JsExpression qualifier) { this.qualifier = qualifier; } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsLiteral.java b/src/com/google/dart/compiler/backend/js/ast/JsLiteral.java index 2e1925abf30..574a7e99e94 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsLiteral.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsLiteral.java @@ -4,7 +4,7 @@ package com.google.dart.compiler.backend.js.ast; -public abstract class JsLiteral extends JsExpressionImpl implements CanBooleanEval { +public abstract class JsLiteral extends JsExpressionImpl { public static final JsValueLiteral THIS = new JsThisRef(); public static final JsNameRef UNDEFINED = new JsNameRef("undefined"); @@ -22,26 +22,6 @@ public abstract class JsLiteral extends JsExpressionImpl implements CanBooleanEv super(); } - @Override - public boolean isBooleanFalse() { - return false; - } - - @Override - public boolean isBooleanTrue() { - return true; - } - - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitThis(this, context); @@ -60,26 +40,6 @@ public abstract class JsLiteral extends JsExpressionImpl implements CanBooleanEv return value; } - @Override - public boolean isBooleanFalse() { - return !value; - } - - @Override - public boolean isBooleanTrue() { - return value; - } - - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitBoolean(this, context); @@ -93,11 +53,6 @@ public abstract class JsLiteral extends JsExpressionImpl implements CanBooleanEv protected JsValueLiteral() { } - @Override - public final boolean hasSideEffects() { - return false; - } - @Override public final boolean isLeaf() { return true; diff --git a/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java b/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java index 97edc3e8728..3dcfea61d98 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsNameRef.java @@ -9,7 +9,7 @@ import com.google.dart.compiler.common.Symbol; /** * Represents a JavaScript expression that references a name. */ -public final class JsNameRef extends JsExpressionImpl implements CanBooleanEval, HasName { +public final class JsNameRef extends JsExpressionImpl implements HasName { private String ident; private JsName name; private JsExpression qualifier; @@ -54,31 +54,6 @@ public final class JsNameRef extends JsExpressionImpl implements CanBooleanEval, return qualifier; } - @Override - public boolean hasSideEffects() { - return qualifier != null && (!qualifier.isDefinitelyNotNull() || qualifier.hasSideEffects()); - } - - @Override - public boolean isBooleanFalse() { - return isDefinitelyNull(); - } - - @Override - public boolean isBooleanTrue() { - return false; - } - - @Override - public boolean isDefinitelyNotNull() { - return false; - } - - @Override - public boolean isDefinitelyNull() { - return name != null && (JsLiteral.UNDEFINED.getName() == name); - } - @Override public boolean isLeaf() { return qualifier == null; diff --git a/src/com/google/dart/compiler/backend/js/ast/JsNew.java b/src/com/google/dart/compiler/backend/js/ast/JsNew.java index 66af5cbf4f5..a5eecda234c 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsNew.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsNew.java @@ -24,23 +24,6 @@ public final class JsNew extends JsExpressionImpl.JsExpressionHasArguments { return constructorExpression; } - @Override - public boolean hasSideEffects() { - return true; - } - - @Override - public boolean isDefinitelyNotNull() { - // Sadly, in JS it can be! - // TODO: analysis could probably determine most instances cannot be null. - return false; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitNew(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsNullLiteral.java b/src/com/google/dart/compiler/backend/js/ast/JsNullLiteral.java index 226c8a3bc49..4d9cd17a333 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsNullLiteral.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsNullLiteral.java @@ -8,26 +8,6 @@ public final class JsNullLiteral extends JsLiteral.JsValueLiteral { JsNullLiteral() { } - @Override - public boolean isBooleanFalse() { - return true; - } - - @Override - public boolean isBooleanTrue() { - return false; - } - - @Override - public boolean isDefinitelyNotNull() { - return false; - } - - @Override - public boolean isDefinitelyNull() { - return true; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitNull(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.java b/src/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.java index 1cf02b66aa6..9ee62587920 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsNumberLiteral.java @@ -5,16 +5,6 @@ package com.google.dart.compiler.backend.js.ast; public abstract class JsNumberLiteral extends JsLiteral.JsValueLiteral { - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - public static final class JsDoubleLiteral extends JsNumberLiteral { public final double value; @@ -22,16 +12,6 @@ public abstract class JsNumberLiteral extends JsLiteral.JsValueLiteral { this.value = value; } - @Override - public boolean isBooleanFalse() { - return value == 0.0; - } - - @Override - public boolean isBooleanTrue() { - return value != 0.0; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitDouble(this, context); @@ -49,16 +29,6 @@ public abstract class JsNumberLiteral extends JsLiteral.JsValueLiteral { this.value = value; } - @Override - public boolean isBooleanFalse() { - return value == 0; - } - - @Override - public boolean isBooleanTrue() { - return value != 0; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitInt(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.java b/src/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.java index 1d3eb811bc0..9aa35198399 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsObjectLiteral.java @@ -38,36 +38,6 @@ public final class JsObjectLiteral extends JsLiteral { return properties; } - @Override - public boolean hasSideEffects() { - for (JsPropertyInitializer prop : properties) { - if (prop.hasSideEffects()) { - return true; - } - } - return false; - } - - @Override - public boolean isBooleanFalse() { - return false; - } - - @Override - public boolean isBooleanTrue() { - return true; - } - - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitObjectLiteral(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.java b/src/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.java index b77826b9fb8..f86231c8ff6 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsPostfixOperation.java @@ -13,16 +13,6 @@ public final class JsPostfixOperation extends JsUnaryOperation { super(op, arg); } - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitPostfixOperation(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.java b/src/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.java index e08cd06876e..9c943e20e02 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsPrefixOperation.java @@ -4,8 +4,7 @@ package com.google.dart.compiler.backend.js.ast; -public final class JsPrefixOperation extends JsUnaryOperation implements CanBooleanEval { - +public final class JsPrefixOperation extends JsUnaryOperation { public JsPrefixOperation(JsUnaryOperator op) { this(op, null); } @@ -14,37 +13,6 @@ public final class JsPrefixOperation extends JsUnaryOperation implements CanBool super(op, arg); } - @Override - public boolean isBooleanFalse() { - if (getOperator() == JsUnaryOperator.VOID) { - return true; - } - if (getOperator() == JsUnaryOperator.NOT && getArg() instanceof CanBooleanEval) { - CanBooleanEval eval = (CanBooleanEval) getArg(); - return eval.isBooleanTrue(); - } - return false; - } - - @Override - public boolean isBooleanTrue() { - if (getOperator() == JsUnaryOperator.NOT && getArg() instanceof CanBooleanEval) { - CanBooleanEval eval = (CanBooleanEval) getArg(); - return eval.isBooleanFalse(); - } - return getOperator() == JsUnaryOperator.TYPEOF; - } - - @Override - public boolean isDefinitelyNotNull() { - return getOperator() == JsUnaryOperator.TYPEOF || getOperator() != JsUnaryOperator.VOID; - } - - @Override - public boolean isDefinitelyNull() { - return getOperator() == JsUnaryOperator.VOID; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitPrefixOperation(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java b/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java index 47d040b7178..9679fd02bb1 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsPropertyInitializer.java @@ -30,10 +30,6 @@ public class JsPropertyInitializer extends SourceInfoAwareJsNode { return valueExpr; } - public boolean hasSideEffects() { - return labelExpr.hasSideEffects() || valueExpr.hasSideEffects(); - } - public void setValueExpr(@NotNull JsExpression valueExpr) { this.valueExpr = valueExpr; } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsRegExp.java b/src/com/google/dart/compiler/backend/js/ast/JsRegExp.java index a9ef973af14..568e9ed82c6 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsRegExp.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsRegExp.java @@ -22,26 +22,6 @@ public final class JsRegExp extends JsLiteral.JsValueLiteral { return pattern; } - @Override - public boolean isBooleanFalse() { - return false; - } - - @Override - public boolean isBooleanTrue() { - return true; - } - - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - public void setFlags(String suffix) { flags = suffix; } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsStringLiteral.java b/src/com/google/dart/compiler/backend/js/ast/JsStringLiteral.java index bdc15456722..9da55039453 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsStringLiteral.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsStringLiteral.java @@ -4,9 +4,6 @@ package com.google.dart.compiler.backend.js.ast; -/** - * A JavaScript string literal expression. - */ public final class JsStringLiteral extends JsLiteral.JsValueLiteral { private final String value; @@ -20,26 +17,6 @@ public final class JsStringLiteral extends JsLiteral.JsValueLiteral { return value; } - @Override - public boolean isBooleanFalse() { - return value.length() == 0; - } - - @Override - public boolean isBooleanTrue() { - return value.length() != 0; - } - - @Override - public boolean isDefinitelyNotNull() { - return true; - } - - @Override - public boolean isDefinitelyNull() { - return false; - } - @Override public void accept(JsVisitor v, JsContext context) { v.visitString(this, context); diff --git a/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.java b/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.java index 4918c4f9713..c428c7d7f69 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsUnaryOperation.java @@ -28,11 +28,6 @@ public abstract class JsUnaryOperation extends JsExpressionImpl { return op; } - @Override - public final boolean hasSideEffects() { - return op.isModifying() || arg.hasSideEffects(); - } - public void setArg(JsExpression arg) { this.arg = arg; }