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

Side by Side Diff: dart/sdk/lib/_internal/compiler/js_lib/js_names.dart

Issue 938413002: Work around Safari for-in bug. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Merged with r43958. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/sdk/lib/_internal/compiler/js_lib/js_mirrors.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart._js_names; 5 library dart._js_names;
6 6
7 import 'dart:_js_embedded_names' show 7 import 'dart:_js_embedded_names' show
8 MANGLED_GLOBAL_NAMES, 8 MANGLED_GLOBAL_NAMES,
9 MANGLED_NAMES; 9 MANGLED_NAMES;
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 preserveNames(); 72 preserveNames();
73 var result = <String, String>{}; 73 var result = <String, String>{};
74 map.forEach((String mangledName, String reflectiveName) { 74 map.forEach((String mangledName, String reflectiveName) {
75 result[reflectiveName] = mangledName; 75 result[reflectiveName] = mangledName;
76 }); 76 });
77 return result; 77 return result;
78 } 78 }
79 79
80 @NoInline() 80 @NoInline()
81 List extractKeys(victim) { 81 List extractKeys(victim) {
82 var result = JS('', ''' 82 var result = JS('', '# ? Object.keys(#) : []', victim, victim);
83 (function(victim, hasOwnProperty) {
84 var result = [];
85 for (var key in victim) {
86 if (hasOwnProperty.call(victim, key)) result.push(key);
87 }
88 return result;
89 })(#, Object.prototype.hasOwnProperty)''', victim);
90 return new JSArray.markFixed(result); 83 return new JSArray.markFixed(result);
91 } 84 }
92 85
93 /** 86 /**
94 * Returns the (global) unmangled version of [name]. 87 * Returns the (global) unmangled version of [name].
95 * 88 *
96 * Normally, you should use [mangledGlobalNames] directly, but this method 89 * Normally, you should use [mangledGlobalNames] directly, but this method
97 * doesn't tell the compiler to preserve names. So this method only returns a 90 * doesn't tell the compiler to preserve names. So this method only returns a
98 * non-null value if some other component has made the compiler preserve names. 91 * non-null value if some other component has made the compiler preserve names.
99 * 92 *
100 * This is used, for example, to return unmangled names from TypeImpl.toString 93 * This is used, for example, to return unmangled names from TypeImpl.toString
101 * *if* names are being preserved for other reasons (use of dart:mirrors, for 94 * *if* names are being preserved for other reasons (use of dart:mirrors, for
102 * example). 95 * example).
103 */ 96 */
104 String unmangleGlobalNameIfPreservedAnyways(String name) { 97 String unmangleGlobalNameIfPreservedAnyways(String name) {
105 var names = JS_EMBEDDED_GLOBAL('=Object', MANGLED_GLOBAL_NAMES); 98 var names = JS_EMBEDDED_GLOBAL('=Object', MANGLED_GLOBAL_NAMES);
106 return JsCache.fetch(names, name); 99 return JsCache.fetch(names, name);
107 } 100 }
108 101
109 String unmangleAllIdentifiersIfPreservedAnyways(String str) { 102 String unmangleAllIdentifiersIfPreservedAnyways(String str) {
110 return JS("String", 103 return JS("String",
111 r"(#).replace(/[^<,> ]+/g," 104 r"(#).replace(/[^<,> ]+/g,"
112 r"function(m) { return #[m] || m; })", 105 r"function(m) { return #[m] || m; })",
113 str, 106 str,
114 JS_EMBEDDED_GLOBAL('', MANGLED_GLOBAL_NAMES)); 107 JS_EMBEDDED_GLOBAL('', MANGLED_GLOBAL_NAMES));
115 } 108 }
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/js_lib/js_mirrors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698