| 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 library dart2js.constant_system.js; | 5 library dart2js.constant_system.js; |
| 6 | 6 |
| 7 import '../compiler.dart' show Compiler; | 7 import '../compiler.dart' show Compiler; |
| 8 import '../constant_system_dart.dart'; | 8 import '../constant_system_dart.dart'; |
| 9 import '../constants/constant_system.dart'; | 9 import '../constants/constant_system.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 NullConstantValue createNull() => new NullConstantValue(); | 313 NullConstantValue createNull() => new NullConstantValue(); |
| 314 | 314 |
| 315 @override | 315 @override |
| 316 ListConstantValue createList( | 316 ListConstantValue createList( |
| 317 ResolutionInterfaceType type, List<ConstantValue> values) { | 317 ResolutionInterfaceType type, List<ConstantValue> values) { |
| 318 return new ListConstantValue(type, values); | 318 return new ListConstantValue(type, values); |
| 319 } | 319 } |
| 320 | 320 |
| 321 @override | 321 @override |
| 322 ConstantValue createType(Compiler compiler, ResolutionDartType type) { | 322 ConstantValue createType(Compiler compiler, ResolutionDartType type) { |
| 323 ResolutionInterfaceType instanceType = compiler | 323 ResolutionInterfaceType instanceType = |
| 324 .backend.backendClasses.typeImplementation | 324 compiler.backend.backendClasses.typeType; |
| 325 .computeType(compiler.resolution); | |
| 326 return new TypeConstantValue(type, instanceType); | 325 return new TypeConstantValue(type, instanceType); |
| 327 } | 326 } |
| 328 | 327 |
| 329 // Integer checks report true for -0.0, INFINITY, and -INFINITY. At | 328 // Integer checks report true for -0.0, INFINITY, and -INFINITY. At |
| 330 // runtime an 'X is int' check is implemented as: | 329 // runtime an 'X is int' check is implemented as: |
| 331 // | 330 // |
| 332 // typeof(X) === "number" && Math.floor(X) === X | 331 // typeof(X) === "number" && Math.floor(X) === X |
| 333 // | 332 // |
| 334 // We consistently match that runtime semantics at compile time as well. | 333 // We consistently match that runtime semantics at compile time as well. |
| 335 bool isInt(ConstantValue constant) { | 334 bool isInt(ConstantValue constant) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 result.add(keyList); | 457 result.add(keyList); |
| 459 } else { | 458 } else { |
| 460 // Add the keys individually to avoid generating an unused list constant | 459 // Add the keys individually to avoid generating an unused list constant |
| 461 // for the keys. | 460 // for the keys. |
| 462 result.addAll(keys); | 461 result.addAll(keys); |
| 463 } | 462 } |
| 464 result.addAll(values); | 463 result.addAll(values); |
| 465 return result; | 464 return result; |
| 466 } | 465 } |
| 467 } | 466 } |
| OLD | NEW |