| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A function element that represents a closure call. The signature is copied | 8 * A function element that represents a closure call. The signature is copied |
| 9 * from the given element. | 9 * from the given element. |
| 10 */ | 10 */ |
| (...skipping 2865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2876 js.if_( | 2876 js.if_( |
| 2877 js('(typeof receiver) != "object"'), | 2877 js('(typeof receiver) != "object"'), |
| 2878 js.return_(js('receiver')))); | 2878 js.return_(js('receiver')))); |
| 2879 | 2879 |
| 2880 // if (receiver instanceof $.Object) return receiver; | 2880 // if (receiver instanceof $.Object) return receiver; |
| 2881 // return $.getNativeInterceptor(receiver); | 2881 // return $.getNativeInterceptor(receiver); |
| 2882 block.statements.add( | 2882 block.statements.add( |
| 2883 js.if_(js('receiver instanceof #', | 2883 js.if_(js('receiver instanceof #', |
| 2884 js(namer.isolateAccess(compiler.objectClass))), | 2884 js(namer.isolateAccess(compiler.objectClass))), |
| 2885 js.return_(js('receiver')))); | 2885 js.return_(js('receiver')))); |
| 2886 | |
| 2887 // TODO(sra): Fold this 'Object' check into the `getNativeInterceptor` | |
| 2888 // check by patching `Object.prototype` with a special hook function. | |
| 2889 // TODO(9556): This test is needed in plain non-browser code because | |
| 2890 // 'holders' are not Dart classes. | |
| 2891 block.statements.add( | |
| 2892 js.if_( | |
| 2893 js('Object.getPrototypeOf(receiver) === Object.prototype'), | |
| 2894 buildReturnInterceptor(backend.jsInterceptorClass))); | |
| 2895 | |
| 2896 block.statements.add( | 2886 block.statements.add( |
| 2897 js.return_( | 2887 js.return_( |
| 2898 js(namer.isolateAccess(backend.getNativeInterceptorMethod))( | 2888 js(namer.isolateAccess(backend.getNativeInterceptorMethod))( |
| 2899 ['receiver']))); | 2889 ['receiver']))); |
| 2900 | 2890 |
| 2901 } else { | 2891 } else { |
| 2902 ClassElement jsUnknown = backend.jsUnknownClass; | 2892 ClassElement jsUnknown = backend.jsUnknownClass; |
| 2903 if (compiler.codegenWorld.instantiatedClasses.contains(jsUnknown)) { | 2893 if (compiler.codegenWorld.instantiatedClasses.contains(jsUnknown)) { |
| 2904 block.statements.add( | 2894 block.statements.add( |
| 2905 js.if_(js('!(receiver instanceof #)', | 2895 js.if_(js('!(receiver instanceof #)', |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3639 | 3629 |
| 3640 const String HOOKS_API_USAGE = """ | 3630 const String HOOKS_API_USAGE = """ |
| 3641 // The code supports the following hooks: | 3631 // The code supports the following hooks: |
| 3642 // dartPrint(message) - if this function is defined it is called | 3632 // dartPrint(message) - if this function is defined it is called |
| 3643 // instead of the Dart [print] method. | 3633 // instead of the Dart [print] method. |
| 3644 // dartMainRunner(main) - if this function is defined, the Dart [main] | 3634 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 3645 // method will not be invoked directly. | 3635 // method will not be invoked directly. |
| 3646 // Instead, a closure that will invoke [main] is | 3636 // Instead, a closure that will invoke [main] is |
| 3647 // passed to [dartMainRunner]. | 3637 // passed to [dartMainRunner]. |
| 3648 """; | 3638 """; |
| OLD | NEW |