| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.constants.expressions; | 5 library dart2js.constants.expressions; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
| 9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
| 10 import '../elements/types.dart'; | 10 import '../elements/types.dart'; |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 @override | 475 @override |
| 476 ConstantValue evaluate( | 476 ConstantValue evaluate( |
| 477 Environment environment, ConstantSystem constantSystem) { | 477 Environment environment, ConstantSystem constantSystem) { |
| 478 Map<ConstantValue, ConstantValue> valueMap = | 478 Map<ConstantValue, ConstantValue> valueMap = |
| 479 <ConstantValue, ConstantValue>{}; | 479 <ConstantValue, ConstantValue>{}; |
| 480 for (int index = 0; index < keys.length; index++) { | 480 for (int index = 0; index < keys.length; index++) { |
| 481 ConstantValue key = keys[index].evaluate(environment, constantSystem); | 481 ConstantValue key = keys[index].evaluate(environment, constantSystem); |
| 482 ConstantValue value = values[index].evaluate(environment, constantSystem); | 482 ConstantValue value = values[index].evaluate(environment, constantSystem); |
| 483 valueMap[key] = value; | 483 valueMap[key] = value; |
| 484 } | 484 } |
| 485 return constantSystem.createMap(environment.compiler, type, | 485 return constantSystem.createMap( |
| 486 valueMap.keys.toList(), valueMap.values.toList()); | 486 environment.commonElements, |
| 487 environment.backendClasses, |
| 488 type, |
| 489 valueMap.keys.toList(), |
| 490 valueMap.values.toList()); |
| 487 } | 491 } |
| 488 | 492 |
| 489 ConstantExpression apply(NormalizedArguments arguments) { | 493 ConstantExpression apply(NormalizedArguments arguments) { |
| 490 return new MapConstantExpression( | 494 return new MapConstantExpression( |
| 491 type, | 495 type, |
| 492 keys.map((k) => k.apply(arguments)).toList(), | 496 keys.map((k) => k.apply(arguments)).toList(), |
| 493 values.map((v) => v.apply(arguments)).toList()); | 497 values.map((v) => v.apply(arguments)).toList()); |
| 494 } | 498 } |
| 495 | 499 |
| 496 @override | 500 @override |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 int _computeHashCode() => 13 * name.hashCode; | 731 int _computeHashCode() => 13 * name.hashCode; |
| 728 | 732 |
| 729 @override | 733 @override |
| 730 bool _equals(SymbolConstantExpression other) { | 734 bool _equals(SymbolConstantExpression other) { |
| 731 return name == other.name; | 735 return name == other.name; |
| 732 } | 736 } |
| 733 | 737 |
| 734 @override | 738 @override |
| 735 ConstantValue evaluate( | 739 ConstantValue evaluate( |
| 736 Environment environment, ConstantSystem constantSystem) { | 740 Environment environment, ConstantSystem constantSystem) { |
| 737 return constantSystem.createSymbol(environment.compiler, name); | 741 return constantSystem.createSymbol( |
| 742 environment.commonElements, environment.backendClasses, name); |
| 738 } | 743 } |
| 739 | 744 |
| 740 @override | 745 @override |
| 741 InterfaceType getKnownType(CommonElements commonElements) => | 746 InterfaceType getKnownType(CommonElements commonElements) => |
| 742 commonElements.symbolType; | 747 commonElements.symbolType; |
| 743 } | 748 } |
| 744 | 749 |
| 745 /// Type literal. | 750 /// Type literal. |
| 746 class TypeConstantExpression extends ConstantExpression { | 751 class TypeConstantExpression extends ConstantExpression { |
| 747 /// Either [DynamicType] or a raw [GenericType]. | 752 /// Either [DynamicType] or a raw [GenericType]. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 762 } | 767 } |
| 763 | 768 |
| 764 @override | 769 @override |
| 765 void _createStructuredText(StringBuffer sb) { | 770 void _createStructuredText(StringBuffer sb) { |
| 766 sb.write('Type(type=$type)'); | 771 sb.write('Type(type=$type)'); |
| 767 } | 772 } |
| 768 | 773 |
| 769 @override | 774 @override |
| 770 ConstantValue evaluate( | 775 ConstantValue evaluate( |
| 771 Environment environment, ConstantSystem constantSystem) { | 776 Environment environment, ConstantSystem constantSystem) { |
| 772 return constantSystem.createType(environment.compiler, type); | 777 return constantSystem.createType( |
| 778 environment.commonElements, environment.backendClasses, type); |
| 773 } | 779 } |
| 774 | 780 |
| 775 @override | 781 @override |
| 776 int _computeHashCode() => 13 * type.hashCode; | 782 int _computeHashCode() => 13 * type.hashCode; |
| 777 | 783 |
| 778 @override | 784 @override |
| 779 bool _equals(TypeConstantExpression other) { | 785 bool _equals(TypeConstantExpression other) { |
| 780 return type == other.type; | 786 return type == other.type; |
| 781 } | 787 } |
| 782 | 788 |
| (...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 visit(exp.name); | 1941 visit(exp.name); |
| 1936 if (exp.defaultValue != null) { | 1942 if (exp.defaultValue != null) { |
| 1937 sb.write(', defaultValue: '); | 1943 sb.write(', defaultValue: '); |
| 1938 visit(exp.defaultValue); | 1944 visit(exp.defaultValue); |
| 1939 } | 1945 } |
| 1940 sb.write(')'); | 1946 sb.write(')'); |
| 1941 } | 1947 } |
| 1942 | 1948 |
| 1943 String toString() => sb.toString(); | 1949 String toString() => sb.toString(); |
| 1944 } | 1950 } |
| OLD | NEW |