OLD | NEW |
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 part of js_ast; | 5 part of js_ast; |
6 | 6 |
7 abstract class NodeVisitor<T> { | 7 abstract class NodeVisitor<T> { |
8 T visitProgram(Program node); | 8 T visitProgram(Program node); |
9 | 9 |
10 T visitBlock(Block node); | 10 T visitBlock(Block node); |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 context.buffer.write('`'); | 277 context.buffer.write('`'); |
278 return context.getText(); | 278 return context.getText(); |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 class Program extends Node { | 282 class Program extends Node { |
283 /// Script tag hash-bang, e.g. `#!/usr/bin/env node` | 283 /// Script tag hash-bang, e.g. `#!/usr/bin/env node` |
284 final String scriptTag; | 284 final String scriptTag; |
285 | 285 |
286 /// Top-level statements in the program. | 286 /// Top-level statements in the program. |
287 final List<Statement> body; | 287 final List<ModuleItem> body; |
288 | 288 |
289 Program(this.body, {this.scriptTag}); | 289 Program(this.body, {this.scriptTag}); |
290 | 290 |
291 accept(NodeVisitor visitor) => visitor.visitProgram(this); | 291 accept(NodeVisitor visitor) => visitor.visitProgram(this); |
292 void visitChildren(NodeVisitor visitor) { | 292 void visitChildren(NodeVisitor visitor) { |
293 for (Statement statement in body) statement.accept(visitor); | 293 for (ModuleItem statement in body) statement.accept(visitor); |
294 } | 294 } |
295 Program _clone() => new Program(body); | 295 Program _clone() => new Program(body); |
296 } | 296 } |
297 | 297 |
298 abstract class Statement extends ModuleItem { | 298 abstract class Statement extends ModuleItem { |
299 Statement toStatement() => this; | 299 Statement toStatement() => this; |
300 Statement toReturn() => new Block([this, new Return()]); | 300 Statement toReturn() => new Block([this, new Return()]); |
301 } | 301 } |
302 | 302 |
303 class Block extends Statement { | 303 class Block extends Statement { |
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 | 1763 |
1764 final List<ModuleItem> body; | 1764 final List<ModuleItem> body; |
1765 Module(this.body, {this.name}); | 1765 Module(this.body, {this.name}); |
1766 | 1766 |
1767 accept(NodeVisitor visitor) => visitor.visitModule(this); | 1767 accept(NodeVisitor visitor) => visitor.visitModule(this); |
1768 void visitChildren(NodeVisitor visitor) { | 1768 void visitChildren(NodeVisitor visitor) { |
1769 for (ModuleItem item in body) item.accept(visitor); | 1769 for (ModuleItem item in body) item.accept(visitor); |
1770 } | 1770 } |
1771 Module _clone() => new Module(body); | 1771 Module _clone() => new Module(body); |
1772 } | 1772 } |
OLD | NEW |