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; | 5 library dart2js.constant_system; |
6 | 6 |
7 import '../dart_types.dart'; | 7 import '../dart_types.dart'; |
8 import '../dart2jslib.dart' show Compiler; | 8 import '../dart2jslib.dart' show Compiler; |
9 import '../resolution/operators.dart'; | 9 import '../resolution/operators.dart'; |
10 import '../tree/tree.dart' show DartString; | 10 import '../tree/tree.dart' show DartString; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 BinaryOperation get codeUnitAt; | 55 BinaryOperation get codeUnitAt; |
56 | 56 |
57 const ConstantSystem(); | 57 const ConstantSystem(); |
58 | 58 |
59 ConstantValue createInt(int i); | 59 ConstantValue createInt(int i); |
60 ConstantValue createDouble(double d); | 60 ConstantValue createDouble(double d); |
61 ConstantValue createString(DartString string); | 61 ConstantValue createString(DartString string); |
62 ConstantValue createBool(bool value); | 62 ConstantValue createBool(bool value); |
63 ConstantValue createNull(); | 63 ConstantValue createNull(); |
| 64 ConstantValue createList(InterfaceType type, |
| 65 List<ConstantValue> values); |
| 66 // TODO(johnniwinther): Remove the need for [compiler]. |
64 ConstantValue createMap(Compiler compiler, | 67 ConstantValue createMap(Compiler compiler, |
65 InterfaceType type, | 68 InterfaceType type, |
66 List<ConstantValue> keys, | 69 List<ConstantValue> keys, |
67 List<ConstantValue> values); | 70 List<ConstantValue> values); |
| 71 // TODO(johnniwinther): Remove the need for [compiler]. |
| 72 ConstantValue createType(Compiler compiler, |
| 73 DartType type); |
68 | 74 |
69 // We need to special case the subtype check for JavaScript constant | 75 // We need to special case the subtype check for JavaScript constant |
70 // system because an int is a double at runtime. | 76 // system because an int is a double at runtime. |
71 bool isSubtype(DartTypes types, DartType s, DartType t); | 77 bool isSubtype(DartTypes types, DartType s, DartType t); |
72 | 78 |
73 /** Returns true if the [constant] is an integer at runtime. */ | 79 /** Returns true if the [constant] is an integer at runtime. */ |
74 bool isInt(ConstantValue constant); | 80 bool isInt(ConstantValue constant); |
75 /** Returns true if the [constant] is a double at runtime. */ | 81 /** Returns true if the [constant] is a double at runtime. */ |
76 bool isDouble(ConstantValue constant); | 82 bool isDouble(ConstantValue constant); |
77 /** Returns true if the [constant] is a string at runtime. */ | 83 /** Returns true if the [constant] is a string at runtime. */ |
(...skipping 29 matching lines...) Expand all Loading... |
107 case BinaryOperatorKind.SHR: return shiftRight; | 113 case BinaryOperatorKind.SHR: return shiftRight; |
108 case BinaryOperatorKind.LT: return less; | 114 case BinaryOperatorKind.LT: return less; |
109 case BinaryOperatorKind.LTEQ: return lessEqual; | 115 case BinaryOperatorKind.LTEQ: return lessEqual; |
110 case BinaryOperatorKind.GT: return greater; | 116 case BinaryOperatorKind.GT: return greater; |
111 case BinaryOperatorKind.GTEQ: return greaterEqual; | 117 case BinaryOperatorKind.GTEQ: return greaterEqual; |
112 case BinaryOperatorKind.EQ: return equal; | 118 case BinaryOperatorKind.EQ: return equal; |
113 default: return null; | 119 default: return null; |
114 } | 120 } |
115 } | 121 } |
116 } | 122 } |
OLD | NEW |