| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/EvaluationResultImpl.java
|
| diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/EvaluationResultImpl.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/EvaluationResultImpl.java
|
| index d8b85a9ed0372c0fd73b2da2f8f17ea8bb8de659..7872dffb9b493aa9496e0e2e90057f0cbe6e5dbe 100644
|
| --- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/EvaluationResultImpl.java
|
| +++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/constant/EvaluationResultImpl.java
|
| @@ -13,213 +13,60 @@
|
| */
|
| package com.google.dart.engine.internal.constant;
|
|
|
| -import com.google.dart.engine.ast.AstNode;
|
| -import com.google.dart.engine.ast.BinaryExpression;
|
| -import com.google.dart.engine.ast.Expression;
|
| +import com.google.dart.engine.error.AnalysisError;
|
| +import com.google.dart.engine.internal.object.DartObjectImpl;
|
| import com.google.dart.engine.internal.resolver.TypeProvider;
|
|
|
| /**
|
| * Instances of the class {@code InternalResult} represent the result of attempting to evaluate a
|
| * expression.
|
| */
|
| -public abstract class EvaluationResultImpl {
|
| - public abstract EvaluationResultImpl add(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| +public class EvaluationResultImpl {
|
| /**
|
| - * Return the result of applying boolean conversion to this result.
|
| - *
|
| - * @param typeProvider the type provider used to access known types
|
| - * @param node the node against which errors should be reported
|
| - * @return the result of applying boolean conversion to the given value
|
| + * The errors encountered while trying to evaluate the compile time constant. These errors may or
|
| + * may not have prevented the expression from being a valid compile time constant.
|
| */
|
| - public abstract EvaluationResultImpl applyBooleanConversion(TypeProvider typeProvider,
|
| - AstNode node);
|
| -
|
| - public abstract EvaluationResultImpl bitAnd(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl bitNot(TypeProvider typeProvider, Expression node);
|
| -
|
| - public abstract EvaluationResultImpl bitOr(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl bitXor(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl concatenate(TypeProvider typeProvider, Expression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl divide(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl equalEqual(TypeProvider typeProvider, Expression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract boolean equalValues(TypeProvider typeProvider, EvaluationResultImpl result);
|
| -
|
| - public abstract EvaluationResultImpl greaterThan(TypeProvider typeProvider,
|
| - BinaryExpression node, EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl greaterThanOrEqual(TypeProvider typeProvider,
|
| - BinaryExpression node, EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl integerDivide(TypeProvider typeProvider,
|
| - BinaryExpression node, EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl lessThan(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl lessThanOrEqual(TypeProvider typeProvider,
|
| - BinaryExpression node, EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl logicalAnd(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl logicalNot(TypeProvider typeProvider, Expression node);
|
| -
|
| - public abstract EvaluationResultImpl logicalOr(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl minus(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl negated(TypeProvider typeProvider, Expression node);
|
| -
|
| - public abstract EvaluationResultImpl notEqual(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl performToString(TypeProvider typeProvider, AstNode node);
|
| -
|
| - public abstract EvaluationResultImpl remainder(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl shiftLeft(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - public abstract EvaluationResultImpl shiftRight(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| + private AnalysisError[] errors;
|
|
|
| /**
|
| - * Return the result of invoking the 'length' getter on this result.
|
| - *
|
| - * @param typeProvider the type provider used to access known types
|
| - * @param node the node against which errors should be reported
|
| - * @return the result of invoking the 'length' getter on this result
|
| + * The value of the expression, or null if the value couldn't be computed due to errors.
|
| */
|
| - public abstract EvaluationResultImpl stringLength(TypeProvider typeProvider, Expression node);
|
| -
|
| - public abstract EvaluationResultImpl times(TypeProvider typeProvider, BinaryExpression node,
|
| - EvaluationResultImpl rightOperand);
|
| -
|
| - protected abstract EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl addToValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl bitAndValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl bitOrValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl bitXorValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl concatenateValid(TypeProvider typeProvider,
|
| - Expression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl divideValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl equalEqualValid(TypeProvider typeProvider,
|
| - Expression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl greaterThanError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl greaterThanOrEqualValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl greaterThanValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl integerDivideError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl integerDivideValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl lessThanError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl lessThanOrEqualError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl lessThanOrEqualValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl lessThanValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl logicalAndError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl logicalAndValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl logicalOrError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl logicalOrValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl minusValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl notEqualError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl notEqualValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl remainderError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl remainderValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl shiftLeftError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl shiftLeftValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl shiftRightError(BinaryExpression node,
|
| - ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl shiftRightValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand);
|
| -
|
| - protected abstract EvaluationResultImpl timesValid(TypeProvider typeProvider,
|
| - BinaryExpression node, ValidResult leftOperand);
|
| + private final DartObjectImpl value;
|
| +
|
| + public EvaluationResultImpl(DartObjectImpl value) {
|
| + this.value = value;
|
| + this.errors = new AnalysisError[0];
|
| + }
|
| +
|
| + public EvaluationResultImpl(DartObjectImpl value, AnalysisError[] errors) {
|
| + this.value = value;
|
| + this.errors = errors;
|
| + }
|
| +
|
| + public boolean equalValues(TypeProvider typeProvider, EvaluationResultImpl result) {
|
| + if (this.value != null) {
|
| + if (result.getValue() == null) {
|
| + return false;
|
| + }
|
| + return value.equals(result.value);
|
| + } else {
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + public AnalysisError[] getErrors() {
|
| + return errors;
|
| + }
|
| +
|
| + public DartObjectImpl getValue() {
|
| + return value;
|
| + }
|
| +
|
| + @Override
|
| + public String toString() {
|
| + if (value == null) {
|
| + return "error";
|
| + }
|
| + return value.toString();
|
| + }
|
| }
|
|
|