| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem(); | 5 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem(); |
| 6 | 6 |
| 7 class JavaScriptBitNotOperation extends BitNotOperation { | 7 class JavaScriptBitNotOperation extends BitNotOperation { |
| 8 const JavaScriptBitNotOperation(); | 8 const JavaScriptBitNotOperation(); |
| 9 | 9 |
| 10 Constant fold(Constant constant) { | 10 Constant fold(Constant constant) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 // values. Furthermore NaN !== NaN. | 124 // values. Furthermore NaN !== NaN. |
| 125 if (left.isNum() && right.isNum()) { | 125 if (left.isNum() && right.isNum()) { |
| 126 NumConstant leftNum = left; | 126 NumConstant leftNum = left; |
| 127 NumConstant rightNum = right; | 127 NumConstant rightNum = right; |
| 128 double leftDouble = leftNum.value.toDouble(); | 128 double leftDouble = leftNum.value.toDouble(); |
| 129 double rightDouble = rightNum.value.toDouble(); | 129 double rightDouble = rightNum.value.toDouble(); |
| 130 return new BoolConstant(leftDouble == rightDouble); | 130 return new BoolConstant(leftDouble == rightDouble); |
| 131 } | 131 } |
| 132 return result; | 132 return result; |
| 133 } | 133 } |
| 134 |
| 135 apply(left, right) => identical(left, right); |
| 134 } | 136 } |
| 135 | 137 |
| 136 /** | 138 /** |
| 137 * Constant system following the semantics for Dart code that has been | 139 * Constant system following the semantics for Dart code that has been |
| 138 * compiled to JavaScript. | 140 * compiled to JavaScript. |
| 139 */ | 141 */ |
| 140 class JavaScriptConstantSystem implements ConstantSystem { | 142 class JavaScriptConstantSystem implements ConstantSystem { |
| 141 const int BITS31 = 0x8FFFFFFF; | 143 const int BITS31 = 0x8FFFFFFF; |
| 142 const int BITS32 = 0xFFFFFFFF; | 144 const int BITS32 = 0xFFFFFFFF; |
| 143 // The maximum integer value a double can represent without losing | 145 // The maximum integer value a double can represent without losing |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 // At runtime, an integer is both an integer and a double: the | 229 // At runtime, an integer is both an integer and a double: the |
| 228 // integer type check is Math.floor, which will return true only | 230 // integer type check is Math.floor, which will return true only |
| 229 // for real integers, and our double type check is 'typeof number' | 231 // for real integers, and our double type check is 'typeof number' |
| 230 // which will return true for both integers and doubles. | 232 // which will return true for both integers and doubles. |
| 231 if (s.element == compiler.intClass && t.element == compiler.doubleClass) { | 233 if (s.element == compiler.intClass && t.element == compiler.doubleClass) { |
| 232 return true; | 234 return true; |
| 233 } | 235 } |
| 234 return compiler.types.isSubtype(s, t); | 236 return compiler.types.isSubtype(s, t); |
| 235 } | 237 } |
| 236 } | 238 } |
| OLD | NEW |