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 '../constants/constant_system.dart'; | 7 import '../constants/constant_system.dart'; |
8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
9 import '../constant_system_dart.dart'; | 9 import '../constant_system_dart.dart'; |
10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 !constant.isMinusZero) { | 233 !constant.isMinusZero) { |
234 int intValue = doubleValue.truncate(); | 234 int intValue = doubleValue.truncate(); |
235 if (intValue == doubleValue) { | 235 if (intValue == doubleValue) { |
236 return new IntConstantValue(intValue); | 236 return new IntConstantValue(intValue); |
237 } | 237 } |
238 } | 238 } |
239 } | 239 } |
240 return constant; | 240 return constant; |
241 } | 241 } |
242 | 242 |
243 NumConstantValue createInt(int i) | 243 @override |
244 => convertToJavaScriptConstant(new IntConstantValue(i)); | 244 NumConstantValue createInt(int i) { |
| 245 return convertToJavaScriptConstant(new IntConstantValue(i)); |
| 246 } |
| 247 |
245 NumConstantValue createInt32(int i) => new IntConstantValue(i & BITS32); | 248 NumConstantValue createInt32(int i) => new IntConstantValue(i & BITS32); |
246 NumConstantValue createDouble(double d) | 249 NumConstantValue createDouble(double d) |
247 => convertToJavaScriptConstant(new DoubleConstantValue(d)); | 250 => convertToJavaScriptConstant(new DoubleConstantValue(d)); |
248 StringConstantValue createString(DartString string) { | 251 StringConstantValue createString(DartString string) { |
249 return new StringConstantValue(string); | 252 return new StringConstantValue(string); |
250 } | 253 } |
251 BoolConstantValue createBool(bool value) => new BoolConstantValue(value); | 254 BoolConstantValue createBool(bool value) => new BoolConstantValue(value); |
252 NullConstantValue createNull() => new NullConstantValue(); | 255 NullConstantValue createNull() => new NullConstantValue(); |
253 | 256 |
| 257 |
| 258 @override |
| 259 ListConstantValue createList(InterfaceType type, |
| 260 List<ConstantValue> values) { |
| 261 return new ListConstantValue(type, values); |
| 262 } |
| 263 |
| 264 @override |
| 265 ConstantValue createType(Compiler compiler, DartType type) { |
| 266 return new TypeConstantValue( |
| 267 type, compiler.backend.typeImplementation.computeType(compiler)); |
| 268 } |
| 269 |
254 // Integer checks don't verify that the number is not -0.0. | 270 // Integer checks don't verify that the number is not -0.0. |
255 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero; | 271 bool isInt(ConstantValue constant) => constant.isInt || constant.isMinusZero; |
256 bool isDouble(ConstantValue constant) | 272 bool isDouble(ConstantValue constant) |
257 => constant.isDouble && !constant.isMinusZero; | 273 => constant.isDouble && !constant.isMinusZero; |
258 bool isString(ConstantValue constant) => constant.isString; | 274 bool isString(ConstantValue constant) => constant.isString; |
259 bool isBool(ConstantValue constant) => constant.isBool; | 275 bool isBool(ConstantValue constant) => constant.isBool; |
260 bool isNull(ConstantValue constant) => constant.isNull; | 276 bool isNull(ConstantValue constant) => constant.isNull; |
261 | 277 |
262 bool isSubtype(DartTypes types, DartType s, DartType t) { | 278 bool isSubtype(DartTypes types, DartType s, DartType t) { |
263 // At runtime, an integer is both an integer and a double: the | 279 // At runtime, an integer is both an integer and a double: the |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 result.add(keyList); | 374 result.add(keyList); |
359 } else { | 375 } else { |
360 // Add the keys individually to avoid generating an unused list constant | 376 // Add the keys individually to avoid generating an unused list constant |
361 // for the keys. | 377 // for the keys. |
362 result.addAll(keys); | 378 result.addAll(keys); |
363 } | 379 } |
364 result.addAll(values); | 380 result.addAll(values); |
365 return result; | 381 return result; |
366 } | 382 } |
367 } | 383 } |
OLD | NEW |