| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 BoolConstant createBool(bool value) => new BoolConstant(value); | 210 BoolConstant createBool(bool value) => new BoolConstant(value); |
| 211 NullConstant createNull() => new NullConstant(); | 211 NullConstant createNull() => new NullConstant(); |
| 212 | 212 |
| 213 // Integer checks don't verify that the number is not -0.0. | 213 // Integer checks don't verify that the number is not -0.0. |
| 214 bool isInt(Constant constant) => constant.isInt() || constant.isMinusZero(); | 214 bool isInt(Constant constant) => constant.isInt() || constant.isMinusZero(); |
| 215 bool isDouble(Constant constant) | 215 bool isDouble(Constant constant) |
| 216 => constant.isDouble() && !constant.isMinusZero(); | 216 => constant.isDouble() && !constant.isMinusZero(); |
| 217 bool isString(Constant constant) => constant.isString(); | 217 bool isString(Constant constant) => constant.isString(); |
| 218 bool isBool(Constant constant) => constant.isBool(); | 218 bool isBool(Constant constant) => constant.isBool(); |
| 219 bool isNull(Constant constant) => constant.isNull(); | 219 bool isNull(Constant constant) => constant.isNull(); |
| 220 } | 220 |
| 221 bool isSubtype(Compiler compiler, DartType s, DartType t) { |
| 222 // At runtime, an integer is both an integer and a double: the |
| 223 // integer type check is Math.floor, which will return true only |
| 224 // for real integers, and our double type check is 'typeof number' |
| 225 // which will return true for both integers and doubles. |
| 226 if (s.element == compiler.intClass && t.element == compiler.doubleClass) { |
| 227 return true; |
| 228 } |
| 229 return compiler.types.isSubtype(s, t); |
| 230 } |
| 231 } |
| OLD | NEW |