| 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 interface Operation { | 5 interface Operation { |
| 6 final SourceString name; | 6 final SourceString name; |
| 7 bool isUserDefinable(); | 7 bool isUserDefinable(); |
| 8 } | 8 } |
| 9 | 9 |
| 10 interface UnaryOperation extends Operation { | 10 interface UnaryOperation extends Operation { |
| 11 /** Returns [:null:] if it was unable to fold the operation. */ | 11 /** Returns [:null:] if it was unable to fold the operation. */ |
| 12 Constant fold(Constant constant); | 12 Constant fold(Constant constant); |
| 13 } | 13 } |
| 14 | 14 |
| 15 interface BinaryOperation extends Operation { | 15 interface BinaryOperation extends Operation { |
| 16 /** Returns [:null:] if it was unable to fold the operation. */ | 16 /** Returns [:null:] if it was unable to fold the operation. */ |
| 17 Constant fold(Constant left, Constant right); | 17 Constant fold(Constant left, Constant right); |
| 18 } | 18 } |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * A [ConstantSystem] is responsible for creating constants and folding them. | 21 * A [ConstantSystem] is responsible for creating constants and folding them. |
| 22 */ | 22 */ |
| 23 interface ConstantSystem { | 23 interface ConstantSystem { |
| 24 BinaryOperation get add(); | 24 BinaryOperation get add; |
| 25 BinaryOperation get bitAnd(); | 25 BinaryOperation get bitAnd; |
| 26 UnaryOperation get bitNot(); | 26 UnaryOperation get bitNot; |
| 27 BinaryOperation get bitOr(); | 27 BinaryOperation get bitOr; |
| 28 BinaryOperation get bitXor(); | 28 BinaryOperation get bitXor; |
| 29 BinaryOperation get booleanAnd(); | 29 BinaryOperation get booleanAnd; |
| 30 BinaryOperation get booleanOr(); | 30 BinaryOperation get booleanOr; |
| 31 BinaryOperation get divide(); | 31 BinaryOperation get divide; |
| 32 BinaryOperation get equal(); | 32 BinaryOperation get equal; |
| 33 BinaryOperation get greaterEqual(); | 33 BinaryOperation get greaterEqual; |
| 34 BinaryOperation get greater(); | 34 BinaryOperation get greater; |
| 35 BinaryOperation get identity(); | 35 BinaryOperation get identity; |
| 36 BinaryOperation get lessEqual(); | 36 BinaryOperation get lessEqual; |
| 37 BinaryOperation get less(); | 37 BinaryOperation get less; |
| 38 BinaryOperation get modulo(); | 38 BinaryOperation get modulo; |
| 39 BinaryOperation get multiply(); | 39 BinaryOperation get multiply; |
| 40 UnaryOperation get negate(); | 40 UnaryOperation get negate; |
| 41 UnaryOperation get not(); | 41 UnaryOperation get not; |
| 42 BinaryOperation get shiftLeft(); | 42 BinaryOperation get shiftLeft; |
| 43 BinaryOperation get shiftRight(); | 43 BinaryOperation get shiftRight; |
| 44 BinaryOperation get subtract(); | 44 BinaryOperation get subtract; |
| 45 BinaryOperation get truncatingDivide(); | 45 BinaryOperation get truncatingDivide; |
| 46 | 46 |
| 47 Constant createInt(int i); | 47 Constant createInt(int i); |
| 48 Constant createDouble(double d); | 48 Constant createDouble(double d); |
| 49 // We need a diagnostic node to report errors in case the string is malformed. | 49 // We need a diagnostic node to report errors in case the string is malformed. |
| 50 Constant createString(DartString string, Node diagnosticNode); | 50 Constant createString(DartString string, Node diagnosticNode); |
| 51 Constant createBool(bool value); | 51 Constant createBool(bool value); |
| 52 Constant createNull(); | 52 Constant createNull(); |
| 53 | 53 |
| 54 /** Returns true if the [constant] is an integer at runtime. */ | 54 /** Returns true if the [constant] is an integer at runtime. */ |
| 55 bool isInt(Constant constant); | 55 bool isInt(Constant constant); |
| 56 /** Returns true if the [constant] is a double at runtime. */ | 56 /** Returns true if the [constant] is a double at runtime. */ |
| 57 bool isDouble(Constant constant); | 57 bool isDouble(Constant constant); |
| 58 /** Returns true if the [constant] is a string at runtime. */ | 58 /** Returns true if the [constant] is a string at runtime. */ |
| 59 bool isString(Constant constant); | 59 bool isString(Constant constant); |
| 60 /** Returns true if the [constant] is a boolean at runtime. */ | 60 /** Returns true if the [constant] is a boolean at runtime. */ |
| 61 bool isBool(Constant constant); | 61 bool isBool(Constant constant); |
| 62 /** Returns true if the [constant] is null at runtime. */ | 62 /** Returns true if the [constant] is null at runtime. */ |
| 63 bool isNull(Constant constant); | 63 bool isNull(Constant constant); |
| 64 } | 64 } |
| OLD | NEW |