| 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 | 228 // TODO(ngeoffray): If this functionality ever become performance |
| 229 // critical, we might want to dynamically change [interceptedNames] | 229 // critical, we might want to dynamically change [interceptedNames] |
| 230 // to be a JavaScript object with intercepted names as property | 230 // to be a JavaScript object with intercepted names as property |
| 231 // instead of a JavaScript array. | 231 // instead of a JavaScript array. |
| 232 // TODO(floitsch): we already add stubs (tear-off getters) as properties | 232 // TODO(floitsch): we already add stubs (tear-off getters) as properties |
| 233 // in the embedded global interceptedNames. | 233 // in the embedded global interceptedNames. |
| 234 // Finish the transition and always use the object as hashtable. | 234 // Finish the transition and always use the object as hashtable. |
| 235 bool isIntercepted = | 235 bool isIntercepted = |
| 236 JS("bool", | 236 JS("bool", 'Object.prototype.hasOwnProperty.call(#, #)', |
| 237 'Object.prototype.hasOwnProperty.call(#, #) || #.indexOf(#) !== -1', | 237 interceptedNames, name); |
| 238 embeddedInterceptedNames, name, interceptedNames, name); | |
| 239 if (isIntercepted) { | 238 if (isIntercepted) { |
| 240 receiver = interceptor; | 239 receiver = interceptor; |
| 241 if (JS('bool', '# === #', object, interceptor)) { | 240 if (JS('bool', '# === #', object, interceptor)) { |
| 242 interceptor = null; | 241 interceptor = null; |
| 243 } | 242 } |
| 244 } else { | 243 } else { |
| 245 interceptor = null; | 244 interceptor = null; |
| 246 } | 245 } |
| 247 bool isCatchAll = false; | 246 bool isCatchAll = false; |
| 248 var method = JS('var', '#[#]', receiver, name); | 247 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'."); | 3435 throw new MainError("No top-level function named 'main'."); |
| 3437 } | 3436 } |
| 3438 | 3437 |
| 3439 void badMain() { | 3438 void badMain() { |
| 3440 throw new MainError("'main' is not a function."); | 3439 throw new MainError("'main' is not a function."); |
| 3441 } | 3440 } |
| 3442 | 3441 |
| 3443 void mainHasTooManyParameters() { | 3442 void mainHasTooManyParameters() { |
| 3444 throw new MainError("'main' expects too many parameters."); | 3443 throw new MainError("'main' expects too many parameters."); |
| 3445 } | 3444 } |
| OLD | NEW |