Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: lib/compiler/implementation/tree/nodes.dart

Issue 10990060: Added support for exports and re-exports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase (again) Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 Visitor<R> { 5 abstract class Visitor<R> {
6 const Visitor(); 6 const Visitor();
7 7
8 abstract R visitNode(Node node); 8 abstract R visitNode(Node node);
9 9
10 R visitBlock(Block node) => visitStatement(node); 10 R visitBlock(Block node) => visitStatement(node);
(...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 1673
1674 accept(Visitor visitor) => visitor.visitLibraryName(this); 1674 accept(Visitor visitor) => visitor.visitLibraryName(this);
1675 1675
1676 visitChildren(Visitor visitor) => name.accept(visitor); 1676 visitChildren(Visitor visitor) => name.accept(visitor);
1677 1677
1678 Token getBeginToken() => libraryKeyword; 1678 Token getBeginToken() => libraryKeyword;
1679 1679
1680 Token getEndToken() => name.getEndToken().next; 1680 Token getEndToken() => name.getEndToken().next;
1681 } 1681 }
1682 1682
1683 class Import extends LibraryTag { 1683 /**
1684 * This tag describes a dependency between one library and the exported
1685 * identifiers of another library. The other library is specified by the [uri].
1686 * Combinators filter away some identifiers from the other library.
1687 */
1688 abstract class LibraryDependency extends LibraryTag {
1684 final LiteralString uri; 1689 final LiteralString uri;
1685 final Identifier prefix;
1686 final NodeList combinators; 1690 final NodeList combinators;
1687 1691
1692 LibraryDependency(this.uri, this.combinators);
1693 }
1694
1695 /**
1696 * An [:import:] library tag.
1697 *
1698 * An import tag is dependency on another library where the exported identifiers
1699 * are put into the import scope of the importing library. The import scope is
1700 * only visible inside the library.
1701 */
1702 class Import extends LibraryDependency {
1703 final Identifier prefix;
1688 final Token importKeyword; 1704 final Token importKeyword;
1689 1705
1690 Import(this.importKeyword, this.uri, this.prefix, this.combinators); 1706 Import(this.importKeyword, LiteralString uri,
1707 this.prefix, NodeList combinators)
1708 : super(uri, combinators);
1691 1709
1692 bool get isImport => true; 1710 bool get isImport => true;
1693 1711
1694 Import asImport() => this; 1712 Import asImport() => this;
1695 1713
1696 Token get asKeyword => prefix == null ? null : uri.getEndToken().next; 1714 Token get asKeyword => prefix == null ? null : uri.getEndToken().next;
1697 1715
1698 accept(Visitor visitor) => visitor.visitImport(this); 1716 accept(Visitor visitor) => visitor.visitImport(this);
1699 1717
1700 visitChildren(Visitor visitor) { 1718 visitChildren(Visitor visitor) {
1701 uri.accept(visitor); 1719 uri.accept(visitor);
1702 if (prefix !== null) prefix.accept(visitor); 1720 if (prefix !== null) prefix.accept(visitor);
1703 if (combinators !== null) combinators.accept(visitor); 1721 if (combinators !== null) combinators.accept(visitor);
1704 } 1722 }
1705 1723
1706 Token getBeginToken() => importKeyword; 1724 Token getBeginToken() => importKeyword;
1707 1725
1708 Token getEndToken() { 1726 Token getEndToken() {
1709 if (combinators !== null) return combinators.getEndToken().next; 1727 if (combinators !== null) return combinators.getEndToken().next;
1710 if (prefix !== null) return prefix.getEndToken().next; 1728 if (prefix !== null) return prefix.getEndToken().next;
1711 return uri.getEndToken().next; 1729 return uri.getEndToken().next;
1712 } 1730 }
1713 } 1731 }
1714 1732
1715 class Export extends LibraryTag { 1733 /**
1716 final LiteralString uri; 1734 * An [:export:] library tag.
1717 final NodeList combinators; 1735 *
1718 1736 * An export tag is dependency on another library where the exported identifiers
1737 * are put into the export scope of the exporting library. The export scope is
1738 * not visible inside the library.
1739 */
1740 class Export extends LibraryDependency {
1719 final Token exportKeyword; 1741 final Token exportKeyword;
1720 1742
1721 Export(this.exportKeyword, this.uri, this.combinators); 1743 Export(this.exportKeyword, LiteralString uri, NodeList combinators)
1744 : super(uri, combinators);
1722 1745
1723 bool get isExport => true; 1746 bool get isExport => true;
1724 1747
1725 Export asExport() => this; 1748 Export asExport() => this;
1726 1749
1727 accept(Visitor visitor) => visitor.visitExport(this); 1750 accept(Visitor visitor) => visitor.visitExport(this);
1728 1751
1729 visitChildren(Visitor visitor) { 1752 visitChildren(Visitor visitor) {
1730 uri.accept(visitor); 1753 uri.accept(visitor);
1731 if (combinators !== null) combinators.accept(visitor); 1754 if (combinators !== null) combinators.accept(visitor);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 * argument). 2000 * argument).
1978 * 2001 *
1979 * TODO(ahe): This method is controversial, the team needs to discuss 2002 * TODO(ahe): This method is controversial, the team needs to discuss
1980 * if top-level methods are acceptable and what naming conventions to 2003 * if top-level methods are acceptable and what naming conventions to
1981 * use. 2004 * use.
1982 */ 2005 */
1983 initializerDo(Node node, f(Node node)) { 2006 initializerDo(Node node, f(Node node)) {
1984 SendSet send = node.asSendSet(); 2007 SendSet send = node.asSendSet();
1985 if (send !== null) return f(send.arguments.head); 2008 if (send !== null) return f(send.arguments.head);
1986 } 2009 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698