| OLD | NEW |
| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 224 |
| 225 class NodeList extends Node { | 225 class NodeList extends Node { |
| 226 // TODO(floitsch): don't make nodes private. This is needed, because we | 226 // TODO(floitsch): don't make nodes private. This is needed, because we |
| 227 // work around a bug in Frog that doesn't allow to initialize the field | 227 // work around a bug in Frog that doesn't allow to initialize the field |
| 228 // with a const object. | 228 // with a const object. |
| 229 final Link<Node> _nodes; | 229 final Link<Node> _nodes; |
| 230 Link<Node> get nodes() => _nodes !== null ? _nodes : const EmptyLink<Node>(); | 230 Link<Node> get nodes() => _nodes !== null ? _nodes : const EmptyLink<Node>(); |
| 231 final Token beginToken; | 231 final Token beginToken; |
| 232 final Token endToken; | 232 final Token endToken; |
| 233 final SourceString delimiter; | 233 final SourceString delimiter; |
| 234 bool isEmpty() => nodes.isEmpty(); |
| 234 | 235 |
| 235 // TODO(floitsch): second argument should be this.nodes. | 236 // TODO(floitsch): second argument should be this.nodes. |
| 236 NodeList([this.beginToken, nodes, this.endToken, this.delimiter]) | 237 NodeList([this.beginToken, nodes, this.endToken, this.delimiter]) |
| 237 : _nodes = nodes; | 238 : _nodes = nodes; |
| 238 | 239 |
| 239 NodeList.singleton(Node node) : this(null, new Link<Node>(node)); | 240 NodeList.singleton(Node node) : this(null, new Link<Node>(node)); |
| 241 NodeList.empty() : this(null, const EmptyLink<Node>()); |
| 240 | 242 |
| 241 NodeList asNodeList() => this; | 243 NodeList asNodeList() => this; |
| 242 | 244 |
| 243 accept(Visitor visitor) => visitor.visitNodeList(this); | 245 accept(Visitor visitor) => visitor.visitNodeList(this); |
| 244 | 246 |
| 245 Token getBeginToken() { | 247 Token getBeginToken() { |
| 246 if (beginToken !== null) return beginToken; | 248 if (beginToken !== null) return beginToken; |
| 247 if (nodes !== null) { | 249 if (nodes !== null) { |
| 248 for (Link<Node> link = nodes; !link.isEmpty(); link = link.tail) { | 250 for (Link<Node> link = nodes; !link.isEmpty(); link = link.tail) { |
| 249 if (link.head.getBeginToken() !== null) { | 251 if (link.head.getBeginToken() !== null) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 316 } |
| 315 | 317 |
| 316 class For extends Loop { | 318 class For extends Loop { |
| 317 /** Either a variable declaration or an ExpressionStatement. */ | 319 /** Either a variable declaration or an ExpressionStatement. */ |
| 318 final Statement initializer; | 320 final Statement initializer; |
| 319 final ExpressionStatement conditionStatement; | 321 final ExpressionStatement conditionStatement; |
| 320 final Node update; // TODO(ahe): Should be an expression list. | 322 final Node update; // TODO(ahe): Should be an expression list. |
| 321 | 323 |
| 322 final Token forToken; | 324 final Token forToken; |
| 323 | 325 |
| 324 For(this.initializer, this.conditionStatement, this.update, body, | 326 For(this.initializer, this.conditionStatement, this.update, body, |
| 325 this.forToken) : super(body); | 327 this.forToken) : super(body); |
| 326 | 328 |
| 327 For asFor() => this; | 329 For asFor() => this; |
| 328 | 330 |
| 329 Expression get condition() { | 331 Expression get condition() { |
| 330 return conditionStatement.expression; | 332 return conditionStatement.expression; |
| 331 } | 333 } |
| 332 | 334 |
| 333 accept(Visitor visitor) => visitor.visitFor(this); | 335 accept(Visitor visitor) => visitor.visitFor(this); |
| 334 | 336 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 } | 611 } |
| 610 | 612 |
| 611 /** Representation of modifiers such as static, abstract, final, etc. */ | 613 /** Representation of modifiers such as static, abstract, final, etc. */ |
| 612 class Modifiers { | 614 class Modifiers { |
| 613 final Link<Token> modifiers; | 615 final Link<Token> modifiers; |
| 614 /** Bit pattern to easy check what modifiers are present. */ | 616 /** Bit pattern to easy check what modifiers are present. */ |
| 615 final int flags; | 617 final int flags; |
| 616 | 618 |
| 617 const Modifiers([this.modifiers, this.flags = 0]); | 619 const Modifiers([this.modifiers, this.flags = 0]); |
| 618 } | 620 } |
| OLD | NEW |