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

Side by Side Diff: dart/sdk/lib/_internal/lib/js_names.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library dart._js_names;
6
7 import 'dart:_foreign_helper' show JS;
8
9 /// No-op method that is called to inform the compiler that unmangled
10 /// named must be preserved.
11 preserveNames() {}
12
13 final Map<String, String> mangledNames = computeMangledNames();
14
15 final Map<String, String> reflectiveNames = computeReflectiveNames();
16
17 Map<String, String> computeMangledNames() {
18 preserveNames();
19 var mangledNames = JS('', 'init.mangledNames');
20 var keys = extractKeys(mangledNames);
21 var result = <String, String>{};
22 for (String key in keys) {
23 result[key] = JS('String', '#[#]', mangledNames, key);
24 }
25 return result;
26 }
27
28 Map<String, String> computeReflectiveNames() {
29 preserveNames();
30 var result = <String, String>{};
31 mangledNames.forEach((String mangledName, String reflectiveName) {
32 result[reflectiveName] = mangledName;
kasperl 2013/06/19 09:19:50 Weird indentation.
ahe 2013/06/19 12:20:59 Done.
33 });
34 return result;
35 }
36
37 List extractKeys(victim) {
38 return JS('List', '''
39 (function(victim, hasOwnProperty) {
40 var result = [];
41 for (var key in victim) {
42 if (hasOwnProperty.call(victim, key)) result.push(key);
43 }
44 return result;
45 })(#, Object.prototype.hasOwnProperty)''', victim);
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698