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

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

Powered by Google App Engine
This is Rietveld 408576698