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 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1713 const SourceString("||") == op.source) { | 1713 const SourceString("||") == op.source) { |
1714 visitLogicalAndOr(node, op); | 1714 visitLogicalAndOr(node, op); |
1715 } else if (const SourceString("!") == op.source) { | 1715 } else if (const SourceString("!") == op.source) { |
1716 visitLogicalNot(node); | 1716 visitLogicalNot(node); |
1717 } else if (node.argumentsNode is Prefix) { | 1717 } else if (node.argumentsNode is Prefix) { |
1718 visitUnary(node, op); | 1718 visitUnary(node, op); |
1719 } else if (const SourceString("is") == op.source) { | 1719 } else if (const SourceString("is") == op.source) { |
1720 visit(node.receiver); | 1720 visit(node.receiver); |
1721 HInstruction expression = pop(); | 1721 HInstruction expression = pop(); |
1722 Node argument = node.arguments.head; | 1722 Node argument = node.arguments.head; |
1723 TypeAnnotation type = argument.asTypeAnnotation(); | 1723 TypeAnnotation typeAnnotation = argument.asTypeAnnotation(); |
1724 bool isNot = false; | 1724 bool isNot = false; |
1725 // TODO(ngeoffray): Duplicating pattern in resolver. We should | 1725 // TODO(ngeoffray): Duplicating pattern in resolver. We should |
1726 // add a new kind of node. | 1726 // add a new kind of node. |
1727 if (type == null) { | 1727 if (typeAnnotation == null) { |
1728 type = argument.asSend().receiver; | 1728 typeAnnotation = argument.asSend().receiver; |
1729 isNot = true; | 1729 isNot = true; |
1730 } | 1730 } |
1731 HInstruction instruction = new HIs(elements[type], expression); | 1731 Type type = elements.getType(typeAnnotation); |
| 1732 HInstruction instruction = new HIs(type, expression); |
1732 if (isNot) { | 1733 if (isNot) { |
1733 add(instruction); | 1734 add(instruction); |
1734 instruction = new HNot(instruction); | 1735 instruction = new HNot(instruction); |
1735 } | 1736 } |
1736 push(instruction); | 1737 push(instruction); |
1737 } else { | 1738 } else { |
1738 visit(node.receiver); | 1739 visit(node.receiver); |
1739 visit(node.argumentsNode); | 1740 visit(node.argumentsNode); |
1740 var right = pop(); | 1741 var right = pop(); |
1741 var left = pop(); | 1742 var left = pop(); |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2777 | 2778 |
2778 Link<Node> link = node.catchBlocks.nodes; | 2779 Link<Node> link = node.catchBlocks.nodes; |
2779 | 2780 |
2780 void pushCondition(CatchBlock catchBlock) { | 2781 void pushCondition(CatchBlock catchBlock) { |
2781 VariableDefinitions declaration = catchBlock.formals.nodes.head; | 2782 VariableDefinitions declaration = catchBlock.formals.nodes.head; |
2782 HInstruction condition = null; | 2783 HInstruction condition = null; |
2783 if (declaration.type == null) { | 2784 if (declaration.type == null) { |
2784 condition = graph.addConstantBool(true); | 2785 condition = graph.addConstantBool(true); |
2785 stack.add(condition); | 2786 stack.add(condition); |
2786 } else { | 2787 } else { |
2787 Element typeElement = elements[declaration.type]; | 2788 Type type = elements.getType(declaration.type); |
2788 if (typeElement == null) { | 2789 if (type == null) { |
2789 compiler.cancel('Catch with unresolved type', node: catchBlock); | 2790 compiler.cancel('Catch with unresolved type', node: catchBlock); |
2790 } | 2791 } |
2791 condition = new HIs(typeElement, unwrappedException, nullOk: true); | 2792 condition = new HIs(type, unwrappedException, nullOk: true); |
2792 push(condition); | 2793 push(condition); |
2793 } | 2794 } |
2794 } | 2795 } |
2795 | 2796 |
2796 void visitThen() { | 2797 void visitThen() { |
2797 CatchBlock catchBlock = link.head; | 2798 CatchBlock catchBlock = link.head; |
2798 link = link.tail; | 2799 link = link.tail; |
2799 localsHandler.updateLocal(elements[catchBlock.exception], | 2800 localsHandler.updateLocal(elements[catchBlock.exception], |
2800 unwrappedException); | 2801 unwrappedException); |
2801 Node trace = catchBlock.trace; | 2802 Node trace = catchBlock.trace; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3039 false, | 3040 false, |
3040 <HInstruction>[target, input])); | 3041 <HInstruction>[target, input])); |
3041 return builder.pop(); | 3042 return builder.pop(); |
3042 } | 3043 } |
3043 | 3044 |
3044 HInstruction result() { | 3045 HInstruction result() { |
3045 flushLiterals(); | 3046 flushLiterals(); |
3046 return prefix; | 3047 return prefix; |
3047 } | 3048 } |
3048 } | 3049 } |
OLD | NEW |