| 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 apply(value); |
| 13 } | 14 } |
| 14 | 15 |
| 15 interface BinaryOperation extends Operation { | 16 interface BinaryOperation extends Operation { |
| 16 /** Returns [:null:] if it was unable to fold the operation. */ | 17 /** Returns [:null:] if it was unable to fold the operation. */ |
| 17 Constant fold(Constant left, Constant right); | 18 Constant fold(Constant left, Constant right); |
| 19 apply(left, right); |
| 18 } | 20 } |
| 19 | 21 |
| 20 /** | 22 /** |
| 21 * A [ConstantSystem] is responsible for creating constants and folding them. | 23 * A [ConstantSystem] is responsible for creating constants and folding them. |
| 22 */ | 24 */ |
| 23 interface ConstantSystem { | 25 interface ConstantSystem { |
| 24 BinaryOperation get add; | 26 BinaryOperation get add; |
| 25 BinaryOperation get bitAnd; | 27 BinaryOperation get bitAnd; |
| 26 UnaryOperation get bitNot; | 28 UnaryOperation get bitNot; |
| 27 BinaryOperation get bitOr; | 29 BinaryOperation get bitOr; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 bool isInt(Constant constant); | 61 bool isInt(Constant constant); |
| 60 /** Returns true if the [constant] is a double at runtime. */ | 62 /** Returns true if the [constant] is a double at runtime. */ |
| 61 bool isDouble(Constant constant); | 63 bool isDouble(Constant constant); |
| 62 /** Returns true if the [constant] is a string at runtime. */ | 64 /** Returns true if the [constant] is a string at runtime. */ |
| 63 bool isString(Constant constant); | 65 bool isString(Constant constant); |
| 64 /** Returns true if the [constant] is a boolean at runtime. */ | 66 /** Returns true if the [constant] is a boolean at runtime. */ |
| 65 bool isBool(Constant constant); | 67 bool isBool(Constant constant); |
| 66 /** Returns true if the [constant] is null at runtime. */ | 68 /** Returns true if the [constant] is null at runtime. */ |
| 67 bool isNull(Constant constant); | 69 bool isNull(Constant constant); |
| 68 } | 70 } |
| OLD | NEW |