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

Side by Side Diff: sdk/lib/_internal/js_runtime/lib/js_names.dart

Issue 2841543002: Spelling a (Closed)
Patch Set: Created 3 years, 7 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
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' 7 import 'dart:_js_embedded_names'
8 show JsGetName, MANGLED_GLOBAL_NAMES, MANGLED_NAMES; 8 show JsGetName, MANGLED_GLOBAL_NAMES, MANGLED_NAMES;
9 9
10 import 'dart:_foreign_helper' show JS, JS_EMBEDDED_GLOBAL, JS_GET_NAME; 10 import 'dart:_foreign_helper' show JS, JS_EMBEDDED_GLOBAL, JS_GET_NAME;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 /// values are the "reflective" names. 44 /// values are the "reflective" names.
45 class _LazyMangledNamesMap { 45 class _LazyMangledNamesMap {
46 /// [_jsMangledNames] is a JavaScript object literal. 46 /// [_jsMangledNames] is a JavaScript object literal.
47 var _jsMangledNames; 47 var _jsMangledNames;
48 48
49 _LazyMangledNamesMap(this._jsMangledNames); 49 _LazyMangledNamesMap(this._jsMangledNames);
50 50
51 String operator [](String key) { 51 String operator [](String key) {
52 var result = JS('var', '#[#]', _jsMangledNames, key); 52 var result = JS('var', '#[#]', _jsMangledNames, key);
53 // Filter out all non-string values to protect against polution from 53 // Filter out all non-string values to protect against polution from
54 // anciliary fields in [_jsMangledNames]. 54 // ancilliary fields in [_jsMangledNames].
55 bool filter = JS('bool', 'typeof # !== "string"', result); 55 bool filter = JS('bool', 'typeof # !== "string"', result);
56 // To ensure that the inferrer sees that result is a String, we explicitly 56 // To ensure that the inferrer sees that result is a String, we explicitly
57 // give it a better type here. 57 // give it a better type here.
58 return filter ? null : JS('String', '#', result); 58 return filter ? null : JS('String', '#', result);
59 } 59 }
60 } 60 }
61 61
62 /// Extends [_LazyMangledNamesMap] with additional support for adding mappings 62 /// Extends [_LazyMangledNamesMap] with additional support for adding mappings
63 /// from mangled setter names to their reflective counterpart by rewriting a 63 /// from mangled setter names to their reflective counterpart by rewriting a
64 /// corresponding entry for a getter name, if it exists. 64 /// corresponding entry for a getter name, if it exists.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 _LazyReflectiveNamesMap(this._jsMangledNames, this._isInstance); 99 _LazyReflectiveNamesMap(this._jsMangledNames, this._isInstance);
100 100
101 Map<String, String> _updateReflectiveNames() { 101 Map<String, String> _updateReflectiveNames() {
102 preserveNames(); 102 preserveNames();
103 Map<String, String> result = <String, String>{}; 103 Map<String, String> result = <String, String>{};
104 List keys = JS('List', 'Object.keys(#)', _jsMangledNames); 104 List keys = JS('List', 'Object.keys(#)', _jsMangledNames);
105 for (String key in keys) { 105 for (String key in keys) {
106 var reflectiveName = JS('var', '#[#]', _jsMangledNames, key); 106 var reflectiveName = JS('var', '#[#]', _jsMangledNames, key);
107 // Filter out all non-string values to protect against polution from 107 // Filter out all non-string values to protect against polution from
108 // anciliary fields in [_jsMangledNames]. 108 // ancilliary fields in [_jsMangledNames].
109 bool filter = JS('bool', 'typeof # !== "string"', reflectiveName); 109 bool filter = JS('bool', 'typeof # !== "string"', reflectiveName);
110 if (filter) continue; 110 if (filter) continue;
111 result[reflectiveName] = JS('String', '#', key); 111 result[reflectiveName] = JS('String', '#', key);
112 112
113 String getterPrefix = JS_GET_NAME(JsGetName.GETTER_PREFIX); 113 String getterPrefix = JS_GET_NAME(JsGetName.GETTER_PREFIX);
114 if (_isInstance && key.startsWith(getterPrefix)) { 114 if (_isInstance && key.startsWith(getterPrefix)) {
115 int getterPrefixLength = getterPrefix.length; 115 int getterPrefixLength = getterPrefix.length;
116 String setterPrefix = JS_GET_NAME(JsGetName.SETTER_PREFIX); 116 String setterPrefix = JS_GET_NAME(JsGetName.SETTER_PREFIX);
117 result['$reflectiveName='] = 117 result['$reflectiveName='] =
118 '$setterPrefix${key.substring(getterPrefixLength)}'; 118 '$setterPrefix${key.substring(getterPrefixLength)}';
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 'String', 160 'String',
161 r''' 161 r'''
162 (function(str, names) { 162 (function(str, names) {
163 return str.replace( 163 return str.replace(
164 /[^<,> ]+/g, 164 /[^<,> ]+/g,
165 function(m) { return names[m] || m; }); 165 function(m) { return names[m] || m; });
166 })(#, #)''', 166 })(#, #)''',
167 str, 167 str,
168 JS_EMBEDDED_GLOBAL('', MANGLED_GLOBAL_NAMES)); 168 JS_EMBEDDED_GLOBAL('', MANGLED_GLOBAL_NAMES));
169 } 169 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_array.dart ('k') | sdk/lib/_internal/js_runtime/lib/preambles/d8.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698