| 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 _js_helper; | 5 library _js_helper; |
| 6 | 6 |
| 7 import 'dart:_js_embedded_names' show | 7 import 'dart:_js_embedded_names' show |
| 8 ALL_CLASSES, | 8 ALL_CLASSES, |
| 9 GET_ISOLATE_TAG, | 9 GET_ISOLATE_TAG, |
| 10 INTERCEPTED_NAMES, | 10 INTERCEPTED_NAMES, |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 _arguments[namedArgumentsStartIndex + i]; | 217 _arguments[namedArgumentsStartIndex + i]; |
| 218 } | 218 } |
| 219 return map; | 219 return map; |
| 220 } | 220 } |
| 221 | 221 |
| 222 _getCachedInvocation(Object object) { | 222 _getCachedInvocation(Object object) { |
| 223 var interceptor = getInterceptor(object); | 223 var interceptor = getInterceptor(object); |
| 224 var receiver = object; | 224 var receiver = object; |
| 225 var name = _internalName; | 225 var name = _internalName; |
| 226 var arguments = _arguments; | 226 var arguments = _arguments; |
| 227 var embeddedInterceptedNames = JS_EMBEDDED_GLOBAL('', INTERCEPTED_NAMES); | 227 var interceptedNames = JS_EMBEDDED_GLOBAL('', INTERCEPTED_NAMES); |
| 228 // TODO(ngeoffray): If this functionality ever become performance | |
| 229 // critical, we might want to dynamically change [interceptedNames] | |
| 230 // to be a JavaScript object with intercepted names as property | |
| 231 // instead of a JavaScript array. | |
| 232 // TODO(floitsch): we already add stubs (tear-off getters) as properties | |
| 233 // in the embedded global interceptedNames. | |
| 234 // Finish the transition and always use the object as hashtable. | |
| 235 bool isIntercepted = | 228 bool isIntercepted = |
| 236 JS("bool", | 229 JS("bool", 'Object.prototype.hasOwnProperty.call(#, #)', |
| 237 'Object.prototype.hasOwnProperty.call(#, #) || #.indexOf(#) !== -1', | 230 interceptedNames, name); |
| 238 embeddedInterceptedNames, name, interceptedNames, name); | |
| 239 if (isIntercepted) { | 231 if (isIntercepted) { |
| 240 receiver = interceptor; | 232 receiver = interceptor; |
| 241 if (JS('bool', '# === #', object, interceptor)) { | 233 if (JS('bool', '# === #', object, interceptor)) { |
| 242 interceptor = null; | 234 interceptor = null; |
| 243 } | 235 } |
| 244 } else { | 236 } else { |
| 245 interceptor = null; | 237 interceptor = null; |
| 246 } | 238 } |
| 247 bool isCatchAll = false; | 239 bool isCatchAll = false; |
| 248 var method = JS('var', '#[#]', receiver, name); | 240 var method = JS('var', '#[#]', receiver, name); |
| (...skipping 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3436 throw new MainError("No top-level function named 'main'."); | 3428 throw new MainError("No top-level function named 'main'."); |
| 3437 } | 3429 } |
| 3438 | 3430 |
| 3439 void badMain() { | 3431 void badMain() { |
| 3440 throw new MainError("'main' is not a function."); | 3432 throw new MainError("'main' is not a function."); |
| 3441 } | 3433 } |
| 3442 | 3434 |
| 3443 void mainHasTooManyParameters() { | 3435 void mainHasTooManyParameters() { |
| 3444 throw new MainError("'main' expects too many parameters."); | 3436 throw new MainError("'main' expects too many parameters."); |
| 3445 } | 3437 } |
| OLD | NEW |