Chromium Code Reviews| 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 3141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3152 } | 3152 } |
| 3153 if (hasBool) { | 3153 if (hasBool) { |
| 3154 block.statements.add(buildInterceptorCheck(backend.jsBoolClass)); | 3154 block.statements.add(buildInterceptorCheck(backend.jsBoolClass)); |
| 3155 } | 3155 } |
| 3156 // TODO(ahe): It might be faster to check for Array before | 3156 // TODO(ahe): It might be faster to check for Array before |
| 3157 // function and bool. | 3157 // function and bool. |
| 3158 if (hasArray) { | 3158 if (hasArray) { |
| 3159 block.statements.add(buildInterceptorCheck(backend.jsArrayClass)); | 3159 block.statements.add(buildInterceptorCheck(backend.jsArrayClass)); |
| 3160 } | 3160 } |
| 3161 | 3161 |
| 3162 // TODO(ahe): Work with sra@ to integrate this with native interceptors, | |
| 3163 // and potentially initialize the dispatch object during finishClasses. | |
|
ngeoffray
2013/09/06 06:54:06
Please add a comment on what this is for, and what
ahe
2013/09/09 11:26:29
Done.
| |
| 3164 block.statements.add( | |
| 3165 js.if_(r'typeof receiver == "function" && "builtin$cls" in receiver', | |
| 3166 buildReturnInterceptor(backend.jsRuntimeType))); | |
| 3167 | |
| 3168 // TODO(ahe): This should be a constant and we should be able to remove | |
| 3169 // this test (so I'm keeping the redundant "object" test). | |
|
ngeoffray
2013/09/06 06:54:06
Ditto for having "func"
ahe
2013/09/09 11:26:29
Done.
| |
| 3170 block.statements.add( | |
| 3171 js.if_(r'typeof receiver == "object"' | |
| 3172 ' && receiver.constructor === Object' | |
|
ngeoffray
2013/09/06 06:54:06
Add a comment on why this constructor check?
ahe
2013/09/09 11:26:29
Done.
| |
| 3173 ' && "func" in receiver', | |
| 3174 buildReturnInterceptor(backend.jsFunctionType))); | |
| 3175 | |
| 3162 if (hasNative) { | 3176 if (hasNative) { |
| 3163 block.statements.add( | 3177 block.statements.add( |
| 3164 js.if_( | 3178 js.if_('typeof receiver != "object"', js.return_('receiver'))); |
| 3165 js('(typeof receiver) != "object"'), | |
| 3166 js.return_(js('receiver')))); | |
| 3167 | 3179 |
| 3168 // if (receiver instanceof $.Object) return receiver; | 3180 // if (receiver instanceof $.Object) return receiver; |
| 3169 // return $.getNativeInterceptor(receiver); | 3181 // return $.getNativeInterceptor(receiver); |
| 3170 block.statements.add( | 3182 block.statements.add( |
| 3171 js.if_(js('receiver instanceof #', | 3183 js.if_(js('receiver instanceof #', |
| 3172 js(namer.isolateAccess(compiler.objectClass))), | 3184 js(namer.isolateAccess(compiler.objectClass))), |
| 3173 js.return_(js('receiver')))); | 3185 js.return_(js('receiver')))); |
| 3174 block.statements.add( | 3186 block.statements.add( |
| 3175 js.return_( | 3187 js.return_( |
| 3176 js(namer.isolateAccess(backend.getNativeInterceptorMethod))( | 3188 js(namer.isolateAccess(backend.getNativeInterceptorMethod))( |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4201 | 4213 |
| 4202 const String HOOKS_API_USAGE = """ | 4214 const String HOOKS_API_USAGE = """ |
| 4203 // The code supports the following hooks: | 4215 // The code supports the following hooks: |
| 4204 // dartPrint(message) - if this function is defined it is called | 4216 // dartPrint(message) - if this function is defined it is called |
| 4205 // instead of the Dart [print] method. | 4217 // instead of the Dart [print] method. |
| 4206 // dartMainRunner(main) - if this function is defined, the Dart [main] | 4218 // dartMainRunner(main) - if this function is defined, the Dart [main] |
| 4207 // method will not be invoked directly. | 4219 // method will not be invoked directly. |
| 4208 // Instead, a closure that will invoke [main] is | 4220 // Instead, a closure that will invoke [main] is |
| 4209 // passed to [dartMainRunner]. | 4221 // passed to [dartMainRunner]. |
| 4210 """; | 4222 """; |
| OLD | NEW |