Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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); |
| 11 R visitBoolify(HBoolify node); | 11 R visitBoolify(HBoolify node); |
| 12 R visitBoundsCheck(HBoundsCheck node); | 12 R visitBoundsCheck(HBoundsCheck node); |
| 13 R visitDivide(HDivide node); | 13 R visitDivide(HDivide node); |
| 14 R visitEquals(HEquals node); | 14 R visitEquals(HEquals node); |
| 15 R visitExit(HExit node); | 15 R visitExit(HExit node); |
| 16 R visitForeign(HForeign node); | 16 R visitForeign(HForeign node); |
| 17 R visitForeignNew(HForeignNew); | 17 R visitForeignNew(HForeignNew); |
| 18 R visitGoto(HGoto node); | 18 R visitGoto(HGoto node); |
| 19 R visitGreater(HGreater node); | 19 R visitGreater(HGreater node); |
| 20 R visitGreaterEqual(HGreaterEqual node); | 20 R visitGreaterEqual(HGreaterEqual node); |
| 21 R visitIdentity(HIdentity node); | |
| 21 R visitIf(HIf node); | 22 R visitIf(HIf node); |
| 22 R visitIndex(HIndex node); | 23 R visitIndex(HIndex node); |
| 23 R visitIndexAssign(HIndexAssign node); | 24 R visitIndexAssign(HIndexAssign node); |
| 24 R visitIntegerCheck(HIntegerCheck node); | 25 R visitIntegerCheck(HIntegerCheck node); |
| 25 R visitInvokeDynamicMethod(HInvokeDynamicMethod node); | 26 R visitInvokeDynamicMethod(HInvokeDynamicMethod node); |
| 26 R visitInvokeDynamicGetter(HInvokeDynamicGetter node); | 27 R visitInvokeDynamicGetter(HInvokeDynamicGetter node); |
| 27 R visitInvokeDynamicSetter(HInvokeDynamicSetter node); | 28 R visitInvokeDynamicSetter(HInvokeDynamicSetter node); |
| 28 R visitInvokeInterceptor(HInvokeInterceptor node); | 29 R visitInvokeInterceptor(HInvokeInterceptor node); |
| 29 R visitInvokeStatic(HInvokeStatic node); | 30 R visitInvokeStatic(HInvokeStatic node); |
| 30 R visitLess(HLess node); | 31 R visitLess(HLess node); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 visitBoundsCheck(HBoundsCheck node) => visitCheck(node); | 201 visitBoundsCheck(HBoundsCheck node) => visitCheck(node); |
| 201 visitCheck(HCheck node) => visitInstruction(node); | 202 visitCheck(HCheck node) => visitInstruction(node); |
| 202 visitDivide(HDivide node) => visitBinaryArithmetic(node); | 203 visitDivide(HDivide node) => visitBinaryArithmetic(node); |
| 203 visitEquals(HEquals node) => visitRelational(node); | 204 visitEquals(HEquals node) => visitRelational(node); |
| 204 visitExit(HExit node) => visitControlFlow(node); | 205 visitExit(HExit node) => visitControlFlow(node); |
| 205 visitForeign(HForeign node) => visitInstruction(node); | 206 visitForeign(HForeign node) => visitInstruction(node); |
| 206 visitForeignNew(HForeignNew node) => visitForeign(node); | 207 visitForeignNew(HForeignNew node) => visitForeign(node); |
| 207 visitGoto(HGoto node) => visitControlFlow(node); | 208 visitGoto(HGoto node) => visitControlFlow(node); |
| 208 visitGreater(HGreater node) => visitRelational(node); | 209 visitGreater(HGreater node) => visitRelational(node); |
| 209 visitGreaterEqual(HGreaterEqual node) => visitRelational(node); | 210 visitGreaterEqual(HGreaterEqual node) => visitRelational(node); |
| 211 visitIdentity(HIdentity node) => visitRelational(node); | |
| 210 visitIf(HIf node) => visitConditionalBranch(node); | 212 visitIf(HIf node) => visitConditionalBranch(node); |
| 211 visitIndex(HIndex node) => visitInvokeStatic(node); | 213 visitIndex(HIndex node) => visitInvokeStatic(node); |
| 212 visitIndexAssign(HIndexAssign node) => visitInvokeStatic(node); | 214 visitIndexAssign(HIndexAssign node) => visitInvokeStatic(node); |
| 213 visitIntegerCheck(HIntegerCheck node) => visitCheck(node); | 215 visitIntegerCheck(HIntegerCheck node) => visitCheck(node); |
| 214 visitInvokeDynamicMethod(HInvokeDynamicMethod node) | 216 visitInvokeDynamicMethod(HInvokeDynamicMethod node) |
| 215 => visitInvokeDynamic(node); | 217 => visitInvokeDynamic(node); |
| 216 visitInvokeDynamicGetter(HInvokeDynamicGetter node) | 218 visitInvokeDynamicGetter(HInvokeDynamicGetter node) |
| 217 => visitInvokeDynamicField(node); | 219 => visitInvokeDynamicField(node); |
| 218 visitInvokeDynamicSetter(HInvokeDynamicSetter node) | 220 visitInvokeDynamicSetter(HInvokeDynamicSetter node) |
| 219 => visitInvokeDynamicField(node); | 221 => visitInvokeDynamicField(node); |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1622 } | 1624 } |
| 1623 } | 1625 } |
| 1624 | 1626 |
| 1625 HType computeType() { | 1627 HType computeType() { |
| 1626 builtin = computeInputsType().isNumber(); | 1628 builtin = computeInputsType().isNumber(); |
| 1627 return HType.BOOLEAN; | 1629 return HType.BOOLEAN; |
| 1628 } | 1630 } |
| 1629 | 1631 |
| 1630 HType computeDesiredInputType(HInstruction input) { | 1632 HType computeDesiredInputType(HInstruction input) { |
| 1631 // TODO(floitsch): we want the target to be a function. | 1633 // TODO(floitsch): we want the target to be a function. |
| 1632 if (input == inputs[0]) return HType.UNKNOWN; | 1634 if (input == target) return HType.UNKNOWN; |
| 1633 // For all relational operations exept HEquals, we expect to only | 1635 // For all relational operations exept HEquals, we expect to only |
| 1634 // get numbers. | 1636 // get numbers. |
| 1635 return HType.NUMBER; | 1637 return HType.NUMBER; |
| 1636 } | 1638 } |
| 1637 | 1639 |
| 1638 // A HRelational goes through the builtin operator or the top level | 1640 // A HRelational goes through the builtin operator or the top level |
| 1639 // element. Therefore, it always has the expected type. | 1641 // element. Therefore, it always has the expected type. |
| 1640 bool hasExpectedType() => true; | 1642 bool hasExpectedType() => true; |
| 1641 | 1643 |
| 1642 abstract bool evaluate(num a, num b); | 1644 abstract bool evaluate(num a, num b); |
| 1643 } | 1645 } |
| 1644 | 1646 |
| 1645 class HEquals extends HRelational { | 1647 class HEquals extends HRelational { |
| 1646 HEquals(HStatic target, HInstruction left, HInstruction right) | 1648 HEquals(HStatic target, HInstruction left, HInstruction right) |
| 1647 : super(target, left, right); | 1649 : super(target, left, right); |
| 1648 bool evaluate(num a, num b) => a == b; | 1650 bool evaluate(num a, num b) => a == b; |
| 1649 accept(HVisitor visitor) => visitor.visitEquals(this); | 1651 accept(HVisitor visitor) => visitor.visitEquals(this); |
| 1650 bool typeEquals(other) => other is HEquals; | 1652 bool typeEquals(other) => other is HEquals; |
| 1651 bool dataEquals(HInstruction other) => true; | 1653 bool dataEquals(HInstruction other) => true; |
| 1652 | 1654 |
| 1653 HType computeDesiredInputType(HInstruction input) { | 1655 HType computeDesiredInputType(HInstruction input) { |
| 1654 // TODO(floitsch): we want the target to be a function. | 1656 // TODO(floitsch): we want the target to be a function. |
| 1655 if (input == inputs[0]) return HType.UNKNOWN; | 1657 if (input == target) return HType.UNKNOWN; |
| 1656 if (left.isNumber() || right.isNumber()) return HType.NUMBER; | 1658 if (left.isNumber() || right.isNumber()) return HType.NUMBER; |
| 1657 return HType.UNKNOWN; | 1659 return HType.UNKNOWN; |
| 1658 } | 1660 } |
| 1659 } | 1661 } |
| 1660 | 1662 |
| 1663 class HIdentity extends HRelational { | |
| 1664 HIdentity(HStatic target, HInstruction left, HInstruction right) | |
| 1665 : super(target, left, right); | |
| 1666 bool evaluate(num a, num b) => a === b; | |
|
ngeoffray
2012/01/06 08:10:20
Should that be really 'num' here?
| |
| 1667 accept(HVisitor visitor) => visitor.visitIdentity(this); | |
| 1668 bool typeEquals(other) => other is HIdentity; | |
| 1669 bool dataEquals(HInstruction other) => true; | |
| 1670 | |
| 1671 HType computeType() { | |
| 1672 builtin = true; | |
| 1673 return HType.BOOLEAN; | |
| 1674 } | |
| 1675 | |
| 1676 bool hasExpectedType() => true; | |
| 1677 | |
| 1678 HType computeDesiredInputType(HInstruction input) => HType.UNKNOWN; | |
| 1679 } | |
| 1680 | |
| 1661 class HGreater extends HRelational { | 1681 class HGreater extends HRelational { |
| 1662 HGreater(HStatic target, HInstruction left, HInstruction right) | 1682 HGreater(HStatic target, HInstruction left, HInstruction right) |
| 1663 : super(target, left, right); | 1683 : super(target, left, right); |
| 1664 bool evaluate(num a, num b) => a > b; | 1684 bool evaluate(num a, num b) => a > b; |
| 1665 accept(HVisitor visitor) => visitor.visitGreater(this); | 1685 accept(HVisitor visitor) => visitor.visitGreater(this); |
| 1666 bool typeEquals(other) => other is HGreater; | 1686 bool typeEquals(other) => other is HGreater; |
| 1667 bool dataEquals(HInstruction other) => true; | 1687 bool dataEquals(HInstruction other) => true; |
| 1668 } | 1688 } |
| 1669 | 1689 |
| 1670 class HGreaterEqual extends HRelational { | 1690 class HGreaterEqual extends HRelational { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1845 HInstruction first, | 1865 HInstruction first, |
| 1846 HInstruction second) | 1866 HInstruction second) |
| 1847 : super(<HInstruction>[first, second]); | 1867 : super(<HInstruction>[first, second]); |
| 1848 toString() => operation; | 1868 toString() => operation; |
| 1849 accept(HVisitor visitor) => visitor.visitLogicalOperator(this); | 1869 accept(HVisitor visitor) => visitor.visitLogicalOperator(this); |
| 1850 HInstruction get left() => inputs[0]; | 1870 HInstruction get left() => inputs[0]; |
| 1851 HInstruction get right() => inputs[1]; | 1871 HInstruction get right() => inputs[1]; |
| 1852 HType computeType() => HType.BOOLEAN; | 1872 HType computeType() => HType.BOOLEAN; |
| 1853 bool hasExpectedType() => true; | 1873 bool hasExpectedType() => true; |
| 1854 } | 1874 } |
| OLD | NEW |