| 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 '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| 11 import '../elements/elements.dart' | 11 import '../elements/elements.dart' |
| 12 show | 12 show |
| 13 ConstructorElement, | 13 ConstructorElement, |
| 14 FieldElement, | 14 FieldElement, |
| 15 FunctionElement, | 15 MethodElement, |
| 16 PrefixElement, | 16 PrefixElement, |
| 17 VariableElement; | 17 VariableElement; |
| 18 import '../resolution/operators.dart'; | 18 import '../resolution/operators.dart'; |
| 19 import '../tree/dartstring.dart' show DartString; | 19 import '../tree/dartstring.dart' show DartString; |
| 20 import '../universe/call_structure.dart' show CallStructure; | 20 import '../universe/call_structure.dart' show CallStructure; |
| 21 import 'evaluation.dart'; | 21 import 'evaluation.dart'; |
| 22 import 'values.dart'; | 22 import 'values.dart'; |
| 23 | 23 |
| 24 enum ConstantExpressionKind { | 24 enum ConstantExpressionKind { |
| 25 BINARY, | 25 BINARY, |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 int _computeHashCode() => 13 * element.hashCode; | 806 int _computeHashCode() => 13 * element.hashCode; |
| 807 | 807 |
| 808 @override | 808 @override |
| 809 bool _equals(VariableConstantExpression other) { | 809 bool _equals(VariableConstantExpression other) { |
| 810 return element == other.element; | 810 return element == other.element; |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 | 813 |
| 814 /// Reference to a top-level or static function. | 814 /// Reference to a top-level or static function. |
| 815 class FunctionConstantExpression extends ConstantExpression { | 815 class FunctionConstantExpression extends ConstantExpression { |
| 816 final FunctionElement element; | 816 final MethodElement element; |
| 817 | 817 |
| 818 FunctionConstantExpression(this.element); | 818 FunctionConstantExpression(this.element); |
| 819 | 819 |
| 820 ConstantExpressionKind get kind => ConstantExpressionKind.FUNCTION; | 820 ConstantExpressionKind get kind => ConstantExpressionKind.FUNCTION; |
| 821 | 821 |
| 822 accept(ConstantExpressionVisitor visitor, [context]) { | 822 accept(ConstantExpressionVisitor visitor, [context]) { |
| 823 return visitor.visitFunction(this, context); | 823 return visitor.visitFunction(this, context); |
| 824 } | 824 } |
| 825 | 825 |
| 826 @override | 826 @override |
| 827 void _createStructuredText(StringBuffer sb) { | 827 void _createStructuredText(StringBuffer sb) { |
| 828 sb.write('Function(element=$element)'); | 828 sb.write('Function(element=$element)'); |
| 829 } | 829 } |
| 830 | 830 |
| 831 @override | 831 @override |
| 832 ConstantValue evaluate( | 832 ConstantValue evaluate( |
| 833 Environment environment, ConstantSystem constantSystem) { | 833 Environment environment, ConstantSystem constantSystem) { |
| 834 return new FunctionConstantValue(element); | 834 return new FunctionConstantValue(element, element.type); |
| 835 } | 835 } |
| 836 | 836 |
| 837 @override | 837 @override |
| 838 int _computeHashCode() => 13 * element.hashCode; | 838 int _computeHashCode() => 13 * element.hashCode; |
| 839 | 839 |
| 840 @override | 840 @override |
| 841 bool _equals(FunctionConstantExpression other) { | 841 bool _equals(FunctionConstantExpression other) { |
| 842 return element == other.element; | 842 return element == other.element; |
| 843 } | 843 } |
| 844 | 844 |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 visit(exp.name); | 1888 visit(exp.name); |
| 1889 if (exp.defaultValue != null) { | 1889 if (exp.defaultValue != null) { |
| 1890 sb.write(', defaultValue: '); | 1890 sb.write(', defaultValue: '); |
| 1891 visit(exp.defaultValue); | 1891 visit(exp.defaultValue); |
| 1892 } | 1892 } |
| 1893 sb.write(')'); | 1893 sb.write(')'); |
| 1894 } | 1894 } |
| 1895 | 1895 |
| 1896 String toString() => sb.toString(); | 1896 String toString() => sb.toString(); |
| 1897 } | 1897 } |
| OLD | NEW |