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

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 (superclass !== null) superclass.accept(visitor); 208 if (superclass !== null) superclass.accept(visitor);
208 if (interfaces !== null) interfaces.accept(visitor); 209 if (interfaces !== null) interfaces.accept(visitor);
210 if (body !== null) body.accept(visitor); // what about typeParameters?
ahe 2012/08/17 06:43:37 Please visit them :-) If you'd rather not, please
messick 2012/08/17 17:16:40 Visiting
209 } 211 }
210 212
211 bool get isInterface() => beginToken.stringValue === 'interface'; 213 bool get isInterface() => beginToken.stringValue === 'interface';
212 214
213 bool get isClass() => !isInterface; 215 bool get isClass() => !isInterface;
214 216
215 Token getBeginToken() => beginToken; 217 Token getBeginToken() => beginToken;
216 218
217 Token getEndToken() => endToken; 219 Token getEndToken() => endToken;
218 } 220 }
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 } 1673 }
1672 1674
1673 class CatchBlock extends Node { 1675 class CatchBlock extends Node {
1674 final TypeAnnotation type; 1676 final TypeAnnotation type;
1675 final NodeList formals; 1677 final NodeList formals;
1676 final Block block; 1678 final Block block;
1677 1679
1678 final Token onKeyword; 1680 final Token onKeyword;
1679 final Token catchKeyword; 1681 final Token catchKeyword;
1680 1682
1681 CatchBlock(this.type, this.formals, this.block, 1683 CatchBlock(this.type, this.formals, this.block,
1682 this.onKeyword, this.catchKeyword); 1684 this.onKeyword, this.catchKeyword);
1683 1685
1684 CatchBlock asCatchBlock() => this; 1686 CatchBlock asCatchBlock() => this;
1685 1687
1686 accept(Visitor visitor) => visitor.visitCatchBlock(this); 1688 accept(Visitor visitor) => visitor.visitCatchBlock(this);
1687 1689
1688 Node get exception() { 1690 Node get exception() {
1689 if (formals.nodes.isEmpty()) return null; 1691 if (formals.nodes.isEmpty()) return null;
1690 VariableDefinitions declarations = formals.nodes.head; 1692 VariableDefinitions declarations = formals.nodes.head;
1691 return declarations.definitions.nodes.head; 1693 return declarations.definitions.nodes.head;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 * argument). 1755 * argument).
1754 * 1756 *
1755 * TODO(ahe): This method is controversial, the team needs to discuss 1757 * TODO(ahe): This method is controversial, the team needs to discuss
1756 * if top-level methods are acceptable and what naming conventions to 1758 * if top-level methods are acceptable and what naming conventions to
1757 * use. 1759 * use.
1758 */ 1760 */
1759 initializerDo(Node node, f(Node node)) { 1761 initializerDo(Node node, f(Node node)) {
1760 SendSet send = node.asSendSet(); 1762 SendSet send = node.asSendSet();
1761 if (send !== null) return f(send.arguments.head); 1763 if (send !== null) return f(send.arguments.head);
1762 } 1764 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698