| 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 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 const SourceString("||") == op.source) { | 1709 const SourceString("||") == op.source) { |
| 1710 visitLogicalAndOr(node, op); | 1710 visitLogicalAndOr(node, op); |
| 1711 } else if (const SourceString("!") == op.source) { | 1711 } else if (const SourceString("!") == op.source) { |
| 1712 visitLogicalNot(node); | 1712 visitLogicalNot(node); |
| 1713 } else if (node.argumentsNode is Prefix) { | 1713 } else if (node.argumentsNode is Prefix) { |
| 1714 visitUnary(node, op); | 1714 visitUnary(node, op); |
| 1715 } else if (const SourceString("is") == op.source) { | 1715 } else if (const SourceString("is") == op.source) { |
| 1716 visit(node.receiver); | 1716 visit(node.receiver); |
| 1717 HInstruction expression = pop(); | 1717 HInstruction expression = pop(); |
| 1718 Node argument = node.arguments.head; | 1718 Node argument = node.arguments.head; |
| 1719 TypeAnnotation typeAnnotation = argument.asTypeAnnotation(); | 1719 TypeAnnotation type = argument.asTypeAnnotation(); |
| 1720 bool isNot = false; | 1720 bool isNot = false; |
| 1721 // TODO(ngeoffray): Duplicating pattern in resolver. We should | 1721 // TODO(ngeoffray): Duplicating pattern in resolver. We should |
| 1722 // add a new kind of node. | 1722 // add a new kind of node. |
| 1723 if (typeAnnotation == null) { | 1723 if (type == null) { |
| 1724 typeAnnotation = argument.asSend().receiver; | 1724 type = argument.asSend().receiver; |
| 1725 isNot = true; | 1725 isNot = true; |
| 1726 } | 1726 } |
| 1727 Type type = elements.getType(typeAnnotation); | 1727 HInstruction instruction = new HIs(elements[type], expression); |
| 1728 HInstruction instruction = new HIs(type, expression); | |
| 1729 if (isNot) { | 1728 if (isNot) { |
| 1730 add(instruction); | 1729 add(instruction); |
| 1731 instruction = new HNot(instruction); | 1730 instruction = new HNot(instruction); |
| 1732 } | 1731 } |
| 1733 push(instruction); | 1732 push(instruction); |
| 1734 } else { | 1733 } else { |
| 1735 visit(node.receiver); | 1734 visit(node.receiver); |
| 1736 visit(node.argumentsNode); | 1735 visit(node.argumentsNode); |
| 1737 var right = pop(); | 1736 var right = pop(); |
| 1738 var left = pop(); | 1737 var left = pop(); |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 | 2762 |
| 2764 Link<Node> link = node.catchBlocks.nodes; | 2763 Link<Node> link = node.catchBlocks.nodes; |
| 2765 | 2764 |
| 2766 void pushCondition(CatchBlock catchBlock) { | 2765 void pushCondition(CatchBlock catchBlock) { |
| 2767 VariableDefinitions declaration = catchBlock.formals.nodes.head; | 2766 VariableDefinitions declaration = catchBlock.formals.nodes.head; |
| 2768 HInstruction condition = null; | 2767 HInstruction condition = null; |
| 2769 if (declaration.type == null) { | 2768 if (declaration.type == null) { |
| 2770 condition = graph.addConstantBool(true); | 2769 condition = graph.addConstantBool(true); |
| 2771 stack.add(condition); | 2770 stack.add(condition); |
| 2772 } else { | 2771 } else { |
| 2773 Type type = elements.getType(declaration.type); | 2772 Element typeElement = elements[declaration.type]; |
| 2774 if (type == null) { | 2773 if (typeElement == null) { |
| 2775 compiler.cancel('Catch with unresolved type', node: catchBlock); | 2774 compiler.cancel('Catch with unresolved type', node: catchBlock); |
| 2776 } | 2775 } |
| 2777 condition = new HIs(type, unwrappedException, nullOk: true); | 2776 condition = new HIs(typeElement, unwrappedException, nullOk: true); |
| 2778 push(condition); | 2777 push(condition); |
| 2779 } | 2778 } |
| 2780 } | 2779 } |
| 2781 | 2780 |
| 2782 void visitThen() { | 2781 void visitThen() { |
| 2783 CatchBlock catchBlock = link.head; | 2782 CatchBlock catchBlock = link.head; |
| 2784 link = link.tail; | 2783 link = link.tail; |
| 2785 localsHandler.updateLocal(elements[catchBlock.exception], | 2784 localsHandler.updateLocal(elements[catchBlock.exception], |
| 2786 unwrappedException); | 2785 unwrappedException); |
| 2787 Node trace = catchBlock.trace; | 2786 Node trace = catchBlock.trace; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3025 false, | 3024 false, |
| 3026 <HInstruction>[target, input])); | 3025 <HInstruction>[target, input])); |
| 3027 return builder.pop(); | 3026 return builder.pop(); |
| 3028 } | 3027 } |
| 3029 | 3028 |
| 3030 HInstruction result() { | 3029 HInstruction result() { |
| 3031 flushLiterals(); | 3030 flushLiterals(); |
| 3032 return prefix; | 3031 return prefix; |
| 3033 } | 3032 } |
| 3034 } | 3033 } |
| OLD | NEW |