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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 NumConstant convertToJavaScriptConstant(NumConstant constant) { | 189 NumConstant convertToJavaScriptConstant(NumConstant constant) { |
190 if (constant.isInt()) { | 190 if (constant.isInt()) { |
191 IntConstant intConstant = constant; | 191 IntConstant intConstant = constant; |
192 int intValue = intConstant.value; | 192 int intValue = intConstant.value; |
193 if (!integerFitsIntoDouble(intValue)) { | 193 if (!integerFitsIntoDouble(intValue)) { |
194 return new DoubleConstant(intValue.toDouble()); | 194 return new DoubleConstant(intValue.toDouble()); |
195 } | 195 } |
196 } else if (constant.isDouble()) { | 196 } else if (constant.isDouble()) { |
197 DoubleConstant doubleResult = constant; | 197 DoubleConstant doubleResult = constant; |
198 double doubleValue = doubleResult.value; | 198 double doubleValue = doubleResult.value; |
199 if (!doubleValue.isInfinite() && !doubleValue.isNaN() && | 199 if (!doubleValue.isInfinite && !doubleValue.isNaN && |
200 !constant.isMinusZero()) { | 200 !constant.isMinusZero()) { |
Mads Ager (google)
2012/10/23 16:06:51
This now looks out of place. Maybe follow up with
floitsch
2012/10/23 16:14:19
The constants have a lot of is-methods. I didn't w
| |
201 int intValue = doubleValue.toInt(); | 201 int intValue = doubleValue.toInt(); |
202 if (intValue == doubleValue && integerFitsIntoDouble(intValue)) { | 202 if (intValue == doubleValue && integerFitsIntoDouble(intValue)) { |
203 return new IntConstant(intValue); | 203 return new IntConstant(intValue); |
204 } | 204 } |
205 } | 205 } |
206 } | 206 } |
207 return constant; | 207 return constant; |
208 } | 208 } |
209 | 209 |
210 NumConstant createInt(int i) | 210 NumConstant createInt(int i) |
(...skipping 18 matching lines...) Expand all Loading... | |
229 // 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 |
230 // integer type check is Math.floor, which will return true only | 230 // integer type check is Math.floor, which will return true only |
231 // for real integers, and our double type check is 'typeof number' | 231 // for real integers, and our double type check is 'typeof number' |
232 // which will return true for both integers and doubles. | 232 // which will return true for both integers and doubles. |
233 if (s.element == compiler.intClass && t.element == compiler.doubleClass) { | 233 if (s.element == compiler.intClass && t.element == compiler.doubleClass) { |
234 return true; | 234 return true; |
235 } | 235 } |
236 return compiler.types.isSubtype(s, t); | 236 return compiler.types.isSubtype(s, t); |
237 } | 237 } |
238 } | 238 } |
OLD | NEW |