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'; |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 expressions.map((a) => a.apply(arguments)).toList()); | 656 expressions.map((a) => a.apply(arguments)).toList()); |
657 } | 657 } |
658 | 658 |
659 @override | 659 @override |
660 ConstantValue evaluate( | 660 ConstantValue evaluate( |
661 Environment environment, ConstantSystem constantSystem) { | 661 Environment environment, ConstantSystem constantSystem) { |
662 DartString accumulator; | 662 DartString accumulator; |
663 for (ConstantExpression expression in expressions) { | 663 for (ConstantExpression expression in expressions) { |
664 ConstantValue value = expression.evaluate(environment, constantSystem); | 664 ConstantValue value = expression.evaluate(environment, constantSystem); |
665 DartString valueString; | 665 DartString valueString; |
666 if (value.isNum || value.isBool) { | 666 if (value.isNum || value.isBool || value.isNull) { |
667 PrimitiveConstantValue primitive = value; | 667 PrimitiveConstantValue primitive = value; |
668 valueString = | 668 valueString = |
669 new DartString.literal(primitive.primitiveValue.toString()); | 669 new DartString.literal(primitive.primitiveValue.toString()); |
670 } else if (value.isString) { | 670 } else if (value.isString) { |
671 PrimitiveConstantValue primitive = value; | 671 PrimitiveConstantValue primitive = value; |
672 valueString = primitive.primitiveValue; | 672 valueString = primitive.primitiveValue; |
673 } else { | 673 } else { |
674 // TODO(johnniwinther): Specialize message to indicated that the problem | 674 // TODO(johnniwinther): Specialize message to indicated that the problem |
675 // is not constness but the types of the const expressions. | 675 // is not constness but the types of the const expressions. |
676 return new NonConstantValue(); | 676 return new NonConstantValue(); |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 visit(exp.name); | 1891 visit(exp.name); |
1892 if (exp.defaultValue != null) { | 1892 if (exp.defaultValue != null) { |
1893 sb.write(', defaultValue: '); | 1893 sb.write(', defaultValue: '); |
1894 visit(exp.defaultValue); | 1894 visit(exp.defaultValue); |
1895 } | 1895 } |
1896 sb.write(')'); | 1896 sb.write(')'); |
1897 } | 1897 } |
1898 | 1898 |
1899 String toString() => sb.toString(); | 1899 String toString() => sb.toString(); |
1900 } | 1900 } |
OLD | NEW |