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