| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem(); | 7 const JAVA_SCRIPT_CONSTANT_SYSTEM = const JavaScriptConstantSystem(); |
| 8 | 8 |
| 9 class JavaScriptBitNotOperation extends BitNotOperation { | 9 class JavaScriptBitNotOperation extends BitNotOperation { |
| 10 const JavaScriptBitNotOperation(); | 10 const JavaScriptBitNotOperation(); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 NullConstantValue createNull() => new NullConstantValue(); | 226 NullConstantValue createNull() => new NullConstantValue(); |
| 227 | 227 |
| 228 // Integer checks don't verify that the number is not -0.0. | 228 // Integer checks don't verify that the number is not -0.0. |
| 229 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero; | 229 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero; |
| 230 bool isDouble(ConstantValue constant) | 230 bool isDouble(ConstantValue constant) |
| 231 => constant.isDouble && !constant.isMinusZero; | 231 => constant.isDouble && !constant.isMinusZero; |
| 232 bool isString(ConstantValue constant) => constant.isString; | 232 bool isString(ConstantValue constant) => constant.isString; |
| 233 bool isBool(ConstantValue constant) => constant.isBool; | 233 bool isBool(ConstantValue constant) => constant.isBool; |
| 234 bool isNull(ConstantValue constant) => constant.isNull; | 234 bool isNull(ConstantValue constant) => constant.isNull; |
| 235 | 235 |
| 236 bool isSubtype(Compiler compiler, DartType s, DartType t) { | 236 bool isSubtype(DartTypes types, DartType s, DartType t) { |
| 237 // At runtime, an integer is both an integer and a double: the | 237 // At runtime, an integer is both an integer and a double: the |
| 238 // integer type check is Math.floor, which will return true only | 238 // integer type check is Math.floor, which will return true only |
| 239 // for real integers, and our double type check is 'typeof number' | 239 // for real integers, and our double type check is 'typeof number' |
| 240 // which will return true for both integers and doubles. | 240 // which will return true for both integers and doubles. |
| 241 if (s.element == compiler.intClass && t.element == compiler.doubleClass) { | 241 if (s == types.coreTypes.intType && t == types.coreTypes.doubleType) { |
| 242 return true; | 242 return true; |
| 243 } | 243 } |
| 244 return compiler.types.isSubtype(s, t); | 244 return types.isSubtype(s, t); |
| 245 } | 245 } |
| 246 | 246 |
| 247 MapConstantValue createMap(Compiler compiler, | 247 MapConstantValue createMap(Compiler compiler, |
| 248 InterfaceType sourceType, | 248 InterfaceType sourceType, |
| 249 List<ConstantValue> keys, | 249 List<ConstantValue> keys, |
| 250 List<ConstantValue> values) { | 250 List<ConstantValue> values) { |
| 251 JavaScriptBackend backend = compiler.backend; | 251 JavaScriptBackend backend = compiler.backend; |
| 252 | 252 |
| 253 bool onlyStringKeys = true; | 253 bool onlyStringKeys = true; |
| 254 ConstantValue protoValue = null; | 254 ConstantValue protoValue = null; |
| 255 for (int i = 0; i < keys.length ; i++) { | 255 for (int i = 0; i < keys.length ; i++) { |
| 256 var key = keys[i]; | 256 var key = keys[i]; |
| 257 if (key.isString) { | 257 if (key.isString) { |
| 258 if (key.primitiveValue == JavaScriptMapConstant.PROTO_PROPERTY) { | 258 if (key.primitiveValue == JavaScriptMapConstant.PROTO_PROPERTY) { |
| 259 protoValue = values[i]; | 259 protoValue = values[i]; |
| 260 } | 260 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 result.add(keyList); | 336 result.add(keyList); |
| 337 } else { | 337 } else { |
| 338 // Add the keys individually to avoid generating an unused list constant | 338 // Add the keys individually to avoid generating an unused list constant |
| 339 // for the keys. | 339 // for the keys. |
| 340 result.addAll(keys); | 340 result.addAll(keys); |
| 341 } | 341 } |
| 342 result.addAll(values); | 342 result.addAll(values); |
| 343 return result; | 343 return result; |
| 344 } | 344 } |
| 345 } | 345 } |
| OLD | NEW |