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

Side by Side Diff: frog/leg/tree/nodes.dart

Issue 8769012: Start resolving classes and default constructors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/typechecker.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 visitClassNode(ClassNode node); 7 R visitClassNode(ClassNode node);
8 R visitDoWhile(DoWhile node); 8 R visitDoWhile(DoWhile node);
9 R visitExpressionStatement(ExpressionStatement node); 9 R visitExpressionStatement(ExpressionStatement node);
10 R visitFor(For node); 10 R visitFor(For node);
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 226
227 class NodeList extends Node { 227 class NodeList extends Node {
228 // TODO(floitsch): don't make nodes private. This is needed, because we 228 // TODO(floitsch): don't make nodes private. This is needed, because we
229 // work around a bug in Frog that doesn't allow to initialize the field 229 // work around a bug in Frog that doesn't allow to initialize the field
230 // with a const object. 230 // with a const object.
231 final Link<Node> _nodes; 231 final Link<Node> _nodes;
232 Link<Node> get nodes() => _nodes !== null ? _nodes : const EmptyLink<Node>(); 232 Link<Node> get nodes() => _nodes !== null ? _nodes : const EmptyLink<Node>();
233 final Token beginToken; 233 final Token beginToken;
234 final Token endToken; 234 final Token endToken;
235 final SourceString delimiter; 235 final SourceString delimiter;
236 bool isEmpty() => nodes.isEmpty();
236 237
237 // TODO(floitsch): second argument should be this.nodes. 238 // TODO(floitsch): second argument should be this.nodes.
238 NodeList([this.beginToken, nodes, this.endToken, this.delimiter]) 239 NodeList([this.beginToken, nodes, this.endToken, this.delimiter])
239 : _nodes = nodes; 240 : _nodes = nodes;
240 241
241 NodeList.singleton(Node node) : this(null, new Link<Node>(node)); 242 NodeList.singleton(Node node) : this(null, new Link<Node>(node));
243 NodeList.empty() : this(null, const EmptyLink<Node>());
242 244
243 NodeList asNodeList() => this; 245 NodeList asNodeList() => this;
244 246
245 accept(Visitor visitor) => visitor.visitNodeList(this); 247 accept(Visitor visitor) => visitor.visitNodeList(this);
246 248
247 Token getBeginToken() { 249 Token getBeginToken() {
248 if (beginToken !== null) return beginToken; 250 if (beginToken !== null) return beginToken;
249 if (nodes !== null) { 251 if (nodes !== null) {
250 for (Link<Node> link = nodes; !link.isEmpty(); link = link.tail) { 252 for (Link<Node> link = nodes; !link.isEmpty(); link = link.tail) {
251 if (link.head.getBeginToken() !== null) { 253 if (link.head.getBeginToken() !== null) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 318 }
317 319
318 class For extends Loop { 320 class For extends Loop {
319 /** Either a variable declaration or an ExpressionStatement. */ 321 /** Either a variable declaration or an ExpressionStatement. */
320 final Statement initializer; 322 final Statement initializer;
321 final ExpressionStatement conditionStatement; 323 final ExpressionStatement conditionStatement;
322 final Node update; // TODO(ahe): Should be an expression list. 324 final Node update; // TODO(ahe): Should be an expression list.
323 325
324 final Token forToken; 326 final Token forToken;
325 327
326 For(this.initializer, this.conditionStatement, this.update, body, 328 For(this.initializer, this.conditionStatement, this.update, body,
327 this.forToken) : super(body); 329 this.forToken) : super(body);
328 330
329 For asFor() => this; 331 For asFor() => this;
330 332
331 Expression get condition() { 333 Expression get condition() {
332 return conditionStatement.expression; 334 return conditionStatement.expression;
333 } 335 }
334 336
335 accept(Visitor visitor) => visitor.visitFor(this); 337 accept(Visitor visitor) => visitor.visitFor(this);
336 338
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 getBeginToken() => firstBeginToken(type, elements); 458 getBeginToken() => firstBeginToken(type, elements);
457 getEndToken() => elements.getEndToken(); 459 getEndToken() => elements.getEndToken();
458 } 460 }
459 461
460 class Identifier extends Expression { 462 class Identifier extends Expression {
461 final Token token; 463 final Token token;
462 464
463 SourceString get source() => token.value; 465 SourceString get source() => token.value;
464 466
465 Identifier(Token this.token); 467 Identifier(Token this.token);
468 Identifier.synthetic(String name) : token = new StringToken(null, name, null);
466 469
467 Identifier asIdentifier() => this; 470 Identifier asIdentifier() => this;
468 471
469 accept(Visitor visitor) => visitor.visitIdentifier(this); 472 accept(Visitor visitor) => visitor.visitIdentifier(this);
470 473
471 getBeginToken() => token; 474 getBeginToken() => token;
472 475
473 getEndToken() => token; 476 getEndToken() => token;
474 } 477 }
475 478
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 626 }
624 627
625 /** Representation of modifiers such as static, abstract, final, etc. */ 628 /** Representation of modifiers such as static, abstract, final, etc. */
626 class Modifiers { 629 class Modifiers {
627 final Link<Token> modifiers; 630 final Link<Token> modifiers;
628 /** Bit pattern to easy check what modifiers are present. */ 631 /** Bit pattern to easy check what modifiers are present. */
629 final int flags; 632 final int flags;
630 633
631 const Modifiers([this.modifiers, this.flags = 0]); 634 const Modifiers([this.modifiers, this.flags = 0]);
632 } 635 }
OLDNEW
« no previous file with comments | « frog/leg/ssa/builder.dart ('k') | frog/leg/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698