| 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 abstract class TreeElements { | 5 abstract class TreeElements { |
| 6 Element operator[](Node node); | 6 Element operator[](Node node); |
| 7 Selector getSelector(Send send); | 7 Selector getSelector(Send send); |
| 8 DartType getType(TypeAnnotation annotation); | 8 DartType getType(TypeAnnotation annotation); |
| 9 bool isParameterChecked(Element element); | 9 bool isParameterChecked(Element element); |
| 10 } | 10 } |
| (...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 | 1744 |
| 1745 visitConditional(Conditional node) { | 1745 visitConditional(Conditional node) { |
| 1746 node.visitChildren(this); | 1746 node.visitChildren(this); |
| 1747 } | 1747 } |
| 1748 | 1748 |
| 1749 visitStringInterpolation(StringInterpolation node) { | 1749 visitStringInterpolation(StringInterpolation node) { |
| 1750 node.visitChildren(this); | 1750 node.visitChildren(this); |
| 1751 } | 1751 } |
| 1752 | 1752 |
| 1753 visitStringInterpolationPart(StringInterpolationPart node) { | 1753 visitStringInterpolationPart(StringInterpolationPart node) { |
| 1754 SourceString name = const SourceString('toString'); | 1754 registerImplicitInvocation(const SourceString('toString'), 0); |
| 1755 LibraryElement library = enclosingElement.getLibrary(); | |
| 1756 Selector selector = new Selector.call(name, library, 0); | |
| 1757 world.registerDynamicInvocation(name, selector); | |
| 1758 node.visitChildren(this); | 1755 node.visitChildren(this); |
| 1759 } | 1756 } |
| 1760 | 1757 |
| 1761 visitBreakStatement(BreakStatement node) { | 1758 visitBreakStatement(BreakStatement node) { |
| 1762 TargetElement target; | 1759 TargetElement target; |
| 1763 if (node.target === null) { | 1760 if (node.target === null) { |
| 1764 target = statementScope.currentBreakTarget(); | 1761 target = statementScope.currentBreakTarget(); |
| 1765 if (target === null) { | 1762 if (target === null) { |
| 1766 error(node, MessageKind.NO_BREAK_TARGET); | 1763 error(node, MessageKind.NO_BREAK_TARGET); |
| 1767 return; | 1764 return; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 // TODO(lrn): Handle continues to switch cases. | 1805 // TODO(lrn): Handle continues to switch cases. |
| 1809 if (target.statement is SwitchCase) { | 1806 if (target.statement is SwitchCase) { |
| 1810 unimplemented(node, "continue to switch case"); | 1807 unimplemented(node, "continue to switch case"); |
| 1811 } | 1808 } |
| 1812 label.setContinueTarget(); | 1809 label.setContinueTarget(); |
| 1813 mapping[node.target] = label; | 1810 mapping[node.target] = label; |
| 1814 } | 1811 } |
| 1815 mapping[node] = target; | 1812 mapping[node] = target; |
| 1816 } | 1813 } |
| 1817 | 1814 |
| 1815 registerImplicitInvocation(SourceString name, int arity) { |
| 1816 Selector selector = new Selector.call(name, null, arity); |
| 1817 world.registerDynamicInvocation(name, selector); |
| 1818 } |
| 1819 |
| 1818 visitForIn(ForIn node) { | 1820 visitForIn(ForIn node) { |
| 1821 for (final name in const [ |
| 1822 const SourceString('iterator'), |
| 1823 const SourceString('next'), |
| 1824 const SourceString('hasNext')]) { |
| 1825 registerImplicitInvocation(name, 0); |
| 1826 } |
| 1819 visit(node.expression); | 1827 visit(node.expression); |
| 1820 Scope blockScope = new BlockScope(scope); | 1828 Scope blockScope = new BlockScope(scope); |
| 1821 Node declaration = node.declaredIdentifier; | 1829 Node declaration = node.declaredIdentifier; |
| 1822 visitIn(declaration, blockScope); | 1830 visitIn(declaration, blockScope); |
| 1823 visitLoopBodyIn(node, node.body, blockScope); | 1831 visitLoopBodyIn(node, node.body, blockScope); |
| 1824 | 1832 |
| 1825 // TODO(lrn): Also allow a single identifier. | 1833 // TODO(lrn): Also allow a single identifier. |
| 1826 if ((declaration is !Send || declaration.asSend().selector is !Identifier) | 1834 if ((declaration is !Send || declaration.asSend().selector is !Identifier) |
| 1827 && (declaration is !VariableDefinitions || | 1835 && (declaration is !VariableDefinitions || |
| 1828 !declaration.asVariableDefinitions().definitions.nodes.tail.isEmpty())) | 1836 !declaration.asVariableDefinitions().definitions.nodes.tail.isEmpty())) |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2817 | 2825 |
| 2818 Element localLookup(SourceString name) => library.find(name); | 2826 Element localLookup(SourceString name) => library.find(name); |
| 2819 Element lookup(SourceString name) => localLookup(name); | 2827 Element lookup(SourceString name) => localLookup(name); |
| 2820 Element lexicalLookup(SourceString name) => localLookup(name); | 2828 Element lexicalLookup(SourceString name) => localLookup(name); |
| 2821 | 2829 |
| 2822 Element add(Element newElement) { | 2830 Element add(Element newElement) { |
| 2823 throw "Cannot add an element in the top scope"; | 2831 throw "Cannot add an element in the top scope"; |
| 2824 } | 2832 } |
| 2825 String toString() => '$element'; | 2833 String toString() => '$element'; |
| 2826 } | 2834 } |
| OLD | NEW |