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

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

Issue 1145243013: Check for duplicate library names (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: 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 87d29fceef6978e42cd9af85c9c150f20aec3050..109462fe52b33b594f725a7f3281a2f41f92d2dd 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -114,7 +114,6 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
jsDefaultValue = getConstantField(jsName, 'name', types.stringType);
}
}
- if (jsDefaultValue == null) jsDefaultValue = '{}';
// TODO(jmesserly): visit scriptTag, directives?
@@ -163,16 +162,16 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
}
var name = new JS.Identifier(jsLibraryName(currentLibrary));
Jennifer Messerly 2015/06/05 16:22:27 suggestion, maybe build the Identifier later, and
vsm 2015/06/05 17:01:04 Done.
+ var jsName = js.string(name.name, "'");
// 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 program = [
- js.statement('var # = dart.defineLibrary(#, #);', [
- name,
- name,
- js.call(jsDefaultValue)
- ])
+ jsDefaultValue != null
+ ? js.statement(
+ 'dart.defineLibrary(#, #);', [jsName, js.call(jsDefaultValue)])
+ : js.statement('dart.defineLibrary(#);', [jsName])
];
var params = [_exportsVar];
@@ -182,7 +181,8 @@ class JSCodegenVisitor extends GeneralizingAstVisitor with ConversionVisitor {
params.add(temp);
args.add(name);
var helper = _loader.libraryIsLoaded(library) ? 'import' : 'lazyImport';
- program.add(js.statement('var # = dart.#(#);', [name, helper, name]));
+ program
+ .add(js.statement('dart.#(#);', [helper, js.string(name.name, "'")]));
});
program.add(js.statement("(function(#) { 'use strict'; #; })(#);", [

Powered by Google App Engine
This is Rietveld 408576698