Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: lib/compiler/implementation/ssa/builder.dart

Issue 9431029: Implement interface types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 const SourceString("||") == op.source) { 1697 const SourceString("||") == op.source) {
1698 visitLogicalAndOr(node, op); 1698 visitLogicalAndOr(node, op);
1699 } else if (const SourceString("!") == op.source) { 1699 } else if (const SourceString("!") == op.source) {
1700 visitLogicalNot(node); 1700 visitLogicalNot(node);
1701 } else if (node.argumentsNode is Prefix) { 1701 } else if (node.argumentsNode is Prefix) {
1702 visitUnary(node, op); 1702 visitUnary(node, op);
1703 } else if (const SourceString("is") == op.source) { 1703 } else if (const SourceString("is") == op.source) {
1704 visit(node.receiver); 1704 visit(node.receiver);
1705 HInstruction expression = pop(); 1705 HInstruction expression = pop();
1706 Node argument = node.arguments.head; 1706 Node argument = node.arguments.head;
1707 TypeAnnotation type = argument.asTypeAnnotation(); 1707 TypeAnnotation typeAnnotation = argument.asTypeAnnotation();
1708 bool isNot = false; 1708 bool isNot = false;
1709 // TODO(ngeoffray): Duplicating pattern in resolver. We should 1709 // TODO(ngeoffray): Duplicating pattern in resolver. We should
1710 // add a new kind of node. 1710 // add a new kind of node.
1711 if (type == null) { 1711 if (typeAnnotation == null) {
1712 type = argument.asSend().receiver; 1712 typeAnnotation = argument.asSend().receiver;
1713 isNot = true; 1713 isNot = true;
1714 } 1714 }
1715 HInstruction instruction = new HIs(elements[type], expression); 1715 Type type = elements.getType(typeAnnotation);
1716 HInstruction instruction = new HIs(type, expression);
1716 if (isNot) { 1717 if (isNot) {
1717 add(instruction); 1718 add(instruction);
1718 instruction = new HNot(instruction); 1719 instruction = new HNot(instruction);
1719 } 1720 }
1720 push(instruction); 1721 push(instruction);
1721 } else { 1722 } else {
1722 visit(node.receiver); 1723 visit(node.receiver);
1723 visit(node.argumentsNode); 1724 visit(node.argumentsNode);
1724 var right = pop(); 1725 var right = pop();
1725 var left = pop(); 1726 var left = pop();
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 2736
2736 Link<Node> link = node.catchBlocks.nodes; 2737 Link<Node> link = node.catchBlocks.nodes;
2737 2738
2738 void pushCondition(CatchBlock catchBlock) { 2739 void pushCondition(CatchBlock catchBlock) {
2739 VariableDefinitions declaration = catchBlock.formals.nodes.head; 2740 VariableDefinitions declaration = catchBlock.formals.nodes.head;
2740 HInstruction condition = null; 2741 HInstruction condition = null;
2741 if (declaration.type == null) { 2742 if (declaration.type == null) {
2742 condition = graph.addConstantBool(true); 2743 condition = graph.addConstantBool(true);
2743 stack.add(condition); 2744 stack.add(condition);
2744 } else { 2745 } else {
2745 Element typeElement = elements[declaration.type]; 2746 Type type = elements.getType(declaration.type);
2746 if (typeElement == null) { 2747 if (type == null) {
2747 compiler.cancel('Catch with unresolved type', node: catchBlock); 2748 compiler.cancel('Catch with unresolved type', node: catchBlock);
2748 } 2749 }
2749 condition = new HIs(typeElement, unwrappedException, nullOk: true); 2750 condition = new HIs(type, unwrappedException, nullOk: true);
2750 push(condition); 2751 push(condition);
2751 } 2752 }
2752 } 2753 }
2753 2754
2754 void visitThen() { 2755 void visitThen() {
2755 CatchBlock catchBlock = link.head; 2756 CatchBlock catchBlock = link.head;
2756 link = link.tail; 2757 link = link.tail;
2757 localsHandler.updateLocal(elements[catchBlock.exception], 2758 localsHandler.updateLocal(elements[catchBlock.exception],
2758 unwrappedException); 2759 unwrappedException);
2759 Node trace = catchBlock.trace; 2760 Node trace = catchBlock.trace;
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2997 false, 2998 false,
2998 <HInstruction>[target, input])); 2999 <HInstruction>[target, input]));
2999 return builder.pop(); 3000 return builder.pop();
3000 } 3001 }
3001 3002
3002 HInstruction result() { 3003 HInstruction result() {
3003 flushLiterals(); 3004 flushLiterals();
3004 return prefix; 3005 return prefix;
3005 } 3006 }
3006 } 3007 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698