| 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 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 addDynamicSendArgumentsToList(node, inputs); | 1878 addDynamicSendArgumentsToList(node, inputs); |
| 1879 push(new HInvokeClosure(selector, inputs)); | 1879 push(new HInvokeClosure(selector, inputs)); |
| 1880 } | 1880 } |
| 1881 | 1881 |
| 1882 void handleForeignJs(Send node) { | 1882 void handleForeignJs(Send node) { |
| 1883 Link<Node> link = node.arguments; | 1883 Link<Node> link = node.arguments; |
| 1884 // If the invoke is on foreign code, don't visit the first | 1884 // If the invoke is on foreign code, don't visit the first |
| 1885 // argument, which is the type, and the second argument, | 1885 // argument, which is the type, and the second argument, |
| 1886 // which is the foreign code. | 1886 // which is the foreign code. |
| 1887 if (link.isEmpty() || link.isEmpty()) { | 1887 if (link.isEmpty() || link.isEmpty()) { |
| 1888 compiler.cancel('At least two arguments expected', node: node.arguments); | 1888 compiler.cancel('At least two arguments expected', |
| 1889 node: node.argumentsNode); |
| 1889 } | 1890 } |
| 1890 link = link.tail.tail; | 1891 link = link.tail.tail; |
| 1891 List<HInstruction> inputs = <HInstruction>[]; | 1892 List<HInstruction> inputs = <HInstruction>[]; |
| 1892 addGenericSendArgumentsToList(link, inputs); | 1893 addGenericSendArgumentsToList(link, inputs); |
| 1893 Node type = node.arguments.head; | 1894 Node type = node.arguments.head; |
| 1894 Node literal = node.arguments.tail.head; | 1895 Node literal = node.arguments.tail.head; |
| 1895 if (literal is !StringNode || literal.dynamic.isInterpolation) { | 1896 if (literal is !StringNode || literal.dynamic.isInterpolation) { |
| 1896 compiler.cancel('JS code must be a string literal', node: literal); | 1897 compiler.cancel('JS code must be a string literal', node: literal); |
| 1897 } | 1898 } |
| 1898 if (type is !LiteralString) { | 1899 if (type is !LiteralString) { |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2676 node: node); | 2677 node: node); |
| 2677 } | 2678 } |
| 2678 visit(node.statements); | 2679 visit(node.statements); |
| 2679 // This must be the final case (otherwise "default" would be invalid), | 2680 // This must be the final case (otherwise "default" would be invalid), |
| 2680 // so we don't need to check for fallthrough. | 2681 // so we don't need to check for fallthrough. |
| 2681 return; | 2682 return; |
| 2682 } | 2683 } |
| 2683 | 2684 |
| 2684 // Recursively build the test conditions. Leaves the result on the | 2685 // Recursively build the test conditions. Leaves the result on the |
| 2685 // expression stack. | 2686 // expression stack. |
| 2686 void buildTests(Link<Node> expressions) { | 2687 void buildTests(Link<Node> remainingExpressions) { |
| 2687 // Build comparison for one case expression. | 2688 // Build comparison for one case expression. |
| 2688 void left() { | 2689 void left() { |
| 2689 Element equalsHelper = interceptors.getEqualsInterceptor(); | 2690 Element equalsHelper = interceptors.getEqualsInterceptor(); |
| 2690 HInstruction target = new HStatic(equalsHelper); | 2691 HInstruction target = new HStatic(equalsHelper); |
| 2691 add(target); | 2692 add(target); |
| 2692 visit(expressions.head); | 2693 visit(remainingExpressions.head); |
| 2693 push(new HEquals(target, pop(), expression)); | 2694 push(new HEquals(target, pop(), expression)); |
| 2694 } | 2695 } |
| 2695 | 2696 |
| 2696 // If this is the last expression, just return it. | 2697 // If this is the last expression, just return it. |
| 2697 if (expressions.tail.isEmpty()) { | 2698 if (remainingExpressions.tail.isEmpty()) { |
| 2698 left(); | 2699 left(); |
| 2699 return; | 2700 return; |
| 2700 } | 2701 } |
| 2701 | 2702 |
| 2702 void right() { | 2703 void right() { |
| 2703 buildTests(expressions.tail); | 2704 buildTests(remainingExpressions.tail); |
| 2704 } | 2705 } |
| 2705 handleLogicalAndOr(left, right, isAnd: false); | 2706 handleLogicalAndOr(left, right, isAnd: false); |
| 2706 } | 2707 } |
| 2707 | 2708 |
| 2708 buildTests(expressions); | 2709 buildTests(expressions); |
| 2709 HInstruction result = popBoolified(); | 2710 HInstruction result = popBoolified(); |
| 2710 | 2711 |
| 2711 if (node.isDefaultCase) { | 2712 if (node.isDefaultCase) { |
| 2712 // Don't actually use the condition result. | 2713 // Don't actually use the condition result. |
| 2713 // This must be final case, so don't check for abort. | 2714 // This must be final case, so don't check for abort. |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3024 false, | 3025 false, |
| 3025 <HInstruction>[target, input])); | 3026 <HInstruction>[target, input])); |
| 3026 return builder.pop(); | 3027 return builder.pop(); |
| 3027 } | 3028 } |
| 3028 | 3029 |
| 3029 HInstruction result() { | 3030 HInstruction result() { |
| 3030 flushLiterals(); | 3031 flushLiterals(); |
| 3031 return prefix; | 3032 return prefix; |
| 3032 } | 3033 } |
| 3033 } | 3034 } |
| OLD | NEW |