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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1182653002: Refactor runtime into libraries, better type reps (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Address comments 2 Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/codegen/html_codegen.dart ('k') | lib/src/dependency_graph.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 20a1eccf4d49d92187b63aa90a9ec7f991c0259e..50b26769efdd4c058928ee2439d68b0b1b1b12a8 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -84,7 +84,9 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
/// The name for the library's exports inside itself.
/// `exports` was chosen as the most similar to ES module patterns.
+ final _dartxVar = new JS.Identifier('dartx');
final _exportsVar = new JS.TemporaryId('exports');
+ final _runtimeLibVar = new JS.Identifier('dart');
final _namedArgTemp = new JS.TemporaryId('opts');
ConstFieldVisitor _constField;
@@ -181,14 +183,14 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
// TODO(jmesserly): it would be great to run the renamer on the body,
// then figure out if we really need each of these parameters.
// See ES6 modules: https://github.com/dart-lang/dev_compiler/issues/34
- var params = [_exportsVar];
+ var params = [_exportsVar, _runtimeLibVar];
var processImport = (LibraryElement library, JS.TemporaryId temp,
List list) {
params.add(temp);
list.add(js.string(jsOutputBase(library, root), "'"));
};
- var imports = [];
+ var imports = [js.string('dart_runtime/dart')];
_imports.forEach((library, temp) {
if (_loader.libraryIsLoaded(library)) {
processImport(library, temp, imports);
@@ -202,11 +204,17 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
}
});
- var module =
- js.call("function(#) { 'use strict'; #; }", [params, _moduleItems]);
+ var dartxImport =
+ js.statement("let # = #.dartx;", [_dartxVar, _runtimeLibVar]);
+
+ var module = js.call("function(#) { 'use strict'; #; #; }", [
+ params,
+ dartxImport,
+ _moduleItems
+ ]);
var program = [
- js.statement("dart.library(#, #, #, #, #)", [
+ js.statement("dart_library.library(#, #, #, #, #)", [
jsPath,
jsDefaultValue != null ? jsDefaultValue : new JS.LiteralNull(),
js.commentExpression(
« no previous file with comments | « lib/src/codegen/html_codegen.dart ('k') | lib/src/dependency_graph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698