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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 abstract class Operation { | 7 abstract class Operation { |
8 SourceString get name; | 8 SourceString get name; |
9 bool isUserDefinable(); | 9 bool isUserDefinable(); |
10 } | 10 } |
(...skipping 30 matching lines...) Expand all Loading... |
41 BinaryOperation get less; | 41 BinaryOperation get less; |
42 BinaryOperation get modulo; | 42 BinaryOperation get modulo; |
43 BinaryOperation get multiply; | 43 BinaryOperation get multiply; |
44 UnaryOperation get negate; | 44 UnaryOperation get negate; |
45 UnaryOperation get not; | 45 UnaryOperation get not; |
46 BinaryOperation get shiftLeft; | 46 BinaryOperation get shiftLeft; |
47 BinaryOperation get shiftRight; | 47 BinaryOperation get shiftRight; |
48 BinaryOperation get subtract; | 48 BinaryOperation get subtract; |
49 BinaryOperation get truncatingDivide; | 49 BinaryOperation get truncatingDivide; |
50 | 50 |
| 51 const ConstantSystem(); |
| 52 |
51 Constant createInt(int i); | 53 Constant createInt(int i); |
52 Constant createDouble(double d); | 54 Constant createDouble(double d); |
53 // We need a diagnostic node to report errors in case the string is malformed. | 55 // We need a diagnostic node to report errors in case the string is malformed. |
54 Constant createString(DartString string, Node diagnosticNode); | 56 Constant createString(DartString string, Node diagnosticNode); |
55 Constant createBool(bool value); | 57 Constant createBool(bool value); |
56 Constant createNull(); | 58 Constant createNull(); |
57 | 59 |
58 // We need to special case the subtype check for JavaScript constant | 60 // We need to special case the subtype check for JavaScript constant |
59 // system because an int is a double at runtime. | 61 // system because an int is a double at runtime. |
60 bool isSubtype(Compiler compiler, DartType s, DartType t); | 62 bool isSubtype(Compiler compiler, DartType s, DartType t); |
61 | 63 |
62 /** Returns true if the [constant] is an integer at runtime. */ | 64 /** Returns true if the [constant] is an integer at runtime. */ |
63 bool isInt(Constant constant); | 65 bool isInt(Constant constant); |
64 /** Returns true if the [constant] is a double at runtime. */ | 66 /** Returns true if the [constant] is a double at runtime. */ |
65 bool isDouble(Constant constant); | 67 bool isDouble(Constant constant); |
66 /** Returns true if the [constant] is a string at runtime. */ | 68 /** Returns true if the [constant] is a string at runtime. */ |
67 bool isString(Constant constant); | 69 bool isString(Constant constant); |
68 /** Returns true if the [constant] is a boolean at runtime. */ | 70 /** Returns true if the [constant] is a boolean at runtime. */ |
69 bool isBool(Constant constant); | 71 bool isBool(Constant constant); |
70 /** Returns true if the [constant] is null at runtime. */ | 72 /** Returns true if the [constant] is null at runtime. */ |
71 bool isNull(Constant constant); | 73 bool isNull(Constant constant); |
| 74 |
| 75 Operation lookupUnary(SourceString operator) { |
| 76 if (operator == const SourceString('-')) return negate; |
| 77 if (operator == const SourceString('~')) return bitNot; |
| 78 return null; |
| 79 } |
72 } | 80 } |
OLD | NEW |