| Index: lib/compiler/implementation/operations.dart
|
| diff --git a/lib/compiler/implementation/operations.dart b/lib/compiler/implementation/operations.dart
|
| index 0fb34cb6d6513145fab4d2d01d3292855487c744..23d5e771b6792dfd6883204bf043a2fb836ff712 100644
|
| --- a/lib/compiler/implementation/operations.dart
|
| +++ b/lib/compiler/implementation/operations.dart
|
| @@ -63,9 +63,9 @@ interface BinaryOperation extends Operation {
|
| /**
|
| * Operations that only work if both arguments are integers.
|
| */
|
| -class BinaryIntOperation implements BinaryOperation {
|
| +class BinaryBitOperation implements BinaryOperation {
|
| bool isUserDefinable() => true;
|
| - const BinaryIntOperation();
|
| + const BinaryBitOperation();
|
| Constant fold(Constant left, Constant right) {
|
| if (left.isInt() && right.isInt()) {
|
| IntConstant leftInt = left;
|
| @@ -80,25 +80,25 @@ class BinaryIntOperation implements BinaryOperation {
|
| abstract int foldInts(int left, int right);
|
| }
|
|
|
| -class BitOrOperation extends BinaryIntOperation {
|
| +class BitOrOperation extends BinaryBitOperation {
|
| final SourceString name = const SourceString('|');
|
| const BitOrOperation();
|
| int foldInts(int left, int right) => left | right;
|
| }
|
|
|
| -class BitAndOperation extends BinaryIntOperation {
|
| +class BitAndOperation extends BinaryBitOperation {
|
| final SourceString name = const SourceString('&');
|
| const BitAndOperation();
|
| int foldInts(int left, int right) => left & right;
|
| }
|
|
|
| -class BitXorOperation extends BinaryIntOperation {
|
| +class BitXorOperation extends BinaryBitOperation {
|
| final SourceString name = const SourceString('^');
|
| const BitXorOperation();
|
| int foldInts(int left, int right) => left ^ right;
|
| }
|
|
|
| -class ShiftLeftOperation extends BinaryIntOperation {
|
| +class ShiftLeftOperation extends BinaryBitOperation {
|
| final SourceString name = const SourceString('<<');
|
| const ShiftLeftOperation();
|
| int foldInts(int left, int right) {
|
| @@ -109,7 +109,7 @@ class ShiftLeftOperation extends BinaryIntOperation {
|
| }
|
| }
|
|
|
| -class ShiftRightOperation extends BinaryIntOperation {
|
| +class ShiftRightOperation extends BinaryBitOperation {
|
| final SourceString name = const SourceString('>>');
|
| const ShiftRightOperation();
|
| int foldInts(int left, int right) {
|
| @@ -134,15 +134,15 @@ class BinaryBoolOperation implements BinaryOperation {
|
| abstract bool foldBools(bool left, bool right);
|
| }
|
|
|
| -class BooleanAnd extends BinaryBoolOperation {
|
| +class BooleanAndOperation extends BinaryBoolOperation {
|
| final SourceString name = const SourceString('&&');
|
| - const BooleanAnd();
|
| + const BooleanAndOperation();
|
| bool foldBools(bool left, bool right) => left && right;
|
| }
|
|
|
| -class BooleanOr extends BinaryBoolOperation {
|
| +class BooleanOrOperation extends BinaryBoolOperation {
|
| final SourceString name = const SourceString('||');
|
| - const BooleanOr();
|
| + const BooleanOrOperation();
|
| bool foldBools(bool left, bool right) => left || right;
|
| }
|
|
|
| @@ -299,7 +299,7 @@ class IdentityOperation implements BinaryOperation {
|
| final SourceString name = const SourceString('===');
|
| bool isUserDefinable() => false;
|
| const IdentityOperation();
|
| - Constant fold(Constant left, Constant right) {
|
| + BoolConstant fold(Constant left, Constant right) {
|
| // In order to preserve runtime semantics which says that NaN !== NaN don't
|
| // constant fold NaN === NaN. Otherwise the output depends on inlined
|
| // variables and other optimizations.
|
| @@ -307,3 +307,56 @@ class IdentityOperation implements BinaryOperation {
|
| return new BoolConstant(left == right);
|
| }
|
| }
|
| +
|
| +interface FoldingOperations {
|
| + BinaryOperation get add();
|
| + BinaryOperation get bitAnd();
|
| + UnaryOperation get bitNot();
|
| + BinaryOperation get bitOr();
|
| + BinaryOperation get bitXor();
|
| + BinaryOperation get booleanAnd();
|
| + BinaryOperation get booleanOr();
|
| + BinaryOperation get divide();
|
| + BinaryOperation get equal();
|
| + BinaryOperation get greaterEqual();
|
| + BinaryOperation get greater();
|
| + BinaryOperation get identity();
|
| + BinaryOperation get lessEqual();
|
| + BinaryOperation get less();
|
| + BinaryOperation get modulo();
|
| + BinaryOperation get multiply();
|
| + UnaryOperation get negate();
|
| + UnaryOperation get not();
|
| + BinaryOperation get shiftLeft();
|
| + BinaryOperation get shiftRight();
|
| + BinaryOperation get subtract();
|
| + BinaryOperation get truncatingDivide();
|
| +}
|
| +
|
| +/** Folding operations following the Dart semantics. */
|
| +class DartFoldingOperations implements FoldingOperations {
|
| + final add = const AddOperation();
|
| + final bitAnd = const BitAndOperation();
|
| + final bitNot = const BitNotOperation();
|
| + final bitOr = const BitOrOperation();
|
| + final bitXor = const BitXorOperation();
|
| + final booleanAnd = const BooleanAndOperation();
|
| + final booleanOr = const BooleanOrOperation();
|
| + final divide = const DivideOperation();
|
| + final equal = const EqualsOperation();
|
| + final greaterEqual = const GreaterEqualOperation();
|
| + final greater = const GreaterOperation();
|
| + final identity = const IdentityOperation();
|
| + final lessEqual = const LessEqualOperation();
|
| + final less = const LessOperation();
|
| + final modulo = const ModuloOperation();
|
| + final multiply = const MultiplyOperation();
|
| + final negate = const NegateOperation();
|
| + final not = const NotOperation();
|
| + final shiftLeft = const ShiftLeftOperation();
|
| + final shiftRight = const ShiftRightOperation();
|
| + final subtract = const SubtractOperation();
|
| + final truncatingDivide = const TruncatingDivideOperation();
|
| +
|
| + const DartFoldingOperations();
|
| +}
|
|
|