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

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: Add missing file 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
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..42d3b60c5015f6980b58e2036920e45ef708ce83 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, _dartxVar];
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/dart_runtime'), js.string('dart/dartx')];
_imports.forEach((library, temp) {
if (_loader.libraryIsLoaded(library)) {
processImport(library, temp, imports);
@@ -206,7 +208,7 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
js.call("function(#) { 'use strict'; #; }", [params, _moduleItems]);
var program = [
- js.statement("dart.library(#, #, #, #, #)", [
+ js.statement("loader.library(#, #, #, #, #)", [
jsPath,
jsDefaultValue != null ? jsDefaultValue : new JS.LiteralNull(),
js.commentExpression(

Powered by Google App Engine
This is Rietveld 408576698