| 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 class Interceptors { | 5 class Interceptors { |
| 6 Compiler compiler; | 6 Compiler compiler; |
| 7 Interceptors(Compiler this.compiler); | 7 Interceptors(Compiler this.compiler); |
| 8 | 8 |
| 9 SourceString mapOperatorToMethodName(Operator op) { | 9 SourceString mapOperatorToMethodName(Operator op) { |
| 10 String name = op.source.stringValue; | 10 String name = op.source.stringValue; |
| (...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 | 1630 |
| 1631 | 1631 |
| 1632 void handleLogicalAndOr(void left(), void right(), [bool isAnd = true]) { | 1632 void handleLogicalAndOr(void left(), void right(), [bool isAnd = true]) { |
| 1633 // x && y is transformed into: | 1633 // x && y is transformed into: |
| 1634 // t0 = boolify(x); | 1634 // t0 = boolify(x); |
| 1635 // if (t0) { | 1635 // if (t0) { |
| 1636 // t1 = boolify(y); | 1636 // t1 = boolify(y); |
| 1637 // } else { | 1637 // } else { |
| 1638 // t2 = t0; | 1638 // t2 = t0; |
| 1639 // } | 1639 // } |
| 1640 // result = phi(t1, t2); | 1640 // result = phi(t1, false); |
| 1641 // | 1641 // |
| 1642 // x || y is transformed into: | 1642 // x || y is transformed into: |
| 1643 // t0 = boolify(x); | 1643 // t0 = boolify(x); |
| 1644 // if (not(t0)) { | 1644 // if (not(t0)) { |
| 1645 // t1 = boolify(y); | 1645 // t1 = boolify(y); |
| 1646 // } else { | 1646 // } else { |
| 1647 // t2 = t0; | 1647 // t2 = t0; |
| 1648 // } | 1648 // } |
| 1649 // result = phi(t1, t2); | 1649 // result = phi(t1, true); |
| 1650 HInstruction boolifiedLeft; | 1650 HInstruction boolifiedLeft; |
| 1651 HInstruction boolifiedRight; | 1651 HInstruction boolifiedRight; |
| 1652 | 1652 |
| 1653 void visitCondition() { | 1653 void visitCondition() { |
| 1654 left(); | 1654 left(); |
| 1655 boolifiedLeft = popBoolified(); | 1655 boolifiedLeft = popBoolified(); |
| 1656 HInstruction condition; | 1656 HInstruction condition; |
| 1657 if (isAnd) { | 1657 if (isAnd) { |
| 1658 condition = boolifiedLeft; | 1658 condition = boolifiedLeft; |
| 1659 } else { | 1659 } else { |
| 1660 condition = new HNot(boolifiedLeft); | 1660 condition = new HNot(boolifiedLeft); |
| 1661 add(condition); | 1661 add(condition); |
| 1662 } | 1662 } |
| 1663 stack.add(condition); | 1663 stack.add(condition); |
| 1664 } | 1664 } |
| 1665 | 1665 |
| 1666 void visitThen() { | 1666 void visitThen() { |
| 1667 right(); | 1667 right(); |
| 1668 boolifiedRight = popBoolified(); | 1668 boolifiedRight = popBoolified(); |
| 1669 } | 1669 } |
| 1670 | 1670 |
| 1671 handleIf(visitCondition, visitThen, null); | 1671 handleIf(visitCondition, visitThen, null); |
| 1672 HPhi result = new HPhi.manyInputs(null, | 1672 HPhi result = new HPhi.manyInputs(null, |
| 1673 <HInstruction>[boolifiedRight, boolifiedLeft]); | 1673 <HInstruction>[boolifiedRight, graph.addConstantBool(!isAnd)]); |
| 1674 current.addPhi(result); | 1674 current.addPhi(result); |
| 1675 stack.add(result); | 1675 stack.add(result); |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 void visitLogicalNot(Send node) { | 1678 void visitLogicalNot(Send node) { |
| 1679 assert(node.argumentsNode is Prefix); | 1679 assert(node.argumentsNode is Prefix); |
| 1680 visit(node.receiver); | 1680 visit(node.receiver); |
| 1681 HNot not = new HNot(popBoolified()); | 1681 HNot not = new HNot(popBoolified()); |
| 1682 push(not); | 1682 push(not); |
| 1683 } | 1683 } |
| (...skipping 1730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3414 <HInstruction>[target, input], | 3414 <HInstruction>[target, input], |
| 3415 HType.STRING)); | 3415 HType.STRING)); |
| 3416 return builder.pop(); | 3416 return builder.pop(); |
| 3417 } | 3417 } |
| 3418 | 3418 |
| 3419 HInstruction result(Node node) { | 3419 HInstruction result(Node node) { |
| 3420 flushLiterals(node); | 3420 flushLiterals(node); |
| 3421 return prefix; | 3421 return prefix; |
| 3422 } | 3422 } |
| 3423 } | 3423 } |
| OLD | NEW |