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

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

Issue 17315012: Generate less code when importing dart:mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 7 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: 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 5e0fc8954ea6d47222363f01c9f7a8d7ac2210b8..1d56354474f277802f866337fa40dbe3369a02b0 100644
--- a/dart/sdk/lib/_internal/lib/js_names.dart
+++ b/dart/sdk/lib/_internal/lib/js_names.dart
@@ -14,7 +14,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'));
+ computeMangledNames(JS('', 'init.mangledNames'), false);
/// A map from "reflective" names to mangled names (the reverse of
/// [mangledNames]).
@@ -24,7 +24,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'));
+ computeMangledNames(JS('', 'init.mangledGlobalNames'), true);
/// A map from "reflective" names to mangled names (the reverse of
/// [mangledGlobalNames]).
@@ -33,12 +33,21 @@ final Map<String, String> reflectiveGlobalNames =
/// [jsMangledNames] is a JavaScript object literal. The keys are the mangled
/// names, and the values are the "reflective" names.
-Map<String, String> computeMangledNames(jsMangledNames) {
+Map<String, String> computeMangledNames(jsMangledNames, bool isGlobal) {
preserveNames();
var keys = extractKeys(jsMangledNames);
var result = <String, String>{};
+ String getterPrefix = JS('String', 'init.getterPrefix');
+ int getterPrefixLength = getterPrefix.length;
+ String setterPrefix = JS('String', 'init.setterPrefix');
for (String key in keys) {
- result[key] = JS('String', '#[#]', jsMangledNames, key);
+ String value = JS('String', '#[#]', jsMangledNames, key);
+ result[key] = value;
+ if (!isGlobal) {
+ if (key.startsWith(getterPrefix)) {
+ result['$setterPrefix${key.substring(getterPrefixLength)}'] = '$value=';
+ }
+ }
}
return result;
}
« no previous file with comments | « dart/sdk/lib/_internal/lib/js_mirrors.dart ('k') | dart/tests/compiler/dart2js/mirror_tree_shaking_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698