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

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

Issue 16851002: Implement minified MirrorSystem.getName. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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_mirrors.dart
diff --git a/dart/sdk/lib/_internal/lib/js_mirrors.dart b/dart/sdk/lib/_internal/lib/js_mirrors.dart
index 3e99fe9f00f0804a57bdf7aedaa19ae605fd21fe..e8de165faa6798603bccf5f9e4871e304214f8ed 100644
--- a/dart/sdk/lib/_internal/lib/js_mirrors.dart
+++ b/dart/sdk/lib/_internal/lib/js_mirrors.dart
@@ -16,27 +16,19 @@ import 'dart:_js_helper' show
Null,
Primitives,
RuntimeError,
- createInvocationMirror;
+ createUnmangledInvocationMirror;
import 'dart:_interceptors' show Interceptor;
+import 'dart:_js_names';
/// No-op method that is called to inform the compiler that
/// tree-shaking needs to be disabled.
disableTreeShaking() => preserveNames();
-/// No-op method that is called to inform the compiler that unmangled
-/// named must be preserved.
-preserveNames() {}
-
String getName(Symbol symbol) {
preserveNames();
return n(symbol);
}
-final Map<String, String> mangledNames = JsMirrorSystem.computeMangledNames();
-
-final Map<String, String> reflectiveNames =
- JsMirrorSystem.computeReflectiveNames();
-
class JsMirrorSystem implements MirrorSystem {
TypeMirror get dynamicType => _dynamicType;
TypeMirror get voidType => _voidType;
@@ -71,26 +63,6 @@ class JsMirrorSystem implements MirrorSystem {
}
return result;
}
-
- static Map<String, String> computeMangledNames() {
- disableTreeShaking();
- var mangledNames = JS('', 'init.mangledNames');
- var keys = extractKeys(mangledNames);
- var result = <String, String>{};
- for (String key in keys) {
- result[key] = JS('String', '#[#]', mangledNames, key);
- }
- return result;
- }
-
- static Map<String, String> computeReflectiveNames() {
- disableTreeShaking();
- var result = <String, String>{};
- mangledNames.forEach((String mangledName, String reflectiveName) {
- result[reflectiveName] = mangledName;
- });
- return result;
- }
}
abstract class JsMirror {
@@ -327,10 +299,11 @@ class JsInstanceMirror extends JsObjectMirror implements InstanceMirror {
int type,
String mangledName,
List arguments) {
+ disableTreeShaking();
// TODO(ahe): Get the argument names.
List<String> argumentNames = [];
- Invocation invocation = createInvocationMirror(
- n(name), mangledName, type, arguments, argumentNames);
+ Invocation invocation = createUnmangledInvocationMirror(
+ name, mangledName, type, arguments, argumentNames);
return reflect(delegate(invocation));
}
@@ -744,14 +717,3 @@ List extractMetadata(victim) {
return (metadataFunction == null)
? const [] : JS('', '#()', metadataFunction);
}
-
-List extractKeys(victim) {
- return JS('List', '''
-(function(victim, hasOwnProperty) {
- var result = [];
- for (var key in victim) {
- if (hasOwnProperty.call(victim, key)) result.push(key);
- }
- return result;
-})(#, Object.prototype.hasOwnProperty)''', victim);
-}

Powered by Google App Engine
This is Rietveld 408576698