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

Unified Diff: pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart

Issue 897013003: dart2js: add common names to mangledGlobalNames in new emitter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comment. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/cyclic_type_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart
diff --git a/pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart
index 3546e185c9513994946a2b4569623299a1f1cff7..6e37f27edaf5e9bce1be9c4199c4851c21c1f9f6 100644
--- a/pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/new_emitter/model_emitter.dart
@@ -6,6 +6,7 @@ library dart2js.new_js_emitter.model_emitter;
import '../../dart2jslib.dart' show Compiler;
import '../../dart_types.dart' show DartType;
+import '../../elements/elements.dart' show ClassElement;
import '../../js/js.dart' as js;
import '../../js_backend/js_backend.dart' show
JavaScriptBackend,
@@ -32,6 +33,7 @@ import '../js_emitter.dart' show NativeGenerator, buildTearOffCode;
import '../model.dart';
+
class ModelEmitter {
final Compiler compiler;
final Namer namer;
@@ -209,8 +211,7 @@ class ModelEmitter {
program.typeToInterceptorMap));
}
- globals.add(new js.Property(js.string(MANGLED_GLOBAL_NAMES),
- js.js('Object.create(null)', [])));
+ globals.add(emitMangledGlobalNames());
globals.add(emitGetTypeFromName());
@@ -234,6 +235,24 @@ class ModelEmitter {
return new js.Block(statements);
}
+ js.Property emitMangledGlobalNames() {
+ List<js.Property> names = <js.Property>[];
+
+ // We want to keep the original names for the most common core classes when
+ // calling toString on them.
+ List<ClassElement> nativeClassesNeedingUnmangledName =
+ [compiler.intClass, compiler.doubleClass, compiler.numClass,
+ compiler.stringClass, compiler.boolClass, compiler.nullClass,
+ compiler.listClass];
+ nativeClassesNeedingUnmangledName.forEach((element) {
+ names.add(new js.Property(js.string(namer.getNameOfClass(element)),
+ js.string(element.name)));
+ });
+
+ return new js.Property(js.string(MANGLED_GLOBAL_NAMES),
+ new js.ObjectInitializer(names));
+ }
+
List<js.Property> emitLoadUrisAndHashes(Map<String, List<Fragment>> loadMap) {
js.ArrayInitializer outputUris(List<Fragment> fragments) {
return js.stringArray(fragments.map((DeferredFragment fragment) =>
« no previous file with comments | « no previous file | tests/language/cyclic_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698