Chromium Code Reviews| 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 | 7 import '../compiler.dart' show |
| 8 Compiler; | 8 Compiler; |
| 9 import '../constants/constant_system.dart'; | 9 import '../constants/constant_system.dart'; |
| 10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 return new ListConstantValue(type, values); | 267 return new ListConstantValue(type, values); |
| 268 } | 268 } |
| 269 | 269 |
| 270 @override | 270 @override |
| 271 ConstantValue createType(Compiler compiler, DartType type) { | 271 ConstantValue createType(Compiler compiler, DartType type) { |
| 272 return new TypeConstantValue( | 272 return new TypeConstantValue( |
| 273 type, | 273 type, |
| 274 compiler.backend.typeImplementation.computeType(compiler.resolution)); | 274 compiler.backend.typeImplementation.computeType(compiler.resolution)); |
| 275 } | 275 } |
| 276 | 276 |
| 277 // Integer checks don't verify that the number is not -0.0. | 277 // Integer checks don't verify that the number is not -0.0. |
|
asgerf
2016/01/26 14:59:18
Update doc comment please.
| |
| 278 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero; | 278 bool isInt(ConstantValue constant) { |
| 279 return constant.isInt || constant.isMinusZero || | |
| 280 constant.isPositiveInfinity || | |
| 281 constant.isNegativeInfinity; | |
| 282 } | |
| 279 bool isDouble(ConstantValue constant) | 283 bool isDouble(ConstantValue constant) |
| 280 => constant.isDouble && !constant.isMinusZero; | 284 => constant.isDouble && !constant.isMinusZero; |
| 281 bool isString(ConstantValue constant) => constant.isString; | 285 bool isString(ConstantValue constant) => constant.isString; |
| 282 bool isBool(ConstantValue constant) => constant.isBool; | 286 bool isBool(ConstantValue constant) => constant.isBool; |
| 283 bool isNull(ConstantValue constant) => constant.isNull; | 287 bool isNull(ConstantValue constant) => constant.isNull; |
| 284 | 288 |
| 285 bool isSubtype(DartTypes types, DartType s, DartType t) { | 289 bool isSubtype(DartTypes types, DartType s, DartType t) { |
| 286 // At runtime, an integer is both an integer and a double: the | 290 // At runtime, an integer is both an integer and a double: the |
| 287 // integer type check is Math.floor, which will return true only | 291 // integer type check is Math.floor, which will return true only |
| 288 // for real integers, and our double type check is 'typeof number' | 292 // for real integers, and our double type check is 'typeof number' |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 result.add(keyList); | 385 result.add(keyList); |
| 382 } else { | 386 } else { |
| 383 // Add the keys individually to avoid generating an unused list constant | 387 // Add the keys individually to avoid generating an unused list constant |
| 384 // for the keys. | 388 // for the keys. |
| 385 result.addAll(keys); | 389 result.addAll(keys); |
| 386 } | 390 } |
| 387 result.addAll(values); | 391 result.addAll(values); |
| 388 return result; | 392 return result; |
| 389 } | 393 } |
| 390 } | 394 } |
| OLD | NEW |