| 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.dart; | 5 library dart2js.constant_system.dart; |
| 6 | 6 |
| 7 import 'compiler.dart' show Compiler; | 7 import 'common/backend_api.dart' show BackendClasses; |
| 8 import 'constants/constant_system.dart'; | 8 import 'constants/constant_system.dart'; |
| 9 import 'constants/values.dart'; | 9 import 'constants/values.dart'; |
| 10 import 'elements/resolution_types.dart'; | 10 import 'core_types.dart' show CommonElements; |
| 11 import 'elements/types.dart'; |
| 12 import 'elements/resolution_types.dart' show DartTypes; |
| 11 import 'tree/dartstring.dart' show DartString; | 13 import 'tree/dartstring.dart' show DartString; |
| 12 | 14 |
| 13 const DART_CONSTANT_SYSTEM = const DartConstantSystem(); | 15 const DART_CONSTANT_SYSTEM = const DartConstantSystem(); |
| 14 | 16 |
| 15 class BitNotOperation implements UnaryOperation { | 17 class BitNotOperation implements UnaryOperation { |
| 16 final String name = '~'; | 18 final String name = '~'; |
| 17 const BitNotOperation(); | 19 const BitNotOperation(); |
| 18 ConstantValue fold(ConstantValue constant) { | 20 ConstantValue fold(ConstantValue constant) { |
| 19 if (constant.isInt) { | 21 if (constant.isInt) { |
| 20 IntConstantValue intConstant = constant; | 22 IntConstantValue intConstant = constant; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 return new StringConstantValue(string); | 437 return new StringConstantValue(string); |
| 436 } | 438 } |
| 437 | 439 |
| 438 @override | 440 @override |
| 439 BoolConstantValue createBool(bool value) => new BoolConstantValue(value); | 441 BoolConstantValue createBool(bool value) => new BoolConstantValue(value); |
| 440 | 442 |
| 441 @override | 443 @override |
| 442 NullConstantValue createNull() => new NullConstantValue(); | 444 NullConstantValue createNull() => new NullConstantValue(); |
| 443 | 445 |
| 444 @override | 446 @override |
| 445 ListConstantValue createList( | 447 ListConstantValue createList(InterfaceType type, List<ConstantValue> values) { |
| 446 ResolutionInterfaceType type, List<ConstantValue> values) { | |
| 447 return new ListConstantValue(type, values); | 448 return new ListConstantValue(type, values); |
| 448 } | 449 } |
| 449 | 450 |
| 450 @override | 451 @override |
| 451 MapConstantValue createMap(Compiler compiler, ResolutionInterfaceType type, | 452 MapConstantValue createMap( |
| 452 List<ConstantValue> keys, List<ConstantValue> values) { | 453 CommonElements commonElements, |
| 454 BackendClasses backendClasses, |
| 455 InterfaceType type, |
| 456 List<ConstantValue> keys, |
| 457 List<ConstantValue> values) { |
| 453 return new MapConstantValue(type, keys, values); | 458 return new MapConstantValue(type, keys, values); |
| 454 } | 459 } |
| 455 | 460 |
| 456 @override | 461 @override |
| 457 ConstantValue createType(Compiler compiler, ResolutionDartType type) { | 462 ConstantValue createType(CommonElements commonElements, |
| 463 BackendClasses backendClasses, DartType type) { |
| 458 // TODO(johnniwinther): Change the `Type` type to | 464 // TODO(johnniwinther): Change the `Type` type to |
| 459 // `compiler.commonElements.typeType` and check the backend specific value | 465 // `compiler.commonElements.typeType` and check the backend specific value |
| 460 // in [checkConstMapKeysDontOverrideEquals] in 'members.dart'. | 466 // in [checkConstMapKeysDontOverrideEquals] in 'members.dart'. |
| 461 ResolutionInterfaceType implementationType = | 467 InterfaceType implementationType = backendClasses.typeType; |
| 462 compiler.backend.backendClasses.typeType; | |
| 463 return new TypeConstantValue(type, implementationType); | 468 return new TypeConstantValue(type, implementationType); |
| 464 } | 469 } |
| 465 | 470 |
| 466 @override | 471 @override |
| 467 ConstantValue createSymbol(Compiler compiler, String text) { | 472 ConstantValue createSymbol(CommonElements commonElements, |
| 468 throw new UnsupportedError('DartConstantSystem.evaluate'); | 473 BackendClasses backendClasses, String text) { |
| 474 throw new UnsupportedError('DartConstantSystem.createSymbol'); |
| 469 } | 475 } |
| 470 | 476 |
| 471 bool isInt(ConstantValue constant) => constant.isInt; | 477 bool isInt(ConstantValue constant) => constant.isInt; |
| 472 bool isDouble(ConstantValue constant) => constant.isDouble; | 478 bool isDouble(ConstantValue constant) => constant.isDouble; |
| 473 bool isString(ConstantValue constant) => constant.isString; | 479 bool isString(ConstantValue constant) => constant.isString; |
| 474 bool isBool(ConstantValue constant) => constant.isBool; | 480 bool isBool(ConstantValue constant) => constant.isBool; |
| 475 bool isNull(ConstantValue constant) => constant.isNull; | 481 bool isNull(ConstantValue constant) => constant.isNull; |
| 476 | 482 |
| 477 bool isSubtype(DartTypes types, ResolutionDartType s, ResolutionDartType t) { | 483 bool isSubtype(DartTypes types, DartType s, DartType t) { |
| 478 return types.isSubtype(s, t); | 484 return types.isSubtype(s, t); |
| 479 } | 485 } |
| 480 } | 486 } |
| OLD | NEW |