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

Side by Side Diff: lib/src/codegen/js_codegen.dart

Issue 1689013002: Use Uris for corelibOrder (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 10 months 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 | « lib/runtime/dart/html.js ('k') | lib/src/codegen/js_module_item_order.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 library js_codegen; 5 library js_codegen;
6 6
7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet; 7 import 'dart:collection' show HashSet, HashMap, SplayTreeSet;
8 8
9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 9 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 10 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 for (var elementIdPairs in _qualifiedIds) { 179 for (var elementIdPairs in _qualifiedIds) {
180 var element = elementIdPairs.e0; 180 var element = elementIdPairs.e0;
181 var id = elementIdPairs.e1; 181 var id = elementIdPairs.e1;
182 id.setQualified(!_loader.isLoaded(element)); 182 id.setQualified(!_loader.isLoaded(element));
183 } 183 }
184 184
185 var moduleBuilder = new ModuleBuilder(options.moduleFormat); 185 var moduleBuilder = new ModuleBuilder(options.moduleFormat);
186 186
187 _exports.forEach(moduleBuilder.addExport); 187 _exports.forEach(moduleBuilder.addExport);
188 188
189 var currentModuleName = compiler.getModuleName(currentLibrary.source.uri);
189 var items = <JS.ModuleItem>[]; 190 var items = <JS.ModuleItem>[];
190 if (!_isDartRuntime) { 191 if (!_isDartRuntime) {
191 if (currentLibrary.source.isInSystemLibrary) { 192 if (currentLibrary.source.isInSystemLibrary) {
192 // Force the import order of runtime libs. 193 // Force the import order of runtime libs.
193 // TODO(ochafik): Reduce this to a minimum. 194 // TODO(ochafik): Reduce this to a minimum.
194 for (var lib in corelibOrder.reversed) { 195 for (var libUri in corelibOrder.reversed) {
195 // TODO(ochafik): Use uris instead in corelibOrder. 196 var moduleName = compiler.getModuleName(libUri);
196 moduleBuilder.addImport(getCorelibModuleName(lib), null); 197 if (moduleName == currentModuleName) continue;
198 moduleBuilder.addImport(moduleName, null);
197 } 199 }
198 } 200 }
199 moduleBuilder.addImport('dart/_runtime', _runtimeLibVar); 201 moduleBuilder.addImport('dart/_runtime', _runtimeLibVar);
200 202
201 var dartxImport = 203 var dartxImport =
202 js.statement("let # = #.dartx;", [_dartxVar, _runtimeLibVar]); 204 js.statement("let # = #.dartx;", [_dartxVar, _runtimeLibVar]);
203 items.add(dartxImport); 205 items.add(dartxImport);
204 } 206 }
205 items.addAll(_moduleItems); 207 items.addAll(_moduleItems);
206 208
207 _imports.forEach((LibraryElement lib, JS.TemporaryId temp) { 209 _imports.forEach((LibraryElement lib, JS.TemporaryId temp) {
208 moduleBuilder.addImport(compiler.getModuleName(lib.source.uri), temp, 210 moduleBuilder.addImport(compiler.getModuleName(lib.source.uri), temp,
209 isLazy: _isDartRuntime || !_loader.libraryIsLoaded(lib)); 211 isLazy: _isDartRuntime || !_loader.libraryIsLoaded(lib));
210 }); 212 });
211 213
212 // TODO(jmesserly): scriptTag support. 214 // TODO(jmesserly): scriptTag support.
213 // Enable this if we know we're targetting command line environment? 215 // Enable this if we know we're targetting command line environment?
214 // It doesn't work in browser. 216 // It doesn't work in browser.
215 // var jsBin = compiler.options.runnerOptions.v8Binary; 217 // var jsBin = compiler.options.runnerOptions.v8Binary;
216 // String scriptTag = null; 218 // String scriptTag = null;
217 // if (library.library.scriptTag != null) scriptTag = '/usr/bin/env $jsBin'; 219 // if (library.library.scriptTag != null) scriptTag = '/usr/bin/env $jsBin';
218 return moduleBuilder.build( 220 return moduleBuilder.build(
219 compiler.getModuleName(currentLibrary.source.uri), 221 currentModuleName,
220 _jsModuleValue, 222 _jsModuleValue,
221 _exportsVar, 223 _exportsVar,
222 items); 224 items);
223 } 225 }
224 226
225 void _emitModuleItem(AstNode node) { 227 void _emitModuleItem(AstNode node) {
226 // Attempt to group adjacent properties. 228 // Attempt to group adjacent properties.
227 if (node is! FunctionDeclaration) _flushLibraryProperties(_moduleItems); 229 if (node is! FunctionDeclaration) _flushLibraryProperties(_moduleItems);
228 230
229 var code = _visit(node); 231 var code = _visit(node);
(...skipping 3459 matching lines...) Expand 10 before | Expand all | Expand 10 after
3689 3691
3690 /// A special kind of element created by the compiler, signifying a temporary 3692 /// A special kind of element created by the compiler, signifying a temporary
3691 /// variable. These objects use instance equality, and should be shared 3693 /// variable. These objects use instance equality, and should be shared
3692 /// everywhere in the tree where they are treated as the same variable. 3694 /// everywhere in the tree where they are treated as the same variable.
3693 class TemporaryVariableElement extends LocalVariableElementImpl { 3695 class TemporaryVariableElement extends LocalVariableElementImpl {
3694 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name); 3696 TemporaryVariableElement.forNode(Identifier name) : super.forNode(name);
3695 3697
3696 int get hashCode => identityHashCode(this); 3698 int get hashCode => identityHashCode(this);
3697 bool operator ==(Object other) => identical(this, other); 3699 bool operator ==(Object other) => identical(this, other);
3698 } 3700 }
OLDNEW
« no previous file with comments | « lib/runtime/dart/html.js ('k') | lib/src/codegen/js_module_item_order.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698