OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dev_compiler.src.codegen.module_builder; | |
6 | |
7 import 'package:path/path.dart' as path; | 5 import 'package:path/path.dart' as path; |
8 | 6 |
9 import '../js/js_ast.dart' as JS; | 7 import '../js/js_ast.dart' as JS; |
10 import '../js/js_ast.dart' show js; | 8 import '../js/js_ast.dart' show js; |
11 import '../options.dart' show ModuleFormat; | 9 import '../options.dart' show ModuleFormat; |
12 | 10 |
13 /// Helper that builds JS modules in a given [ModuleFormat]. | 11 /// Helper that builds JS modules in a given [ModuleFormat]. |
14 abstract class ModuleBuilder { | 12 abstract class ModuleBuilder { |
15 final List<String> _exports = <String>[]; | 13 final List<String> _exports = <String>[]; |
16 final List<_ModuleImport> _imports = <_ModuleImport>[]; | 14 final List<_ModuleImport> _imports = <_ModuleImport>[]; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 154 |
157 /// Flattens blocks in [stats] to a single list of module items. | 155 /// Flattens blocks in [stats] to a single list of module items. |
158 /// Note that in general, blocks should not be flattened, because it can | 156 /// Note that in general, blocks should not be flattened, because it can |
159 /// mess up with block-level scoping (let, const). | 157 /// mess up with block-level scoping (let, const). |
160 // TODO(ochafik): Remove this / find better pattern (adding statements as they | 158 // TODO(ochafik): Remove this / find better pattern (adding statements as they |
161 // are generated from [JSCodegenVisitor], instead of composing them with | 159 // are generated from [JSCodegenVisitor], instead of composing them with |
162 // [_statements]). | 160 // [_statements]). |
163 Iterable<JS.ModuleItem> _flattenBlocks(List<JS.ModuleItem> stats) => | 161 Iterable<JS.ModuleItem> _flattenBlocks(List<JS.ModuleItem> stats) => |
164 stats.expand( | 162 stats.expand( |
165 (item) => item is JS.Block ? _flattenBlocks(item.statements) : [item]); | 163 (item) => item is JS.Block ? _flattenBlocks(item.statements) : [item]); |
OLD | NEW |