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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/module_builder.dart

Issue 2470053002: Fix summary path for tests (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | pkg/dev_compiler/test/worker/worker_test.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) 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 import 'package:args/args.dart' show ArgParser, ArgResults; 5 import 'package:args/args.dart' show ArgParser, ArgResults;
6 import 'package:path/path.dart' as path; 6 import 'package:path/path.dart' as path;
7 7
8 import '../js_ast/js_ast.dart'; 8 import '../js_ast/js_ast.dart';
9 import 'js_names.dart'; 9 import 'js_names.dart';
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 /// Transforms an ES6 [module] into a given module [format]. 74 /// Transforms an ES6 [module] into a given module [format].
75 /// 75 ///
76 /// If the format is [ModuleFormat.es6] this will return [module] unchanged. 76 /// If the format is [ModuleFormat.es6] this will return [module] unchanged.
77 /// 77 ///
78 /// Because JS ASTs are immutable the resulting module will share as much 78 /// Because JS ASTs are immutable the resulting module will share as much
79 /// structure as possible with the original. The transformation is a shallow one 79 /// structure as possible with the original. The transformation is a shallow one
80 /// that affects the top-level module items, especially [ImportDeclaration]s and 80 /// that affects the top-level module items, especially [ImportDeclaration]s and
81 /// [ExportDeclaration]s. 81 /// [ExportDeclaration]s.
82 Program transformModuleFormat( 82 Program transformModuleFormat(ModuleFormat format, Program module,
83 ModuleFormat format, Program module, {bool singleOutFile: false}) { 83 {bool singleOutFile: false}) {
84 switch (format) { 84 switch (format) {
85 case ModuleFormat.legacy: 85 case ModuleFormat.legacy:
86 // Legacy format always generates output compatible with single file mode. 86 // Legacy format always generates output compatible with single file mode.
87 return new LegacyModuleBuilder().build(module); 87 return new LegacyModuleBuilder().build(module);
88 case ModuleFormat.common: 88 case ModuleFormat.common:
89 assert(!singleOutFile); 89 assert(!singleOutFile);
90 return new CommonJSModuleBuilder().build(module); 90 return new CommonJSModuleBuilder().build(module);
91 case ModuleFormat.amd: 91 case ModuleFormat.amd:
92 // TODO(jmesserly): encode singleOutFile as a module format? 92 // TODO(jmesserly): encode singleOutFile as a module format?
93 // Since it's irrelevant except for AMD. 93 // Since it's irrelevant except for AMD.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 visitStatement(Statement node) { 137 visitStatement(Statement node) {
138 statements.add(node); 138 statements.add(node);
139 } 139 }
140 } 140 }
141 141
142 /// Generates modules for with our legacy `dart_library.js` loading mechanism. 142 /// Generates modules for with our legacy `dart_library.js` loading mechanism.
143 // TODO(jmesserly): remove this and replace with something that interoperates. 143 // TODO(jmesserly): remove this and replace with something that interoperates.
144 class LegacyModuleBuilder extends _ModuleBuilder { 144 class LegacyModuleBuilder extends _ModuleBuilder {
145
146 Program build(Program module) { 145 Program build(Program module) {
147 // Collect imports/exports/statements. 146 // Collect imports/exports/statements.
148 visitProgram(module); 147 visitProgram(module);
149 148
150 // Build import parameters. 149 // Build import parameters.
151 var exportsVar = new TemporaryId('exports'); 150 var exportsVar = new TemporaryId('exports');
152 var parameters = <TemporaryId>[exportsVar]; 151 var parameters = <TemporaryId>[exportsVar];
153 var importNames = <Expression>[]; 152 var importNames = <Expression>[];
154 var importStatements = <Statement>[]; 153 var importStatements = <Statement>[];
155 for (var import in imports) { 154 for (var import in imports) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 // Ensure the identifier first character is not numeric and that the whole 333 // Ensure the identifier first character is not numeric and that the whole
335 // identifier is not a keyword. 334 // identifier is not a keyword.
336 if (result.startsWith(new RegExp('[0-9]')) || invalidVariableName(result)) { 335 if (result.startsWith(new RegExp('[0-9]')) || invalidVariableName(result)) {
337 return '\$$result'; 336 return '\$$result';
338 } 337 }
339 return result; 338 return result;
340 } 339 }
341 340
342 // Invalid characters for identifiers, which would need to be escaped. 341 // Invalid characters for identifiers, which would need to be escaped.
343 final _invalidCharInIdentifier = new RegExp(r'[^A-Za-z_$0-9]'); 342 final _invalidCharInIdentifier = new RegExp(r'[^A-Za-z_$0-9]');
OLDNEW
« no previous file with comments | « no previous file | pkg/dev_compiler/test/worker/worker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698