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 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1702 addGenericSendArgumentsToList(link, inputs); | 1702 addGenericSendArgumentsToList(link, inputs); |
1703 LiteralString type = node.arguments.head; | 1703 LiteralString type = node.arguments.head; |
1704 LiteralString literal = node.arguments.tail.head; | 1704 LiteralString literal = node.arguments.tail.head; |
1705 compiler.ensure(literal is LiteralString); | 1705 compiler.ensure(literal is LiteralString); |
1706 compiler.ensure(type is LiteralString); | 1706 compiler.ensure(type is LiteralString); |
1707 push(new HForeign(literal.dartString, type.dartString, inputs)); | 1707 push(new HForeign(literal.dartString, type.dartString, inputs)); |
1708 break; | 1708 break; |
1709 case "UNINTERCEPTED": | 1709 case "UNINTERCEPTED": |
1710 Link<Node> link = node.arguments; | 1710 Link<Node> link = node.arguments; |
1711 if (!link.tail.isEmpty()) { | 1711 if (!link.tail.isEmpty()) { |
1712 compiler.cancel('More than one expression in UNINTERCEPTED()'); | 1712 compiler.cancel( |
1713 'More than one expression in UNINTERCEPTED()', node: node); | |
1713 } | 1714 } |
1714 Expression expression = link.head; | 1715 Expression expression = link.head; |
1715 disableMethodInterception(); | 1716 disableMethodInterception(); |
1716 visit(expression); | 1717 visit(expression); |
1717 enableMethodInterception(); | 1718 enableMethodInterception(); |
1718 break; | 1719 break; |
1719 case "JS_HAS_EQUALS": | 1720 case "JS_HAS_EQUALS": |
1720 List<HInstruction> inputs = <HInstruction>[]; | 1721 List<HInstruction> inputs = <HInstruction>[]; |
1721 if (!node.arguments.tail.isEmpty()) { | 1722 if (!node.arguments.tail.isEmpty()) { |
1722 compiler.cancel('More than one expression in JS_HAS_EQUALS()'); | 1723 compiler.cancel( |
1724 'More than one expression in JS_HAS_EQUALS()', node: node); | |
1723 } | 1725 } |
1724 addGenericSendArgumentsToList(node.arguments, inputs); | 1726 addGenericSendArgumentsToList(node.arguments, inputs); |
1725 String name = compiler.namer.instanceMethodName( | 1727 String name = compiler.namer.instanceMethodName( |
1726 Namer.OPERATOR_EQUALS, 1); | 1728 Namer.OPERATOR_EQUALS, 1); |
1727 push(new HForeign(new DartString.literal('!!#.$name'), | 1729 push(new HForeign(new DartString.literal('!!#.$name'), |
1728 const LiteralDartString('bool'), | 1730 const LiteralDartString('bool'), |
1729 inputs)); | 1731 inputs)); |
1730 break; | 1732 break; |
1733 case "JS_CURRENT_ISOLATE": | |
1734 if (!node.arguments.isEmpty()) { | |
kasperl
2012/03/16 11:06:42
There's sooo much code in these cases. Maybe this
ngeoffray
2012/03/19 10:29:58
Done.
| |
1735 compiler.cancel( | |
1736 'Too many arguments to JS_CURRENT_ISOLATE', node: node); | |
1737 } | |
1738 | |
1739 if (!compiler.hasIsolateSupport()) { | |
1740 // If the isolate library is not used, we just generate code | |
1741 // to fetch the Leg's current isolate. | |
1742 String name = compiler.namer.CURRENT_ISOLATE; | |
1743 push(new HForeign(new DartString.literal(name), | |
1744 const LiteralDartString('bool'), | |
kasperl
2012/03/16 11:06:42
Not sure I understand the use of bool here.
ngeoffray
2012/03/19 10:29:58
Typo, replaced with 'var'.
| |
1745 <HInstruction>[])); | |
1746 } else { | |
1747 // Call a helper method from the isolate library. | |
kasperl
2012/03/16 11:06:42
Maybe explain here why you cannot just grab hold o
ngeoffray
2012/03/19 10:29:58
Done.
| |
1748 Element element = compiler.isolateLibrary.find( | |
1749 const SourceString('_currentIsolate')); | |
1750 if (element === null) { | |
1751 compiler.cancel( | |
1752 'Isolate library and compiler mismatch', node: node); | |
1753 } | |
1754 HStatic target = new HStatic(element); | |
1755 add(target); | |
1756 push(new HInvokeStatic(Selector.INVOCATION_0, | |
1757 <HInstruction>[target])); | |
1758 } | |
1759 break; | |
1760 case "JS_CALL_IN_ISOLATE": | |
1761 Link<Node> link = node.arguments; | |
1762 if (!compiler.hasIsolateSupport()) { | |
1763 // If the isolate library is not used, we just invoke the | |
1764 // closure. | |
1765 visit(link.tail.head); | |
1766 push(new HInvokeClosure(Selector.INVOCATION_0, | |
1767 <HInstruction>[pop()])); | |
1768 } else { | |
1769 // Call a helper method from the isolate library. | |
1770 Element element = compiler.isolateLibrary.find( | |
1771 const SourceString('_callInIsolate')); | |
1772 if (element === null) { | |
1773 compiler.cancel( | |
1774 'Isolate library and compiler mismatch', node: node); | |
1775 } | |
1776 HStatic target = new HStatic(element); | |
1777 add(target); | |
1778 List<HInstruction> inputs = <HInstruction>[target]; | |
1779 addGenericSendArgumentsToList(link, inputs); | |
1780 push(new HInvokeStatic(Selector.INVOCATION_0, inputs)); | |
1781 } | |
1782 break; | |
1731 case "native": | 1783 case "native": |
1732 native.handleSsaNative(this, node); | 1784 native.handleSsaNative(this, node); |
1733 break; | 1785 break; |
1734 default: | 1786 default: |
1735 throw "Unknown foreign: ${node.selector}"; | 1787 throw "Unknown foreign: ${node.selector}"; |
1736 } | 1788 } |
1737 } | 1789 } |
1738 | 1790 |
1739 visitSuperSend(Send node) { | 1791 visitSuperSend(Send node) { |
1740 Selector selector = elements.getSelector(node); | 1792 Selector selector = elements.getSelector(node); |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2520 buildBody() { | 2572 buildBody() { |
2521 // TODO(lrn): Make sure to take continue into account. | 2573 // TODO(lrn): Make sure to take continue into account. |
2522 visit(body); | 2574 visit(body); |
2523 if (isAborted()) { | 2575 if (isAborted()) { |
2524 compiler.reportWarning(body, "aborting loop body"); | 2576 compiler.reportWarning(body, "aborting loop body"); |
2525 } | 2577 } |
2526 } | 2578 } |
2527 handleIf(buildBody, null); | 2579 handleIf(buildBody, null); |
2528 } | 2580 } |
2529 } | 2581 } |
OLD | NEW |