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> implements TypeRefVisitor<T> { | 7 abstract class NodeVisitor<T> implements TypeRefVisitor<T> { |
8 T visitProgram(Program node); | 8 T visitProgram(Program node); |
9 | 9 |
10 T visitBlock(Block node); | 10 T visitBlock(Block node); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 String toString() { | 297 String toString() { |
298 var context = new SimpleJavaScriptPrintingContext(); | 298 var context = new SimpleJavaScriptPrintingContext(); |
299 var opts = new JavaScriptPrintingOptions(allowKeywordsInProperties: true); | 299 var opts = new JavaScriptPrintingOptions(allowKeywordsInProperties: true); |
300 context.buffer.write('js_ast `'); | 300 context.buffer.write('js_ast `'); |
301 accept(new Printer(opts, context)); | 301 accept(new Printer(opts, context)); |
302 context.buffer.write('`'); | 302 context.buffer.write('`'); |
303 return context.getText(); | 303 return context.getText(); |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
| 307 // TODO(jmesserly): rename to Module. |
307 class Program extends Node { | 308 class Program extends Node { |
308 /// Script tag hash-bang, e.g. `#!/usr/bin/env node` | 309 /// Script tag hash-bang, e.g. `#!/usr/bin/env node` |
309 final String scriptTag; | 310 final String scriptTag; |
310 | 311 |
311 /// Top-level statements in the program. | 312 /// Top-level statements in the program. |
312 final List<ModuleItem> body; | 313 final List<ModuleItem> body; |
313 | 314 |
314 /// The module's own name. | 315 /// The module's own name. |
315 /// | 316 /// |
316 /// This is not used in ES6, but is provided to allow module lowering. | 317 /// This is not used in ES6, but is provided to allow module lowering. |
(...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 | 1866 |
1866 final List<ModuleItem> body; | 1867 final List<ModuleItem> body; |
1867 Module(this.body, {this.name}); | 1868 Module(this.body, {this.name}); |
1868 | 1869 |
1869 accept(NodeVisitor visitor) => visitor.visitModule(this); | 1870 accept(NodeVisitor visitor) => visitor.visitModule(this); |
1870 void visitChildren(NodeVisitor visitor) { | 1871 void visitChildren(NodeVisitor visitor) { |
1871 for (ModuleItem item in body) item.accept(visitor); | 1872 for (ModuleItem item in body) item.accept(visitor); |
1872 } | 1873 } |
1873 Module _clone() => new Module(body); | 1874 Module _clone() => new Module(body); |
1874 } | 1875 } |
OLD | NEW |