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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 * compile-time constant that evaluates to the given value. | 95 * compile-time constant that evaluates to the given value. |
96 * | 96 * |
97 * @param value the value of the expression | 97 * @param value the value of the expression |
98 * @return the result of evaluating an expression that is a compile-time const
ant | 98 * @return the result of evaluating an expression that is a compile-time const
ant |
99 */ | 99 */ |
100 static EvaluationResult forValue(Object value) => new EvaluationResult(value,
null); | 100 static EvaluationResult forValue(Object value) => new EvaluationResult(value,
null); |
101 | 101 |
102 /** | 102 /** |
103 * The value of the expression. | 103 * The value of the expression. |
104 */ | 104 */ |
105 Object _value; | 105 Object value; |
106 | 106 |
107 /** | 107 /** |
108 * The errors that should be reported for the expression(s) that were evaluate
d. | 108 * The errors that should be reported for the expression(s) that were evaluate
d. |
109 */ | 109 */ |
110 List<AnalysisError> _errors; | 110 List<AnalysisError> _errors; |
111 | 111 |
112 /** | 112 /** |
113 * Initialize a newly created result object with the given state. Clients shou
ld use one of the | 113 * Initialize a newly created result object with the given state. Clients shou
ld use one of the |
114 * factory methods: [forErrors] and [forValue]. | 114 * factory methods: [forErrors] and [forValue]. |
115 * | 115 * |
116 * @param value the value of the expression | 116 * @param value the value of the expression |
117 * @param errors the errors that should be reported for the expression(s) that
were evaluated | 117 * @param errors the errors that should be reported for the expression(s) that
were evaluated |
118 */ | 118 */ |
119 EvaluationResult(Object value, List<AnalysisError> errors) { | 119 EvaluationResult(Object value, List<AnalysisError> errors) { |
120 this._value = value; | 120 this.value = value; |
121 this._errors = errors; | 121 this._errors = errors; |
122 } | 122 } |
123 | 123 |
124 /** | 124 /** |
125 * Return an array containing the errors that should be reported for the expre
ssion(s) that were | 125 * Return an array containing the errors that should be reported for the expre
ssion(s) that were |
126 * evaluated. If there are no such errors, the array will be empty. The array
can be empty even if | 126 * evaluated. If there are no such errors, the array will be empty. The array
can be empty even if |
127 * the expression is not a valid compile time constant if the errors would hav
e been reported by | 127 * the expression is not a valid compile time constant if the errors would hav
e been reported by |
128 * other parts of the analysis engine. | 128 * other parts of the analysis engine. |
129 */ | 129 */ |
130 List<AnalysisError> get errors => _errors == null ? AnalysisError.NO_ERRORS :
_errors; | 130 List<AnalysisError> get errors => _errors == null ? AnalysisError.NO_ERRORS :
_errors; |
131 | 131 |
132 /** | 132 /** |
133 * Return the value of the expression, or `null` if the expression evaluated t
o `null` | |
134 * or if the expression could not be evaluated, either because it was not a co
mpile-time constant | |
135 * expression or because it would throw an exception when evaluated. | |
136 * | |
137 * @return the value of the expression | |
138 */ | |
139 Object get value => _value; | |
140 | |
141 /** | |
142 * Return `true` if the expression is a compile-time constant expression that
would not | 133 * Return `true` if the expression is a compile-time constant expression that
would not |
143 * throw an exception when evaluated. | 134 * throw an exception when evaluated. |
144 * | 135 * |
145 * @return `true` if the expression is a valid compile-time constant expressio
n | 136 * @return `true` if the expression is a valid compile-time constant expressio
n |
146 */ | 137 */ |
147 bool get isValid => _errors == null; | 138 bool get isValid => _errors == null; |
148 } | 139 } |
149 /** | 140 /** |
150 * Instances of the class `ConstantFinder` are used to traverse the AST structur
es of all of | 141 * Instances of the class `ConstantFinder` are used to traverse the AST structur
es of all of |
151 * the compilation units being resolved and build a table mapping constant varia
ble elements to the | 142 * the compilation units being resolved and build a table mapping constant varia
ble elements to the |
152 * declarations of those variables. | 143 * declarations of those variables. |
153 */ | 144 */ |
154 class ConstantFinder extends RecursiveASTVisitor<Object> { | 145 class ConstantFinder extends RecursiveASTVisitor<Object> { |
155 | 146 |
156 /** | 147 /** |
157 * A table mapping constant variable elements to the declarations of those var
iables. | 148 * A table mapping constant variable elements to the declarations of those var
iables. |
158 */ | 149 */ |
159 Map<VariableElement, VariableDeclaration> _variableMap = new Map<VariableEleme
nt, VariableDeclaration>(); | 150 final Map<VariableElement, VariableDeclaration> variableMap = new Map<Variable
Element, VariableDeclaration>(); |
160 | |
161 /** | |
162 * Return a table mapping constant variable elements to the declarations of th
ose variables. | |
163 * | |
164 * @return a table mapping constant variable elements to the declarations of t
hose variables | |
165 */ | |
166 Map<VariableElement, VariableDeclaration> get variableMap => _variableMap; | |
167 Object visitVariableDeclaration(VariableDeclaration node) { | 151 Object visitVariableDeclaration(VariableDeclaration node) { |
168 super.visitVariableDeclaration(node); | 152 super.visitVariableDeclaration(node); |
169 Expression initializer = node.initializer; | 153 Expression initializer = node.initializer; |
170 if (initializer != null && node.isConst) { | 154 if (initializer != null && node.isConst) { |
171 VariableElement element = node.element; | 155 VariableElement element = node.element; |
172 if (element != null) { | 156 if (element != null) { |
173 _variableMap[element] = node; | 157 variableMap[element] = node; |
174 } | 158 } |
175 } | 159 } |
176 return null; | 160 return null; |
177 } | 161 } |
178 } | 162 } |
179 /** | 163 /** |
180 * 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 |
181 * one or more compilation units. The expected usage pattern is for the compilat
ion units to be | 165 * one or more compilation units. The expected usage pattern is for the compilat
ion units to be |
182 * added to this computer using the method [add] and then for the method | 166 * added to this computer using the method [add] and then for the method |
183 * [computeValues] to invoked exactly once. Any use of an instance after invokin
g the | 167 * [computeValues] to invoked exactly once. Any use of an instance after invokin
g the |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 } | 687 } |
704 /** | 688 /** |
705 * Instances of the class `ErrorResult` represent the result of evaluating an ex
pression that | 689 * Instances of the class `ErrorResult` represent the result of evaluating an ex
pression that |
706 * is not a valid compile time constant. | 690 * is not a valid compile time constant. |
707 */ | 691 */ |
708 class ErrorResult extends EvaluationResultImpl { | 692 class ErrorResult extends EvaluationResultImpl { |
709 | 693 |
710 /** | 694 /** |
711 * The errors that prevent the expression from being a valid compile time cons
tant. | 695 * The errors that prevent the expression from being a valid compile time cons
tant. |
712 */ | 696 */ |
713 List<ErrorResult_ErrorData> _errors = new List<ErrorResult_ErrorData>(); | 697 final List<ErrorResult_ErrorData> errorData = new List<ErrorResult_ErrorData>(
); |
714 | 698 |
715 /** | 699 /** |
716 * Initialize a newly created result representing the error with the given cod
e reported against | 700 * Initialize a newly created result representing the error with the given cod
e reported against |
717 * the given node. | 701 * the given node. |
718 * | 702 * |
719 * @param node the node against which the error should be reported | 703 * @param node the node against which the error should be reported |
720 * @param errorCode the error code for the error to be generated | 704 * @param errorCode the error code for the error to be generated |
721 */ | 705 */ |
722 ErrorResult.con1(ASTNode node, ErrorCode errorCode) { | 706 ErrorResult.con1(ASTNode node, ErrorCode errorCode) { |
723 _errors.add(new ErrorResult_ErrorData(node, errorCode)); | 707 errorData.add(new ErrorResult_ErrorData(node, errorCode)); |
724 } | 708 } |
725 | 709 |
726 /** | 710 /** |
727 * Initialize a newly created result to represent the union of the errors in t
he given result | 711 * Initialize a newly created result to represent the union of the errors in t
he given result |
728 * objects. | 712 * objects. |
729 * | 713 * |
730 * @param firstResult the first set of results being merged | 714 * @param firstResult the first set of results being merged |
731 * @param secondResult the second set of results being merged | 715 * @param secondResult the second set of results being merged |
732 */ | 716 */ |
733 ErrorResult.con2(ErrorResult firstResult, ErrorResult secondResult) { | 717 ErrorResult.con2(ErrorResult firstResult, ErrorResult secondResult) { |
734 _errors.addAll(firstResult._errors); | 718 errorData.addAll(firstResult.errorData); |
735 _errors.addAll(secondResult._errors); | 719 errorData.addAll(secondResult.errorData); |
736 } | 720 } |
737 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper
and) => rightOperand.addToError(node, this); | 721 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper
and) => rightOperand.addToError(node, this); |
738 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitAndError(node, this); | 722 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitAndError(node, this); |
739 EvaluationResultImpl bitNot(Expression node) => this; | 723 EvaluationResultImpl bitNot(Expression node) => this; |
740 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.bitOrError(node, this); | 724 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.bitOrError(node, this); |
741 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitXorError(node, this); | 725 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitXorError(node, this); |
742 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp
erand) => rightOperand.concatenateError(node, this); | 726 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp
erand) => rightOperand.concatenateError(node, this); |
743 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.divideError(node, this); | 727 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.divideError(node, this); |
744 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe
rand) => rightOperand.equalEqualError(node, this); | 728 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe
rand) => rightOperand.equalEqualError(node, this); |
745 bool equalValues(EvaluationResultImpl result) => false; | 729 bool equalValues(EvaluationResultImpl result) => false; |
746 List<ErrorResult_ErrorData> get errorData => _errors; | |
747 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r
ightOperand) => rightOperand.greaterThanError(node, this); | 730 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r
ightOperand) => rightOperand.greaterThanError(node, this); |
748 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul
tImpl rightOperand) => rightOperand.greaterThanOrEqualError(node, this); | 731 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul
tImpl rightOperand) => rightOperand.greaterThanOrEqualError(node, this); |
749 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl
rightOperand) => rightOperand.integerDivideError(node, this); | 732 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl
rightOperand) => rightOperand.integerDivideError(node, this); |
750 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef
tOperand) => this; | 733 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef
tOperand) => this; |
751 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ
tOperand) => rightOperand.lessThanError(node, this); | 734 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ
tOperand) => rightOperand.lessThanError(node, this); |
752 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm
pl rightOperand) => rightOperand.lessThanOrEqualError(node, this); | 735 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm
pl rightOperand) => rightOperand.lessThanOrEqualError(node, this); |
753 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.logicalAndError(node, this); | 736 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.logicalAndError(node, this); |
754 EvaluationResultImpl logicalNot(Expression node) => this; | 737 EvaluationResultImpl logicalNot(Expression node) => this; |
755 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.logicalOrError(node, this); | 738 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.logicalOrError(node, this); |
756 EvaluationResultImpl minus(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.minusError(node, this); | 739 EvaluationResultImpl minus(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.minusError(node, this); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => new ErrorResult.con2(this, leftOperand); | 782 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => new ErrorResult.con2(this, leftOperand); |
800 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp
erand) => this; | 783 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp
erand) => this; |
801 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); | 784 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => new ErrorResult.con2(this, leftOperand); |
802 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand
) => this; | 785 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand
) => this; |
803 } | 786 } |
804 class ErrorResult_ErrorData { | 787 class ErrorResult_ErrorData { |
805 | 788 |
806 /** | 789 /** |
807 * The node against which the error should be reported. | 790 * The node against which the error should be reported. |
808 */ | 791 */ |
809 ASTNode _node; | 792 ASTNode node; |
810 | 793 |
811 /** | 794 /** |
812 * The error code for the error to be generated. | 795 * The error code for the error to be generated. |
813 */ | 796 */ |
814 ErrorCode _errorCode; | 797 ErrorCode errorCode; |
815 | 798 |
816 /** | 799 /** |
817 * Initialize a newly created data holder to represent the error with the give
n code reported | 800 * Initialize a newly created data holder to represent the error with the give
n code reported |
818 * against the given node. | 801 * against the given node. |
819 * | 802 * |
820 * @param node the node against which the error should be reported | 803 * @param node the node against which the error should be reported |
821 * @param errorCode the error code for the error to be generated | 804 * @param errorCode the error code for the error to be generated |
822 */ | 805 */ |
823 ErrorResult_ErrorData(ASTNode node, ErrorCode errorCode) { | 806 ErrorResult_ErrorData(ASTNode node, ErrorCode errorCode) { |
824 this._node = node; | 807 this.node = node; |
825 this._errorCode = errorCode; | 808 this.errorCode = errorCode; |
826 } | 809 } |
827 | |
828 /** | |
829 * Return the error code for the error to be generated. | |
830 * | |
831 * @return the error code for the error to be generated | |
832 */ | |
833 ErrorCode get errorCode => _errorCode; | |
834 | |
835 /** | |
836 * Return the node against which the error should be reported. | |
837 * | |
838 * @return the node against which the error should be reported | |
839 */ | |
840 ASTNode get node => _node; | |
841 } | 810 } |
842 /** | 811 /** |
843 * Instances of the class `InternalResult` represent the result of attempting to
evaluate a | 812 * Instances of the class `InternalResult` represent the result of attempting to
evaluate a |
844 * expression. | 813 * expression. |
845 */ | 814 */ |
846 abstract class EvaluationResultImpl { | 815 abstract class EvaluationResultImpl { |
847 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper
and); | 816 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper
and); |
848 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO
perand); | 817 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO
perand); |
849 EvaluationResultImpl bitNot(Expression node); | 818 EvaluationResultImpl bitNot(Expression node); |
850 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp
erand); | 819 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp
erand); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 static ValidResult RESULT_STRING = new ValidResult("<string>"); | 975 static ValidResult RESULT_STRING = new ValidResult("<string>"); |
1007 | 976 |
1008 /** | 977 /** |
1009 * A result object representing the value 'true'. | 978 * A result object representing the value 'true'. |
1010 */ | 979 */ |
1011 static ValidResult RESULT_TRUE = new ValidResult(true); | 980 static ValidResult RESULT_TRUE = new ValidResult(true); |
1012 | 981 |
1013 /** | 982 /** |
1014 * The value of the expression. | 983 * The value of the expression. |
1015 */ | 984 */ |
1016 Object _value; | 985 Object value; |
1017 | 986 |
1018 /** | 987 /** |
1019 * Initialize a newly created result to represent the given value. | 988 * Initialize a newly created result to represent the given value. |
1020 * | 989 * |
1021 * @param value the value of the expression | 990 * @param value the value of the expression |
1022 */ | 991 */ |
1023 ValidResult(Object value) { | 992 ValidResult(Object value) { |
1024 this._value = value; | 993 this.value = value; |
1025 } | 994 } |
1026 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper
and) => rightOperand.addToValid(node, this); | 995 EvaluationResultImpl add(BinaryExpression node, EvaluationResultImpl rightOper
and) => rightOperand.addToValid(node, this); |
1027 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitAndValid(node, this); | 996 EvaluationResultImpl bitAnd(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitAndValid(node, this); |
1028 EvaluationResultImpl bitNot(Expression node) { | 997 EvaluationResultImpl bitNot(Expression node) { |
1029 if (isSomeInt) { | 998 if (isSomeInt) { |
1030 return RESULT_INT; | 999 return RESULT_INT; |
1031 } | 1000 } |
1032 if (_value == null) { | 1001 if (value == null) { |
1033 return error(node); | 1002 return error(node); |
1034 } else if (_value is int) { | 1003 } else if (value is int) { |
1035 return valueOf(~((_value as int))); | 1004 return valueOf(~((value as int))); |
1036 } | 1005 } |
1037 return error(node); | 1006 return error(node); |
1038 } | 1007 } |
1039 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.bitOrValid(node, this); | 1008 EvaluationResultImpl bitOr(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.bitOrValid(node, this); |
1040 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitXorValid(node, this); | 1009 EvaluationResultImpl bitXor(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.bitXorValid(node, this); |
1041 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp
erand) => rightOperand.concatenateValid(node, this); | 1010 EvaluationResultImpl concatenate(Expression node, EvaluationResultImpl rightOp
erand) => rightOperand.concatenateValid(node, this); |
1042 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.divideValid(node, this); | 1011 EvaluationResultImpl divide(BinaryExpression node, EvaluationResultImpl rightO
perand) => rightOperand.divideValid(node, this); |
1043 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe
rand) => rightOperand.equalEqualValid(node, this); | 1012 EvaluationResultImpl equalEqual(Expression node, EvaluationResultImpl rightOpe
rand) => rightOperand.equalEqualValid(node, this); |
1044 bool equalValues(EvaluationResultImpl result) => identical(equalEqual(null, re
sult), RESULT_TRUE); | 1013 bool equalValues(EvaluationResultImpl result) => identical(equalEqual(null, re
sult), RESULT_TRUE); |
1045 Object get value => _value; | |
1046 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r
ightOperand) => rightOperand.greaterThanValid(node, this); | 1014 EvaluationResultImpl greaterThan(BinaryExpression node, EvaluationResultImpl r
ightOperand) => rightOperand.greaterThanValid(node, this); |
1047 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul
tImpl rightOperand) => rightOperand.greaterThanOrEqualValid(node, this); | 1015 EvaluationResultImpl greaterThanOrEqual(BinaryExpression node, EvaluationResul
tImpl rightOperand) => rightOperand.greaterThanOrEqualValid(node, this); |
1048 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl
rightOperand) => rightOperand.integerDivideValid(node, this); | 1016 EvaluationResultImpl integerDivide(BinaryExpression node, EvaluationResultImpl
rightOperand) => rightOperand.integerDivideValid(node, this); |
1049 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ
tOperand) => rightOperand.lessThanValid(node, this); | 1017 EvaluationResultImpl lessThan(BinaryExpression node, EvaluationResultImpl righ
tOperand) => rightOperand.lessThanValid(node, this); |
1050 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm
pl rightOperand) => rightOperand.lessThanOrEqualValid(node, this); | 1018 EvaluationResultImpl lessThanOrEqual(BinaryExpression node, EvaluationResultIm
pl rightOperand) => rightOperand.lessThanOrEqualValid(node, this); |
1051 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.logicalAndValid(node, this); | 1019 EvaluationResultImpl logicalAnd(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.logicalAndValid(node, this); |
1052 EvaluationResultImpl logicalNot(Expression node) { | 1020 EvaluationResultImpl logicalNot(Expression node) { |
1053 if (isSomeBool) { | 1021 if (isSomeBool) { |
1054 return RESULT_BOOL; | 1022 return RESULT_BOOL; |
1055 } | 1023 } |
1056 if (_value == null) { | 1024 if (value == null) { |
1057 return RESULT_TRUE; | 1025 return RESULT_TRUE; |
1058 } else if (_value is bool) { | 1026 } else if (value is bool) { |
1059 return ((_value as bool)) ? RESULT_FALSE : RESULT_TRUE; | 1027 return ((value as bool)) ? RESULT_FALSE : RESULT_TRUE; |
1060 } | 1028 } |
1061 return error(node); | 1029 return error(node); |
1062 } | 1030 } |
1063 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.logicalOrValid(node, this); | 1031 EvaluationResultImpl logicalOr(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.logicalOrValid(node, this); |
1064 EvaluationResultImpl minus(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.minusValid(node, this); | 1032 EvaluationResultImpl minus(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.minusValid(node, this); |
1065 EvaluationResultImpl negated(Expression node) { | 1033 EvaluationResultImpl negated(Expression node) { |
1066 if (isSomeNum) { | 1034 if (isSomeNum) { |
1067 return RESULT_INT; | 1035 return RESULT_INT; |
1068 } | 1036 } |
1069 if (_value == null) { | 1037 if (value == null) { |
1070 return error(node); | 1038 return error(node); |
1071 } else if (_value is int) { | 1039 } else if (value is int) { |
1072 return valueOf(-((_value as int))); | 1040 return valueOf(-((value as int))); |
1073 } else if (_value is double) { | 1041 } else if (value is double) { |
1074 return valueOf3(-((_value as double))); | 1042 return valueOf3(-((value as double))); |
1075 } | 1043 } |
1076 return error(node); | 1044 return error(node); |
1077 } | 1045 } |
1078 EvaluationResultImpl notEqual(BinaryExpression node, EvaluationResultImpl righ
tOperand) => rightOperand.notEqualValid(node, this); | 1046 EvaluationResultImpl notEqual(BinaryExpression node, EvaluationResultImpl righ
tOperand) => rightOperand.notEqualValid(node, this); |
1079 EvaluationResultImpl performToString(ASTNode node) { | 1047 EvaluationResultImpl performToString(ASTNode node) { |
1080 if (_value == null) { | 1048 if (value == null) { |
1081 return valueOf4("null"); | 1049 return valueOf4("null"); |
1082 } else if (_value is bool) { | 1050 } else if (value is bool) { |
1083 return valueOf4(((_value as bool)).toString()); | 1051 return valueOf4(((value as bool)).toString()); |
1084 } else if (_value is int) { | 1052 } else if (value is int) { |
1085 return valueOf4(((_value as int)).toString()); | 1053 return valueOf4(((value as int)).toString()); |
1086 } else if (_value is double) { | 1054 } else if (value is double) { |
1087 return valueOf4(((_value as double)).toString()); | 1055 return valueOf4(((value as double)).toString()); |
1088 } else if (_value is String) { | 1056 } else if (value is String) { |
1089 return this; | 1057 return this; |
1090 } | 1058 } |
1091 return error(node); | 1059 return error(node); |
1092 } | 1060 } |
1093 EvaluationResultImpl remainder(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.remainderValid(node, this); | 1061 EvaluationResultImpl remainder(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.remainderValid(node, this); |
1094 EvaluationResultImpl shiftLeft(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.shiftLeftValid(node, this); | 1062 EvaluationResultImpl shiftLeft(BinaryExpression node, EvaluationResultImpl rig
htOperand) => rightOperand.shiftLeftValid(node, this); |
1095 EvaluationResultImpl shiftRight(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.shiftRightValid(node, this); | 1063 EvaluationResultImpl shiftRight(BinaryExpression node, EvaluationResultImpl ri
ghtOperand) => rightOperand.shiftRightValid(node, this); |
1096 EvaluationResultImpl times(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.timesValid(node, this); | 1064 EvaluationResultImpl times(BinaryExpression node, EvaluationResultImpl rightOp
erand) => rightOperand.timesValid(node, this); |
1097 String toString() { | 1065 String toString() { |
1098 if (_value == null) { | 1066 if (value == null) { |
1099 return "null"; | 1067 return "null"; |
1100 } | 1068 } |
1101 return _value.toString(); | 1069 return value.toString(); |
1102 } | 1070 } |
1103 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1071 EvaluationResultImpl addToError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
1104 EvaluationResultImpl addToValid(BinaryExpression node, ValidResult leftOperand
2) { | 1072 EvaluationResultImpl addToValid(BinaryExpression node, ValidResult leftOperand
2) { |
1105 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1073 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1106 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1074 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1107 } | 1075 } |
1108 if (isSomeInt || leftOperand2.isSomeInt) { | 1076 if (isSomeInt || leftOperand2.isSomeInt) { |
1109 return RESULT_INT; | 1077 return RESULT_INT; |
1110 } else if (isSomeNum || leftOperand2.isSomeNum) { | 1078 } else if (isSomeNum || leftOperand2.isSomeNum) { |
1111 return RESULT_NUM; | 1079 return RESULT_NUM; |
1112 } | 1080 } |
1113 Object leftValue = leftOperand2.value; | 1081 Object leftValue = leftOperand2.value; |
1114 if (leftValue == null) { | 1082 if (leftValue == null) { |
1115 return error(node.leftOperand); | 1083 return error(node.leftOperand); |
1116 } else if (_value == null) { | 1084 } else if (value == null) { |
1117 return error(node.rightOperand); | 1085 return error(node.rightOperand); |
1118 } else if (leftValue is int) { | 1086 } else if (leftValue is int) { |
1119 if (_value is int) { | 1087 if (value is int) { |
1120 return valueOf(((leftValue as int)) + (_value as int)); | 1088 return valueOf(((leftValue as int)) + (value as int)); |
1121 } else if (_value is double) { | 1089 } else if (value is double) { |
1122 return valueOf3(((leftValue as int)).toDouble() + ((_value as double))); | 1090 return valueOf3(((leftValue as int)).toDouble() + ((value as double))); |
1123 } | 1091 } |
1124 } else if (leftValue is double) { | 1092 } else if (leftValue is double) { |
1125 if (_value is int) { | 1093 if (value is int) { |
1126 return valueOf3(((leftValue as double)) + ((_value as int)).toDouble()); | 1094 return valueOf3(((leftValue as double)) + ((value as int)).toDouble()); |
1127 } else if (_value is double) { | 1095 } else if (value is double) { |
1128 return valueOf3(((leftValue as double)) + ((_value as double))); | 1096 return valueOf3(((leftValue as double)) + ((value as double))); |
1129 } | 1097 } |
1130 } else if (leftValue is String) { | 1098 } else if (leftValue is String) { |
1131 if (_value is String) { | 1099 if (value is String) { |
1132 return valueOf4("${((leftValue as String))}${((_value as String))}"); | 1100 return valueOf4("${((leftValue as String))}${((value as String))}"); |
1133 } | 1101 } |
1134 } | 1102 } |
1135 return error(node); | 1103 return error(node); |
1136 } | 1104 } |
1137 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1105 EvaluationResultImpl bitAndError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
1138 EvaluationResultImpl bitAndValid(BinaryExpression node, ValidResult leftOperan
d2) { | 1106 EvaluationResultImpl bitAndValid(BinaryExpression node, ValidResult leftOperan
d2) { |
1139 if (!isAnyInt || !leftOperand2.isAnyInt) { | 1107 if (!isAnyInt || !leftOperand2.isAnyInt) { |
1140 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1108 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
1141 } | 1109 } |
1142 if (isSomeInt || leftOperand2.isSomeInt) { | 1110 if (isSomeInt || leftOperand2.isSomeInt) { |
1143 return RESULT_INT; | 1111 return RESULT_INT; |
1144 } | 1112 } |
1145 Object leftValue = leftOperand2.value; | 1113 Object leftValue = leftOperand2.value; |
1146 if (leftValue == null) { | 1114 if (leftValue == null) { |
1147 return error(node.leftOperand); | 1115 return error(node.leftOperand); |
1148 } else if (_value == null) { | 1116 } else if (value == null) { |
1149 return error(node.rightOperand); | 1117 return error(node.rightOperand); |
1150 } else if (leftValue is int) { | 1118 } else if (leftValue is int) { |
1151 if (_value is int) { | 1119 if (value is int) { |
1152 return valueOf(((leftValue as int)) & (_value as int)); | 1120 return valueOf(((leftValue as int)) & (value as int)); |
1153 } | 1121 } |
1154 return error(node.leftOperand); | 1122 return error(node.leftOperand); |
1155 } | 1123 } |
1156 if (_value is int) { | 1124 if (value is int) { |
1157 return error(node.rightOperand); | 1125 return error(node.rightOperand); |
1158 } | 1126 } |
1159 return union(error(node.leftOperand), error(node.rightOperand)); | 1127 return union(error(node.leftOperand), error(node.rightOperand)); |
1160 } | 1128 } |
1161 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1129 EvaluationResultImpl bitOrError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
1162 EvaluationResultImpl bitOrValid(BinaryExpression node, ValidResult leftOperand
2) { | 1130 EvaluationResultImpl bitOrValid(BinaryExpression node, ValidResult leftOperand
2) { |
1163 if (!isAnyInt || !leftOperand2.isAnyInt) { | 1131 if (!isAnyInt || !leftOperand2.isAnyInt) { |
1164 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1132 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
1165 } | 1133 } |
1166 if (isSomeInt || leftOperand2.isSomeInt) { | 1134 if (isSomeInt || leftOperand2.isSomeInt) { |
1167 return RESULT_INT; | 1135 return RESULT_INT; |
1168 } | 1136 } |
1169 Object leftValue = leftOperand2.value; | 1137 Object leftValue = leftOperand2.value; |
1170 if (leftValue == null) { | 1138 if (leftValue == null) { |
1171 return error(node.leftOperand); | 1139 return error(node.leftOperand); |
1172 } else if (_value == null) { | 1140 } else if (value == null) { |
1173 return error(node.rightOperand); | 1141 return error(node.rightOperand); |
1174 } else if (leftValue is int) { | 1142 } else if (leftValue is int) { |
1175 if (_value is int) { | 1143 if (value is int) { |
1176 return valueOf(((leftValue as int)) | (_value as int)); | 1144 return valueOf(((leftValue as int)) | (value as int)); |
1177 } | 1145 } |
1178 return error(node.leftOperand); | 1146 return error(node.leftOperand); |
1179 } | 1147 } |
1180 if (_value is int) { | 1148 if (value is int) { |
1181 return error(node.rightOperand); | 1149 return error(node.rightOperand); |
1182 } | 1150 } |
1183 return union(error(node.leftOperand), error(node.rightOperand)); | 1151 return union(error(node.leftOperand), error(node.rightOperand)); |
1184 } | 1152 } |
1185 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1153 EvaluationResultImpl bitXorError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
1186 EvaluationResultImpl bitXorValid(BinaryExpression node, ValidResult leftOperan
d2) { | 1154 EvaluationResultImpl bitXorValid(BinaryExpression node, ValidResult leftOperan
d2) { |
1187 if (!isAnyInt || !leftOperand2.isAnyInt) { | 1155 if (!isAnyInt || !leftOperand2.isAnyInt) { |
1188 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1156 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
1189 } | 1157 } |
1190 if (isSomeInt || leftOperand2.isSomeInt) { | 1158 if (isSomeInt || leftOperand2.isSomeInt) { |
1191 return RESULT_INT; | 1159 return RESULT_INT; |
1192 } | 1160 } |
1193 Object leftValue = leftOperand2.value; | 1161 Object leftValue = leftOperand2.value; |
1194 if (leftValue == null) { | 1162 if (leftValue == null) { |
1195 return error(node.leftOperand); | 1163 return error(node.leftOperand); |
1196 } else if (_value == null) { | 1164 } else if (value == null) { |
1197 return error(node.rightOperand); | 1165 return error(node.rightOperand); |
1198 } else if (leftValue is int) { | 1166 } else if (leftValue is int) { |
1199 if (_value is int) { | 1167 if (value is int) { |
1200 return valueOf(((leftValue as int)) ^ (_value as int)); | 1168 return valueOf(((leftValue as int)) ^ (value as int)); |
1201 } | 1169 } |
1202 return error(node.leftOperand); | 1170 return error(node.leftOperand); |
1203 } | 1171 } |
1204 if (_value is int) { | 1172 if (value is int) { |
1205 return error(node.rightOperand); | 1173 return error(node.rightOperand); |
1206 } | 1174 } |
1207 return union(error(node.leftOperand), error(node.rightOperand)); | 1175 return union(error(node.leftOperand), error(node.rightOperand)); |
1208 } | 1176 } |
1209 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => leftOperand; | 1177 EvaluationResultImpl concatenateError(Expression node, ErrorResult leftOperand
) => leftOperand; |
1210 EvaluationResultImpl concatenateValid(Expression node, ValidResult leftOperand
) { | 1178 EvaluationResultImpl concatenateValid(Expression node, ValidResult leftOperand
) { |
1211 Object leftValue = leftOperand.value; | 1179 Object leftValue = leftOperand.value; |
1212 if (leftValue is String && _value is String) { | 1180 if (leftValue is String && value is String) { |
1213 return valueOf4("${((leftValue as String))}${((_value as String))}"); | 1181 return valueOf4("${((leftValue as String))}${((value as String))}"); |
1214 } | 1182 } |
1215 return error(node); | 1183 return error(node); |
1216 } | 1184 } |
1217 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; | 1185 EvaluationResultImpl divideError(BinaryExpression node, ErrorResult leftOperan
d) => leftOperand; |
1218 EvaluationResultImpl divideValid(BinaryExpression node, ValidResult leftOperan
d2) { | 1186 EvaluationResultImpl divideValid(BinaryExpression node, ValidResult leftOperan
d2) { |
1219 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1187 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1220 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1188 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1221 } | 1189 } |
1222 if (isSomeNum || leftOperand2.isSomeNum) { | 1190 if (isSomeNum || leftOperand2.isSomeNum) { |
1223 return RESULT_NUM; | 1191 return RESULT_NUM; |
1224 } | 1192 } |
1225 Object leftValue = leftOperand2.value; | 1193 Object leftValue = leftOperand2.value; |
1226 if (leftValue == null) { | 1194 if (leftValue == null) { |
1227 return error(node.leftOperand); | 1195 return error(node.leftOperand); |
1228 } else if (_value == null) { | 1196 } else if (value == null) { |
1229 return error(node.rightOperand); | 1197 return error(node.rightOperand); |
1230 } else if (leftValue is int) { | 1198 } else if (leftValue is int) { |
1231 if (_value is int) { | 1199 if (value is int) { |
1232 if (((_value as int)) == 0) { | 1200 if (((value as int)) == 0) { |
1233 return valueOf3(((leftValue as int)).toDouble() / ((_value as int)).to
Double()); | 1201 return valueOf3(((leftValue as int)).toDouble() / ((value as int)).toD
ouble()); |
1234 } | 1202 } |
1235 return valueOf(((leftValue as int)) ~/ (_value as int)); | 1203 return valueOf(((leftValue as int)) ~/ (value as int)); |
1236 } else if (_value is double) { | 1204 } else if (value is double) { |
1237 return valueOf3(((leftValue as int)).toDouble() / ((_value as double))); | 1205 return valueOf3(((leftValue as int)).toDouble() / ((value as double))); |
1238 } | 1206 } |
1239 } else if (leftValue is double) { | 1207 } else if (leftValue is double) { |
1240 if (_value is int) { | 1208 if (value is int) { |
1241 return valueOf3(((leftValue as double)) / ((_value as int)).toDouble()); | 1209 return valueOf3(((leftValue as double)) / ((value as int)).toDouble()); |
1242 } else if (_value is double) { | 1210 } else if (value is double) { |
1243 return valueOf3(((leftValue as double)) / ((_value as double))); | 1211 return valueOf3(((leftValue as double)) / ((value as double))); |
1244 } | 1212 } |
1245 } | 1213 } |
1246 return error(node); | 1214 return error(node); |
1247 } | 1215 } |
1248 EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand)
=> leftOperand; | 1216 EvaluationResultImpl equalEqualError(Expression node, ErrorResult leftOperand)
=> leftOperand; |
1249 EvaluationResultImpl equalEqualValid(Expression node, ValidResult leftOperand)
{ | 1217 EvaluationResultImpl equalEqualValid(Expression node, ValidResult leftOperand)
{ |
1250 if (node is BinaryExpression) { | 1218 if (node is BinaryExpression) { |
1251 if (!isAnyNullBoolNumString || !leftOperand.isAnyNullBoolNumString) { | 1219 if (!isAnyNullBoolNumString || !leftOperand.isAnyNullBoolNumString) { |
1252 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING
); | 1220 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING
); |
1253 } | 1221 } |
1254 } | 1222 } |
1255 Object leftValue = leftOperand.value; | 1223 Object leftValue = leftOperand.value; |
1256 if (leftValue == null) { | 1224 if (leftValue == null) { |
1257 return valueOf2(_value == null); | 1225 return valueOf2(value == null); |
1258 } else if (leftValue is bool) { | 1226 } else if (leftValue is bool) { |
1259 if (_value is bool) { | 1227 if (value is bool) { |
1260 return valueOf2(identical(leftValue as bool, _value as bool)); | 1228 return valueOf2(identical(leftValue as bool, value as bool)); |
1261 } | 1229 } |
1262 return RESULT_FALSE; | 1230 return RESULT_FALSE; |
1263 } else if (leftValue is int) { | 1231 } else if (leftValue is int) { |
1264 if (_value is int) { | 1232 if (value is int) { |
1265 return valueOf2(((leftValue as int)) == _value); | 1233 return valueOf2(((leftValue as int)) == value); |
1266 } else if (_value is double) { | 1234 } else if (value is double) { |
1267 return valueOf2(toDouble(leftValue as int) == _value); | 1235 return valueOf2(toDouble(leftValue as int) == value); |
1268 } | 1236 } |
1269 return RESULT_FALSE; | 1237 return RESULT_FALSE; |
1270 } else if (leftValue is double) { | 1238 } else if (leftValue is double) { |
1271 if (_value is int) { | 1239 if (value is int) { |
1272 return valueOf2(((leftValue as double)) == toDouble(_value as int)); | 1240 return valueOf2(((leftValue as double)) == toDouble(value as int)); |
1273 } else if (_value is double) { | 1241 } else if (value is double) { |
1274 return valueOf2(((leftValue as double)) == _value); | 1242 return valueOf2(((leftValue as double)) == value); |
1275 } | 1243 } |
1276 return RESULT_FALSE; | 1244 return RESULT_FALSE; |
1277 } else if (leftValue is String) { | 1245 } else if (leftValue is String) { |
1278 if (_value is String) { | 1246 if (value is String) { |
1279 return valueOf2(((leftValue as String)) == _value); | 1247 return valueOf2(((leftValue as String)) == value); |
1280 } | 1248 } |
1281 return RESULT_FALSE; | 1249 return RESULT_FALSE; |
1282 } | 1250 } |
1283 return RESULT_FALSE; | 1251 return RESULT_FALSE; |
1284 } | 1252 } |
1285 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => leftOperand; | 1253 EvaluationResultImpl greaterThanError(BinaryExpression node, ErrorResult leftO
perand) => leftOperand; |
1286 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => leftOperand; | 1254 EvaluationResultImpl greaterThanOrEqualError(BinaryExpression node, ErrorResul
t leftOperand) => leftOperand; |
1287 EvaluationResultImpl greaterThanOrEqualValid(BinaryExpression node, ValidResul
t leftOperand2) { | 1255 EvaluationResultImpl greaterThanOrEqualValid(BinaryExpression node, ValidResul
t leftOperand2) { |
1288 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1256 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1289 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1257 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1290 } | 1258 } |
1291 if (isSomeNum || leftOperand2.isSomeNum) { | 1259 if (isSomeNum || leftOperand2.isSomeNum) { |
1292 return RESULT_BOOL; | 1260 return RESULT_BOOL; |
1293 } | 1261 } |
1294 Object leftValue = leftOperand2.value; | 1262 Object leftValue = leftOperand2.value; |
1295 if (leftValue == null) { | 1263 if (leftValue == null) { |
1296 return error(node.leftOperand); | 1264 return error(node.leftOperand); |
1297 } else if (_value == null) { | 1265 } else if (value == null) { |
1298 return error(node.rightOperand); | 1266 return error(node.rightOperand); |
1299 } else if (leftValue is int) { | 1267 } else if (leftValue is int) { |
1300 if (_value is int) { | 1268 if (value is int) { |
1301 return valueOf2(((leftValue as int)).compareTo(_value as int) >= 0); | 1269 return valueOf2(((leftValue as int)).compareTo(value as int) >= 0); |
1302 } else if (_value is double) { | 1270 } else if (value is double) { |
1303 return valueOf2(((leftValue as int)).toDouble() >= ((_value as double)))
; | 1271 return valueOf2(((leftValue as int)).toDouble() >= ((value as double))); |
1304 } | 1272 } |
1305 } else if (leftValue is double) { | 1273 } else if (leftValue is double) { |
1306 if (_value is int) { | 1274 if (value is int) { |
1307 return valueOf2(((leftValue as double)) >= ((_value as int)).toDouble())
; | 1275 return valueOf2(((leftValue as double)) >= ((value as int)).toDouble()); |
1308 } else if (_value is double) { | 1276 } else if (value is double) { |
1309 return valueOf2(((leftValue as double)) >= ((_value as double))); | 1277 return valueOf2(((leftValue as double)) >= ((value as double))); |
1310 } | 1278 } |
1311 } | 1279 } |
1312 return error(node); | 1280 return error(node); |
1313 } | 1281 } |
1314 EvaluationResultImpl greaterThanValid(BinaryExpression node, ValidResult leftO
perand2) { | 1282 EvaluationResultImpl greaterThanValid(BinaryExpression node, ValidResult leftO
perand2) { |
1315 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1283 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1316 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1284 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1317 } | 1285 } |
1318 if (isSomeNum || leftOperand2.isSomeNum) { | 1286 if (isSomeNum || leftOperand2.isSomeNum) { |
1319 return RESULT_BOOL; | 1287 return RESULT_BOOL; |
1320 } | 1288 } |
1321 Object leftValue = leftOperand2.value; | 1289 Object leftValue = leftOperand2.value; |
1322 if (leftValue == null) { | 1290 if (leftValue == null) { |
1323 return error(node.leftOperand); | 1291 return error(node.leftOperand); |
1324 } else if (_value == null) { | 1292 } else if (value == null) { |
1325 return error(node.rightOperand); | 1293 return error(node.rightOperand); |
1326 } else if (leftValue is int) { | 1294 } else if (leftValue is int) { |
1327 if (_value is int) { | 1295 if (value is int) { |
1328 return valueOf2(((leftValue as int)).compareTo(_value as int) > 0); | 1296 return valueOf2(((leftValue as int)).compareTo(value as int) > 0); |
1329 } else if (_value is double) { | 1297 } else if (value is double) { |
1330 return valueOf2(((leftValue as int)).toDouble() > ((_value as double))); | 1298 return valueOf2(((leftValue as int)).toDouble() > ((value as double))); |
1331 } | 1299 } |
1332 } else if (leftValue is double) { | 1300 } else if (leftValue is double) { |
1333 if (_value is int) { | 1301 if (value is int) { |
1334 return valueOf2(((leftValue as double)) > ((_value as int)).toDouble()); | 1302 return valueOf2(((leftValue as double)) > ((value as int)).toDouble()); |
1335 } else if (_value is double) { | 1303 } else if (value is double) { |
1336 return valueOf2(((leftValue as double)) > ((_value as double))); | 1304 return valueOf2(((leftValue as double)) > ((value as double))); |
1337 } | 1305 } |
1338 } | 1306 } |
1339 return error(node); | 1307 return error(node); |
1340 } | 1308 } |
1341 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => leftOperand; | 1309 EvaluationResultImpl integerDivideError(BinaryExpression node, ErrorResult lef
tOperand) => leftOperand; |
1342 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef
tOperand2) { | 1310 EvaluationResultImpl integerDivideValid(BinaryExpression node, ValidResult lef
tOperand2) { |
1343 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1311 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1344 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1312 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1345 } | 1313 } |
1346 if (isSomeNum || leftOperand2.isSomeNum) { | 1314 if (isSomeNum || leftOperand2.isSomeNum) { |
1347 return RESULT_INT; | 1315 return RESULT_INT; |
1348 } | 1316 } |
1349 Object leftValue = leftOperand2.value; | 1317 Object leftValue = leftOperand2.value; |
1350 if (leftValue == null) { | 1318 if (leftValue == null) { |
1351 return error(node.leftOperand); | 1319 return error(node.leftOperand); |
1352 } else if (_value == null) { | 1320 } else if (value == null) { |
1353 return error(node.rightOperand); | 1321 return error(node.rightOperand); |
1354 } else if (leftValue is int) { | 1322 } else if (leftValue is int) { |
1355 if (_value is int) { | 1323 if (value is int) { |
1356 if (((_value as int)) == 0) { | 1324 if (((value as int)) == 0) { |
1357 return error2(node, CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE); | 1325 return error2(node, CompileTimeErrorCode.CONST_EVAL_THROWS_IDBZE); |
1358 } | 1326 } |
1359 return valueOf(((leftValue as int)) ~/ (_value as int)); | 1327 return valueOf(((leftValue as int)) ~/ (value as int)); |
1360 } else if (_value is double) { | 1328 } else if (value is double) { |
1361 double result = ((leftValue as int)).toDouble() / ((_value as double)); | 1329 double result = ((leftValue as int)).toDouble() / ((value as double)); |
1362 return valueOf(result.toInt()); | 1330 return valueOf(result.toInt()); |
1363 } | 1331 } |
1364 } else if (leftValue is double) { | 1332 } else if (leftValue is double) { |
1365 if (_value is int) { | 1333 if (value is int) { |
1366 double result = ((leftValue as double)) / ((_value as int)).toDouble(); | 1334 double result = ((leftValue as double)) / ((value as int)).toDouble(); |
1367 return valueOf(result.toInt()); | 1335 return valueOf(result.toInt()); |
1368 } else if (_value is double) { | 1336 } else if (value is double) { |
1369 double result = ((leftValue as double)) / ((_value as double)); | 1337 double result = ((leftValue as double)) / ((value as double)); |
1370 return valueOf(result.toInt()); | 1338 return valueOf(result.toInt()); |
1371 } | 1339 } |
1372 } | 1340 } |
1373 return error(node); | 1341 return error(node); |
1374 } | 1342 } |
1375 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; | 1343 EvaluationResultImpl lessThanError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; |
1376 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => leftOperand; | 1344 EvaluationResultImpl lessThanOrEqualError(BinaryExpression node, ErrorResult l
eftOperand) => leftOperand; |
1377 EvaluationResultImpl lessThanOrEqualValid(BinaryExpression node, ValidResult l
eftOperand2) { | 1345 EvaluationResultImpl lessThanOrEqualValid(BinaryExpression node, ValidResult l
eftOperand2) { |
1378 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1346 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1379 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1347 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1380 } | 1348 } |
1381 if (isSomeNum || leftOperand2.isSomeNum) { | 1349 if (isSomeNum || leftOperand2.isSomeNum) { |
1382 return RESULT_BOOL; | 1350 return RESULT_BOOL; |
1383 } | 1351 } |
1384 Object leftValue = leftOperand2.value; | 1352 Object leftValue = leftOperand2.value; |
1385 if (leftValue == null) { | 1353 if (leftValue == null) { |
1386 return error(node.leftOperand); | 1354 return error(node.leftOperand); |
1387 } else if (_value == null) { | 1355 } else if (value == null) { |
1388 return error(node.rightOperand); | 1356 return error(node.rightOperand); |
1389 } else if (leftValue is int) { | 1357 } else if (leftValue is int) { |
1390 if (_value is int) { | 1358 if (value is int) { |
1391 return valueOf2(((leftValue as int)).compareTo(_value as int) <= 0); | 1359 return valueOf2(((leftValue as int)).compareTo(value as int) <= 0); |
1392 } else if (_value is double) { | 1360 } else if (value is double) { |
1393 return valueOf2(((leftValue as int)).toDouble() <= ((_value as double)))
; | 1361 return valueOf2(((leftValue as int)).toDouble() <= ((value as double))); |
1394 } | 1362 } |
1395 } else if (leftValue is double) { | 1363 } else if (leftValue is double) { |
1396 if (_value is int) { | 1364 if (value is int) { |
1397 return valueOf2(((leftValue as double)) <= ((_value as int)).toDouble())
; | 1365 return valueOf2(((leftValue as double)) <= ((value as int)).toDouble()); |
1398 } else if (_value is double) { | 1366 } else if (value is double) { |
1399 return valueOf2(((leftValue as double)) <= ((_value as double))); | 1367 return valueOf2(((leftValue as double)) <= ((value as double))); |
1400 } | 1368 } |
1401 } | 1369 } |
1402 return error(node); | 1370 return error(node); |
1403 } | 1371 } |
1404 EvaluationResultImpl lessThanValid(BinaryExpression node, ValidResult leftOper
and2) { | 1372 EvaluationResultImpl lessThanValid(BinaryExpression node, ValidResult leftOper
and2) { |
1405 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1373 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1406 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1374 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1407 } | 1375 } |
1408 if (isSomeNum || leftOperand2.isSomeNum) { | 1376 if (isSomeNum || leftOperand2.isSomeNum) { |
1409 return RESULT_BOOL; | 1377 return RESULT_BOOL; |
1410 } | 1378 } |
1411 Object leftValue = leftOperand2.value; | 1379 Object leftValue = leftOperand2.value; |
1412 if (leftValue == null) { | 1380 if (leftValue == null) { |
1413 return error(node.leftOperand); | 1381 return error(node.leftOperand); |
1414 } else if (_value == null) { | 1382 } else if (value == null) { |
1415 return error(node.rightOperand); | 1383 return error(node.rightOperand); |
1416 } else if (leftValue is int) { | 1384 } else if (leftValue is int) { |
1417 if (_value is int) { | 1385 if (value is int) { |
1418 return valueOf2(((leftValue as int)).compareTo(_value as int) < 0); | 1386 return valueOf2(((leftValue as int)).compareTo(value as int) < 0); |
1419 } else if (_value is double) { | 1387 } else if (value is double) { |
1420 return valueOf2(((leftValue as int)).toDouble() < ((_value as double))); | 1388 return valueOf2(((leftValue as int)).toDouble() < ((value as double))); |
1421 } | 1389 } |
1422 } else if (leftValue is double) { | 1390 } else if (leftValue is double) { |
1423 if (_value is int) { | 1391 if (value is int) { |
1424 return valueOf2(((leftValue as double)) < ((_value as int)).toDouble()); | 1392 return valueOf2(((leftValue as double)) < ((value as int)).toDouble()); |
1425 } else if (_value is double) { | 1393 } else if (value is double) { |
1426 return valueOf2(((leftValue as double)) < ((_value as double))); | 1394 return valueOf2(((leftValue as double)) < ((value as double))); |
1427 } | 1395 } |
1428 } | 1396 } |
1429 return error(node); | 1397 return error(node); |
1430 } | 1398 } |
1431 EvaluationResultImpl logicalAndError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; | 1399 EvaluationResultImpl logicalAndError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; |
1432 EvaluationResultImpl logicalAndValid(BinaryExpression node, ValidResult leftOp
erand) { | 1400 EvaluationResultImpl logicalAndValid(BinaryExpression node, ValidResult leftOp
erand) { |
1433 if (!isAnyBool || !leftOperand.isAnyBool) { | 1401 if (!isAnyBool || !leftOperand.isAnyBool) { |
1434 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL); | 1402 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL); |
1435 } | 1403 } |
1436 if (isSomeBool || leftOperand.isSomeBool) { | 1404 if (isSomeBool || leftOperand.isSomeBool) { |
1437 return RESULT_BOOL; | 1405 return RESULT_BOOL; |
1438 } | 1406 } |
1439 Object leftValue = leftOperand.value; | 1407 Object leftValue = leftOperand.value; |
1440 if (leftValue is bool) { | 1408 if (leftValue is bool) { |
1441 if (((leftValue as bool))) { | 1409 if (((leftValue as bool))) { |
1442 return booleanConversion(node.rightOperand, _value); | 1410 return booleanConversion(node.rightOperand, value); |
1443 } | 1411 } |
1444 return RESULT_FALSE; | 1412 return RESULT_FALSE; |
1445 } | 1413 } |
1446 return error(node); | 1414 return error(node); |
1447 } | 1415 } |
1448 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1416 EvaluationResultImpl logicalOrError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
1449 EvaluationResultImpl logicalOrValid(BinaryExpression node, ValidResult leftOpe
rand) { | 1417 EvaluationResultImpl logicalOrValid(BinaryExpression node, ValidResult leftOpe
rand) { |
1450 if (!isAnyBool || !leftOperand.isAnyBool) { | 1418 if (!isAnyBool || !leftOperand.isAnyBool) { |
1451 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL); | 1419 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL); |
1452 } | 1420 } |
1453 if (isSomeBool || leftOperand.isSomeBool) { | 1421 if (isSomeBool || leftOperand.isSomeBool) { |
1454 return RESULT_BOOL; | 1422 return RESULT_BOOL; |
1455 } | 1423 } |
1456 Object leftValue = leftOperand.value; | 1424 Object leftValue = leftOperand.value; |
1457 if (leftValue is bool && ((leftValue as bool))) { | 1425 if (leftValue is bool && ((leftValue as bool))) { |
1458 return RESULT_TRUE; | 1426 return RESULT_TRUE; |
1459 } | 1427 } |
1460 return booleanConversion(node.rightOperand, _value); | 1428 return booleanConversion(node.rightOperand, value); |
1461 } | 1429 } |
1462 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1430 EvaluationResultImpl minusError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
1463 EvaluationResultImpl minusValid(BinaryExpression node, ValidResult leftOperand
2) { | 1431 EvaluationResultImpl minusValid(BinaryExpression node, ValidResult leftOperand
2) { |
1464 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1432 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1465 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1433 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1466 } | 1434 } |
1467 if (isSomeInt || leftOperand2.isSomeInt) { | 1435 if (isSomeInt || leftOperand2.isSomeInt) { |
1468 return RESULT_INT; | 1436 return RESULT_INT; |
1469 } else if (isSomeNum || leftOperand2.isSomeNum) { | 1437 } else if (isSomeNum || leftOperand2.isSomeNum) { |
1470 return RESULT_NUM; | 1438 return RESULT_NUM; |
1471 } | 1439 } |
1472 Object leftValue = leftOperand2.value; | 1440 Object leftValue = leftOperand2.value; |
1473 if (leftValue == null) { | 1441 if (leftValue == null) { |
1474 return error(node.leftOperand); | 1442 return error(node.leftOperand); |
1475 } else if (_value == null) { | 1443 } else if (value == null) { |
1476 return error(node.rightOperand); | 1444 return error(node.rightOperand); |
1477 } else if (leftValue is int) { | 1445 } else if (leftValue is int) { |
1478 if (_value is int) { | 1446 if (value is int) { |
1479 return valueOf(((leftValue as int)) - (_value as int)); | 1447 return valueOf(((leftValue as int)) - (value as int)); |
1480 } else if (_value is double) { | 1448 } else if (value is double) { |
1481 return valueOf3(((leftValue as int)).toDouble() - ((_value as double))); | 1449 return valueOf3(((leftValue as int)).toDouble() - ((value as double))); |
1482 } | 1450 } |
1483 } else if (leftValue is double) { | 1451 } else if (leftValue is double) { |
1484 if (_value is int) { | 1452 if (value is int) { |
1485 return valueOf3(((leftValue as double)) - ((_value as int)).toDouble()); | 1453 return valueOf3(((leftValue as double)) - ((value as int)).toDouble()); |
1486 } else if (_value is double) { | 1454 } else if (value is double) { |
1487 return valueOf3(((leftValue as double)) - ((_value as double))); | 1455 return valueOf3(((leftValue as double)) - ((value as double))); |
1488 } | 1456 } |
1489 } | 1457 } |
1490 return error(node); | 1458 return error(node); |
1491 } | 1459 } |
1492 EvaluationResultImpl notEqualError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; | 1460 EvaluationResultImpl notEqualError(BinaryExpression node, ErrorResult leftOper
and) => leftOperand; |
1493 EvaluationResultImpl notEqualValid(BinaryExpression node, ValidResult leftOper
and) { | 1461 EvaluationResultImpl notEqualValid(BinaryExpression node, ValidResult leftOper
and) { |
1494 if (!isAnyNullBoolNumString || !leftOperand.isAnyNullBoolNumString) { | 1462 if (!isAnyNullBoolNumString || !leftOperand.isAnyNullBoolNumString) { |
1495 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); | 1463 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_BOOL_NUM_STRING); |
1496 } | 1464 } |
1497 Object leftValue = leftOperand.value; | 1465 Object leftValue = leftOperand.value; |
1498 if (leftValue == null) { | 1466 if (leftValue == null) { |
1499 return valueOf2(_value != null); | 1467 return valueOf2(value != null); |
1500 } else if (leftValue is bool) { | 1468 } else if (leftValue is bool) { |
1501 if (_value is bool) { | 1469 if (value is bool) { |
1502 return valueOf2(((leftValue as bool)) != ((_value as bool))); | 1470 return valueOf2(((leftValue as bool)) != ((value as bool))); |
1503 } | 1471 } |
1504 return RESULT_TRUE; | 1472 return RESULT_TRUE; |
1505 } else if (leftValue is int) { | 1473 } else if (leftValue is int) { |
1506 if (_value is int) { | 1474 if (value is int) { |
1507 return valueOf2(((leftValue as int)) != _value); | 1475 return valueOf2(((leftValue as int)) != value); |
1508 } else if (_value is double) { | 1476 } else if (value is double) { |
1509 return valueOf2(toDouble(leftValue as int) != _value); | 1477 return valueOf2(toDouble(leftValue as int) != value); |
1510 } | 1478 } |
1511 return RESULT_TRUE; | 1479 return RESULT_TRUE; |
1512 } else if (leftValue is double) { | 1480 } else if (leftValue is double) { |
1513 if (_value is int) { | 1481 if (value is int) { |
1514 return valueOf2(((leftValue as double)) != toDouble(_value as int)); | 1482 return valueOf2(((leftValue as double)) != toDouble(value as int)); |
1515 } else if (_value is double) { | 1483 } else if (value is double) { |
1516 return valueOf2(((leftValue as double)) != _value); | 1484 return valueOf2(((leftValue as double)) != value); |
1517 } | 1485 } |
1518 return RESULT_TRUE; | 1486 return RESULT_TRUE; |
1519 } else if (leftValue is String) { | 1487 } else if (leftValue is String) { |
1520 if (_value is String) { | 1488 if (value is String) { |
1521 return valueOf2(((leftValue as String)) != _value); | 1489 return valueOf2(((leftValue as String)) != value); |
1522 } | 1490 } |
1523 return RESULT_TRUE; | 1491 return RESULT_TRUE; |
1524 } | 1492 } |
1525 return RESULT_TRUE; | 1493 return RESULT_TRUE; |
1526 } | 1494 } |
1527 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1495 EvaluationResultImpl remainderError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
1528 EvaluationResultImpl remainderValid(BinaryExpression node, ValidResult leftOpe
rand2) { | 1496 EvaluationResultImpl remainderValid(BinaryExpression node, ValidResult leftOpe
rand2) { |
1529 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1497 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1530 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1498 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1531 } | 1499 } |
1532 if (isSomeInt || leftOperand2.isSomeInt) { | 1500 if (isSomeInt || leftOperand2.isSomeInt) { |
1533 return RESULT_INT; | 1501 return RESULT_INT; |
1534 } else if (isSomeNum || leftOperand2.isSomeNum) { | 1502 } else if (isSomeNum || leftOperand2.isSomeNum) { |
1535 return RESULT_NUM; | 1503 return RESULT_NUM; |
1536 } | 1504 } |
1537 Object leftValue = leftOperand2.value; | 1505 Object leftValue = leftOperand2.value; |
1538 if (leftValue == null) { | 1506 if (leftValue == null) { |
1539 return error(node.leftOperand); | 1507 return error(node.leftOperand); |
1540 } else if (_value == null) { | 1508 } else if (value == null) { |
1541 return error(node.rightOperand); | 1509 return error(node.rightOperand); |
1542 } else if (leftValue is int) { | 1510 } else if (leftValue is int) { |
1543 if (_value is int) { | 1511 if (value is int) { |
1544 if (((_value as int)) == 0) { | 1512 if (((value as int)) == 0) { |
1545 return valueOf3(((leftValue as int)).toDouble() % ((_value as int)).to
Double()); | 1513 return valueOf3(((leftValue as int)).toDouble() % ((value as int)).toD
ouble()); |
1546 } | 1514 } |
1547 return valueOf(((leftValue as int)).remainder(_value as int)); | 1515 return valueOf(((leftValue as int)).remainder(value as int)); |
1548 } else if (_value is double) { | 1516 } else if (value is double) { |
1549 return valueOf3(((leftValue as int)).toDouble() % ((_value as double))); | 1517 return valueOf3(((leftValue as int)).toDouble() % ((value as double))); |
1550 } | 1518 } |
1551 } else if (leftValue is double) { | 1519 } else if (leftValue is double) { |
1552 if (_value is int) { | 1520 if (value is int) { |
1553 return valueOf3(((leftValue as double)) % ((_value as int)).toDouble()); | 1521 return valueOf3(((leftValue as double)) % ((value as int)).toDouble()); |
1554 } else if (_value is double) { | 1522 } else if (value is double) { |
1555 return valueOf3(((leftValue as double)) % ((_value as double))); | 1523 return valueOf3(((leftValue as double)) % ((value as double))); |
1556 } | 1524 } |
1557 } | 1525 } |
1558 return error(node); | 1526 return error(node); |
1559 } | 1527 } |
1560 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; | 1528 EvaluationResultImpl shiftLeftError(BinaryExpression node, ErrorResult leftOpe
rand) => leftOperand; |
1561 EvaluationResultImpl shiftLeftValid(BinaryExpression node, ValidResult leftOpe
rand2) { | 1529 EvaluationResultImpl shiftLeftValid(BinaryExpression node, ValidResult leftOpe
rand2) { |
1562 if (!isAnyInt || !leftOperand2.isAnyInt) { | 1530 if (!isAnyInt || !leftOperand2.isAnyInt) { |
1563 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1531 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
1564 } | 1532 } |
1565 if (isSomeInt || leftOperand2.isSomeInt) { | 1533 if (isSomeInt || leftOperand2.isSomeInt) { |
1566 return RESULT_INT; | 1534 return RESULT_INT; |
1567 } | 1535 } |
1568 Object leftValue = leftOperand2.value; | 1536 Object leftValue = leftOperand2.value; |
1569 if (leftValue == null) { | 1537 if (leftValue == null) { |
1570 return error(node.leftOperand); | 1538 return error(node.leftOperand); |
1571 } else if (_value == null) { | 1539 } else if (value == null) { |
1572 return error(node.rightOperand); | 1540 return error(node.rightOperand); |
1573 } else if (leftValue is int) { | 1541 } else if (leftValue is int) { |
1574 if (_value is int) { | 1542 if (value is int) { |
1575 return valueOf(((leftValue as int)) << ((_value as int))); | 1543 return valueOf(((leftValue as int)) << ((value as int))); |
1576 } | 1544 } |
1577 return error(node.rightOperand); | 1545 return error(node.rightOperand); |
1578 } | 1546 } |
1579 if (_value is int) { | 1547 if (value is int) { |
1580 return error(node.leftOperand); | 1548 return error(node.leftOperand); |
1581 } | 1549 } |
1582 return union(error(node.leftOperand), error(node.rightOperand)); | 1550 return union(error(node.leftOperand), error(node.rightOperand)); |
1583 } | 1551 } |
1584 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; | 1552 EvaluationResultImpl shiftRightError(BinaryExpression node, ErrorResult leftOp
erand) => leftOperand; |
1585 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp
erand2) { | 1553 EvaluationResultImpl shiftRightValid(BinaryExpression node, ValidResult leftOp
erand2) { |
1586 if (!isAnyInt || !leftOperand2.isAnyInt) { | 1554 if (!isAnyInt || !leftOperand2.isAnyInt) { |
1587 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); | 1555 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_INT); |
1588 } | 1556 } |
1589 if (isSomeInt || leftOperand2.isSomeInt) { | 1557 if (isSomeInt || leftOperand2.isSomeInt) { |
1590 return RESULT_INT; | 1558 return RESULT_INT; |
1591 } | 1559 } |
1592 Object leftValue = leftOperand2.value; | 1560 Object leftValue = leftOperand2.value; |
1593 if (leftValue == null) { | 1561 if (leftValue == null) { |
1594 return error(node.leftOperand); | 1562 return error(node.leftOperand); |
1595 } else if (_value == null) { | 1563 } else if (value == null) { |
1596 return error(node.rightOperand); | 1564 return error(node.rightOperand); |
1597 } else if (leftValue is int) { | 1565 } else if (leftValue is int) { |
1598 if (_value is int) { | 1566 if (value is int) { |
1599 return valueOf(((leftValue as int)) >> ((_value as int))); | 1567 return valueOf(((leftValue as int)) >> ((value as int))); |
1600 } | 1568 } |
1601 return error(node.rightOperand); | 1569 return error(node.rightOperand); |
1602 } | 1570 } |
1603 if (_value is int) { | 1571 if (value is int) { |
1604 return error(node.leftOperand); | 1572 return error(node.leftOperand); |
1605 } | 1573 } |
1606 return union(error(node.leftOperand), error(node.rightOperand)); | 1574 return union(error(node.leftOperand), error(node.rightOperand)); |
1607 } | 1575 } |
1608 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; | 1576 EvaluationResultImpl timesError(BinaryExpression node, ErrorResult leftOperand
) => leftOperand; |
1609 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand
2) { | 1577 EvaluationResultImpl timesValid(BinaryExpression node, ValidResult leftOperand
2) { |
1610 if (!isAnyNum || !leftOperand2.isAnyNum) { | 1578 if (!isAnyNum || !leftOperand2.isAnyNum) { |
1611 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); | 1579 return error2(node, CompileTimeErrorCode.CONST_EVAL_TYPE_NUM); |
1612 } | 1580 } |
1613 if (isSomeInt || leftOperand2.isSomeInt) { | 1581 if (isSomeInt || leftOperand2.isSomeInt) { |
1614 return RESULT_INT; | 1582 return RESULT_INT; |
1615 } else if (isSomeNum || leftOperand2.isSomeNum) { | 1583 } else if (isSomeNum || leftOperand2.isSomeNum) { |
1616 return RESULT_NUM; | 1584 return RESULT_NUM; |
1617 } | 1585 } |
1618 Object leftValue = leftOperand2.value; | 1586 Object leftValue = leftOperand2.value; |
1619 if (leftValue == null) { | 1587 if (leftValue == null) { |
1620 return error(node.leftOperand); | 1588 return error(node.leftOperand); |
1621 } else if (_value == null) { | 1589 } else if (value == null) { |
1622 return error(node.rightOperand); | 1590 return error(node.rightOperand); |
1623 } else if (leftValue is int) { | 1591 } else if (leftValue is int) { |
1624 if (_value is int) { | 1592 if (value is int) { |
1625 return valueOf(((leftValue as int)) * (_value as int)); | 1593 return valueOf(((leftValue as int)) * (value as int)); |
1626 } else if (_value is double) { | 1594 } else if (value is double) { |
1627 return valueOf3(((leftValue as int)).toDouble() * ((_value as double))); | 1595 return valueOf3(((leftValue as int)).toDouble() * ((value as double))); |
1628 } | 1596 } |
1629 } else if (leftValue is double) { | 1597 } else if (leftValue is double) { |
1630 if (_value is int) { | 1598 if (value is int) { |
1631 return valueOf3(((leftValue as double)) * ((_value as int)).toDouble()); | 1599 return valueOf3(((leftValue as double)) * ((value as int)).toDouble()); |
1632 } else if (_value is double) { | 1600 } else if (value is double) { |
1633 return valueOf3(((leftValue as double)) * ((_value as double))); | 1601 return valueOf3(((leftValue as double)) * ((value as double))); |
1634 } | 1602 } |
1635 } | 1603 } |
1636 return error(node); | 1604 return error(node); |
1637 } | 1605 } |
1638 bool get isNull => identical(this, RESULT_NULL); | 1606 bool get isNull => identical(this, RESULT_NULL); |
1639 | 1607 |
1640 /** | 1608 /** |
1641 * Return the result of applying boolean conversion to the given value. | 1609 * Return the result of applying boolean conversion to the given value. |
1642 * | 1610 * |
1643 * @param node the node against which errors should be reported | 1611 * @param node the node against which errors should be reported |
(...skipping 22 matching lines...) Expand all Loading... |
1666 ErrorResult error2(ASTNode node, ErrorCode code) => new ErrorResult.con1(node,
code); | 1634 ErrorResult error2(ASTNode node, ErrorCode code) => new ErrorResult.con1(node,
code); |
1667 | 1635 |
1668 /** | 1636 /** |
1669 * Checks if this result has type "bool", with known or unknown value. | 1637 * Checks if this result has type "bool", with known or unknown value. |
1670 */ | 1638 */ |
1671 bool get isAnyBool => isSomeBool || identical(this, RESULT_TRUE) || identical(
this, RESULT_FALSE); | 1639 bool get isAnyBool => isSomeBool || identical(this, RESULT_TRUE) || identical(
this, RESULT_FALSE); |
1672 | 1640 |
1673 /** | 1641 /** |
1674 * Checks if this result has type "int", with known or unknown value. | 1642 * Checks if this result has type "int", with known or unknown value. |
1675 */ | 1643 */ |
1676 bool get isAnyInt => identical(this, RESULT_INT) || _value is int; | 1644 bool get isAnyInt => identical(this, RESULT_INT) || value is int; |
1677 | 1645 |
1678 /** | 1646 /** |
1679 * Checks if this result has one of the types - "bool", "num" or "string"; or
may be `null`. | 1647 * Checks if this result has one of the types - "bool", "num" or "string"; or
may be `null`. |
1680 */ | 1648 */ |
1681 bool get isAnyNullBoolNumString => isNull || isAnyBool || isAnyNum || _value i
s String; | 1649 bool get isAnyNullBoolNumString => isNull || isAnyBool || isAnyNum || value is
String; |
1682 | 1650 |
1683 /** | 1651 /** |
1684 * Checks if this result has type "num", with known or unknown value. | 1652 * Checks if this result has type "num", with known or unknown value. |
1685 */ | 1653 */ |
1686 bool get isAnyNum => isSomeNum || _value is num; | 1654 bool get isAnyNum => isSomeNum || value is num; |
1687 | 1655 |
1688 /** | 1656 /** |
1689 * Checks if this result has type "bool", exact value of which we don't know. | 1657 * Checks if this result has type "bool", exact value of which we don't know. |
1690 */ | 1658 */ |
1691 bool get isSomeBool => identical(this, RESULT_BOOL); | 1659 bool get isSomeBool => identical(this, RESULT_BOOL); |
1692 | 1660 |
1693 /** | 1661 /** |
1694 * Checks if this result has type "int", exact value of which we don't know. | 1662 * Checks if this result has type "int", exact value of which we don't know. |
1695 */ | 1663 */ |
1696 bool get isSomeInt => identical(this, RESULT_INT); | 1664 bool get isSomeInt => identical(this, RESULT_INT); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 ValidResult valueOf3(double value) => new ValidResult(value); | 1703 ValidResult valueOf3(double value) => new ValidResult(value); |
1736 | 1704 |
1737 /** | 1705 /** |
1738 * Return a result object representing the given value. | 1706 * Return a result object representing the given value. |
1739 * | 1707 * |
1740 * @param value the value to be represented as a result object | 1708 * @param value the value to be represented as a result object |
1741 * @return a result object representing the given value | 1709 * @return a result object representing the given value |
1742 */ | 1710 */ |
1743 ValidResult valueOf4(String value) => new ValidResult(value); | 1711 ValidResult valueOf4(String value) => new ValidResult(value); |
1744 } | 1712 } |
OLD | NEW |