| 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_mirrors; | 5 library dart._js_mirrors; |
| 6 | 6 |
| 7 import 'dart:_js_embedded_names' show | 7 import 'dart:_js_embedded_names' show |
| 8 ALL_CLASSES, | 8 ALL_CLASSES, |
| 9 LAZIES, | 9 LAZIES, |
| 10 LIBRARIES, | 10 LIBRARIES, |
| (...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2227 String cacheName = Primitives.mirrorFunctionCacheName; | 2227 String cacheName = Primitives.mirrorFunctionCacheName; |
| 2228 JsMethodMirror cachedFunction; | 2228 JsMethodMirror cachedFunction; |
| 2229 // TODO(ahe): Restore caching. | 2229 // TODO(ahe): Restore caching. |
| 2230 //= JS('JsMethodMirror|Null', r'#.constructor[#]', reflectee, cacheName); | 2230 //= JS('JsMethodMirror|Null', r'#.constructor[#]', reflectee, cacheName); |
| 2231 if (cachedFunction != null) return cachedFunction; | 2231 if (cachedFunction != null) return cachedFunction; |
| 2232 disableTreeShaking(); | 2232 disableTreeShaking(); |
| 2233 // TODO(ahe): What about optional parameters (named or not). | 2233 // TODO(ahe): What about optional parameters (named or not). |
| 2234 String callPrefix = "${JS_GET_NAME("CALL_PREFIX")}\$"; | 2234 String callPrefix = "${JS_GET_NAME("CALL_PREFIX")}\$"; |
| 2235 var extractCallName = JS('', r''' | 2235 var extractCallName = JS('', r''' |
| 2236 function(reflectee) { | 2236 function(reflectee) { |
| 2237 for (var property in reflectee) { | 2237 var properties = Object.keys(reflectee.constructor.prototype); |
| 2238 for (var i = 0; i < properties.length; i++) { |
| 2239 var property = properties[i]; |
| 2238 if (# == property.substring(0, #) && | 2240 if (# == property.substring(0, #) && |
| 2239 property[#] >= '0' && | 2241 property[#] >= '0' && |
| 2240 property[#] <= '9') return property; | 2242 property[#] <= '9') return property; |
| 2241 } | 2243 } |
| 2242 return null; | 2244 return null; |
| 2243 } | 2245 } |
| 2244 ''', callPrefix, callPrefix.length, callPrefix.length, callPrefix.length); | 2246 ''', callPrefix, callPrefix.length, callPrefix.length, callPrefix.length); |
| 2245 String callName = JS('String|Null', '#(#)', extractCallName, reflectee); | 2247 String callName = JS('String|Null', '#(#)', extractCallName, reflectee); |
| 2246 if (callName == null) { | 2248 if (callName == null) { |
| 2247 throw new RuntimeError('Cannot find callName on "$reflectee"'); | 2249 throw new RuntimeError('Cannot find callName on "$reflectee"'); |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3025 // have a part (following a '.') that starts with '_'. | 3027 // have a part (following a '.') that starts with '_'. |
| 3026 const int UNDERSCORE = 0x5f; | 3028 const int UNDERSCORE = 0x5f; |
| 3027 if (name.isEmpty) return true; | 3029 if (name.isEmpty) return true; |
| 3028 int index = -1; | 3030 int index = -1; |
| 3029 do { | 3031 do { |
| 3030 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; | 3032 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; |
| 3031 index = name.indexOf('.', index + 1); | 3033 index = name.indexOf('.', index + 1); |
| 3032 } while (index >= 0 && index + 1 < name.length); | 3034 } while (index >= 0 && index + 1 < name.length); |
| 3033 return true; | 3035 return true; |
| 3034 } | 3036 } |
| OLD | NEW |