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

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

Issue 10834374: Add a field to ClassNode that holds a NodeList of its members. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitBreakStatement(BreakStatement node); 7 R visitBreakStatement(BreakStatement node);
8 R visitCascade(Cascade node); 8 R visitCascade(Cascade node);
9 R visitCascadeReceiver(CascadeReceiver node); 9 R visitCascadeReceiver(CascadeReceiver node);
10 R visitCaseMatch(CaseMatch node); 10 R visitCaseMatch(CaseMatch node);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 bool isValidBreakTarget() => false; 180 bool isValidBreakTarget() => false;
181 bool isValidContinueTarget() => false; 181 bool isValidContinueTarget() => false;
182 } 182 }
183 183
184 class ClassNode extends Node { 184 class ClassNode extends Node {
185 final Identifier name; 185 final Identifier name;
186 final TypeAnnotation superclass; 186 final TypeAnnotation superclass;
187 final NodeList interfaces; 187 final NodeList interfaces;
188 final NodeList typeParameters; 188 final NodeList typeParameters;
189 final NodeList body;
189 190
190 // TODO(ahe, karlklose): the default keyword is not recorded. 191 // TODO(ahe, karlklose): the default keyword is not recorded.
191 final TypeAnnotation defaultClause; 192 final TypeAnnotation defaultClause;
192 193
193 final Token beginToken; 194 final Token beginToken;
194 final Token extendsKeyword; 195 final Token extendsKeyword;
195 final Token endToken; 196 final Token endToken;
196 197
197 ClassNode(this.name, this.typeParameters, this.superclass, this.interfaces, 198 ClassNode(this.name, this.typeParameters, this.superclass, this.interfaces,
198 this.defaultClause, this.beginToken, this.extendsKeyword, 199 this.defaultClause, this.beginToken, this.extendsKeyword,
199 this.endToken); 200 this.body, this.endToken);
200 201
201 ClassNode asClassNode() => this; 202 ClassNode asClassNode() => this;
202 203
203 accept(Visitor visitor) => visitor.visitClassNode(this); 204 accept(Visitor visitor) => visitor.visitClassNode(this);
204 205
205 visitChildren(Visitor visitor) { 206 visitChildren(Visitor visitor) {
206 if (name !== null) name.accept(visitor); 207 if (name !== null) name.accept(visitor);
207 if (typeParameters !== null) typeParameters.accept(visitor); 208 if (typeParameters !== null) typeParameters.accept(visitor);
208 if (superclass !== null) superclass.accept(visitor); 209 if (superclass !== null) superclass.accept(visitor);
209 if (interfaces !== null) interfaces.accept(visitor); 210 if (interfaces !== null) interfaces.accept(visitor);
211 if (body !== null) body.accept(visitor);
210 } 212 }
211 213
212 bool get isInterface() => beginToken.stringValue === 'interface'; 214 bool get isInterface() => beginToken.stringValue === 'interface';
213 215
214 bool get isClass() => !isInterface; 216 bool get isClass() => !isInterface;
215 217
216 Token getBeginToken() => beginToken; 218 Token getBeginToken() => beginToken;
217 219
218 Token getEndToken() => endToken; 220 Token getEndToken() => endToken;
219 } 221 }
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 } 1674 }
1673 1675
1674 class CatchBlock extends Node { 1676 class CatchBlock extends Node {
1675 final TypeAnnotation type; 1677 final TypeAnnotation type;
1676 final NodeList formals; 1678 final NodeList formals;
1677 final Block block; 1679 final Block block;
1678 1680
1679 final Token onKeyword; 1681 final Token onKeyword;
1680 final Token catchKeyword; 1682 final Token catchKeyword;
1681 1683
1682 CatchBlock(this.type, this.formals, this.block, 1684 CatchBlock(this.type, this.formals, this.block,
1683 this.onKeyword, this.catchKeyword); 1685 this.onKeyword, this.catchKeyword);
1684 1686
1685 CatchBlock asCatchBlock() => this; 1687 CatchBlock asCatchBlock() => this;
1686 1688
1687 accept(Visitor visitor) => visitor.visitCatchBlock(this); 1689 accept(Visitor visitor) => visitor.visitCatchBlock(this);
1688 1690
1689 Node get exception() { 1691 Node get exception() {
1690 if (formals.nodes.isEmpty()) return null; 1692 if (formals.nodes.isEmpty()) return null;
1691 VariableDefinitions declarations = formals.nodes.head; 1693 VariableDefinitions declarations = formals.nodes.head;
1692 return declarations.definitions.nodes.head; 1694 return declarations.definitions.nodes.head;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 * argument). 1756 * argument).
1755 * 1757 *
1756 * TODO(ahe): This method is controversial, the team needs to discuss 1758 * TODO(ahe): This method is controversial, the team needs to discuss
1757 * if top-level methods are acceptable and what naming conventions to 1759 * if top-level methods are acceptable and what naming conventions to
1758 * use. 1760 * use.
1759 */ 1761 */
1760 initializerDo(Node node, f(Node node)) { 1762 initializerDo(Node node, f(Node node)) {
1761 SendSet send = node.asSendSet(); 1763 SendSet send = node.asSendSet();
1762 if (send !== null) return f(send.arguments.head); 1764 if (send !== null) return f(send.arguments.head);
1763 } 1765 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/scanner/listener.dart ('k') | lib/compiler/implementation/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698