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

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

Issue 11033003: Unparse new library syntax. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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);
11 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node); 11 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node);
12 R visitCascade(Cascade node) => visitExpression(node); 12 R visitCascade(Cascade node) => visitExpression(node);
13 R visitCascadeReceiver(CascadeReceiver node) => visitExpression(node); 13 R visitCascadeReceiver(CascadeReceiver node) => visitExpression(node);
14 R visitCaseMatch(CaseMatch node) => visitNode(node); 14 R visitCaseMatch(CaseMatch node) => visitNode(node);
15 R visitCatchBlock(CatchBlock node) => visitNode(node); 15 R visitCatchBlock(CatchBlock node) => visitNode(node);
16 R visitClassNode(ClassNode node) => visitNode(node); 16 R visitClassNode(ClassNode node) => visitNode(node);
17 R visitConditional(Conditional node) => visitExpression(node); 17 R visitConditional(Conditional node) => visitExpression(node);
18 R visitContinueStatement(ContinueStatement node) => visitGotoStatement(node); 18 R visitContinueStatement(ContinueStatement node) => visitGotoStatement(node);
19 R visitDoWhile(DoWhile node) => visitLoop(node); 19 R visitDoWhile(DoWhile node) => visitLoop(node);
20 R visitEmptyStatement(EmptyStatement node) => visitStatement(node); 20 R visitEmptyStatement(EmptyStatement node) => visitStatement(node);
21 R visitExport(Export node) => visitNode(node);
21 R visitExpression(Expression node) => visitNode(node); 22 R visitExpression(Expression node) => visitNode(node);
22 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node); 23 R visitExpressionStatement(ExpressionStatement node) => visitStatement(node);
23 R visitFor(For node) => visitLoop(node); 24 R visitFor(For node) => visitLoop(node);
24 R visitForIn(ForIn node) => visitLoop(node); 25 R visitForIn(ForIn node) => visitLoop(node);
25 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node); 26 R visitFunctionDeclaration(FunctionDeclaration node) => visitStatement(node);
26 R visitFunctionExpression(FunctionExpression node) => visitExpression(node); 27 R visitFunctionExpression(FunctionExpression node) => visitExpression(node);
27 R visitGotoStatement(GotoStatement node) => visitStatement(node); 28 R visitGotoStatement(GotoStatement node) => visitStatement(node);
28 R visitIdentifier(Identifier node) => visitExpression(node); 29 R visitIdentifier(Identifier node) => visitExpression(node);
29 R visitIf(If node) => visitStatement(node); 30 R visitIf(If node) => visitStatement(node);
31 R visitImport(Import node) => visitNode(node);
30 R visitLabel(Label node) => visitNode(node); 32 R visitLabel(Label node) => visitNode(node);
31 R visitLabeledStatement(LabeledStatement node) => visitStatement(node); 33 R visitLabeledStatement(LabeledStatement node) => visitStatement(node);
34 R visitLibraryName(LibraryName node) => visitNode(node);
32 R visitLiteral(Literal node) => visitExpression(node); 35 R visitLiteral(Literal node) => visitExpression(node);
33 R visitLiteralBool(LiteralBool node) => visitLiteral(node); 36 R visitLiteralBool(LiteralBool node) => visitLiteral(node);
34 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node); 37 R visitLiteralDouble(LiteralDouble node) => visitLiteral(node);
35 R visitLiteralInt(LiteralInt node) => visitLiteral(node); 38 R visitLiteralInt(LiteralInt node) => visitLiteral(node);
36 R visitLiteralList(LiteralList node) => visitExpression(node); 39 R visitLiteralList(LiteralList node) => visitExpression(node);
37 R visitLiteralMap(LiteralMap node) => visitExpression(node); 40 R visitLiteralMap(LiteralMap node) => visitExpression(node);
38 R visitLiteralMapEntry(LiteralMapEntry node) => visitNode(node); 41 R visitLiteralMapEntry(LiteralMapEntry node) => visitNode(node);
39 R visitLiteralNull(LiteralNull node) => visitLiteral(node); 42 R visitLiteralNull(LiteralNull node) => visitLiteral(node);
40 R visitLiteralString(LiteralString node) => visitStringNode(node); 43 R visitLiteralString(LiteralString node) => visitStringNode(node);
41 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node); 44 R visitStringJuxtaposition(StringJuxtaposition node) => visitStringNode(node);
42 R visitLoop(Loop node) => visitStatement(node); 45 R visitLoop(Loop node) => visitStatement(node);
43 R visitModifiers(Modifiers node) => visitNode(node); 46 R visitModifiers(Modifiers node) => visitNode(node);
44 R visitNamedArgument(NamedArgument node) => visitExpression(node); 47 R visitNamedArgument(NamedArgument node) => visitExpression(node);
45 R visitNewExpression(NewExpression node) => visitExpression(node); 48 R visitNewExpression(NewExpression node) => visitExpression(node);
46 R visitNodeList(NodeList node) => visitNode(node); 49 R visitNodeList(NodeList node) => visitNode(node);
47 R visitOperator(Operator node) => visitIdentifier(node); 50 R visitOperator(Operator node) => visitIdentifier(node);
48 R visitParenthesizedExpression(ParenthesizedExpression node) { 51 R visitParenthesizedExpression(ParenthesizedExpression node) {
49 return visitExpression(node); 52 return visitExpression(node);
50 } 53 }
54 R visitPart(Part node) => visitNode(node);
55 R visitPartOf(PartOf node) => visitNode(node);
51 R visitPostfix(Postfix node) => visitNodeList(node); 56 R visitPostfix(Postfix node) => visitNodeList(node);
52 R visitPrefix(Prefix node) => visitNodeList(node); 57 R visitPrefix(Prefix node) => visitNodeList(node);
53 R visitReturn(Return node) => visitStatement(node); 58 R visitReturn(Return node) => visitStatement(node);
54 R visitScriptTag(ScriptTag node) => visitNode(node); 59 R visitScriptTag(ScriptTag node) => visitNode(node);
55 R visitSend(Send node) => visitExpression(node); 60 R visitSend(Send node) => visitExpression(node);
56 R visitSendSet(SendSet node) => visitSend(node); 61 R visitSendSet(SendSet node) => visitSend(node);
57 R visitStatement(Statement node) => visitNode(node); 62 R visitStatement(Statement node) => visitNode(node);
58 R visitStringNode(StringNode node) => visitExpression(node); 63 R visitStringNode(StringNode node) => visitExpression(node);
59 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node); 64 R visitStringInterpolation(StringInterpolation node) => visitStringNode(node);
60 R visitStringInterpolationPart(StringInterpolationPart node) { 65 R visitStringInterpolationPart(StringInterpolationPart node) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 BreakStatement asBreakStatement() => null; 139 BreakStatement asBreakStatement() => null;
135 Cascade asCascade() => null; 140 Cascade asCascade() => null;
136 CascadeReceiver asCascadeReceiver() => null; 141 CascadeReceiver asCascadeReceiver() => null;
137 CaseMatch asCaseMatch() => null; 142 CaseMatch asCaseMatch() => null;
138 CatchBlock asCatchBlock() => null; 143 CatchBlock asCatchBlock() => null;
139 ClassNode asClassNode() => null; 144 ClassNode asClassNode() => null;
140 Conditional asConditional() => null; 145 Conditional asConditional() => null;
141 ContinueStatement asContinueStatement() => null; 146 ContinueStatement asContinueStatement() => null;
142 DoWhile asDoWhile() => null; 147 DoWhile asDoWhile() => null;
143 EmptyStatement asEmptyStatement() => null; 148 EmptyStatement asEmptyStatement() => null;
149 Export AsExport() => Null;
144 Expression asExpression() => null; 150 Expression asExpression() => null;
145 ExpressionStatement asExpressionStatement() => null; 151 ExpressionStatement asExpressionStatement() => null;
146 For asFor() => null; 152 For asFor() => null;
147 ForIn asForIn() => null; 153 ForIn asForIn() => null;
148 FunctionDeclaration asFunctionDeclaration() => null; 154 FunctionDeclaration asFunctionDeclaration() => null;
149 FunctionExpression asFunctionExpression() => null; 155 FunctionExpression asFunctionExpression() => null;
150 Identifier asIdentifier() => null; 156 Identifier asIdentifier() => null;
151 If asIf() => null; 157 If asIf() => null;
158 Import AsImport() => Null;
152 Label asLabel() => null; 159 Label asLabel() => null;
153 LabeledStatement asLabeledStatement() => null; 160 LabeledStatement asLabeledStatement() => null;
161 LibraryName AsLibraryName() => Null;
154 LiteralBool asLiteralBool() => null; 162 LiteralBool asLiteralBool() => null;
155 LiteralDouble asLiteralDouble() => null; 163 LiteralDouble asLiteralDouble() => null;
156 LiteralInt asLiteralInt() => null; 164 LiteralInt asLiteralInt() => null;
157 LiteralList asLiteralList() => null; 165 LiteralList asLiteralList() => null;
158 LiteralMap asLiteralMap() => null; 166 LiteralMap asLiteralMap() => null;
159 LiteralMapEntry asLiteralMapEntry() => null; 167 LiteralMapEntry asLiteralMapEntry() => null;
160 LiteralNull asLiteralNull() => null; 168 LiteralNull asLiteralNull() => null;
161 LiteralString asLiteralString() => null; 169 LiteralString asLiteralString() => null;
162 Modifiers asModifiers() => null; 170 Modifiers asModifiers() => null;
163 NamedArgument asNamedArgument() => null; 171 NamedArgument asNamedArgument() => null;
164 NodeList asNodeList() => null; 172 NodeList asNodeList() => null;
165 Operator asOperator() => null; 173 Operator asOperator() => null;
166 ParenthesizedExpression asParenthesizedExpression() => null; 174 ParenthesizedExpression asParenthesizedExpression() => null;
175 Part AsPart() => Null;
176 PartOf AsPartOf() => Null;
167 Return asReturn() => null; 177 Return asReturn() => null;
168 ScriptTag asScriptTag() => null; 178 ScriptTag asScriptTag() => null;
169 Send asSend() => null; 179 Send asSend() => null;
170 SendSet asSendSet() => null; 180 SendSet asSendSet() => null;
171 Statement asStatement() => null; 181 Statement asStatement() => null;
172 StringNode asStringNode() => null;
173 StringInterpolation asStringInterpolation() => null; 182 StringInterpolation asStringInterpolation() => null;
174 StringInterpolationPart asStringInterpolationPart() => null; 183 StringInterpolationPart asStringInterpolationPart() => null;
175 StringJuxtaposition asStringJuxtaposition() => null; 184 StringJuxtaposition asStringJuxtaposition() => null;
185 StringNode asStringNode() => null;
176 SwitchCase asSwitchCase() => null; 186 SwitchCase asSwitchCase() => null;
177 SwitchStatement asSwitchStatement() => null; 187 SwitchStatement asSwitchStatement() => null;
178 Throw asThrow() => null; 188 Throw asThrow() => null;
179 TryStatement asTryStatement() => null; 189 TryStatement asTryStatement() => null;
180 TypeAnnotation asTypeAnnotation() => null; 190 TypeAnnotation asTypeAnnotation() => null;
191 TypeVariable asTypeVariable() => null;
181 Typedef asTypedef() => null; 192 Typedef asTypedef() => null;
182 TypeVariable asTypeVariable() => null;
183 VariableDefinitions asVariableDefinitions() => null; 193 VariableDefinitions asVariableDefinitions() => null;
184 While asWhile() => null; 194 While asWhile() => null;
185 195
186 bool isValidBreakTarget() => false; 196 bool isValidBreakTarget() => false;
187 bool isValidContinueTarget() => false; 197 bool isValidContinueTarget() => false;
188 } 198 }
189 199
190 class ClassNode extends Node { 200 class ClassNode extends Node {
191 final Identifier name; 201 final Identifier name;
192 final TypeAnnotation superclass; 202 final TypeAnnotation superclass;
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 throw 'Unknown script tag ${tag.token.slowToString()}'; 1646 throw 'Unknown script tag ${tag.token.slowToString()}';
1637 } 1647 }
1638 } 1648 }
1639 } 1649 }
1640 1650
1641 class LibraryTag extends Node { 1651 class LibraryTag extends Node {
1642 bool get isLibraryName => false; 1652 bool get isLibraryName => false;
1643 bool get isImport => false; 1653 bool get isImport => false;
1644 bool get isExport => false; 1654 bool get isExport => false;
1645 bool get isPart => false; 1655 bool get isPart => false;
1656 bool get isPartOf => false;
1646 } 1657 }
1647 1658
1648 class LibraryName extends LibraryTag { 1659 class LibraryName extends LibraryTag {
1649 final Expression name; 1660 final Expression name;
1650 1661
1651 final Token libraryKeyword; 1662 final Token libraryKeyword;
1652 1663
1653 LibraryName(this.libraryKeyword, this.name); 1664 LibraryName(this.libraryKeyword, this.name);
1654 1665
1655 bool get isLibraryName => true; 1666 bool get isLibraryName => true;
(...skipping 15 matching lines...) Expand all
1671 final NodeList combinators; 1682 final NodeList combinators;
1672 1683
1673 final Token importKeyword; 1684 final Token importKeyword;
1674 1685
1675 Import(this.importKeyword, this.uri, this.prefix, this.combinators); 1686 Import(this.importKeyword, this.uri, this.prefix, this.combinators);
1676 1687
1677 bool get isImport => true; 1688 bool get isImport => true;
1678 1689
1679 Import asImport() => this; 1690 Import asImport() => this;
1680 1691
1692 Token get asKeyword => prefix == null ? null : uri.getEndToken().next;
1693
1681 accept(Visitor visitor) => visitor.visitImport(this); 1694 accept(Visitor visitor) => visitor.visitImport(this);
1682 1695
1683 visitChildren(Visitor visitor) { 1696 visitChildren(Visitor visitor) {
1684 uri.accept(visitor); 1697 uri.accept(visitor);
1685 if (prefix !== null) prefix.accept(visitor); 1698 if (prefix !== null) prefix.accept(visitor);
1686 if (combinators !== null) combinators.accept(visitor); 1699 if (combinators !== null) combinators.accept(visitor);
1687 } 1700 }
1688 1701
1689 Token getBeginToken() => importKeyword; 1702 Token getBeginToken() => importKeyword;
1690 1703
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 1748
1736 accept(Visitor visitor) => visitor.visitPart(this); 1749 accept(Visitor visitor) => visitor.visitPart(this);
1737 1750
1738 visitChildren(Visitor visitor) => uri.accept(visitor); 1751 visitChildren(Visitor visitor) => uri.accept(visitor);
1739 1752
1740 Token getBeginToken() => partKeyword; 1753 Token getBeginToken() => partKeyword;
1741 1754
1742 Token getEndToken() => uri.getEndToken().next; 1755 Token getEndToken() => uri.getEndToken().next;
1743 } 1756 }
1744 1757
1758 class PartOf extends LibraryTag {
1759 final Expression name;
1760
1761 final Token partKeyword;
1762
1763 PartOf(this.partKeyword, this.name);
1764
1765 Token get ofKeyword => partKeyword.next;
1766
1767 bool get isPartOf => true;
1768
1769 Part asPartOf() => this;
1770
1771 accept(Visitor visitor) => visitor.visitPartOf(this);
1772
1773 visitChildren(Visitor visitor) => name.accept(visitor);
1774
1775 Token getBeginToken() => partKeyword;
1776
1777 Token getEndToken() => name.getEndToken().next;
1778 }
1779
1745 class Typedef extends Node { 1780 class Typedef extends Node {
1746 final TypeAnnotation returnType; 1781 final TypeAnnotation returnType;
1747 final Identifier name; 1782 final Identifier name;
1748 final NodeList typeParameters; 1783 final NodeList typeParameters;
1749 final NodeList formals; 1784 final NodeList formals;
1750 1785
1751 final Token typedefKeyword; 1786 final Token typedefKeyword;
1752 final Token endToken; 1787 final Token endToken;
1753 1788
1754 Typedef(this.returnType, this.name, this.typeParameters, this.formals, 1789 Typedef(this.returnType, this.name, this.typeParameters, this.formals,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 * argument). 1951 * argument).
1917 * 1952 *
1918 * TODO(ahe): This method is controversial, the team needs to discuss 1953 * TODO(ahe): This method is controversial, the team needs to discuss
1919 * if top-level methods are acceptable and what naming conventions to 1954 * if top-level methods are acceptable and what naming conventions to
1920 * use. 1955 * use.
1921 */ 1956 */
1922 initializerDo(Node node, f(Node node)) { 1957 initializerDo(Node node, f(Node node)) {
1923 SendSet send = node.asSendSet(); 1958 SendSet send = node.asSendSet();
1924 if (send !== null) return f(send.arguments.head); 1959 if (send !== null) return f(send.arguments.head);
1925 } 1960 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/scanner/scanner_task.dart ('k') | dart/lib/compiler/implementation/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698