Chromium Code Reviews| 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 JsGetName, | 8 JsGetName, |
| 9 ALL_CLASSES, | 9 ALL_CLASSES, |
| 10 LAZIES, | 10 LAZIES, |
| (...skipping 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2229 String cacheName = Primitives.mirrorFunctionCacheName; | 2229 String cacheName = Primitives.mirrorFunctionCacheName; |
| 2230 JsMethodMirror cachedFunction; | 2230 JsMethodMirror cachedFunction; |
| 2231 // TODO(ahe): Restore caching. | 2231 // TODO(ahe): Restore caching. |
| 2232 //= JS('JsMethodMirror|Null', r'#.constructor[#]', reflectee, cacheName); | 2232 //= JS('JsMethodMirror|Null', r'#.constructor[#]', reflectee, cacheName); |
| 2233 if (cachedFunction != null) return cachedFunction; | 2233 if (cachedFunction != null) return cachedFunction; |
| 2234 disableTreeShaking(); | 2234 disableTreeShaking(); |
| 2235 // TODO(ahe): What about optional parameters (named or not). | 2235 // TODO(ahe): What about optional parameters (named or not). |
| 2236 String callPrefix = "${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$"; | 2236 String callPrefix = "${JS_GET_NAME(JsGetName.CALL_PREFIX)}\$"; |
| 2237 var extractCallName = JS('', r''' | 2237 var extractCallName = JS('', r''' |
| 2238 function(reflectee) { | 2238 function(reflectee) { |
| 2239 for (var property in reflectee) { | 2239 var properties = Object.keys(reflectee); |
|
ahe
2015/02/20 14:32:16
I'm pretty sure I was too lazy to use hasOwnProper
floitsch
2015/02/20 16:08:03
Change LGTM. The call-properties are stored on the
ahe
2015/02/20 18:05:19
Turns out that the property is stored on the proto
| |
| 2240 if (# == property.substring(0, #) && | 2240 for (var i = 0; i < properties.length; i++) { |
| 2241 property[#] >= '0' && | 2241 var property = properties[i]; |
| 2242 property[#] <= '9') return property; | 2242 if (#callPrefix == property.substring(0, #callPrefix_length) && |
| 2243 property[#callPrefix_length] >= '0' && | |
| 2244 property[#callPrefix_length] <= '9') return property; | |
| 2243 } | 2245 } |
| 2244 return null; | 2246 return null; |
| 2245 } | 2247 } |
| 2246 ''', callPrefix, callPrefix.length, callPrefix.length, callPrefix.length); | 2248 ''', { 'callPrefix': callPrefix, 'callPrefix_length': callPrefix.length }); |
| 2247 String callName = JS('String|Null', '#(#)', extractCallName, reflectee); | 2249 String callName = JS('String|Null', '#(#)', extractCallName, reflectee); |
| 2248 if (callName == null) { | 2250 if (callName == null) { |
| 2249 throw new RuntimeError('Cannot find callName on "$reflectee"'); | 2251 throw new RuntimeError('Cannot find callName on "$reflectee"'); |
| 2250 } | 2252 } |
| 2251 // TODO(floitsch): What about optional parameters? | 2253 // TODO(floitsch): What about optional parameters? |
| 2252 int parameterCount = int.parse(callName.split(r'$')[1]); | 2254 int parameterCount = int.parse(callName.split(r'$')[1]); |
| 2253 if (reflectee is BoundClosure) { | 2255 if (reflectee is BoundClosure) { |
| 2254 var target = BoundClosure.targetOf(reflectee); | 2256 var target = BoundClosure.targetOf(reflectee); |
| 2255 var self = BoundClosure.selfOf(reflectee); | 2257 var self = BoundClosure.selfOf(reflectee); |
| 2256 var name = mangledNames[BoundClosure.nameOf(reflectee)]; | 2258 var name = mangledNames[BoundClosure.nameOf(reflectee)]; |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3027 // have a part (following a '.') that starts with '_'. | 3029 // have a part (following a '.') that starts with '_'. |
| 3028 const int UNDERSCORE = 0x5f; | 3030 const int UNDERSCORE = 0x5f; |
| 3029 if (name.isEmpty) return true; | 3031 if (name.isEmpty) return true; |
| 3030 int index = -1; | 3032 int index = -1; |
| 3031 do { | 3033 do { |
| 3032 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; | 3034 if (name.codeUnitAt(index + 1) == UNDERSCORE) return false; |
| 3033 index = name.indexOf('.', index + 1); | 3035 index = name.indexOf('.', index + 1); |
| 3034 } while (index >= 0 && index + 1 < name.length); | 3036 } while (index >= 0 && index + 1 < name.length); |
| 3035 return true; | 3037 return true; |
| 3036 } | 3038 } |
| OLD | NEW |