| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 library engine.constant; | 3 library engine.constant; |
| 4 import 'java_core.dart'; | 4 import 'java_core.dart'; |
| 5 import 'source.dart' show Source; | 5 import 'source.dart' show Source; |
| 6 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; | 6 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; |
| 7 import 'scanner.dart' show TokenType; | 7 import 'scanner.dart' show TokenType; |
| 8 import 'ast.dart'; | 8 import 'ast.dart'; |
| 9 import 'element.dart'; | 9 import 'element.dart'; |
| 10 import 'engine.dart' show AnalysisEngine; | 10 import 'engine.dart' show AnalysisEngine; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 * expression or because it would throw an exception when evaluated. | 122 * expression or because it would throw an exception when evaluated. |
| 123 * @return the value of the expression | 123 * @return the value of the expression |
| 124 */ | 124 */ |
| 125 Object get value => _value; | 125 Object get value => _value; |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * Return `true` if the expression is a compile-time constant expression that
would not | 128 * Return `true` if the expression is a compile-time constant expression that
would not |
| 129 * throw an exception when evaluated. | 129 * throw an exception when evaluated. |
| 130 * @return `true` if the expression is a valid compile-time constant expressio
n | 130 * @return `true` if the expression is a valid compile-time constant expressio
n |
| 131 */ | 131 */ |
| 132 bool isValid() => _errors == null; | 132 bool get isValid => _errors == null; |
| 133 } | 133 } |
| 134 /** | 134 /** |
| 135 * Instances of the class `ConstantFinder` are used to traverse the AST structur
es of all of | 135 * Instances of the class `ConstantFinder` are used to traverse the AST structur
es of all of |
| 136 * the compilation units being resolved and build a table mapping constant varia
ble elements to the | 136 * the compilation units being resolved and build a table mapping constant varia
ble elements to the |
| 137 * declarations of those variables. | 137 * declarations of those variables. |
| 138 */ | 138 */ |
| 139 class ConstantFinder extends RecursiveASTVisitor<Object> { | 139 class ConstantFinder extends RecursiveASTVisitor<Object> { |
| 140 | 140 |
| 141 /** | 141 /** |
| 142 * A table mapping constant variable elements to the declarations of those var
iables. | 142 * A table mapping constant variable elements to the declarations of those var
iables. |
| 143 */ | 143 */ |
| 144 Map<VariableElement, VariableDeclaration> _variableMap = new Map<VariableEleme
nt, VariableDeclaration>(); | 144 Map<VariableElement, VariableDeclaration> _variableMap = new Map<VariableEleme
nt, VariableDeclaration>(); |
| 145 | 145 |
| 146 /** | 146 /** |
| 147 * Return a table mapping constant variable elements to the declarations of th
ose variables. | 147 * Return a table mapping constant variable elements to the declarations of th
ose variables. |
| 148 * @return a table mapping constant variable elements to the declarations of t
hose variables | 148 * @return a table mapping constant variable elements to the declarations of t
hose variables |
| 149 */ | 149 */ |
| 150 Map<VariableElement, VariableDeclaration> get variableMap => _variableMap; | 150 Map<VariableElement, VariableDeclaration> get variableMap => _variableMap; |
| 151 Object visitVariableDeclaration(VariableDeclaration node) { | 151 Object visitVariableDeclaration(VariableDeclaration node) { |
| 152 super.visitVariableDeclaration(node); | 152 super.visitVariableDeclaration(node); |
| 153 Expression initializer = node.initializer; | 153 Expression initializer = node.initializer; |
| 154 if (initializer != null && node.isConst()) { | 154 if (initializer != null && node.isConst) { |
| 155 VariableElement element = node.element; | 155 VariableElement element = node.element; |
| 156 if (element != null) { | 156 if (element != null) { |
| 157 _variableMap[element] = node; | 157 _variableMap[element] = node; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 return null; | 160 return null; |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 /** | 163 /** |
| 164 * Instances of the class `ConstantValueComputer` compute the values of constant
variables in | 164 * Instances of the class `ConstantValueComputer` compute the values of constant
variables in |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 * Compute values for all of the constant variables in the compilation units t
hat were added. | 197 * Compute values for all of the constant variables in the compilation units t
hat were added. |
| 198 */ | 198 */ |
| 199 void computeValues() { | 199 void computeValues() { |
| 200 _declarationMap = _constantFinder.variableMap; | 200 _declarationMap = _constantFinder.variableMap; |
| 201 for (MapEntry<VariableElement, VariableDeclaration> entry in getMapEntrySet(
_declarationMap)) { | 201 for (MapEntry<VariableElement, VariableDeclaration> entry in getMapEntrySet(
_declarationMap)) { |
| 202 VariableElement element = entry.getKey(); | 202 VariableElement element = entry.getKey(); |
| 203 ReferenceFinder referenceFinder = new ReferenceFinder(element, _referenceG
raph); | 203 ReferenceFinder referenceFinder = new ReferenceFinder(element, _referenceG
raph); |
| 204 _referenceGraph.addNode(element); | 204 _referenceGraph.addNode(element); |
| 205 entry.getValue().initializer.accept(referenceFinder); | 205 entry.getValue().initializer.accept(referenceFinder); |
| 206 } | 206 } |
| 207 while (!_referenceGraph.isEmpty()) { | 207 while (!_referenceGraph.isEmpty) { |
| 208 VariableElement element = _referenceGraph.removeSink(); | 208 VariableElement element = _referenceGraph.removeSink(); |
| 209 while (element != null) { | 209 while (element != null) { |
| 210 computeValueFor(element); | 210 computeValueFor(element); |
| 211 element = _referenceGraph.removeSink(); | 211 element = _referenceGraph.removeSink(); |
| 212 } | 212 } |
| 213 if (!_referenceGraph.isEmpty()) { | 213 if (!_referenceGraph.isEmpty) { |
| 214 List<VariableElement> variablesInCycle = _referenceGraph.findCycle(); | 214 List<VariableElement> variablesInCycle = _referenceGraph.findCycle(); |
| 215 if (variablesInCycle == null) { | 215 if (variablesInCycle == null) { |
| 216 AnalysisEngine.instance.logger.logError("Exiting constant value comput
er with ${_referenceGraph.nodeCount} variables that are neither sinks no in a cy
cle"); | 216 AnalysisEngine.instance.logger.logError("Exiting constant value comput
er with ${_referenceGraph.nodeCount} variables that are neither sinks no in a cy
cle"); |
| 217 return; | 217 return; |
| 218 } | 218 } |
| 219 for (VariableElement variable in variablesInCycle) { | 219 for (VariableElement variable in variablesInCycle) { |
| 220 generateCycleError(variablesInCycle, variable); | 220 generateCycleError(variablesInCycle, variable); |
| 221 } | 221 } |
| 222 _referenceGraph.removeAllNodes(variablesInCycle); | 222 _referenceGraph.removeAllNodes(variablesInCycle); |
| 223 } | 223 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 result = result.concatenate(node, string.accept(this)); | 291 result = result.concatenate(node, string.accept(this)); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 return result; | 294 return result; |
| 295 } | 295 } |
| 296 EvaluationResultImpl visitBinaryExpression(BinaryExpression node) { | 296 EvaluationResultImpl visitBinaryExpression(BinaryExpression node) { |
| 297 EvaluationResultImpl leftResult = node.leftOperand.accept(this); | 297 EvaluationResultImpl leftResult = node.leftOperand.accept(this); |
| 298 EvaluationResultImpl rightResult = node.rightOperand.accept(this); | 298 EvaluationResultImpl rightResult = node.rightOperand.accept(this); |
| 299 TokenType operatorType = node.operator.type; | 299 TokenType operatorType = node.operator.type; |
| 300 if (operatorType != TokenType.BANG_EQ && operatorType != TokenType.EQ_EQ) { | 300 if (operatorType != TokenType.BANG_EQ && operatorType != TokenType.EQ_EQ) { |
| 301 if (leftResult is ValidResult && ((leftResult as ValidResult)).isNull() ||
rightResult is ValidResult && ((rightResult as ValidResult)).isNull()) { | 301 if (leftResult is ValidResult && ((leftResult as ValidResult)).isNull || r
ightResult is ValidResult && ((rightResult as ValidResult)).isNull) { |
| 302 return error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); | 302 return error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); |
| 303 } | 303 } |
| 304 } | 304 } |
| 305 while (true) { | 305 while (true) { |
| 306 if (operatorType == TokenType.AMPERSAND) { | 306 if (operatorType == TokenType.AMPERSAND) { |
| 307 return leftResult.bitAnd(node, rightResult); | 307 return leftResult.bitAnd(node, rightResult); |
| 308 } else if (operatorType == TokenType.AMPERSAND_AMPERSAND) { | 308 } else if (operatorType == TokenType.AMPERSAND_AMPERSAND) { |
| 309 return leftResult.logicalAnd(node, rightResult); | 309 return leftResult.logicalAnd(node, rightResult); |
| 310 } else if (operatorType == TokenType.BANG_EQ) { | 310 } else if (operatorType == TokenType.BANG_EQ) { |
| 311 return leftResult.notEqual(node, rightResult); | 311 return leftResult.notEqual(node, rightResult); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 return leftResult.integerDivide(node, rightResult); | 343 return leftResult.integerDivide(node, rightResult); |
| 344 } | 344 } |
| 345 break; | 345 break; |
| 346 } | 346 } |
| 347 return error(node, null); | 347 return error(node, null); |
| 348 } | 348 } |
| 349 EvaluationResultImpl visitBooleanLiteral(BooleanLiteral node) => node.value ?
ValidResult.RESULT_TRUE : ValidResult.RESULT_FALSE; | 349 EvaluationResultImpl visitBooleanLiteral(BooleanLiteral node) => node.value ?
ValidResult.RESULT_TRUE : ValidResult.RESULT_FALSE; |
| 350 EvaluationResultImpl visitDoubleLiteral(DoubleLiteral node) => new ValidResult
(node.value); | 350 EvaluationResultImpl visitDoubleLiteral(DoubleLiteral node) => new ValidResult
(node.value); |
| 351 EvaluationResultImpl visitInstanceCreationExpression(InstanceCreationExpressio
n node) { | 351 EvaluationResultImpl visitInstanceCreationExpression(InstanceCreationExpressio
n node) { |
| 352 ConstructorElement constructor = node.element; | 352 ConstructorElement constructor = node.element; |
| 353 if (constructor != null && constructor.isConst()) { | 353 if (constructor != null && constructor.isConst) { |
| 354 node.argumentList.accept(this); | 354 node.argumentList.accept(this); |
| 355 return ValidResult.RESULT_OBJECT; | 355 return ValidResult.RESULT_OBJECT; |
| 356 } | 356 } |
| 357 return error(node, null); | 357 return error(node, null); |
| 358 } | 358 } |
| 359 EvaluationResultImpl visitIntegerLiteral(IntegerLiteral node) => new ValidResu
lt(node.value); | 359 EvaluationResultImpl visitIntegerLiteral(IntegerLiteral node) => new ValidResu
lt(node.value); |
| 360 EvaluationResultImpl visitInterpolationExpression(InterpolationExpression node
) { | 360 EvaluationResultImpl visitInterpolationExpression(InterpolationExpression node
) { |
| 361 EvaluationResultImpl result = node.expression.accept(this); | 361 EvaluationResultImpl result = node.expression.accept(this); |
| 362 return result.performToString(node); | 362 return result.performToString(node); |
| 363 } | 363 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 392 EvaluationResultImpl visitMethodInvocation(MethodInvocation node) { | 392 EvaluationResultImpl visitMethodInvocation(MethodInvocation node) { |
| 393 Element element = node.methodName.element; | 393 Element element = node.methodName.element; |
| 394 if (element is FunctionElement) { | 394 if (element is FunctionElement) { |
| 395 FunctionElement function = element as FunctionElement; | 395 FunctionElement function = element as FunctionElement; |
| 396 if (function.name == "identical") { | 396 if (function.name == "identical") { |
| 397 NodeList<Expression> arguments = node.argumentList.arguments; | 397 NodeList<Expression> arguments = node.argumentList.arguments; |
| 398 if (arguments.length == 2) { | 398 if (arguments.length == 2) { |
| 399 Element enclosingElement = function.enclosingElement; | 399 Element enclosingElement = function.enclosingElement; |
| 400 if (enclosingElement is CompilationUnitElement) { | 400 if (enclosingElement is CompilationUnitElement) { |
| 401 LibraryElement library = ((enclosingElement as CompilationUnitElemen
t)).library; | 401 LibraryElement library = ((enclosingElement as CompilationUnitElemen
t)).library; |
| 402 if (library.isDartCore()) { | 402 if (library.isDartCore) { |
| 403 EvaluationResultImpl leftArgument = arguments[0].accept(this); | 403 EvaluationResultImpl leftArgument = arguments[0].accept(this); |
| 404 EvaluationResultImpl rightArgument = arguments[1].accept(this); | 404 EvaluationResultImpl rightArgument = arguments[1].accept(this); |
| 405 return leftArgument.equalEqual(node, rightArgument); | 405 return leftArgument.equalEqual(node, rightArgument); |
| 406 } | 406 } |
| 407 } | 407 } |
| 408 } | 408 } |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 return error(node, null); | 411 return error(node, null); |
| 412 } | 412 } |
| 413 EvaluationResultImpl visitNode(ASTNode node) => error(node, null); | 413 EvaluationResultImpl visitNode(ASTNode node) => error(node, null); |
| 414 EvaluationResultImpl visitNullLiteral(NullLiteral node) => ValidResult.RESULT_
NULL; | 414 EvaluationResultImpl visitNullLiteral(NullLiteral node) => ValidResult.RESULT_
NULL; |
| 415 EvaluationResultImpl visitParenthesizedExpression(ParenthesizedExpression node
) => node.expression.accept(this); | 415 EvaluationResultImpl visitParenthesizedExpression(ParenthesizedExpression node
) => node.expression.accept(this); |
| 416 EvaluationResultImpl visitPrefixedIdentifier(PrefixedIdentifier node) => getCo
nstantValue(node, node.element); | 416 EvaluationResultImpl visitPrefixedIdentifier(PrefixedIdentifier node) => getCo
nstantValue(node, node.element); |
| 417 EvaluationResultImpl visitPrefixExpression(PrefixExpression node) { | 417 EvaluationResultImpl visitPrefixExpression(PrefixExpression node) { |
| 418 EvaluationResultImpl operand = node.operand.accept(this); | 418 EvaluationResultImpl operand = node.operand.accept(this); |
| 419 if (operand is ValidResult && ((operand as ValidResult)).isNull()) { | 419 if (operand is ValidResult && ((operand as ValidResult)).isNull) { |
| 420 return error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); | 420 return error(node, CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION); |
| 421 } | 421 } |
| 422 while (true) { | 422 while (true) { |
| 423 if (node.operator.type == TokenType.BANG) { | 423 if (node.operator.type == TokenType.BANG) { |
| 424 return operand.logicalNot(node); | 424 return operand.logicalNot(node); |
| 425 } else if (node.operator.type == TokenType.TILDE) { | 425 } else if (node.operator.type == TokenType.TILDE) { |
| 426 return operand.bitNot(node); | 426 return operand.bitNot(node); |
| 427 } else if (node.operator.type == TokenType.MINUS) { | 427 } else if (node.operator.type == TokenType.MINUS) { |
| 428 return operand.negated(node); | 428 return operand.negated(node); |
| 429 } | 429 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 if (tails == null) { | 566 if (tails == null) { |
| 567 return new Set<N>(); | 567 return new Set<N>(); |
| 568 } | 568 } |
| 569 return tails; | 569 return tails; |
| 570 } | 570 } |
| 571 | 571 |
| 572 /** | 572 /** |
| 573 * Return `true` if this graph is empty. | 573 * Return `true` if this graph is empty. |
| 574 * @return `true` if this graph is empty | 574 * @return `true` if this graph is empty |
| 575 */ | 575 */ |
| 576 bool isEmpty() => _edges.isEmpty; | 576 bool get isEmpty => _edges.isEmpty; |
| 577 | 577 |
| 578 /** | 578 /** |
| 579 * Remove all of the given nodes from this graph. As a consequence, any edges
for which those | 579 * Remove all of the given nodes from this graph. As a consequence, any edges
for which those |
| 580 * nodes were either a head or a tail will also be removed. | 580 * nodes were either a head or a tail will also be removed. |
| 581 * @param nodes the nodes to be removed | 581 * @param nodes the nodes to be removed |
| 582 */ | 582 */ |
| 583 void removeAllNodes(List<N> nodes) { | 583 void removeAllNodes(List<N> nodes) { |
| 584 for (N node in nodes) { | 584 for (N node in nodes) { |
| 585 removeNode(node); | 585 removeNode(node); |
| 586 } | 586 } |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 this._source = source; | 880 this._source = source; |
| 881 this._referenceGraph = referenceGraph; | 881 this._referenceGraph = referenceGraph; |
| 882 } | 882 } |
| 883 Object visitSimpleIdentifier(SimpleIdentifier node) { | 883 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 884 Element element = node.element; | 884 Element element = node.element; |
| 885 if (element is PropertyAccessorElement) { | 885 if (element is PropertyAccessorElement) { |
| 886 element = ((element as PropertyAccessorElement)).variable; | 886 element = ((element as PropertyAccessorElement)).variable; |
| 887 } | 887 } |
| 888 if (element is VariableElement) { | 888 if (element is VariableElement) { |
| 889 VariableElement variable = element as VariableElement; | 889 VariableElement variable = element as VariableElement; |
| 890 if (variable.isConst()) { | 890 if (variable.isConst) { |
| 891 _referenceGraph.addEdge(_source, variable); | 891 _referenceGraph.addEdge(_source, variable); |
| 892 } | 892 } |
| 893 } | 893 } |
| 894 return null; | 894 return null; |
| 895 } | 895 } |
| 896 } | 896 } |
| 897 /** | 897 /** |
| 898 * Instances of the class `ValidResult` represent the result of attempting to ev
aluate a valid | 898 * Instances of the class `ValidResult` represent the result of attempting to ev
aluate a valid |
| 899 * compile time constant expression. | 899 * compile time constant expression. |
| 900 */ | 900 */ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 /** | 959 /** |
| 960 * Initialize a newly created result to represent the given value. | 960 * Initialize a newly created result to represent the given value. |
| 961 * @param value the value of the expression | 961 * @param value the value of the expression |
| 962 */ | 962 */ |
| 963 ValidResult(Object value) { | 963 ValidResult(Object value) { |
| 964 this._value = value; | 964 this._value = value; |
| 965 } | 965 } |
| 966 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper
and) => rightOperand.addToValid(node, this); | 966 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper
and) => rightOperand.addToValid(node, this); |
| 967 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitAndValid(node, this); | 967 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitAndValid(node, this); |
| 968 EvaluationResultImpl bitNot(Expression node) { | 968 EvaluationResultImpl bitNot(Expression node) { |
| 969 if (isSomeInt()) { | 969 if (isSomeInt) { |
| 970 return RESULT_INT; | 970 return RESULT_INT; |
| 971 } | 971 } |
| 972 if (_value == null) { | 972 if (_value == null) { |
| 973 return error(node); | 973 return error(node); |
| 974 } else if (_value is int) { | 974 } else if (_value is int) { |
| 975 return valueOf(~((_value as int))); | 975 return valueOf(~((_value as int))); |
| 976 } | 976 } |
| 977 return error(node); | 977 return error(node); |
| 978 } | 978 } |
| 979 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.bitOrValid(node, this); | 979 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.bitOrValid(node, this); |
| 980 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitXorValid(node, this); | 980 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitXorValid(node, this); |
| 981 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp
erand) => rightOperand.concatenateValid(node, this); | 981 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp
erand) => rightOperand.concatenateValid(node, this); |
| 982 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.divideValid(node, this); | 982 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.divideValid(node, this); |
| 983 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe
rand) => rightOperand.equalEqualValid(node, this); | 983 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe
rand) => rightOperand.equalEqualValid(node, this); |
| 984 bool equalValues(EvaluationResultImpl result) => identical(equalEqual(null, re
sult), RESULT_TRUE); | 984 bool equalValues(EvaluationResultImpl result) => identical(equalEqual(null, re
sult), RESULT_TRUE); |
| 985 Object get value => _value; | 985 Object get value => _value; |
| 986 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r
ightOperand) => rightOperand.greaterThanValid(node, this); | 986 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r
ightOperand) => rightOperand.greaterThanValid(node, this); |
| 987 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul
tImpl rightOperand) => rightOperand.greaterThanOrEqualValid(node, this); | 987 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul
tImpl rightOperand) => rightOperand.greaterThanOrEqualValid(node, this); |
| 988 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl
rightOperand) => rightOperand.integerDivideValid(node, this); | 988 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl
rightOperand) => rightOperand.integerDivideValid(node, this); |
| 989 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ
tOperand) => rightOperand.lessThanValid(node, this); | 989 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ
tOperand) => rightOperand.lessThanValid(node, this); |
| 990 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm
pl rightOperand) => rightOperand.lessThanOrEqualValid(node, this); | 990 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm
pl rightOperand) => rightOperand.lessThanOrEqualValid(node, this); |
| 991 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.logicalAndValid(node, this); | 991 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.logicalAndValid(node, this); |
| 992 EvaluationResultImpl logicalNot(Expression node) { | 992 EvaluationResultImpl logicalNot(Expression node) { |
| 993 if (isSomeBool()) { | 993 if (isSomeBool) { |
| 994 return RESULT_BOOL; | 994 return RESULT_BOOL; |
| 995 } | 995 } |
| 996 if (_value == null) { | 996 if (_value == null) { |
| 997 return RESULT_TRUE; | 997 return RESULT_TRUE; |
| 998 } else if (_value is bool) { | 998 } else if (_value is bool) { |
| 999 return ((_value as bool)) ? RESULT_FALSE : RESULT_TRUE; | 999 return ((_value as bool)) ? RESULT_FALSE : RESULT_TRUE; |
| 1000 } | 1000 } |
| 1001 return error(node); | 1001 return error(node); |
| 1002 } | 1002 } |
| 1003 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.logicalOrValid(node, this); | 1003 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.logicalOrValid(node, this); |
| 1004 EvaluationResultImpl minus(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.minusValid(node, this); | 1004 EvaluationResultImpl minus(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.minusValid(node, this); |
| 1005 EvaluationResultImpl negated(Expression node) { | 1005 EvaluationResultImpl negated(Expression node) { |
| 1006 if (isSomeNum()) { | 1006 if (isSomeNum) { |
| 1007 return RESULT_INT; | 1007 return RESULT_INT; |
| 1008 } | 1008 } |
| 1009 if (_value == null) { | 1009 if (_value == null) { |
| 1010 return error(node); | 1010 return error(node); |
| 1011 } else if (_value is int) { | 1011 } else if (_value is int) { |
| 1012 return valueOf(-((_value as int))); | 1012 return valueOf(-((_value as int))); |
| 1013 } else if (_value is double) { | 1013 } else if (_value is double) { |
| 1014 return valueOf3(-((_value as double))); | 1014 return valueOf3(-((_value as double))); |
| 1015 } | 1015 } |
| 1016 return error(node); | 1016 return error(node); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1035 EvaluationResultImpl shiftRight(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.shiftRightValid(node, this); | 1035 EvaluationResultImpl shiftRight(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.shiftRightValid(node, this); |
| 1036 EvaluationResultImpl times(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.timesValid(node, this); | 1036 EvaluationResultImpl times(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.timesValid(node, this); |
| 1037 String toString() { | 1037 String toString() { |
| 1038 if (_value == null) { | 1038 if (_value == null) { |
| 1039 return "null"; | 1039 return "null"; |
| 1040 } | 1040 } |
| 1041 return _value.toString(); | 1041 return _value.toString(); |
| 1042 } | 1042 } |
| 1043 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1043 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1044 EvaluationResultImpl addToValid(BinaryExpression node, ValidResult leftOperand
2) { | 1044 EvaluationResultImpl addToValid(BinaryExpression node, ValidResult leftOperand
2) { |
| 1045 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1045 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1046 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1046 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1047 return RESULT_NUM; | 1047 return RESULT_NUM; |
| 1048 } | 1048 } |
| 1049 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1049 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1050 } | 1050 } |
| 1051 Object leftValue = leftOperand2.value; | 1051 Object leftValue = leftOperand2.value; |
| 1052 if (leftValue == null) { | 1052 if (leftValue == null) { |
| 1053 return error(node.leftOperand); | 1053 return error(node.leftOperand); |
| 1054 } else if (_value == null) { | 1054 } else if (_value == null) { |
| 1055 return error(node.rightOperand); | 1055 return error(node.rightOperand); |
| 1056 } else if (leftValue is int) { | 1056 } else if (leftValue is int) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1067 } | 1067 } |
| 1068 } else if (leftValue is String) { | 1068 } else if (leftValue is String) { |
| 1069 if (_value is String) { | 1069 if (_value is String) { |
| 1070 return valueOf4("${((leftValue as String))}${((_value as String))}"); | 1070 return valueOf4("${((leftValue as String))}${((_value as String))}"); |
| 1071 } | 1071 } |
| 1072 } | 1072 } |
| 1073 return error(node); | 1073 return error(node); |
| 1074 } | 1074 } |
| 1075 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1075 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 1076 EvaluationResultImpl bitAndValid(BinaryExpression node, ValidResult leftOperan
d2) { | 1076 EvaluationResultImpl bitAndValid(BinaryExpression node, ValidResult leftOperan
d2) { |
| 1077 if (isSomeInt() || leftOperand2.isSomeInt()) { | 1077 if (isSomeInt || leftOperand2.isSomeInt) { |
| 1078 if (isAnyInt() && leftOperand2.isAnyInt()) { | 1078 if (isAnyInt && leftOperand2.isAnyInt) { |
| 1079 return RESULT_INT; | 1079 return RESULT_INT; |
| 1080 } | 1080 } |
| 1081 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1081 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
| 1082 } | 1082 } |
| 1083 Object leftValue = leftOperand2.value; | 1083 Object leftValue = leftOperand2.value; |
| 1084 if (leftValue == null) { | 1084 if (leftValue == null) { |
| 1085 return error(node.leftOperand); | 1085 return error(node.leftOperand); |
| 1086 } else if (_value == null) { | 1086 } else if (_value == null) { |
| 1087 return error(node.rightOperand); | 1087 return error(node.rightOperand); |
| 1088 } else if (leftValue is int) { | 1088 } else if (leftValue is int) { |
| 1089 if (_value is int) { | 1089 if (_value is int) { |
| 1090 return valueOf(((leftValue as int)) & (_value as int)); | 1090 return valueOf(((leftValue as int)) & (_value as int)); |
| 1091 } | 1091 } |
| 1092 return error(node.leftOperand); | 1092 return error(node.leftOperand); |
| 1093 } | 1093 } |
| 1094 if (_value is int) { | 1094 if (_value is int) { |
| 1095 return error(node.rightOperand); | 1095 return error(node.rightOperand); |
| 1096 } | 1096 } |
| 1097 return union(error(node.leftOperand), error(node.rightOperand)); | 1097 return union(error(node.leftOperand), error(node.rightOperand)); |
| 1098 } | 1098 } |
| 1099 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1099 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1100 EvaluationResultImpl bitOrValid(BinaryExpression node, ValidResult leftOperand
2) { | 1100 EvaluationResultImpl bitOrValid(BinaryExpression node, ValidResult leftOperand
2) { |
| 1101 if (isSomeInt() || leftOperand2.isSomeInt()) { | 1101 if (isSomeInt || leftOperand2.isSomeInt) { |
| 1102 if (isAnyInt() && leftOperand2.isAnyInt()) { | 1102 if (isAnyInt && leftOperand2.isAnyInt) { |
| 1103 return RESULT_INT; | 1103 return RESULT_INT; |
| 1104 } | 1104 } |
| 1105 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1105 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
| 1106 } | 1106 } |
| 1107 Object leftValue = leftOperand2.value; | 1107 Object leftValue = leftOperand2.value; |
| 1108 if (leftValue == null) { | 1108 if (leftValue == null) { |
| 1109 return error(node.leftOperand); | 1109 return error(node.leftOperand); |
| 1110 } else if (_value == null) { | 1110 } else if (_value == null) { |
| 1111 return error(node.rightOperand); | 1111 return error(node.rightOperand); |
| 1112 } else if (leftValue is int) { | 1112 } else if (leftValue is int) { |
| 1113 if (_value is int) { | 1113 if (_value is int) { |
| 1114 return valueOf(((leftValue as int)) | (_value as int)); | 1114 return valueOf(((leftValue as int)) | (_value as int)); |
| 1115 } | 1115 } |
| 1116 return error(node.leftOperand); | 1116 return error(node.leftOperand); |
| 1117 } | 1117 } |
| 1118 if (_value is int) { | 1118 if (_value is int) { |
| 1119 return error(node.rightOperand); | 1119 return error(node.rightOperand); |
| 1120 } | 1120 } |
| 1121 return union(error(node.leftOperand), error(node.rightOperand)); | 1121 return union(error(node.leftOperand), error(node.rightOperand)); |
| 1122 } | 1122 } |
| 1123 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1123 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 1124 EvaluationResultImpl bitXorValid(BinaryExpression node, ValidResult leftOperan
d2) { | 1124 EvaluationResultImpl bitXorValid(BinaryExpression node, ValidResult leftOperan
d2) { |
| 1125 if (isSomeInt() || leftOperand2.isSomeInt()) { | 1125 if (isSomeInt || leftOperand2.isSomeInt) { |
| 1126 if (isAnyInt() && leftOperand2.isAnyInt()) { | 1126 if (isAnyInt && leftOperand2.isAnyInt) { |
| 1127 return RESULT_INT; | 1127 return RESULT_INT; |
| 1128 } | 1128 } |
| 1129 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1129 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
| 1130 } | 1130 } |
| 1131 Object leftValue = leftOperand2.value; | 1131 Object leftValue = leftOperand2.value; |
| 1132 if (leftValue == null) { | 1132 if (leftValue == null) { |
| 1133 return error(node.leftOperand); | 1133 return error(node.leftOperand); |
| 1134 } else if (_value == null) { | 1134 } else if (_value == null) { |
| 1135 return error(node.rightOperand); | 1135 return error(node.rightOperand); |
| 1136 } else if (leftValue is int) { | 1136 } else if (leftValue is int) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1147 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => leftOperand; | 1147 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => leftOperand; |
| 1148 EvaluationResultImpl concatenateValid(Expression node, ValidResult leftOperand
) { | 1148 EvaluationResultImpl concatenateValid(Expression node, ValidResult leftOperand
) { |
| 1149 Object leftValue = leftOperand.value; | 1149 Object leftValue = leftOperand.value; |
| 1150 if (leftValue is String && _value is String) { | 1150 if (leftValue is String && _value is String) { |
| 1151 return valueOf4("${((leftValue as String))}${((_value as String))}"); | 1151 return valueOf4("${((leftValue as String))}${((_value as String))}"); |
| 1152 } | 1152 } |
| 1153 return error(node); | 1153 return error(node); |
| 1154 } | 1154 } |
| 1155 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1155 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 1156 EvaluationResultImpl divideValid(BinaryExpression node, ValidResult leftOperan
d2) { | 1156 EvaluationResultImpl divideValid(BinaryExpression node, ValidResult leftOperan
d2) { |
| 1157 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1157 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1158 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1158 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1159 return RESULT_NUM; | 1159 return RESULT_NUM; |
| 1160 } | 1160 } |
| 1161 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1161 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1162 } | 1162 } |
| 1163 Object leftValue = leftOperand2.value; | 1163 Object leftValue = leftOperand2.value; |
| 1164 if (leftValue == null) { | 1164 if (leftValue == null) { |
| 1165 return error(node.leftOperand); | 1165 return error(node.leftOperand); |
| 1166 } else if (_value == null) { | 1166 } else if (_value == null) { |
| 1167 return error(node.rightOperand); | 1167 return error(node.rightOperand); |
| 1168 } else if (leftValue is int) { | 1168 } else if (leftValue is int) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1179 return valueOf3(((leftValue as double)) / ((_value as int)).toDouble()); | 1179 return valueOf3(((leftValue as double)) / ((_value as int)).toDouble()); |
| 1180 } else if (_value is double) { | 1180 } else if (_value is double) { |
| 1181 return valueOf3(((leftValue as double)) / ((_value as double))); | 1181 return valueOf3(((leftValue as double)) / ((_value as double))); |
| 1182 } | 1182 } |
| 1183 } | 1183 } |
| 1184 return error(node); | 1184 return error(node); |
| 1185 } | 1185 } |
| 1186 EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand)
=> leftOperand; | 1186 EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand)
=> leftOperand; |
| 1187 EvaluationResultImpl equalEqualValid(Expression node, ValidResult leftOperand)
{ | 1187 EvaluationResultImpl equalEqualValid(Expression node, ValidResult leftOperand)
{ |
| 1188 if (node is BinaryExpression) { | 1188 if (node is BinaryExpression) { |
| 1189 if (!isAnyNullBoolNumString() || !leftOperand.isAnyNullBoolNumString()) { | 1189 if (!isAnyNullBoolNumString || !leftOperand.isAnyNullBoolNumString) { |
| 1190 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING
); | 1190 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING
); |
| 1191 } | 1191 } |
| 1192 } | 1192 } |
| 1193 Object leftValue = leftOperand.value; | 1193 Object leftValue = leftOperand.value; |
| 1194 if (leftValue == null) { | 1194 if (leftValue == null) { |
| 1195 return valueOf2(_value == null); | 1195 return valueOf2(_value == null); |
| 1196 } else if (leftValue is bool) { | 1196 } else if (leftValue is bool) { |
| 1197 if (_value is bool) { | 1197 if (_value is bool) { |
| 1198 return valueOf2(identical(((leftValue as bool)), ((_value as bool)))); | 1198 return valueOf2(identical(((leftValue as bool)), ((_value as bool)))); |
| 1199 } | 1199 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1216 if (_value is String) { | 1216 if (_value is String) { |
| 1217 return valueOf2(((leftValue as String)) == _value); | 1217 return valueOf2(((leftValue as String)) == _value); |
| 1218 } | 1218 } |
| 1219 return RESULT_FALSE; | 1219 return RESULT_FALSE; |
| 1220 } | 1220 } |
| 1221 return RESULT_FALSE; | 1221 return RESULT_FALSE; |
| 1222 } | 1222 } |
| 1223 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => leftOperand; | 1223 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => leftOperand; |
| 1224 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => leftOperand; | 1224 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => leftOperand; |
| 1225 EvaluationResultImpl greaterThanOrEqualValid(BinaryExpression node, ValidResul
t leftOperand2) { | 1225 EvaluationResultImpl greaterThanOrEqualValid(BinaryExpression node, ValidResul
t leftOperand2) { |
| 1226 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1226 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1227 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1227 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1228 return RESULT_BOOL; | 1228 return RESULT_BOOL; |
| 1229 } | 1229 } |
| 1230 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1230 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1231 } | 1231 } |
| 1232 Object leftValue = leftOperand2.value; | 1232 Object leftValue = leftOperand2.value; |
| 1233 if (leftValue == null) { | 1233 if (leftValue == null) { |
| 1234 return error(node.leftOperand); | 1234 return error(node.leftOperand); |
| 1235 } else if (_value == null) { | 1235 } else if (_value == null) { |
| 1236 return error(node.rightOperand); | 1236 return error(node.rightOperand); |
| 1237 } else if (leftValue is int) { | 1237 } else if (leftValue is int) { |
| 1238 if (_value is int) { | 1238 if (_value is int) { |
| 1239 return valueOf2(((leftValue as int)).compareTo((_value as int)) >= 0); | 1239 return valueOf2(((leftValue as int)).compareTo((_value as int)) >= 0); |
| 1240 } else if (_value is double) { | 1240 } else if (_value is double) { |
| 1241 return valueOf2(((leftValue as int)).toDouble() >= ((_value as double)))
; | 1241 return valueOf2(((leftValue as int)).toDouble() >= ((_value as double)))
; |
| 1242 } | 1242 } |
| 1243 } else if (leftValue is double) { | 1243 } else if (leftValue is double) { |
| 1244 if (_value is int) { | 1244 if (_value is int) { |
| 1245 return valueOf2(((leftValue as double)) >= ((_value as int)).toDouble())
; | 1245 return valueOf2(((leftValue as double)) >= ((_value as int)).toDouble())
; |
| 1246 } else if (_value is double) { | 1246 } else if (_value is double) { |
| 1247 return valueOf2(((leftValue as double)) >= ((_value as double))); | 1247 return valueOf2(((leftValue as double)) >= ((_value as double))); |
| 1248 } | 1248 } |
| 1249 } | 1249 } |
| 1250 return error(node); | 1250 return error(node); |
| 1251 } | 1251 } |
| 1252 EvaluationResultImpl greaterThanValid(BinaryExpression node, ValidResult leftO
perand2) { | 1252 EvaluationResultImpl greaterThanValid(BinaryExpression node, ValidResult leftO
perand2) { |
| 1253 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1253 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1254 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1254 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1255 return RESULT_BOOL; | 1255 return RESULT_BOOL; |
| 1256 } | 1256 } |
| 1257 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1257 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1258 } | 1258 } |
| 1259 Object leftValue = leftOperand2.value; | 1259 Object leftValue = leftOperand2.value; |
| 1260 if (leftValue == null) { | 1260 if (leftValue == null) { |
| 1261 return error(node.leftOperand); | 1261 return error(node.leftOperand); |
| 1262 } else if (_value == null) { | 1262 } else if (_value == null) { |
| 1263 return error(node.rightOperand); | 1263 return error(node.rightOperand); |
| 1264 } else if (leftValue is int) { | 1264 } else if (leftValue is int) { |
| 1265 if (_value is int) { | 1265 if (_value is int) { |
| 1266 return valueOf2(((leftValue as int)).compareTo((_value as int)) > 0); | 1266 return valueOf2(((leftValue as int)).compareTo((_value as int)) > 0); |
| 1267 } else if (_value is double) { | 1267 } else if (_value is double) { |
| 1268 return valueOf2(((leftValue as int)).toDouble() > ((_value as double))); | 1268 return valueOf2(((leftValue as int)).toDouble() > ((_value as double))); |
| 1269 } | 1269 } |
| 1270 } else if (leftValue is double) { | 1270 } else if (leftValue is double) { |
| 1271 if (_value is int) { | 1271 if (_value is int) { |
| 1272 return valueOf2(((leftValue as double)) > ((_value as int)).toDouble()); | 1272 return valueOf2(((leftValue as double)) > ((_value as int)).toDouble()); |
| 1273 } else if (_value is double) { | 1273 } else if (_value is double) { |
| 1274 return valueOf2(((leftValue as double)) > ((_value as double))); | 1274 return valueOf2(((leftValue as double)) > ((_value as double))); |
| 1275 } | 1275 } |
| 1276 } | 1276 } |
| 1277 return error(node); | 1277 return error(node); |
| 1278 } | 1278 } |
| 1279 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => leftOperand; | 1279 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => leftOperand; |
| 1280 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef
tOperand2) { | 1280 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef
tOperand2) { |
| 1281 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1281 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1282 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1282 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1283 return RESULT_INT; | 1283 return RESULT_INT; |
| 1284 } | 1284 } |
| 1285 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1285 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1286 } | 1286 } |
| 1287 Object leftValue = leftOperand2.value; | 1287 Object leftValue = leftOperand2.value; |
| 1288 if (leftValue == null) { | 1288 if (leftValue == null) { |
| 1289 return error(node.leftOperand); | 1289 return error(node.leftOperand); |
| 1290 } else if (_value == null) { | 1290 } else if (_value == null) { |
| 1291 return error(node.rightOperand); | 1291 return error(node.rightOperand); |
| 1292 } else if (leftValue is int) { | 1292 } else if (leftValue is int) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1306 } else if (_value is double) { | 1306 } else if (_value is double) { |
| 1307 double result = ((leftValue as double)) / ((_value as double)); | 1307 double result = ((leftValue as double)) / ((_value as double)); |
| 1308 return valueOf(result.toInt()); | 1308 return valueOf(result.toInt()); |
| 1309 } | 1309 } |
| 1310 } | 1310 } |
| 1311 return error(node); | 1311 return error(node); |
| 1312 } | 1312 } |
| 1313 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; | 1313 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; |
| 1314 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => leftOperand; | 1314 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => leftOperand; |
| 1315 EvaluationResultImpl lessThanOrEqualValid(BinaryExpression node, ValidResult l
eftOperand2) { | 1315 EvaluationResultImpl lessThanOrEqualValid(BinaryExpression node, ValidResult l
eftOperand2) { |
| 1316 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1316 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1317 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1317 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1318 return RESULT_BOOL; | 1318 return RESULT_BOOL; |
| 1319 } | 1319 } |
| 1320 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1320 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1321 } | 1321 } |
| 1322 Object leftValue = leftOperand2.value; | 1322 Object leftValue = leftOperand2.value; |
| 1323 if (leftValue == null) { | 1323 if (leftValue == null) { |
| 1324 return error(node.leftOperand); | 1324 return error(node.leftOperand); |
| 1325 } else if (_value == null) { | 1325 } else if (_value == null) { |
| 1326 return error(node.rightOperand); | 1326 return error(node.rightOperand); |
| 1327 } else if (leftValue is int) { | 1327 } else if (leftValue is int) { |
| 1328 if (_value is int) { | 1328 if (_value is int) { |
| 1329 return valueOf2(((leftValue as int)).compareTo((_value as int)) <= 0); | 1329 return valueOf2(((leftValue as int)).compareTo((_value as int)) <= 0); |
| 1330 } else if (_value is double) { | 1330 } else if (_value is double) { |
| 1331 return valueOf2(((leftValue as int)).toDouble() <= ((_value as double)))
; | 1331 return valueOf2(((leftValue as int)).toDouble() <= ((_value as double)))
; |
| 1332 } | 1332 } |
| 1333 } else if (leftValue is double) { | 1333 } else if (leftValue is double) { |
| 1334 if (_value is int) { | 1334 if (_value is int) { |
| 1335 return valueOf2(((leftValue as double)) <= ((_value as int)).toDouble())
; | 1335 return valueOf2(((leftValue as double)) <= ((_value as int)).toDouble())
; |
| 1336 } else if (_value is double) { | 1336 } else if (_value is double) { |
| 1337 return valueOf2(((leftValue as double)) <= ((_value as double))); | 1337 return valueOf2(((leftValue as double)) <= ((_value as double))); |
| 1338 } | 1338 } |
| 1339 } | 1339 } |
| 1340 return error(node); | 1340 return error(node); |
| 1341 } | 1341 } |
| 1342 EvaluationResultImpl lessThanValid(BinaryExpression node, ValidResult leftOper
and2) { | 1342 EvaluationResultImpl lessThanValid(BinaryExpression node, ValidResult leftOper
and2) { |
| 1343 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1343 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1344 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1344 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1345 return RESULT_BOOL; | 1345 return RESULT_BOOL; |
| 1346 } | 1346 } |
| 1347 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1347 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1348 } | 1348 } |
| 1349 Object leftValue = leftOperand2.value; | 1349 Object leftValue = leftOperand2.value; |
| 1350 if (leftValue == null) { | 1350 if (leftValue == null) { |
| 1351 return error(node.leftOperand); | 1351 return error(node.leftOperand); |
| 1352 } else if (_value == null) { | 1352 } else if (_value == null) { |
| 1353 return error(node.rightOperand); | 1353 return error(node.rightOperand); |
| 1354 } else if (leftValue is int) { | 1354 } else if (leftValue is int) { |
| 1355 if (_value is int) { | 1355 if (_value is int) { |
| 1356 return valueOf2(((leftValue as int)).compareTo((_value as int)) < 0); | 1356 return valueOf2(((leftValue as int)).compareTo((_value as int)) < 0); |
| 1357 } else if (_value is double) { | 1357 } else if (_value is double) { |
| 1358 return valueOf2(((leftValue as int)).toDouble() < ((_value as double))); | 1358 return valueOf2(((leftValue as int)).toDouble() < ((_value as double))); |
| 1359 } | 1359 } |
| 1360 } else if (leftValue is double) { | 1360 } else if (leftValue is double) { |
| 1361 if (_value is int) { | 1361 if (_value is int) { |
| 1362 return valueOf2(((leftValue as double)) < ((_value as int)).toDouble()); | 1362 return valueOf2(((leftValue as double)) < ((_value as int)).toDouble()); |
| 1363 } else if (_value is double) { | 1363 } else if (_value is double) { |
| 1364 return valueOf2(((leftValue as double)) < ((_value as double))); | 1364 return valueOf2(((leftValue as double)) < ((_value as double))); |
| 1365 } | 1365 } |
| 1366 } | 1366 } |
| 1367 return error(node); | 1367 return error(node); |
| 1368 } | 1368 } |
| 1369 EvaluationResultImpl logicalAndError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; | 1369 EvaluationResultImpl logicalAndError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; |
| 1370 EvaluationResultImpl logicalAndValid(BinaryExpression node, ValidResult leftOp
erand) { | 1370 EvaluationResultImpl logicalAndValid(BinaryExpression node, ValidResult leftOp
erand) { |
| 1371 if (isSomeBool() || leftOperand.isSomeBool()) { | 1371 if (isSomeBool || leftOperand.isSomeBool) { |
| 1372 if (isAnyBool() && leftOperand.isAnyBool()) { | 1372 if (isAnyBool && leftOperand.isAnyBool) { |
| 1373 return RESULT_BOOL; | 1373 return RESULT_BOOL; |
| 1374 } | 1374 } |
| 1375 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL); | 1375 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL); |
| 1376 } | 1376 } |
| 1377 Object leftValue = leftOperand.value; | 1377 Object leftValue = leftOperand.value; |
| 1378 if (leftValue is bool) { | 1378 if (leftValue is bool) { |
| 1379 if (((leftValue as bool))) { | 1379 if (((leftValue as bool))) { |
| 1380 return booleanConversion(node.rightOperand, _value); | 1380 return booleanConversion(node.rightOperand, _value); |
| 1381 } | 1381 } |
| 1382 return RESULT_FALSE; | 1382 return RESULT_FALSE; |
| 1383 } | 1383 } |
| 1384 return error(node); | 1384 return error(node); |
| 1385 } | 1385 } |
| 1386 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1386 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1387 EvaluationResultImpl logicalOrValid(BinaryExpression node, ValidResult leftOpe
rand) { | 1387 EvaluationResultImpl logicalOrValid(BinaryExpression node, ValidResult leftOpe
rand) { |
| 1388 if (isSomeBool() || leftOperand.isSomeBool()) { | 1388 if (isSomeBool || leftOperand.isSomeBool) { |
| 1389 if (isAnyBool() && leftOperand.isAnyBool()) { | 1389 if (isAnyBool && leftOperand.isAnyBool) { |
| 1390 return RESULT_BOOL; | 1390 return RESULT_BOOL; |
| 1391 } | 1391 } |
| 1392 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL); | 1392 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL); |
| 1393 } | 1393 } |
| 1394 Object leftValue = leftOperand.value; | 1394 Object leftValue = leftOperand.value; |
| 1395 if (leftValue is bool && ((leftValue as bool))) { | 1395 if (leftValue is bool && ((leftValue as bool))) { |
| 1396 return RESULT_TRUE; | 1396 return RESULT_TRUE; |
| 1397 } | 1397 } |
| 1398 return booleanConversion(node.rightOperand, _value); | 1398 return booleanConversion(node.rightOperand, _value); |
| 1399 } | 1399 } |
| 1400 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1400 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1401 EvaluationResultImpl minusValid(BinaryExpression node, ValidResult leftOperand
2) { | 1401 EvaluationResultImpl minusValid(BinaryExpression node, ValidResult leftOperand
2) { |
| 1402 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1402 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1403 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1403 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1404 return RESULT_NUM; | 1404 return RESULT_NUM; |
| 1405 } | 1405 } |
| 1406 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1406 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1407 } | 1407 } |
| 1408 Object leftValue = leftOperand2.value; | 1408 Object leftValue = leftOperand2.value; |
| 1409 if (leftValue == null) { | 1409 if (leftValue == null) { |
| 1410 return error(node.leftOperand); | 1410 return error(node.leftOperand); |
| 1411 } else if (_value == null) { | 1411 } else if (_value == null) { |
| 1412 return error(node.rightOperand); | 1412 return error(node.rightOperand); |
| 1413 } else if (leftValue is int) { | 1413 } else if (leftValue is int) { |
| 1414 if (_value is int) { | 1414 if (_value is int) { |
| 1415 return valueOf(((leftValue as int)) - (_value as int)); | 1415 return valueOf(((leftValue as int)) - (_value as int)); |
| 1416 } else if (_value is double) { | 1416 } else if (_value is double) { |
| 1417 return valueOf3(((leftValue as int)).toDouble() - ((_value as double))); | 1417 return valueOf3(((leftValue as int)).toDouble() - ((_value as double))); |
| 1418 } | 1418 } |
| 1419 } else if (leftValue is double) { | 1419 } else if (leftValue is double) { |
| 1420 if (_value is int) { | 1420 if (_value is int) { |
| 1421 return valueOf3(((leftValue as double)) - ((_value as int)).toDouble()); | 1421 return valueOf3(((leftValue as double)) - ((_value as int)).toDouble()); |
| 1422 } else if (_value is double) { | 1422 } else if (_value is double) { |
| 1423 return valueOf3(((leftValue as double)) - ((_value as double))); | 1423 return valueOf3(((leftValue as double)) - ((_value as double))); |
| 1424 } | 1424 } |
| 1425 } | 1425 } |
| 1426 return error(node); | 1426 return error(node); |
| 1427 } | 1427 } |
| 1428 EvaluationResultImpl notEqualError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; | 1428 EvaluationResultImpl notEqualError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; |
| 1429 EvaluationResultImpl notEqualValid(BinaryExpression node, ValidResult leftOper
and) { | 1429 EvaluationResultImpl notEqualValid(BinaryExpression node, ValidResult leftOper
and) { |
| 1430 if (!isAnyNullBoolNumString() || !leftOperand.isAnyNullBoolNumString()) { | 1430 if (!isAnyNullBoolNumString || !leftOperand.isAnyNullBoolNumString) { |
| 1431 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); | 1431 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); |
| 1432 } | 1432 } |
| 1433 Object leftValue = leftOperand.value; | 1433 Object leftValue = leftOperand.value; |
| 1434 if (leftValue == null) { | 1434 if (leftValue == null) { |
| 1435 return valueOf2(_value != null); | 1435 return valueOf2(_value != null); |
| 1436 } else if (leftValue is bool) { | 1436 } else if (leftValue is bool) { |
| 1437 if (_value is bool) { | 1437 if (_value is bool) { |
| 1438 return valueOf2(((leftValue as bool)) != ((_value as bool))); | 1438 return valueOf2(((leftValue as bool)) != ((_value as bool))); |
| 1439 } | 1439 } |
| 1440 return RESULT_TRUE; | 1440 return RESULT_TRUE; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1455 } else if (leftValue is String) { | 1455 } else if (leftValue is String) { |
| 1456 if (_value is String) { | 1456 if (_value is String) { |
| 1457 return valueOf2(((leftValue as String)) != _value); | 1457 return valueOf2(((leftValue as String)) != _value); |
| 1458 } | 1458 } |
| 1459 return RESULT_TRUE; | 1459 return RESULT_TRUE; |
| 1460 } | 1460 } |
| 1461 return RESULT_TRUE; | 1461 return RESULT_TRUE; |
| 1462 } | 1462 } |
| 1463 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1463 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1464 EvaluationResultImpl remainderValid(BinaryExpression node, ValidResult leftOpe
rand2) { | 1464 EvaluationResultImpl remainderValid(BinaryExpression node, ValidResult leftOpe
rand2) { |
| 1465 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1465 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1466 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1466 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1467 return RESULT_NUM; | 1467 return RESULT_NUM; |
| 1468 } | 1468 } |
| 1469 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1469 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1470 } | 1470 } |
| 1471 Object leftValue = leftOperand2.value; | 1471 Object leftValue = leftOperand2.value; |
| 1472 if (leftValue == null) { | 1472 if (leftValue == null) { |
| 1473 return error(node.leftOperand); | 1473 return error(node.leftOperand); |
| 1474 } else if (_value == null) { | 1474 } else if (_value == null) { |
| 1475 return error(node.rightOperand); | 1475 return error(node.rightOperand); |
| 1476 } else if (leftValue is int) { | 1476 } else if (leftValue is int) { |
| 1477 if (_value is int) { | 1477 if (_value is int) { |
| 1478 if (((_value as int)) == 0) { | 1478 if (((_value as int)) == 0) { |
| 1479 return valueOf3(((leftValue as int)).toDouble() % ((_value as int)).to
Double()); | 1479 return valueOf3(((leftValue as int)).toDouble() % ((_value as int)).to
Double()); |
| 1480 } | 1480 } |
| 1481 return valueOf(((leftValue as int)).remainder((_value as int))); | 1481 return valueOf(((leftValue as int)).remainder((_value as int))); |
| 1482 } else if (_value is double) { | 1482 } else if (_value is double) { |
| 1483 return valueOf3(((leftValue as int)).toDouble() % ((_value as double))); | 1483 return valueOf3(((leftValue as int)).toDouble() % ((_value as double))); |
| 1484 } | 1484 } |
| 1485 } else if (leftValue is double) { | 1485 } else if (leftValue is double) { |
| 1486 if (_value is int) { | 1486 if (_value is int) { |
| 1487 return valueOf3(((leftValue as double)) % ((_value as int)).toDouble()); | 1487 return valueOf3(((leftValue as double)) % ((_value as int)).toDouble()); |
| 1488 } else if (_value is double) { | 1488 } else if (_value is double) { |
| 1489 return valueOf3(((leftValue as double)) % ((_value as double))); | 1489 return valueOf3(((leftValue as double)) % ((_value as double))); |
| 1490 } | 1490 } |
| 1491 } | 1491 } |
| 1492 return error(node); | 1492 return error(node); |
| 1493 } | 1493 } |
| 1494 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1494 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1495 EvaluationResultImpl shiftLeftValid(BinaryExpression node, ValidResult leftOpe
rand2) { | 1495 EvaluationResultImpl shiftLeftValid(BinaryExpression node, ValidResult leftOpe
rand2) { |
| 1496 if (isSomeInt() || leftOperand2.isSomeInt()) { | 1496 if (isSomeInt || leftOperand2.isSomeInt) { |
| 1497 if (isAnyInt() && leftOperand2.isAnyInt()) { | 1497 if (isAnyInt && leftOperand2.isAnyInt) { |
| 1498 return RESULT_INT; | 1498 return RESULT_INT; |
| 1499 } | 1499 } |
| 1500 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1500 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
| 1501 } | 1501 } |
| 1502 Object leftValue = leftOperand2.value; | 1502 Object leftValue = leftOperand2.value; |
| 1503 if (leftValue == null) { | 1503 if (leftValue == null) { |
| 1504 return error(node.leftOperand); | 1504 return error(node.leftOperand); |
| 1505 } else if (_value == null) { | 1505 } else if (_value == null) { |
| 1506 return error(node.rightOperand); | 1506 return error(node.rightOperand); |
| 1507 } else if (leftValue is int) { | 1507 } else if (leftValue is int) { |
| 1508 if (_value is int) { | 1508 if (_value is int) { |
| 1509 return valueOf(((leftValue as int)) << ((_value as int))); | 1509 return valueOf(((leftValue as int)) << ((_value as int))); |
| 1510 } | 1510 } |
| 1511 return error(node.rightOperand); | 1511 return error(node.rightOperand); |
| 1512 } | 1512 } |
| 1513 if (_value is int) { | 1513 if (_value is int) { |
| 1514 return error(node.leftOperand); | 1514 return error(node.leftOperand); |
| 1515 } | 1515 } |
| 1516 return union(error(node.leftOperand), error(node.rightOperand)); | 1516 return union(error(node.leftOperand), error(node.rightOperand)); |
| 1517 } | 1517 } |
| 1518 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; | 1518 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; |
| 1519 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp
erand2) { | 1519 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp
erand2) { |
| 1520 if (isSomeInt() || leftOperand2.isSomeInt()) { | 1520 if (isSomeInt || leftOperand2.isSomeInt) { |
| 1521 if (isAnyInt() && leftOperand2.isAnyInt()) { | 1521 if (isAnyInt && leftOperand2.isAnyInt) { |
| 1522 return RESULT_INT; | 1522 return RESULT_INT; |
| 1523 } | 1523 } |
| 1524 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1524 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
| 1525 } | 1525 } |
| 1526 Object leftValue = leftOperand2.value; | 1526 Object leftValue = leftOperand2.value; |
| 1527 if (leftValue == null) { | 1527 if (leftValue == null) { |
| 1528 return error(node.leftOperand); | 1528 return error(node.leftOperand); |
| 1529 } else if (_value == null) { | 1529 } else if (_value == null) { |
| 1530 return error(node.rightOperand); | 1530 return error(node.rightOperand); |
| 1531 } else if (leftValue is int) { | 1531 } else if (leftValue is int) { |
| 1532 if (_value is int) { | 1532 if (_value is int) { |
| 1533 return valueOf(((leftValue as int)) >> ((_value as int))); | 1533 return valueOf(((leftValue as int)) >> ((_value as int))); |
| 1534 } | 1534 } |
| 1535 return error(node.rightOperand); | 1535 return error(node.rightOperand); |
| 1536 } | 1536 } |
| 1537 if (_value is int) { | 1537 if (_value is int) { |
| 1538 return error(node.leftOperand); | 1538 return error(node.leftOperand); |
| 1539 } | 1539 } |
| 1540 return union(error(node.leftOperand), error(node.rightOperand)); | 1540 return union(error(node.leftOperand), error(node.rightOperand)); |
| 1541 } | 1541 } |
| 1542 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1542 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1543 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand
2) { | 1543 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand
2) { |
| 1544 if (isSomeNum() || leftOperand2.isSomeNum()) { | 1544 if (isSomeNum || leftOperand2.isSomeNum) { |
| 1545 if (isAnyNum() && leftOperand2.isAnyNum()) { | 1545 if (isAnyNum && leftOperand2.isAnyNum) { |
| 1546 return RESULT_NUM; | 1546 return RESULT_NUM; |
| 1547 } | 1547 } |
| 1548 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1548 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
| 1549 } | 1549 } |
| 1550 Object leftValue = leftOperand2.value; | 1550 Object leftValue = leftOperand2.value; |
| 1551 if (leftValue == null) { | 1551 if (leftValue == null) { |
| 1552 return error(node.leftOperand); | 1552 return error(node.leftOperand); |
| 1553 } else if (_value == null) { | 1553 } else if (_value == null) { |
| 1554 return error(node.rightOperand); | 1554 return error(node.rightOperand); |
| 1555 } else if (leftValue is int) { | 1555 } else if (leftValue is int) { |
| 1556 if (_value is int) { | 1556 if (_value is int) { |
| 1557 return valueOf(((leftValue as int)) * (_value as int)); | 1557 return valueOf(((leftValue as int)) * (_value as int)); |
| 1558 } else if (_value is double) { | 1558 } else if (_value is double) { |
| 1559 return valueOf3(((leftValue as int)).toDouble() * ((_value as double))); | 1559 return valueOf3(((leftValue as int)).toDouble() * ((_value as double))); |
| 1560 } | 1560 } |
| 1561 } else if (leftValue is double) { | 1561 } else if (leftValue is double) { |
| 1562 if (_value is int) { | 1562 if (_value is int) { |
| 1563 return valueOf3(((leftValue as double)) * ((_value as int)).toDouble()); | 1563 return valueOf3(((leftValue as double)) * ((_value as int)).toDouble()); |
| 1564 } else if (_value is double) { | 1564 } else if (_value is double) { |
| 1565 return valueOf3(((leftValue as double)) * ((_value as double))); | 1565 return valueOf3(((leftValue as double)) * ((_value as double))); |
| 1566 } | 1566 } |
| 1567 } | 1567 } |
| 1568 return error(node); | 1568 return error(node); |
| 1569 } | 1569 } |
| 1570 bool isNull() => identical(this, RESULT_NULL); | 1570 bool get isNull => identical(this, RESULT_NULL); |
| 1571 | 1571 |
| 1572 /** | 1572 /** |
| 1573 * Return the result of applying boolean conversion to the given value. | 1573 * Return the result of applying boolean conversion to the given value. |
| 1574 * @param node the node against which errors should be reported | 1574 * @param node the node against which errors should be reported |
| 1575 * @param value the value to be converted to a boolean | 1575 * @param value the value to be converted to a boolean |
| 1576 * @return the result of applying boolean conversion to the given value | 1576 * @return the result of applying boolean conversion to the given value |
| 1577 */ | 1577 */ |
| 1578 EvaluationResultImpl booleanConversion(ASTNode node, Object value) { | 1578 EvaluationResultImpl booleanConversion(ASTNode node, Object value) { |
| 1579 if (value is bool) { | 1579 if (value is bool) { |
| 1580 if (((value as bool))) { | 1580 if (((value as bool))) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1591 * Return a result object representing an error associated with the given node
. | 1591 * Return a result object representing an error associated with the given node
. |
| 1592 * @param node the AST node associated with the error | 1592 * @param node the AST node associated with the error |
| 1593 * @param code the error code indicating the nature of the error | 1593 * @param code the error code indicating the nature of the error |
| 1594 * @return a result object representing an error associated with the given nod
e | 1594 * @return a result object representing an error associated with the given nod
e |
| 1595 */ | 1595 */ |
| 1596 ErrorResult error2(ASTNode node, ErrorCode code) => new ErrorResult.con1(node,
code); | 1596 ErrorResult error2(ASTNode node, ErrorCode code) => new ErrorResult.con1(node,
code); |
| 1597 | 1597 |
| 1598 /** | 1598 /** |
| 1599 * Checks if this result has type "bool", with known or unknown value. | 1599 * Checks if this result has type "bool", with known or unknown value. |
| 1600 */ | 1600 */ |
| 1601 bool isAnyBool() => isSomeBool() || identical(this, RESULT_TRUE) || identical(
this, RESULT_FALSE); | 1601 bool get isAnyBool => isSomeBool || identical(this, RESULT_TRUE) || identical(
this, RESULT_FALSE); |
| 1602 | 1602 |
| 1603 /** | 1603 /** |
| 1604 * Checks if this result has type "int", with known or unknown value. | 1604 * Checks if this result has type "int", with known or unknown value. |
| 1605 */ | 1605 */ |
| 1606 bool isAnyInt() => identical(this, RESULT_INT) || _value is int; | 1606 bool get isAnyInt => identical(this, RESULT_INT) || _value is int; |
| 1607 | 1607 |
| 1608 /** | 1608 /** |
| 1609 * Checks if this result has one of the types - "bool", "num" or "string"; or
may be `null`. | 1609 * Checks if this result has one of the types - "bool", "num" or "string"; or
may be `null`. |
| 1610 */ | 1610 */ |
| 1611 bool isAnyNullBoolNumString() => isNull() || isAnyBool() || isAnyNum() || _val
ue is String; | 1611 bool get isAnyNullBoolNumString => isNull || isAnyBool || isAnyNum || _value i
s String; |
| 1612 | 1612 |
| 1613 /** | 1613 /** |
| 1614 * Checks if this result has type "num", with known or unknown value. | 1614 * Checks if this result has type "num", with known or unknown value. |
| 1615 */ | 1615 */ |
| 1616 bool isAnyNum() => isSomeNum() || _value is num; | 1616 bool get isAnyNum => isSomeNum || _value is num; |
| 1617 | 1617 |
| 1618 /** | 1618 /** |
| 1619 * Checks if this result has type "bool", exact value of which we don't know. | 1619 * Checks if this result has type "bool", exact value of which we don't know. |
| 1620 */ | 1620 */ |
| 1621 bool isSomeBool() => identical(this, RESULT_BOOL); | 1621 bool get isSomeBool => identical(this, RESULT_BOOL); |
| 1622 | 1622 |
| 1623 /** | 1623 /** |
| 1624 * Checks if this result has type "int", exact value of which we don't know. | 1624 * Checks if this result has type "int", exact value of which we don't know. |
| 1625 */ | 1625 */ |
| 1626 bool isSomeInt() => identical(this, RESULT_INT); | 1626 bool get isSomeInt => identical(this, RESULT_INT); |
| 1627 | 1627 |
| 1628 /** | 1628 /** |
| 1629 * Checks if this result has type "num" (or "int"), exact value of which we do
n't know. | 1629 * Checks if this result has type "num" (or "int"), exact value of which we do
n't know. |
| 1630 */ | 1630 */ |
| 1631 bool isSomeNum() => identical(this, RESULT_DYNAMIC) || identical(this, RESULT_
INT) || identical(this, RESULT_NUM); | 1631 bool get isSomeNum => identical(this, RESULT_DYNAMIC) || identical(this, RESUL
T_INT) || identical(this, RESULT_NUM); |
| 1632 double toDouble(int value) => value.toDouble(); | 1632 double toDouble(int value) => value.toDouble(); |
| 1633 | 1633 |
| 1634 /** | 1634 /** |
| 1635 * Return an error result that is the union of the two given error results. | 1635 * Return an error result that is the union of the two given error results. |
| 1636 * @param firstError the first error to be combined | 1636 * @param firstError the first error to be combined |
| 1637 * @param secondError the second error to be combined | 1637 * @param secondError the second error to be combined |
| 1638 * @return an error result that is the union of the two given error results | 1638 * @return an error result that is the union of the two given error results |
| 1639 */ | 1639 */ |
| 1640 ErrorResult union(ErrorResult firstError, ErrorResult secondError) => new Erro
rResult.con2(firstError, secondError); | 1640 ErrorResult union(ErrorResult firstError, ErrorResult secondError) => new Erro
rResult.con2(firstError, secondError); |
| 1641 | 1641 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1660 */ | 1660 */ |
| 1661 ValidResult valueOf3(double value) => new ValidResult(value); | 1661 ValidResult valueOf3(double value) => new ValidResult(value); |
| 1662 | 1662 |
| 1663 /** | 1663 /** |
| 1664 * Return a result object representing the given value. | 1664 * Return a result object representing the given value. |
| 1665 * @param value the value to be represented as a result object | 1665 * @param value the value to be represented as a result object |
| 1666 * @return a result object representing the given value | 1666 * @return a result object representing the given value |
| 1667 */ | 1667 */ |
| 1668 ValidResult valueOf4(String value) => new ValidResult(value); | 1668 ValidResult valueOf4(String value) => new ValidResult(value); |
| 1669 } | 1669 } |
| OLD | NEW |