| 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 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 addDynamicSendArgumentsToList(node, inputs); | 1882 addDynamicSendArgumentsToList(node, inputs); |
| 1883 push(new HInvokeClosure(selector, inputs)); | 1883 push(new HInvokeClosure(selector, inputs)); |
| 1884 } | 1884 } |
| 1885 | 1885 |
| 1886 void handleForeignJs(Send node) { | 1886 void handleForeignJs(Send node) { |
| 1887 Link<Node> link = node.arguments; | 1887 Link<Node> link = node.arguments; |
| 1888 // If the invoke is on foreign code, don't visit the first | 1888 // If the invoke is on foreign code, don't visit the first |
| 1889 // argument, which is the type, and the second argument, | 1889 // argument, which is the type, and the second argument, |
| 1890 // which is the foreign code. | 1890 // which is the foreign code. |
| 1891 if (link.isEmpty() || link.isEmpty()) { | 1891 if (link.isEmpty() || link.isEmpty()) { |
| 1892 compiler.cancel('At least two arguments expected', node: node.arguments); | 1892 compiler.cancel('At least two arguments expected', |
| 1893 node: node.argumentsNode); |
| 1893 } | 1894 } |
| 1894 link = link.tail.tail; | 1895 link = link.tail.tail; |
| 1895 List<HInstruction> inputs = <HInstruction>[]; | 1896 List<HInstruction> inputs = <HInstruction>[]; |
| 1896 addGenericSendArgumentsToList(link, inputs); | 1897 addGenericSendArgumentsToList(link, inputs); |
| 1897 Node type = node.arguments.head; | 1898 Node type = node.arguments.head; |
| 1898 Node literal = node.arguments.tail.head; | 1899 Node literal = node.arguments.tail.head; |
| 1899 if (literal is !StringNode || literal.dynamic.isInterpolation) { | 1900 if (literal is !StringNode || literal.dynamic.isInterpolation) { |
| 1900 compiler.cancel('JS code must be a string literal', node: literal); | 1901 compiler.cancel('JS code must be a string literal', node: literal); |
| 1901 } | 1902 } |
| 1902 if (type is !LiteralString) { | 1903 if (type is !LiteralString) { |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2691 node: node); | 2692 node: node); |
| 2692 } | 2693 } |
| 2693 visit(node.statements); | 2694 visit(node.statements); |
| 2694 // This must be the final case (otherwise "default" would be invalid), | 2695 // This must be the final case (otherwise "default" would be invalid), |
| 2695 // so we don't need to check for fallthrough. | 2696 // so we don't need to check for fallthrough. |
| 2696 return; | 2697 return; |
| 2697 } | 2698 } |
| 2698 | 2699 |
| 2699 // Recursively build the test conditions. Leaves the result on the | 2700 // Recursively build the test conditions. Leaves the result on the |
| 2700 // expression stack. | 2701 // expression stack. |
| 2701 void buildTests(Link<Node> expressions) { | 2702 void buildTests(Link<Node> remainingExpressions) { |
| 2702 // Build comparison for one case expression. | 2703 // Build comparison for one case expression. |
| 2703 void left() { | 2704 void left() { |
| 2704 Element equalsHelper = interceptors.getEqualsInterceptor(); | 2705 Element equalsHelper = interceptors.getEqualsInterceptor(); |
| 2705 HInstruction target = new HStatic(equalsHelper); | 2706 HInstruction target = new HStatic(equalsHelper); |
| 2706 add(target); | 2707 add(target); |
| 2707 visit(expressions.head); | 2708 visit(remainingExpressions.head); |
| 2708 push(new HEquals(target, pop(), expression)); | 2709 push(new HEquals(target, pop(), expression)); |
| 2709 } | 2710 } |
| 2710 | 2711 |
| 2711 // If this is the last expression, just return it. | 2712 // If this is the last expression, just return it. |
| 2712 if (expressions.tail.isEmpty()) { | 2713 if (remainingExpressions.tail.isEmpty()) { |
| 2713 left(); | 2714 left(); |
| 2714 return; | 2715 return; |
| 2715 } | 2716 } |
| 2716 | 2717 |
| 2717 void right() { | 2718 void right() { |
| 2718 buildTests(expressions.tail); | 2719 buildTests(remainingExpressions.tail); |
| 2719 } | 2720 } |
| 2720 handleLogicalAndOr(left, right, isAnd: false); | 2721 handleLogicalAndOr(left, right, isAnd: false); |
| 2721 } | 2722 } |
| 2722 | 2723 |
| 2723 buildTests(expressions); | 2724 buildTests(expressions); |
| 2724 HInstruction result = popBoolified(); | 2725 HInstruction result = popBoolified(); |
| 2725 | 2726 |
| 2726 if (node.isDefaultCase) { | 2727 if (node.isDefaultCase) { |
| 2727 // Don't actually use the condition result. | 2728 // Don't actually use the condition result. |
| 2728 // This must be final case, so don't check for abort. | 2729 // This must be final case, so don't check for abort. |
| (...skipping 310 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 |