| OLD | NEW |
| 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 JsGetName, | 8 JsGetName, |
| 9 MANGLED_GLOBAL_NAMES, | 9 MANGLED_GLOBAL_NAMES, |
| 10 MANGLED_NAMES; | 10 MANGLED_NAMES; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 if (_isInstance && key.startsWith(getterPrefix)) { | 123 if (_isInstance && key.startsWith(getterPrefix)) { |
| 124 int getterPrefixLength = getterPrefix.length; | 124 int getterPrefixLength = getterPrefix.length; |
| 125 String setterPrefix = JS_GET_NAME(JsGetName.SETTER_PREFIX); | 125 String setterPrefix = JS_GET_NAME(JsGetName.SETTER_PREFIX); |
| 126 result['$reflectiveName='] = | 126 result['$reflectiveName='] = |
| 127 '$setterPrefix${key.substring(getterPrefixLength)}'; | 127 '$setterPrefix${key.substring(getterPrefixLength)}'; |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 return result; | 130 return result; |
| 131 } | 131 } |
| 132 | 132 |
| 133 int get _jsMangledNamesLength => JS('int', '#.length', _jsMangledNames); | 133 int get _jsMangledNamesLength => JS('int', 'Object.keys(#).length', |
| 134 _jsMangledNames); |
| 134 | 135 |
| 135 String operator[](String key) { | 136 String operator[](String key) { |
| 136 if (_cache == null || _jsMangledNamesLength != _cacheLength) { | 137 if (_cache == null || _jsMangledNamesLength != _cacheLength) { |
| 137 _cache = _updateReflectiveNames(); | 138 _cache = _updateReflectiveNames(); |
| 138 _cacheLength = _jsMangledNamesLength; | 139 _cacheLength = _jsMangledNamesLength; |
| 139 } | 140 } |
| 140 return _cache[key]; | 141 return _cache[key]; |
| 141 } | 142 } |
| 142 } | 143 } |
| 143 | 144 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 163 return JsCache.fetch(names, name); | 164 return JsCache.fetch(names, name); |
| 164 } | 165 } |
| 165 | 166 |
| 166 String unmangleAllIdentifiersIfPreservedAnyways(String str) { | 167 String unmangleAllIdentifiersIfPreservedAnyways(String str) { |
| 167 return JS("String", | 168 return JS("String", |
| 168 r"(#).replace(/[^<,> ]+/g," | 169 r"(#).replace(/[^<,> ]+/g," |
| 169 r"function(m) { return #[m] || m; })", | 170 r"function(m) { return #[m] || m; })", |
| 170 str, | 171 str, |
| 171 JS_EMBEDDED_GLOBAL('', MANGLED_GLOBAL_NAMES)); | 172 JS_EMBEDDED_GLOBAL('', MANGLED_GLOBAL_NAMES)); |
| 172 } | 173 } |
| OLD | NEW |