| 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 HVisitor<R> { | 5 interface HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBitAnd(HBitAnd node); | 7 R visitBitAnd(HBitAnd node); |
| 8 R visitBitNot(HBitNot node); | 8 R visitBitNot(HBitNot node); |
| 9 R visitBitOr(HBitOr node); | 9 R visitBitOr(HBitOr node); |
| 10 R visitBitXor(HBitXor node); | 10 R visitBitXor(HBitXor node); |
| (...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 clearAllSideEffects(); | 1374 clearAllSideEffects(); |
| 1375 setUseGvn(); | 1375 setUseGvn(); |
| 1376 } else { | 1376 } else { |
| 1377 setAllSideEffects(); | 1377 setAllSideEffects(); |
| 1378 } | 1378 } |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 bool get builtin() => left.isNumber() && right.isNumber(); | 1381 bool get builtin() => left.isNumber() && right.isNumber(); |
| 1382 | 1382 |
| 1383 HType computeTypeFromInputTypes() { | 1383 HType computeTypeFromInputTypes() { |
| 1384 if (left.isInteger() && right.isInteger()) return left.propagatedType; | 1384 if (left.isInteger() && right.isInteger()) return HType.INTEGER; |
| 1385 if (left.isNumber()) { | 1385 if (left.isNumber()) { |
| 1386 if (left.isDouble() || right.isDouble()) return HType.DOUBLE; | 1386 if (left.isDouble() || right.isDouble()) return HType.DOUBLE; |
| 1387 return HType.NUMBER; | 1387 return HType.NUMBER; |
| 1388 } | 1388 } |
| 1389 return HType.UNKNOWN; | 1389 return HType.UNKNOWN; |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1392 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1393 // If the desired output type should be an integer we want to get two | 1393 // If the desired output type should be an integer we want to get two |
| 1394 // integers as arguments. | 1394 // integers as arguments. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 } | 1551 } |
| 1552 | 1552 |
| 1553 class HShiftLeft extends HBinaryBitOp { | 1553 class HShiftLeft extends HBinaryBitOp { |
| 1554 HShiftLeft(HStatic target, HInstruction left, HInstruction right) | 1554 HShiftLeft(HStatic target, HInstruction left, HInstruction right) |
| 1555 : super(target, left, right); | 1555 : super(target, left, right); |
| 1556 accept(HVisitor visitor) => visitor.visitShiftLeft(this); | 1556 accept(HVisitor visitor) => visitor.visitShiftLeft(this); |
| 1557 | 1557 |
| 1558 // Shift left cannot be mapped to the native operator unless the | 1558 // Shift left cannot be mapped to the native operator unless the |
| 1559 // shift count is guaranteed to be an integer in the [0,31] range. | 1559 // shift count is guaranteed to be an integer in the [0,31] range. |
| 1560 bool get builtin() { | 1560 bool get builtin() { |
| 1561 if (!left.isInteger() || !right.isConstantInteger()) return false; | 1561 if (!left.isNumber() || !right.isConstantInteger()) return false; |
| 1562 HConstant rightConstant = right; | 1562 HConstant rightConstant = right; |
| 1563 IntConstant intConstant = rightConstant.constant; | 1563 IntConstant intConstant = rightConstant.constant; |
| 1564 int count = intConstant.value; | 1564 int count = intConstant.value; |
| 1565 return count >= 0 && count <= 31; | 1565 return count >= 0 && count <= 31; |
| 1566 } | 1566 } |
| 1567 | 1567 |
| 1568 ShiftLeftOperation get operation() => const ShiftLeftOperation(); | 1568 ShiftLeftOperation get operation() => const ShiftLeftOperation(); |
| 1569 int typeCode() => 11; | 1569 int typeCode() => 11; |
| 1570 bool typeEquals(other) => other is HShiftLeft; | 1570 bool typeEquals(other) => other is HShiftLeft; |
| 1571 bool dataEquals(HInstruction other) => true; | 1571 bool dataEquals(HInstruction other) => true; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 NegateOperation get operation() => const NegateOperation(); | 1665 NegateOperation get operation() => const NegateOperation(); |
| 1666 int typeCode() => 16; | 1666 int typeCode() => 16; |
| 1667 bool typeEquals(other) => other is HNegate; | 1667 bool typeEquals(other) => other is HNegate; |
| 1668 bool dataEquals(HInstruction other) => true; | 1668 bool dataEquals(HInstruction other) => true; |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 class HBitNot extends HInvokeUnary { | 1671 class HBitNot extends HInvokeUnary { |
| 1672 HBitNot(HStatic target, HInstruction input) : super(target, input); | 1672 HBitNot(HStatic target, HInstruction input) : super(target, input); |
| 1673 accept(HVisitor visitor) => visitor.visitBitNot(this); | 1673 accept(HVisitor visitor) => visitor.visitBitNot(this); |
| 1674 | 1674 |
| 1675 bool get builtin() => operand.isInteger(); | |
| 1676 | |
| 1677 HType computeTypeFromInputTypes() { | 1675 HType computeTypeFromInputTypes() { |
| 1678 // All bitwise operations on primitive types either produce an | 1676 // All bitwise operations on primitive types either produce an |
| 1679 // integer or throw an error. | 1677 // integer or throw an error. |
| 1680 if (operand.isPrimitive()) return HType.INTEGER; | 1678 if (operand.isPrimitive()) return HType.INTEGER; |
| 1681 return HType.UNKNOWN; | 1679 return HType.UNKNOWN; |
| 1682 } | 1680 } |
| 1683 | 1681 |
| 1684 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1682 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1685 // Bit operations only work on integers. If there is no desired output | 1683 // Bit operations only work on integers. If there is no desired output |
| 1686 // type or if it as a number we want to get an integer as input. | 1684 // type or if it as a number we want to get an integer as input. |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2620 HBasicBlock get start() => expression.start; | 2618 HBasicBlock get start() => expression.start; |
| 2621 HBasicBlock get end() { | 2619 HBasicBlock get end() { |
| 2622 // We don't create a switch block if there are no cases. | 2620 // We don't create a switch block if there are no cases. |
| 2623 assert(!statements.isEmpty()); | 2621 assert(!statements.isEmpty()); |
| 2624 return statements.last().end; | 2622 return statements.last().end; |
| 2625 } | 2623 } |
| 2626 | 2624 |
| 2627 bool accept(HStatementInformationVisitor visitor) => | 2625 bool accept(HStatementInformationVisitor visitor) => |
| 2628 visitor.visitSwitchInfo(this); | 2626 visitor.visitSwitchInfo(this); |
| 2629 } | 2627 } |
| OLD | NEW |