| 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 | 3 |
| 4 library engine.constant; | 4 library engine.constant; |
| 5 | 5 |
| 6 import 'java_core.dart'; | 6 import 'java_core.dart'; |
| 7 import 'source.dart' show Source; | 7 import 'source.dart' show Source; |
| 8 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; | 8 import 'error.dart' show AnalysisError, ErrorCode, CompileTimeErrorCode; |
| 9 import 'scanner.dart' show TokenType; | 9 import 'scanner.dart' show TokenType; |
| 10 import 'ast.dart'; | 10 import 'ast.dart'; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 */ | 139 */ |
| 140 ConstantFinder() : super() { | 140 ConstantFinder() : super() { |
| 141 } | 141 } |
| 142 /** | 142 /** |
| 143 * Return a table mapping constant variable elements to the declarations of th
ose variables. | 143 * Return a table mapping constant variable elements to the declarations of th
ose variables. |
| 144 * @return a table mapping constant variable elements to the declarations of t
hose variables | 144 * @return a table mapping constant variable elements to the declarations of t
hose variables |
| 145 */ | 145 */ |
| 146 Map<VariableElement, VariableDeclaration> get variableMap => _variableMap; | 146 Map<VariableElement, VariableDeclaration> get variableMap => _variableMap; |
| 147 Object visitVariableDeclaration(VariableDeclaration node) { | 147 Object visitVariableDeclaration(VariableDeclaration node) { |
| 148 super.visitVariableDeclaration(node); | 148 super.visitVariableDeclaration(node); |
| 149 Expression initializer4 = node.initializer; | 149 Expression initializer2 = node.initializer; |
| 150 if (initializer4 != null && node.isConst()) { | 150 if (initializer2 != null && node.isConst()) { |
| 151 VariableElement element23 = node.element; | 151 VariableElement element2 = node.element; |
| 152 if (element23 != null) { | 152 if (element2 != null) { |
| 153 _variableMap[element23] = node; | 153 _variableMap[element2] = node; |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 return null; | 156 return null; |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 /** | 159 /** |
| 160 * Instances of the class {@code ConstantValueComputer} compute the values of co
nstant variables in | 160 * Instances of the class {@code ConstantValueComputer} compute the values of co
nstant variables in |
| 161 * one or more compilation units. The expected usage pattern is for the compilat
ion units to be | 161 * one or more compilation units. The expected usage pattern is for the compilat
ion units to be |
| 162 * added to this computer using the method {@link #add(CompilationUnit)} and the
n for the method{@link #computeValues()} to invoked exactly once. Any use of an
instance after invoking the | 162 * added to this computer using the method {@link #add(CompilationUnit)} and the
n for the method{@link #computeValues()} to invoked exactly once. Any use of an
instance after invoking the |
| 163 * method {@link #computeValues()} will result in unpredictable behavior. | 163 * method {@link #computeValues()} will result in unpredictable behavior. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 void computeValueFor(VariableElement variable) { | 226 void computeValueFor(VariableElement variable) { |
| 227 VariableDeclaration declaration = _declarationMap[variable]; | 227 VariableDeclaration declaration = _declarationMap[variable]; |
| 228 if (declaration == null) { | 228 if (declaration == null) { |
| 229 return; | 229 return; |
| 230 } | 230 } |
| 231 EvaluationResultImpl result = declaration.initializer.accept(new ConstantVis
itor()); | 231 EvaluationResultImpl result = declaration.initializer.accept(new ConstantVis
itor()); |
| 232 ((variable as VariableElementImpl)).evaluationResult = result; | 232 ((variable as VariableElementImpl)).evaluationResult = result; |
| 233 if (result is ErrorResult) { | 233 if (result is ErrorResult) { |
| 234 List<AnalysisError> errors = new List<AnalysisError>(); | 234 List<AnalysisError> errors = new List<AnalysisError>(); |
| 235 for (ErrorResult_ErrorData data in ((result as ErrorResult)).errorData) { | 235 for (ErrorResult_ErrorData data in ((result as ErrorResult)).errorData) { |
| 236 ASTNode node3 = data.node; | 236 ASTNode node2 = data.node; |
| 237 Source source10 = variable.getAncestor(CompilationUnitElement).source; | 237 Source source2 = variable.getAncestor(CompilationUnitElement).source; |
| 238 errors.add(new AnalysisError.con2(source10, node3.offset, node3.length,
data.errorCode, [])); | 238 errors.add(new AnalysisError.con2(source2, node2.offset, node2.length, d
ata.errorCode, [])); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 /** | 242 /** |
| 243 * Generate an error indicating that the given variable is not a valid compile
-time constant | 243 * Generate an error indicating that the given variable is not a valid compile
-time constant |
| 244 * because it references at least one of the variables in the given cycle, eac
h of which directly | 244 * because it references at least one of the variables in the given cycle, eac
h of which directly |
| 245 * or indirectly references the variable. | 245 * or indirectly references the variable. |
| 246 * @param variablesInCycle the variables in the cycle that includes the given
variable | 246 * @param variablesInCycle the variables in the cycle that includes the given
variable |
| 247 * @param variable the variable that is not a valid compile-time constant | 247 * @param variable the variable that is not a valid compile-time constant |
| 248 */ | 248 */ |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 for (MapLiteralEntry entry in node.entries) { | 370 for (MapLiteralEntry entry in node.entries) { |
| 371 result = union(result, entry.key.accept(this)); | 371 result = union(result, entry.key.accept(this)); |
| 372 result = union(result, entry.value.accept(this)); | 372 result = union(result, entry.value.accept(this)); |
| 373 } | 373 } |
| 374 if (result != null) { | 374 if (result != null) { |
| 375 return result; | 375 return result; |
| 376 } | 376 } |
| 377 return ValidResult.RESULT_OBJECT; | 377 return ValidResult.RESULT_OBJECT; |
| 378 } | 378 } |
| 379 EvaluationResultImpl visitMethodInvocation(MethodInvocation node) { | 379 EvaluationResultImpl visitMethodInvocation(MethodInvocation node) { |
| 380 Element element24 = node.methodName.element; | 380 Element element2 = node.methodName.element; |
| 381 if (element24 is FunctionElement) { | 381 if (element2 is FunctionElement) { |
| 382 FunctionElement function = element24 as FunctionElement; | 382 FunctionElement function = element2 as FunctionElement; |
| 383 if (function.name == "identical") { | 383 if (function.name == "identical") { |
| 384 NodeList<Expression> arguments3 = node.argumentList.arguments; | 384 NodeList<Expression> arguments2 = node.argumentList.arguments; |
| 385 if (arguments3.length == 2) { | 385 if (arguments2.length == 2) { |
| 386 Element enclosingElement2 = function.enclosingElement; | 386 Element enclosingElement2 = function.enclosingElement; |
| 387 if (enclosingElement2 is CompilationUnitElement) { | 387 if (enclosingElement2 is CompilationUnitElement) { |
| 388 LibraryElement library30 = ((enclosingElement2 as CompilationUnitEle
ment)).library; | 388 LibraryElement library2 = ((enclosingElement2 as CompilationUnitElem
ent)).library; |
| 389 if (library30.isDartCore()) { | 389 if (library2.isDartCore()) { |
| 390 EvaluationResultImpl leftArgument = arguments3[0].accept(this); | 390 EvaluationResultImpl leftArgument = arguments2[0].accept(this); |
| 391 EvaluationResultImpl rightArgument = arguments3[1].accept(this); | 391 EvaluationResultImpl rightArgument = arguments2[1].accept(this); |
| 392 return leftArgument.equalEqual(node, rightArgument); | 392 return leftArgument.equalEqual(node, rightArgument); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 return error(node, null); | 398 return error(node, null); |
| 399 } | 399 } |
| 400 EvaluationResultImpl visitNode(ASTNode node) => error(node, null); | 400 EvaluationResultImpl visitNode(ASTNode node) => error(node, null); |
| 401 EvaluationResultImpl visitNullLiteral(NullLiteral node) => new ValidResult(nul
l); | 401 EvaluationResultImpl visitNullLiteral(NullLiteral node) => new ValidResult(nul
l); |
| 402 EvaluationResultImpl visitParenthesizedExpression(ParenthesizedExpression node
) => node.expression.accept(this); | 402 EvaluationResultImpl visitParenthesizedExpression(ParenthesizedExpression node
) => node.expression.accept(this); |
| 403 EvaluationResultImpl visitPrefixedIdentifier(PrefixedIdentifier node) => getCo
nstantValue(node, node.element); | 403 EvaluationResultImpl visitPrefixedIdentifier(PrefixedIdentifier node) => getCo
nstantValue(node, node.element); |
| 404 EvaluationResultImpl visitPrefixExpression(PrefixExpression node) { | 404 EvaluationResultImpl visitPrefixExpression(PrefixExpression node) { |
| 405 EvaluationResultImpl operand3 = node.operand.accept(this); | 405 EvaluationResultImpl operand2 = node.operand.accept(this); |
| 406 while (true) { | 406 while (true) { |
| 407 if (node.operator.type == TokenType.BANG) { | 407 if (node.operator.type == TokenType.BANG) { |
| 408 return operand3.logicalNot(node); | 408 return operand2.logicalNot(node); |
| 409 } else if (node.operator.type == TokenType.TILDE) { | 409 } else if (node.operator.type == TokenType.TILDE) { |
| 410 return operand3.bitNot(node); | 410 return operand2.bitNot(node); |
| 411 } else if (node.operator.type == TokenType.MINUS) { | 411 } else if (node.operator.type == TokenType.MINUS) { |
| 412 return operand3.negated(node); | 412 return operand2.negated(node); |
| 413 } | 413 } |
| 414 break; | 414 break; |
| 415 } | 415 } |
| 416 return error(node, null); | 416 return error(node, null); |
| 417 } | 417 } |
| 418 EvaluationResultImpl visitPropertyAccess(PropertyAccess node) => getConstantVa
lue(node, node.propertyName.element); | 418 EvaluationResultImpl visitPropertyAccess(PropertyAccess node) => getConstantVa
lue(node, node.propertyName.element); |
| 419 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) => getConsta
ntValue(node, node.element); | 419 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) => getConsta
ntValue(node, node.element); |
| 420 EvaluationResultImpl visitSimpleStringLiteral(SimpleStringLiteral node) => new
ValidResult(node.value); | 420 EvaluationResultImpl visitSimpleStringLiteral(SimpleStringLiteral node) => new
ValidResult(node.value); |
| 421 EvaluationResultImpl visitStringInterpolation(StringInterpolation node) { | 421 EvaluationResultImpl visitStringInterpolation(StringInterpolation node) { |
| 422 EvaluationResultImpl result = null; | 422 EvaluationResultImpl result = null; |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 * variables and to add those references to the given graph. | 835 * variables and to add those references to the given graph. |
| 836 * @param source the element representing the variable whose initializer will
be visited | 836 * @param source the element representing the variable whose initializer will
be visited |
| 837 * @param referenceGraph a graph recording which variables (heads) reference w
hich other variables | 837 * @param referenceGraph a graph recording which variables (heads) reference w
hich other variables |
| 838 * (tails) in their initializers | 838 * (tails) in their initializers |
| 839 */ | 839 */ |
| 840 ReferenceFinder(VariableElement source, DirectedGraph<VariableElement> referen
ceGraph) { | 840 ReferenceFinder(VariableElement source, DirectedGraph<VariableElement> referen
ceGraph) { |
| 841 this._source = source; | 841 this._source = source; |
| 842 this._referenceGraph = referenceGraph; | 842 this._referenceGraph = referenceGraph; |
| 843 } | 843 } |
| 844 Object visitSimpleIdentifier(SimpleIdentifier node) { | 844 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 845 Element element25 = node.element; | 845 Element element2 = node.element; |
| 846 if (element25 is PropertyAccessorElement) { | 846 if (element2 is PropertyAccessorElement) { |
| 847 element25 = ((element25 as PropertyAccessorElement)).variable; | 847 element2 = ((element2 as PropertyAccessorElement)).variable; |
| 848 } | 848 } |
| 849 if (element25 is VariableElement) { | 849 if (element2 is VariableElement) { |
| 850 VariableElement variable = element25 as VariableElement; | 850 VariableElement variable = element2 as VariableElement; |
| 851 if (variable.isConst()) { | 851 if (variable.isConst()) { |
| 852 _referenceGraph.addEdge(_source, variable); | 852 _referenceGraph.addEdge(_source, variable); |
| 853 } | 853 } |
| 854 } | 854 } |
| 855 return null; | 855 return null; |
| 856 } | 856 } |
| 857 } | 857 } |
| 858 /** | 858 /** |
| 859 * Instances of the class {@code ValidResult} represent the result of attempting
to evaluate a valid | 859 * Instances of the class {@code ValidResult} represent the result of attempting
to evaluate a valid |
| 860 * compile time constant expression. | 860 * compile time constant expression. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 EvaluationResultImpl shiftLeft(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.shiftLeftValid(node, this); | 945 EvaluationResultImpl shiftLeft(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.shiftLeftValid(node, this); |
| 946 EvaluationResultImpl shiftRight(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.shiftRightValid(node, this); | 946 EvaluationResultImpl shiftRight(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.shiftRightValid(node, this); |
| 947 EvaluationResultImpl times(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.timesValid(node, this); | 947 EvaluationResultImpl times(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.timesValid(node, this); |
| 948 String toString() { | 948 String toString() { |
| 949 if (_value == null) { | 949 if (_value == null) { |
| 950 return "null"; | 950 return "null"; |
| 951 } | 951 } |
| 952 return _value.toString(); | 952 return _value.toString(); |
| 953 } | 953 } |
| 954 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 954 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 955 EvaluationResultImpl addToValid(BinaryExpression node, ValidResult leftOperand
3) { | 955 EvaluationResultImpl addToValid(BinaryExpression node, ValidResult leftOperand
2) { |
| 956 Object leftValue = leftOperand3.value; | 956 Object leftValue = leftOperand2.value; |
| 957 if (leftValue == null) { | 957 if (leftValue == null) { |
| 958 return error(node.leftOperand); | 958 return error(node.leftOperand); |
| 959 } else if (_value == null) { | 959 } else if (_value == null) { |
| 960 return error(node.rightOperand); | 960 return error(node.rightOperand); |
| 961 } else if (leftValue is int) { | 961 } else if (leftValue is int) { |
| 962 if (_value is int) { | 962 if (_value is int) { |
| 963 return valueOf(((leftValue as int)) + (_value as int)); | 963 return valueOf(((leftValue as int)) + (_value as int)); |
| 964 } else if (_value is double) { | 964 } else if (_value is double) { |
| 965 return valueOf3(((leftValue as int)).toDouble() + ((_value as double))); | 965 return valueOf3(((leftValue as int)).toDouble() + ((_value as double))); |
| 966 } | 966 } |
| 967 } else if (leftValue is double) { | 967 } else if (leftValue is double) { |
| 968 if (_value is int) { | 968 if (_value is int) { |
| 969 return valueOf3(((leftValue as double)) + ((_value as int)).toDouble()); | 969 return valueOf3(((leftValue as double)) + ((_value as int)).toDouble()); |
| 970 } else if (_value is double) { | 970 } else if (_value is double) { |
| 971 return valueOf3(((leftValue as double)) + ((_value as double))); | 971 return valueOf3(((leftValue as double)) + ((_value as double))); |
| 972 } | 972 } |
| 973 } else if (leftValue is String) { | 973 } else if (leftValue is String) { |
| 974 if (_value is String) { | 974 if (_value is String) { |
| 975 return valueOf4("${((leftValue as String))}${((_value as String))}"); | 975 return valueOf4("${((leftValue as String))}${((_value as String))}"); |
| 976 } | 976 } |
| 977 } | 977 } |
| 978 return error(node); | 978 return error(node); |
| 979 } | 979 } |
| 980 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 980 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 981 EvaluationResultImpl bitAndValid(BinaryExpression node, ValidResult leftOperan
d4) { | 981 EvaluationResultImpl bitAndValid(BinaryExpression node, ValidResult leftOperan
d2) { |
| 982 Object leftValue = leftOperand4.value; | 982 Object leftValue = leftOperand2.value; |
| 983 if (leftValue == null) { | 983 if (leftValue == null) { |
| 984 return error(node.leftOperand); | 984 return error(node.leftOperand); |
| 985 } else if (_value == null) { | 985 } else if (_value == null) { |
| 986 return error(node.rightOperand); | 986 return error(node.rightOperand); |
| 987 } else if (leftValue is int) { | 987 } else if (leftValue is int) { |
| 988 if (_value is int) { | 988 if (_value is int) { |
| 989 return valueOf(((leftValue as int)) & (_value as int)); | 989 return valueOf(((leftValue as int)) & (_value as int)); |
| 990 } | 990 } |
| 991 return error(node.leftOperand); | 991 return error(node.leftOperand); |
| 992 } | 992 } |
| 993 if (_value is int) { | 993 if (_value is int) { |
| 994 return error(node.rightOperand); | 994 return error(node.rightOperand); |
| 995 } | 995 } |
| 996 return union(error(node.leftOperand), error(node.rightOperand)); | 996 return union(error(node.leftOperand), error(node.rightOperand)); |
| 997 } | 997 } |
| 998 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 998 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 999 EvaluationResultImpl bitOrValid(BinaryExpression node, ValidResult leftOperand
5) { | 999 EvaluationResultImpl bitOrValid(BinaryExpression node, ValidResult leftOperand
2) { |
| 1000 Object leftValue = leftOperand5.value; | 1000 Object leftValue = leftOperand2.value; |
| 1001 if (leftValue == null) { | 1001 if (leftValue == null) { |
| 1002 return error(node.leftOperand); | 1002 return error(node.leftOperand); |
| 1003 } else if (_value == null) { | 1003 } else if (_value == null) { |
| 1004 return error(node.rightOperand); | 1004 return error(node.rightOperand); |
| 1005 } else if (leftValue is int) { | 1005 } else if (leftValue is int) { |
| 1006 if (_value is int) { | 1006 if (_value is int) { |
| 1007 return valueOf(((leftValue as int)) | (_value as int)); | 1007 return valueOf(((leftValue as int)) | (_value as int)); |
| 1008 } | 1008 } |
| 1009 return error(node.leftOperand); | 1009 return error(node.leftOperand); |
| 1010 } | 1010 } |
| 1011 if (_value is int) { | 1011 if (_value is int) { |
| 1012 return error(node.rightOperand); | 1012 return error(node.rightOperand); |
| 1013 } | 1013 } |
| 1014 return union(error(node.leftOperand), error(node.rightOperand)); | 1014 return union(error(node.leftOperand), error(node.rightOperand)); |
| 1015 } | 1015 } |
| 1016 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1016 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 1017 EvaluationResultImpl bitXorValid(BinaryExpression node, ValidResult leftOperan
d6) { | 1017 EvaluationResultImpl bitXorValid(BinaryExpression node, ValidResult leftOperan
d2) { |
| 1018 Object leftValue = leftOperand6.value; | 1018 Object leftValue = leftOperand2.value; |
| 1019 if (leftValue == null) { | 1019 if (leftValue == null) { |
| 1020 return error(node.leftOperand); | 1020 return error(node.leftOperand); |
| 1021 } else if (_value == null) { | 1021 } else if (_value == null) { |
| 1022 return error(node.rightOperand); | 1022 return error(node.rightOperand); |
| 1023 } else if (leftValue is int) { | 1023 } else if (leftValue is int) { |
| 1024 if (_value is int) { | 1024 if (_value is int) { |
| 1025 return valueOf(((leftValue as int)) ^ (_value as int)); | 1025 return valueOf(((leftValue as int)) ^ (_value as int)); |
| 1026 } | 1026 } |
| 1027 return error(node.leftOperand); | 1027 return error(node.leftOperand); |
| 1028 } | 1028 } |
| 1029 if (_value is int) { | 1029 if (_value is int) { |
| 1030 return error(node.rightOperand); | 1030 return error(node.rightOperand); |
| 1031 } | 1031 } |
| 1032 return union(error(node.leftOperand), error(node.rightOperand)); | 1032 return union(error(node.leftOperand), error(node.rightOperand)); |
| 1033 } | 1033 } |
| 1034 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => leftOperand; | 1034 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => leftOperand; |
| 1035 EvaluationResultImpl concatenateValid(Expression node, ValidResult leftOperand
) { | 1035 EvaluationResultImpl concatenateValid(Expression node, ValidResult leftOperand
) { |
| 1036 Object leftValue = leftOperand.value; | 1036 Object leftValue = leftOperand.value; |
| 1037 if (leftValue is String && _value is String) { | 1037 if (leftValue is String && _value is String) { |
| 1038 return valueOf4("${((leftValue as String))}${((_value as String))}"); | 1038 return valueOf4("${((leftValue as String))}${((_value as String))}"); |
| 1039 } | 1039 } |
| 1040 return error(node); | 1040 return error(node); |
| 1041 } | 1041 } |
| 1042 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1042 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
| 1043 EvaluationResultImpl divideValid(BinaryExpression node, ValidResult leftOperan
d7) { | 1043 EvaluationResultImpl divideValid(BinaryExpression node, ValidResult leftOperan
d2) { |
| 1044 Object leftValue = leftOperand7.value; | 1044 Object leftValue = leftOperand2.value; |
| 1045 if (leftValue == null) { | 1045 if (leftValue == null) { |
| 1046 return error(node.leftOperand); | 1046 return error(node.leftOperand); |
| 1047 } else if (_value == null) { | 1047 } else if (_value == null) { |
| 1048 return error(node.rightOperand); | 1048 return error(node.rightOperand); |
| 1049 } else if (leftValue is int) { | 1049 } else if (leftValue is int) { |
| 1050 if (_value is int) { | 1050 if (_value is int) { |
| 1051 if (((_value as int)) == 0) { | 1051 if (((_value as int)) == 0) { |
| 1052 return valueOf3(((leftValue as int)).toDouble() / ((_value as int)).to
Double()); | 1052 return valueOf3(((leftValue as int)).toDouble() / ((_value as int)).to
Double()); |
| 1053 } | 1053 } |
| 1054 return valueOf(((leftValue as int)) ~/ (_value as int)); | 1054 return valueOf(((leftValue as int)) ~/ (_value as int)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 } else if (leftValue is String) { | 1091 } else if (leftValue is String) { |
| 1092 if (_value is String) { | 1092 if (_value is String) { |
| 1093 return valueOf2(((leftValue as String)) == _value); | 1093 return valueOf2(((leftValue as String)) == _value); |
| 1094 } | 1094 } |
| 1095 return RESULT_FALSE; | 1095 return RESULT_FALSE; |
| 1096 } | 1096 } |
| 1097 return RESULT_FALSE; | 1097 return RESULT_FALSE; |
| 1098 } | 1098 } |
| 1099 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => leftOperand; | 1099 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => leftOperand; |
| 1100 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => leftOperand; | 1100 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => leftOperand; |
| 1101 EvaluationResultImpl greaterThanOrEqualValid(BinaryExpression node, ValidResul
t leftOperand8) { | 1101 EvaluationResultImpl greaterThanOrEqualValid(BinaryExpression node, ValidResul
t leftOperand2) { |
| 1102 Object leftValue = leftOperand8.value; | 1102 Object leftValue = leftOperand2.value; |
| 1103 if (leftValue == null) { | 1103 if (leftValue == null) { |
| 1104 return error(node.leftOperand); | 1104 return error(node.leftOperand); |
| 1105 } else if (_value == null) { | 1105 } else if (_value == null) { |
| 1106 return error(node.rightOperand); | 1106 return error(node.rightOperand); |
| 1107 } else if (leftValue is int) { | 1107 } else if (leftValue is int) { |
| 1108 if (_value is int) { | 1108 if (_value is int) { |
| 1109 return valueOf2(((leftValue as int)).compareTo((_value as int)) >= 0); | 1109 return valueOf2(((leftValue as int)).compareTo((_value as int)) >= 0); |
| 1110 } else if (_value is double) { | 1110 } else if (_value is double) { |
| 1111 return valueOf2(((leftValue as int)).toDouble() >= ((_value as double)))
; | 1111 return valueOf2(((leftValue as int)).toDouble() >= ((_value as double)))
; |
| 1112 } | 1112 } |
| 1113 } else if (leftValue is double) { | 1113 } else if (leftValue is double) { |
| 1114 if (_value is int) { | 1114 if (_value is int) { |
| 1115 return valueOf2(((leftValue as double)) >= ((_value as int)).toDouble())
; | 1115 return valueOf2(((leftValue as double)) >= ((_value as int)).toDouble())
; |
| 1116 } else if (_value is double) { | 1116 } else if (_value is double) { |
| 1117 return valueOf2(((leftValue as double)) >= ((_value as double))); | 1117 return valueOf2(((leftValue as double)) >= ((_value as double))); |
| 1118 } | 1118 } |
| 1119 } | 1119 } |
| 1120 return error(node); | 1120 return error(node); |
| 1121 } | 1121 } |
| 1122 EvaluationResultImpl greaterThanValid(BinaryExpression node, ValidResult leftO
perand9) { | 1122 EvaluationResultImpl greaterThanValid(BinaryExpression node, ValidResult leftO
perand2) { |
| 1123 Object leftValue = leftOperand9.value; | 1123 Object leftValue = leftOperand2.value; |
| 1124 if (leftValue == null) { | 1124 if (leftValue == null) { |
| 1125 return error(node.leftOperand); | 1125 return error(node.leftOperand); |
| 1126 } else if (_value == null) { | 1126 } else if (_value == null) { |
| 1127 return error(node.rightOperand); | 1127 return error(node.rightOperand); |
| 1128 } else if (leftValue is int) { | 1128 } else if (leftValue is int) { |
| 1129 if (_value is int) { | 1129 if (_value is int) { |
| 1130 return valueOf2(((leftValue as int)).compareTo((_value as int)) > 0); | 1130 return valueOf2(((leftValue as int)).compareTo((_value as int)) > 0); |
| 1131 } else if (_value is double) { | 1131 } else if (_value is double) { |
| 1132 return valueOf2(((leftValue as int)).toDouble() > ((_value as double))); | 1132 return valueOf2(((leftValue as int)).toDouble() > ((_value as double))); |
| 1133 } | 1133 } |
| 1134 } else if (leftValue is double) { | 1134 } else if (leftValue is double) { |
| 1135 if (_value is int) { | 1135 if (_value is int) { |
| 1136 return valueOf2(((leftValue as double)) > ((_value as int)).toDouble()); | 1136 return valueOf2(((leftValue as double)) > ((_value as int)).toDouble()); |
| 1137 } else if (_value is double) { | 1137 } else if (_value is double) { |
| 1138 return valueOf2(((leftValue as double)) > ((_value as double))); | 1138 return valueOf2(((leftValue as double)) > ((_value as double))); |
| 1139 } | 1139 } |
| 1140 } | 1140 } |
| 1141 return error(node); | 1141 return error(node); |
| 1142 } | 1142 } |
| 1143 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => leftOperand; | 1143 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => leftOperand; |
| 1144 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef
tOperand10) { | 1144 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef
tOperand2) { |
| 1145 Object leftValue = leftOperand10.value; | 1145 Object leftValue = leftOperand2.value; |
| 1146 if (leftValue == null) { | 1146 if (leftValue == null) { |
| 1147 return error(node.leftOperand); | 1147 return error(node.leftOperand); |
| 1148 } else if (_value == null) { | 1148 } else if (_value == null) { |
| 1149 return error(node.rightOperand); | 1149 return error(node.rightOperand); |
| 1150 } else if (leftValue is int) { | 1150 } else if (leftValue is int) { |
| 1151 if (_value is int) { | 1151 if (_value is int) { |
| 1152 if (((_value as int)) == 0) { | 1152 if (((_value as int)) == 0) { |
| 1153 return valueOf3(((leftValue as int)).toDouble() / ((_value as int)).to
Double()); | 1153 return valueOf3(((leftValue as int)).toDouble() / ((_value as int)).to
Double()); |
| 1154 } | 1154 } |
| 1155 return valueOf(((leftValue as int)) ~/ (_value as int)); | 1155 return valueOf(((leftValue as int)) ~/ (_value as int)); |
| 1156 } else if (_value is double) { | 1156 } else if (_value is double) { |
| 1157 double result = ((leftValue as int)).toDouble() / ((_value as double)); | 1157 double result = ((leftValue as int)).toDouble() / ((_value as double)); |
| 1158 return valueOf((result as int)); | 1158 return valueOf((result as int)); |
| 1159 } | 1159 } |
| 1160 } else if (leftValue is double) { | 1160 } else if (leftValue is double) { |
| 1161 if (_value is int) { | 1161 if (_value is int) { |
| 1162 double result = ((leftValue as double)) / ((_value as int)).toDouble(); | 1162 double result = ((leftValue as double)) / ((_value as int)).toDouble(); |
| 1163 return valueOf((result as int)); | 1163 return valueOf((result as int)); |
| 1164 } else if (_value is double) { | 1164 } else if (_value is double) { |
| 1165 double result = ((leftValue as double)) / ((_value as double)); | 1165 double result = ((leftValue as double)) / ((_value as double)); |
| 1166 return valueOf((result as int)); | 1166 return valueOf((result as int)); |
| 1167 } | 1167 } |
| 1168 } | 1168 } |
| 1169 return error(node); | 1169 return error(node); |
| 1170 } | 1170 } |
| 1171 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; | 1171 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; |
| 1172 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => leftOperand; | 1172 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => leftOperand; |
| 1173 EvaluationResultImpl lessThanOrEqualValid(BinaryExpression node, ValidResult l
eftOperand11) { | 1173 EvaluationResultImpl lessThanOrEqualValid(BinaryExpression node, ValidResult l
eftOperand2) { |
| 1174 Object leftValue = leftOperand11.value; | 1174 Object leftValue = leftOperand2.value; |
| 1175 if (leftValue == null) { | 1175 if (leftValue == null) { |
| 1176 return error(node.leftOperand); | 1176 return error(node.leftOperand); |
| 1177 } else if (_value == null) { | 1177 } else if (_value == null) { |
| 1178 return error(node.rightOperand); | 1178 return error(node.rightOperand); |
| 1179 } else if (leftValue is int) { | 1179 } else if (leftValue is int) { |
| 1180 if (_value is int) { | 1180 if (_value is int) { |
| 1181 return valueOf2(((leftValue as int)).compareTo((_value as int)) <= 0); | 1181 return valueOf2(((leftValue as int)).compareTo((_value as int)) <= 0); |
| 1182 } else if (_value is double) { | 1182 } else if (_value is double) { |
| 1183 return valueOf2(((leftValue as int)).toDouble() <= ((_value as double)))
; | 1183 return valueOf2(((leftValue as int)).toDouble() <= ((_value as double)))
; |
| 1184 } | 1184 } |
| 1185 } else if (leftValue is double) { | 1185 } else if (leftValue is double) { |
| 1186 if (_value is int) { | 1186 if (_value is int) { |
| 1187 return valueOf2(((leftValue as double)) <= ((_value as int)).toDouble())
; | 1187 return valueOf2(((leftValue as double)) <= ((_value as int)).toDouble())
; |
| 1188 } else if (_value is double) { | 1188 } else if (_value is double) { |
| 1189 return valueOf2(((leftValue as double)) <= ((_value as double))); | 1189 return valueOf2(((leftValue as double)) <= ((_value as double))); |
| 1190 } | 1190 } |
| 1191 } | 1191 } |
| 1192 return error(node); | 1192 return error(node); |
| 1193 } | 1193 } |
| 1194 EvaluationResultImpl lessThanValid(BinaryExpression node, ValidResult leftOper
and12) { | 1194 EvaluationResultImpl lessThanValid(BinaryExpression node, ValidResult leftOper
and2) { |
| 1195 Object leftValue = leftOperand12.value; | 1195 Object leftValue = leftOperand2.value; |
| 1196 if (leftValue == null) { | 1196 if (leftValue == null) { |
| 1197 return error(node.leftOperand); | 1197 return error(node.leftOperand); |
| 1198 } else if (_value == null) { | 1198 } else if (_value == null) { |
| 1199 return error(node.rightOperand); | 1199 return error(node.rightOperand); |
| 1200 } else if (leftValue is int) { | 1200 } else if (leftValue is int) { |
| 1201 if (_value is int) { | 1201 if (_value is int) { |
| 1202 return valueOf2(((leftValue as int)).compareTo((_value as int)) < 0); | 1202 return valueOf2(((leftValue as int)).compareTo((_value as int)) < 0); |
| 1203 } else if (_value is double) { | 1203 } else if (_value is double) { |
| 1204 return valueOf2(((leftValue as int)).toDouble() < ((_value as double))); | 1204 return valueOf2(((leftValue as int)).toDouble() < ((_value as double))); |
| 1205 } | 1205 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1222 } | 1222 } |
| 1223 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1223 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1224 EvaluationResultImpl logicalOrValid(BinaryExpression node, ValidResult leftOpe
rand) { | 1224 EvaluationResultImpl logicalOrValid(BinaryExpression node, ValidResult leftOpe
rand) { |
| 1225 Object leftValue = leftOperand.value; | 1225 Object leftValue = leftOperand.value; |
| 1226 if (leftValue is bool && ((leftValue as bool))) { | 1226 if (leftValue is bool && ((leftValue as bool))) { |
| 1227 return RESULT_TRUE; | 1227 return RESULT_TRUE; |
| 1228 } | 1228 } |
| 1229 return booleanConversion(node.rightOperand, _value); | 1229 return booleanConversion(node.rightOperand, _value); |
| 1230 } | 1230 } |
| 1231 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1231 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1232 EvaluationResultImpl minusValid(BinaryExpression node, ValidResult leftOperand
13) { | 1232 EvaluationResultImpl minusValid(BinaryExpression node, ValidResult leftOperand
2) { |
| 1233 Object leftValue = leftOperand13.value; | 1233 Object leftValue = leftOperand2.value; |
| 1234 if (leftValue == null) { | 1234 if (leftValue == null) { |
| 1235 return error(node.leftOperand); | 1235 return error(node.leftOperand); |
| 1236 } else if (_value == null) { | 1236 } else if (_value == null) { |
| 1237 return error(node.rightOperand); | 1237 return error(node.rightOperand); |
| 1238 } else if (leftValue is int) { | 1238 } else if (leftValue is int) { |
| 1239 if (_value is int) { | 1239 if (_value is int) { |
| 1240 return valueOf(((leftValue as int)) - (_value as int)); | 1240 return valueOf(((leftValue as int)) - (_value as int)); |
| 1241 } else if (_value is double) { | 1241 } else if (_value is double) { |
| 1242 return valueOf3(((leftValue as int)).toDouble() - ((_value as double))); | 1242 return valueOf3(((leftValue as int)).toDouble() - ((_value as double))); |
| 1243 } | 1243 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 return RESULT_TRUE; | 1276 return RESULT_TRUE; |
| 1277 } else if (leftValue is String) { | 1277 } else if (leftValue is String) { |
| 1278 if (_value is String) { | 1278 if (_value is String) { |
| 1279 return valueOf2(((leftValue as String)) != _value); | 1279 return valueOf2(((leftValue as String)) != _value); |
| 1280 } | 1280 } |
| 1281 return RESULT_TRUE; | 1281 return RESULT_TRUE; |
| 1282 } | 1282 } |
| 1283 return RESULT_TRUE; | 1283 return RESULT_TRUE; |
| 1284 } | 1284 } |
| 1285 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1285 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1286 EvaluationResultImpl remainderValid(BinaryExpression node, ValidResult leftOpe
rand14) { | 1286 EvaluationResultImpl remainderValid(BinaryExpression node, ValidResult leftOpe
rand2) { |
| 1287 Object leftValue = leftOperand14.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) { |
| 1293 if (_value is int) { | 1293 if (_value is int) { |
| 1294 if (((_value as int)) == 0) { | 1294 if (((_value as int)) == 0) { |
| 1295 return valueOf3(((leftValue as int)).toDouble() % ((_value as int)).to
Double()); | 1295 return valueOf3(((leftValue as int)).toDouble() % ((_value as int)).to
Double()); |
| 1296 } | 1296 } |
| 1297 return valueOf(((leftValue as int)).remainder((_value as int))); | 1297 return valueOf(((leftValue as int)).remainder((_value as int))); |
| 1298 } else if (_value is double) { | 1298 } else if (_value is double) { |
| 1299 return valueOf3(((leftValue as int)).toDouble() % ((_value as double))); | 1299 return valueOf3(((leftValue as int)).toDouble() % ((_value as double))); |
| 1300 } | 1300 } |
| 1301 } else if (leftValue is double) { | 1301 } else if (leftValue is double) { |
| 1302 if (_value is int) { | 1302 if (_value is int) { |
| 1303 return valueOf3(((leftValue as double)) % ((_value as int)).toDouble()); | 1303 return valueOf3(((leftValue as double)) % ((_value as int)).toDouble()); |
| 1304 } else if (_value is double) { | 1304 } else if (_value is double) { |
| 1305 return valueOf3(((leftValue as double)) % ((_value as double))); | 1305 return valueOf3(((leftValue as double)) % ((_value as double))); |
| 1306 } | 1306 } |
| 1307 } | 1307 } |
| 1308 return error(node); | 1308 return error(node); |
| 1309 } | 1309 } |
| 1310 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1310 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
| 1311 EvaluationResultImpl shiftLeftValid(BinaryExpression node, ValidResult leftOpe
rand15) { | 1311 EvaluationResultImpl shiftLeftValid(BinaryExpression node, ValidResult leftOpe
rand2) { |
| 1312 Object leftValue = leftOperand15.value; | 1312 Object leftValue = leftOperand2.value; |
| 1313 if (leftValue == null) { | 1313 if (leftValue == null) { |
| 1314 return error(node.leftOperand); | 1314 return error(node.leftOperand); |
| 1315 } else if (_value == null) { | 1315 } else if (_value == null) { |
| 1316 return error(node.rightOperand); | 1316 return error(node.rightOperand); |
| 1317 } else if (leftValue is int) { | 1317 } else if (leftValue is int) { |
| 1318 if (_value is int) { | 1318 if (_value is int) { |
| 1319 return valueOf(((leftValue as int)) << ((_value as int))); | 1319 return valueOf(((leftValue as int)) << ((_value as int))); |
| 1320 } | 1320 } |
| 1321 return error(node.rightOperand); | 1321 return error(node.rightOperand); |
| 1322 } | 1322 } |
| 1323 if (_value is int) { | 1323 if (_value is int) { |
| 1324 return error(node.leftOperand); | 1324 return error(node.leftOperand); |
| 1325 } | 1325 } |
| 1326 return union(error(node.leftOperand), error(node.rightOperand)); | 1326 return union(error(node.leftOperand), error(node.rightOperand)); |
| 1327 } | 1327 } |
| 1328 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; | 1328 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; |
| 1329 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp
erand16) { | 1329 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp
erand2) { |
| 1330 Object leftValue = leftOperand16.value; | 1330 Object leftValue = leftOperand2.value; |
| 1331 if (leftValue == null) { | 1331 if (leftValue == null) { |
| 1332 return error(node.leftOperand); | 1332 return error(node.leftOperand); |
| 1333 } else if (_value == null) { | 1333 } else if (_value == null) { |
| 1334 return error(node.rightOperand); | 1334 return error(node.rightOperand); |
| 1335 } else if (leftValue is int) { | 1335 } else if (leftValue is int) { |
| 1336 if (_value is int) { | 1336 if (_value is int) { |
| 1337 return valueOf(((leftValue as int)) >> ((_value as int))); | 1337 return valueOf(((leftValue as int)) >> ((_value as int))); |
| 1338 } | 1338 } |
| 1339 return error(node.rightOperand); | 1339 return error(node.rightOperand); |
| 1340 } | 1340 } |
| 1341 if (_value is int) { | 1341 if (_value is int) { |
| 1342 return error(node.leftOperand); | 1342 return error(node.leftOperand); |
| 1343 } | 1343 } |
| 1344 return union(error(node.leftOperand), error(node.rightOperand)); | 1344 return union(error(node.leftOperand), error(node.rightOperand)); |
| 1345 } | 1345 } |
| 1346 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1346 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
| 1347 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand
17) { | 1347 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand
2) { |
| 1348 Object leftValue = leftOperand17.value; | 1348 Object leftValue = leftOperand2.value; |
| 1349 if (leftValue == null) { | 1349 if (leftValue == null) { |
| 1350 return error(node.leftOperand); | 1350 return error(node.leftOperand); |
| 1351 } else if (_value == null) { | 1351 } else if (_value == null) { |
| 1352 return error(node.rightOperand); | 1352 return error(node.rightOperand); |
| 1353 } else if (leftValue is int) { | 1353 } else if (leftValue is int) { |
| 1354 if (_value is int) { | 1354 if (_value is int) { |
| 1355 return valueOf(((leftValue as int)) * (_value as int)); | 1355 return valueOf(((leftValue as int)) * (_value as int)); |
| 1356 } else if (_value is double) { | 1356 } else if (_value is double) { |
| 1357 return valueOf3(((leftValue as int)).toDouble() * ((_value as double))); | 1357 return valueOf3(((leftValue as int)).toDouble() * ((_value as double))); |
| 1358 } | 1358 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 * @return a result object representing the given value | 1413 * @return a result object representing the given value |
| 1414 */ | 1414 */ |
| 1415 ValidResult valueOf3(double value) => new ValidResult(value); | 1415 ValidResult valueOf3(double value) => new ValidResult(value); |
| 1416 /** | 1416 /** |
| 1417 * Return a result object representing the given value. | 1417 * Return a result object representing the given value. |
| 1418 * @param value the value to be represented as a result object | 1418 * @param value the value to be represented as a result object |
| 1419 * @return a result object representing the given value | 1419 * @return a result object representing the given value |
| 1420 */ | 1420 */ |
| 1421 ValidResult valueOf4(String value) => new ValidResult(value); | 1421 ValidResult valueOf4(String value) => new ValidResult(value); |
| 1422 } | 1422 } |
| OLD | NEW |