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

Unified Diff: dart/sdk/lib/_internal/lib/js_names.dart

Issue 22859004: Improve type literals in minified mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added a test, and changed how names are unmangled. Created 7 years, 4 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 | « dart/sdk/lib/_internal/lib/js_mirrors.dart ('k') | dart/sdk/lib/_internal/lib/js_rti.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/lib/js_names.dart
diff --git a/dart/sdk/lib/_internal/lib/js_names.dart b/dart/sdk/lib/_internal/lib/js_names.dart
index 4b3e9a9f8267612a6623afe5866e2bcd99ddc26c..9eaf777c4119a135644e74d136f77a04511a481b 100644
--- a/dart/sdk/lib/_internal/lib/js_names.dart
+++ b/dart/sdk/lib/_internal/lib/js_names.dart
@@ -6,6 +6,8 @@ library dart._js_names;
import 'dart:_foreign_helper' show JS, JS_GET_NAME;
+import 'dart:_js_helper' show JsCache;
+
/// No-op method that is called to inform the compiler that unmangled named
/// must be preserved.
preserveNames() {}
@@ -14,7 +16,7 @@ preserveNames() {}
/// with some additional information, such as, number of required arguments.
/// This map is for mangled names used as instance members.
final Map<String, String> mangledNames =
- computeMangledNames(JS('', 'init.mangledNames'), false);
+ computeMangledNames(JS('=Object', 'init.mangledNames'), false);
/// A map from "reflective" names to mangled names (the reverse of
/// [mangledNames]).
@@ -24,7 +26,7 @@ final Map<String, String> reflectiveNames =
/// A map from mangled names to "reflective" names (see [mangledNames]). This
/// map is for globals, that is, static and top-level members.
final Map<String, String> mangledGlobalNames =
- computeMangledNames(JS('', 'init.mangledGlobalNames'), true);
+ computeMangledNames(JS('=Object', 'init.mangledGlobalNames'), true);
/// A map from "reflective" names to mangled names (the reverse of
/// [mangledGlobalNames]).
@@ -71,3 +73,19 @@ List extractKeys(victim) {
return result;
})(#, Object.prototype.hasOwnProperty)''', victim);
}
+
+/**
+ * Returns the (global) unmangled version of [name].
+ *
+ * Normally, you should use [mangledGlobalNames] directly, but this method
+ * doesn't tell the compiler to preserve names. So this method only returns a
+ * non-null value if some other component has made the compiler preserve names.
+ *
+ * This is used, for example, to return unmangled names from TypeImpl.toString
+ * *if* names are being preserved for other reasons (use of dart:mirrors, for
+ * example).
+ */
+String unmangleGlobalNameIfPreservedAnyways(String name) {
+ var names = JS('=Object', 'init.mangledGlobalNames');
+ return JsCache.fetch(names, name);
+}
« no previous file with comments | « dart/sdk/lib/_internal/lib/js_mirrors.dart ('k') | dart/sdk/lib/_internal/lib/js_rti.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698