| 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 part of tree; | 5 part of tree; |
| 6 | 6 |
| 7 abstract class Visitor<R> { | 7 abstract class Visitor<R> { |
| 8 const Visitor(); | 8 const Visitor(); |
| 9 | 9 |
| 10 R visitNode(Node node); | 10 R visitNode(Node node); |
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 if (isImport()) { | 1694 if (isImport()) { |
| 1695 Identifier prefixNode; | 1695 Identifier prefixNode; |
| 1696 if (prefix != null) { | 1696 if (prefix != null) { |
| 1697 SourceString source = prefix.dartString.source; | 1697 SourceString source = prefix.dartString.source; |
| 1698 Token prefixToken = prefix.getBeginToken(); | 1698 Token prefixToken = prefix.getBeginToken(); |
| 1699 Token token = new StringToken.fromSource(IDENTIFIER_INFO, source, | 1699 Token token = new StringToken.fromSource(IDENTIFIER_INFO, source, |
| 1700 prefixToken.charOffset); | 1700 prefixToken.charOffset); |
| 1701 token.next = prefixToken.next; | 1701 token.next = prefixToken.next; |
| 1702 prefixNode = new Identifier(token); | 1702 prefixNode = new Identifier(token); |
| 1703 } | 1703 } |
| 1704 return new Import(tag.token, argument, prefixNode, null); | 1704 return new Import(tag.token, argument, prefixNode, null, null); |
| 1705 } else if (isLibrary()) { | 1705 } else if (isLibrary()) { |
| 1706 return new LibraryName(tag.token, argument); | 1706 return new LibraryName(tag.token, argument, null); |
| 1707 } else if (isSource()) { | 1707 } else if (isSource()) { |
| 1708 return new Part(tag.token, argument); | 1708 return new Part(tag.token, argument, null); |
| 1709 } else { | 1709 } else { |
| 1710 throw 'Unknown script tag ${tag.token.slowToString()}'; | 1710 throw 'Unknown script tag ${tag.token.slowToString()}'; |
| 1711 } | 1711 } |
| 1712 } | 1712 } |
| 1713 } | 1713 } |
| 1714 | 1714 |
| 1715 abstract class LibraryTag extends Node { | 1715 abstract class LibraryTag extends Node { |
| 1716 final Link<MetadataAnnotation> metadata; |
| 1717 |
| 1718 LibraryTag(this.metadata); |
| 1719 |
| 1716 bool get isLibraryName => false; | 1720 bool get isLibraryName => false; |
| 1717 bool get isImport => false; | 1721 bool get isImport => false; |
| 1718 bool get isExport => false; | 1722 bool get isExport => false; |
| 1719 bool get isPart => false; | 1723 bool get isPart => false; |
| 1720 bool get isPartOf => false; | 1724 bool get isPartOf => false; |
| 1721 } | 1725 } |
| 1722 | 1726 |
| 1723 class LibraryName extends LibraryTag { | 1727 class LibraryName extends LibraryTag { |
| 1724 final Expression name; | 1728 final Expression name; |
| 1725 | 1729 |
| 1726 final Token libraryKeyword; | 1730 final Token libraryKeyword; |
| 1727 | 1731 |
| 1728 LibraryName(this.libraryKeyword, this.name); | 1732 LibraryName(this.libraryKeyword, |
| 1733 this.name, |
| 1734 Link<MetadataAnnotation> metadata) |
| 1735 : super(metadata); |
| 1729 | 1736 |
| 1730 bool get isLibraryName => true; | 1737 bool get isLibraryName => true; |
| 1731 | 1738 |
| 1732 LibraryName asLibraryName() => this; | 1739 LibraryName asLibraryName() => this; |
| 1733 | 1740 |
| 1734 accept(Visitor visitor) => visitor.visitLibraryName(this); | 1741 accept(Visitor visitor) => visitor.visitLibraryName(this); |
| 1735 | 1742 |
| 1736 visitChildren(Visitor visitor) => name.accept(visitor); | 1743 visitChildren(Visitor visitor) => name.accept(visitor); |
| 1737 | 1744 |
| 1738 Token getBeginToken() => libraryKeyword; | 1745 Token getBeginToken() => libraryKeyword; |
| 1739 | 1746 |
| 1740 Token getEndToken() => name.getEndToken().next; | 1747 Token getEndToken() => name.getEndToken().next; |
| 1741 } | 1748 } |
| 1742 | 1749 |
| 1743 /** | 1750 /** |
| 1744 * This tag describes a dependency between one library and the exported | 1751 * This tag describes a dependency between one library and the exported |
| 1745 * identifiers of another library. The other library is specified by the [uri]. | 1752 * identifiers of another library. The other library is specified by the [uri]. |
| 1746 * Combinators filter away some identifiers from the other library. | 1753 * Combinators filter away some identifiers from the other library. |
| 1747 */ | 1754 */ |
| 1748 abstract class LibraryDependency extends LibraryTag { | 1755 abstract class LibraryDependency extends LibraryTag { |
| 1749 final StringNode uri; | 1756 final StringNode uri; |
| 1750 final NodeList combinators; | 1757 final NodeList combinators; |
| 1751 | 1758 |
| 1752 LibraryDependency(this.uri, this.combinators); | 1759 LibraryDependency(this.uri, |
| 1760 this.combinators, |
| 1761 Link<MetadataAnnotation> metadata) |
| 1762 : super(metadata); |
| 1753 } | 1763 } |
| 1754 | 1764 |
| 1755 /** | 1765 /** |
| 1756 * An [:import:] library tag. | 1766 * An [:import:] library tag. |
| 1757 * | 1767 * |
| 1758 * An import tag is dependency on another library where the exported identifiers | 1768 * An import tag is dependency on another library where the exported identifiers |
| 1759 * are put into the import scope of the importing library. The import scope is | 1769 * are put into the import scope of the importing library. The import scope is |
| 1760 * only visible inside the library. | 1770 * only visible inside the library. |
| 1761 */ | 1771 */ |
| 1762 class Import extends LibraryDependency { | 1772 class Import extends LibraryDependency { |
| 1763 final Identifier prefix; | 1773 final Identifier prefix; |
| 1764 final Token importKeyword; | 1774 final Token importKeyword; |
| 1765 | 1775 |
| 1766 Import(this.importKeyword, StringNode uri, | 1776 Import(this.importKeyword, StringNode uri, |
| 1767 this.prefix, NodeList combinators) | 1777 this.prefix, NodeList combinators, |
| 1768 : super(uri, combinators); | 1778 Link<MetadataAnnotation> metadata) |
| 1779 : super(uri, combinators, metadata); |
| 1769 | 1780 |
| 1770 bool get isImport => true; | 1781 bool get isImport => true; |
| 1771 | 1782 |
| 1772 Import asImport() => this; | 1783 Import asImport() => this; |
| 1773 | 1784 |
| 1774 Token get asKeyword => prefix == null ? null : uri.getEndToken().next; | 1785 Token get asKeyword => prefix == null ? null : uri.getEndToken().next; |
| 1775 | 1786 |
| 1776 accept(Visitor visitor) => visitor.visitImport(this); | 1787 accept(Visitor visitor) => visitor.visitImport(this); |
| 1777 | 1788 |
| 1778 visitChildren(Visitor visitor) { | 1789 visitChildren(Visitor visitor) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1793 /** | 1804 /** |
| 1794 * An [:export:] library tag. | 1805 * An [:export:] library tag. |
| 1795 * | 1806 * |
| 1796 * An export tag is dependency on another library where the exported identifiers | 1807 * An export tag is dependency on another library where the exported identifiers |
| 1797 * are put into the export scope of the exporting library. The export scope is | 1808 * are put into the export scope of the exporting library. The export scope is |
| 1798 * not visible inside the library. | 1809 * not visible inside the library. |
| 1799 */ | 1810 */ |
| 1800 class Export extends LibraryDependency { | 1811 class Export extends LibraryDependency { |
| 1801 final Token exportKeyword; | 1812 final Token exportKeyword; |
| 1802 | 1813 |
| 1803 Export(this.exportKeyword, StringNode uri, NodeList combinators) | 1814 Export(this.exportKeyword, |
| 1804 : super(uri, combinators); | 1815 StringNode uri, |
| 1816 NodeList combinators, |
| 1817 Link<MetadataAnnotation> metadata) |
| 1818 : super(uri, combinators, metadata); |
| 1805 | 1819 |
| 1806 bool get isExport => true; | 1820 bool get isExport => true; |
| 1807 | 1821 |
| 1808 Export asExport() => this; | 1822 Export asExport() => this; |
| 1809 | 1823 |
| 1810 accept(Visitor visitor) => visitor.visitExport(this); | 1824 accept(Visitor visitor) => visitor.visitExport(this); |
| 1811 | 1825 |
| 1812 visitChildren(Visitor visitor) { | 1826 visitChildren(Visitor visitor) { |
| 1813 uri.accept(visitor); | 1827 uri.accept(visitor); |
| 1814 if (combinators != null) combinators.accept(visitor); | 1828 if (combinators != null) combinators.accept(visitor); |
| 1815 } | 1829 } |
| 1816 | 1830 |
| 1817 Token getBeginToken() => exportKeyword; | 1831 Token getBeginToken() => exportKeyword; |
| 1818 | 1832 |
| 1819 Token getEndToken() { | 1833 Token getEndToken() { |
| 1820 if (combinators != null) return combinators.getEndToken().next; | 1834 if (combinators != null) return combinators.getEndToken().next; |
| 1821 return uri.getEndToken().next; | 1835 return uri.getEndToken().next; |
| 1822 } | 1836 } |
| 1823 } | 1837 } |
| 1824 | 1838 |
| 1825 class Part extends LibraryTag { | 1839 class Part extends LibraryTag { |
| 1826 final StringNode uri; | 1840 final StringNode uri; |
| 1827 | 1841 |
| 1828 final Token partKeyword; | 1842 final Token partKeyword; |
| 1829 | 1843 |
| 1830 Part(this.partKeyword, this.uri); | 1844 Part(this.partKeyword, this.uri, Link<MetadataAnnotation> metadata) |
| 1845 : super(metadata); |
| 1831 | 1846 |
| 1832 bool get isPart => true; | 1847 bool get isPart => true; |
| 1833 | 1848 |
| 1834 Part asPart() => this; | 1849 Part asPart() => this; |
| 1835 | 1850 |
| 1836 accept(Visitor visitor) => visitor.visitPart(this); | 1851 accept(Visitor visitor) => visitor.visitPart(this); |
| 1837 | 1852 |
| 1838 visitChildren(Visitor visitor) => uri.accept(visitor); | 1853 visitChildren(Visitor visitor) => uri.accept(visitor); |
| 1839 | 1854 |
| 1840 Token getBeginToken() => partKeyword; | 1855 Token getBeginToken() => partKeyword; |
| 1841 | 1856 |
| 1842 Token getEndToken() => uri.getEndToken().next; | 1857 Token getEndToken() => uri.getEndToken().next; |
| 1843 } | 1858 } |
| 1844 | 1859 |
| 1845 class PartOf extends Node { | 1860 class PartOf extends Node { |
| 1846 final Expression name; | 1861 final Expression name; |
| 1847 | 1862 |
| 1848 final Token partKeyword; | 1863 final Token partKeyword; |
| 1849 | 1864 |
| 1850 PartOf(this.partKeyword, this.name); | 1865 final Link<MetadataAnnotation> metadata; |
| 1866 |
| 1867 PartOf(this.partKeyword, this.name, this.metadata); |
| 1851 | 1868 |
| 1852 Token get ofKeyword => partKeyword.next; | 1869 Token get ofKeyword => partKeyword.next; |
| 1853 | 1870 |
| 1854 bool get isPartOf => true; | 1871 bool get isPartOf => true; |
| 1855 | 1872 |
| 1856 PartOf asPartOf() => this; | 1873 PartOf asPartOf() => this; |
| 1857 | 1874 |
| 1858 accept(Visitor visitor) => visitor.visitPartOf(this); | 1875 accept(Visitor visitor) => visitor.visitPartOf(this); |
| 1859 | 1876 |
| 1860 visitChildren(Visitor visitor) => name.accept(visitor); | 1877 visitChildren(Visitor visitor) => name.accept(visitor); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2060 * argument). | 2077 * argument). |
| 2061 * | 2078 * |
| 2062 * TODO(ahe): This method is controversial, the team needs to discuss | 2079 * TODO(ahe): This method is controversial, the team needs to discuss |
| 2063 * if top-level methods are acceptable and what naming conventions to | 2080 * if top-level methods are acceptable and what naming conventions to |
| 2064 * use. | 2081 * use. |
| 2065 */ | 2082 */ |
| 2066 initializerDo(Node node, f(Node node)) { | 2083 initializerDo(Node node, f(Node node)) { |
| 2067 SendSet send = node.asSendSet(); | 2084 SendSet send = node.asSendSet(); |
| 2068 if (send != null) return f(send.arguments.head); | 2085 if (send != null) return f(send.arguments.head); |
| 2069 } | 2086 } |
| OLD | NEW |