OLD | NEW |
---|---|
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
6 | 6 |
7 class InterceptorStubGenerator { | 7 class InterceptorStubGenerator { |
8 final Compiler compiler; | 8 final Compiler compiler; |
9 final Namer namer; | 9 final Namer namer; |
10 final JavaScriptBackend backend; | 10 final JavaScriptBackend backend; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 statements.add(buildInterceptorCheck(backend.jsBoolClass)); | 133 statements.add(buildInterceptorCheck(backend.jsBoolClass)); |
134 } | 134 } |
135 // TODO(ahe): It might be faster to check for Array before | 135 // TODO(ahe): It might be faster to check for Array before |
136 // function and bool. | 136 // function and bool. |
137 if (hasArray) { | 137 if (hasArray) { |
138 statements.add(buildInterceptorCheck(backend.jsArrayClass)); | 138 statements.add(buildInterceptorCheck(backend.jsArrayClass)); |
139 } | 139 } |
140 | 140 |
141 if (hasNative) { | 141 if (hasNative) { |
142 statements.add(js.statement(r'''{ | 142 statements.add(js.statement(r'''{ |
143 if (typeof receiver != "object") return receiver; | 143 if (typeof receiver != "object" |
144 && typeof receiver != "function" ) return receiver; | |
sra1
2015/10/01 20:55:28
This is a hot path. Make the most of every test.
Jacob
2015/10/02 20:08:15
I was concerned about this code as well. Added you
| |
144 if (receiver instanceof #) return receiver; | 145 if (receiver instanceof #) return receiver; |
145 return #(receiver); | 146 return #(receiver); |
146 }''', [ | 147 }''', [ |
147 backend.emitter.constructorAccess(compiler.objectClass), | 148 backend.emitter.constructorAccess(compiler.objectClass), |
148 backend.emitter | 149 backend.emitter |
149 .staticFunctionAccess(backend.getNativeInterceptorMethod)])); | 150 .staticFunctionAccess(backend.getNativeInterceptorMethod)])); |
150 | 151 |
151 } else { | 152 } else { |
152 ClassElement jsUnknown = backend.jsUnknownJavaScriptObjectClass; | 153 ClassElement jsUnknown = backend.jsUnknownJavaScriptObjectClass; |
153 if (compiler.codegenWorld | 154 if (compiler.codegenWorld |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 | 364 |
364 var map = new jsAst.ObjectInitializer(properties); | 365 var map = new jsAst.ObjectInitializer(properties); |
365 elements.add(map); | 366 elements.add(map); |
366 } | 367 } |
367 } | 368 } |
368 } | 369 } |
369 | 370 |
370 return new jsAst.ArrayInitializer(elements); | 371 return new jsAst.ArrayInitializer(elements); |
371 } | 372 } |
372 } | 373 } |
OLD | NEW |