| 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 library dart2js.js_emitter.native_emitter; | 5 library dart2js.js_emitter.native_emitter; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
| 9 import '../elements/types.dart' show DartType, FunctionType; | 9 import '../elements/types.dart' show DartType, FunctionType; |
| 10 import '../elements/entities.dart'; | 10 import '../elements/entities.dart'; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 324 |
| 325 if (isInterceptedMethod) { | 325 if (isInterceptedMethod) { |
| 326 receiver = argumentsBuffer[0]; | 326 receiver = argumentsBuffer[0]; |
| 327 arguments = argumentsBuffer.sublist( | 327 arguments = argumentsBuffer.sublist( |
| 328 1, indexOfLastOptionalArgumentInParameters + 1); | 328 1, indexOfLastOptionalArgumentInParameters + 1); |
| 329 } else { | 329 } else { |
| 330 // Native methods that are not intercepted must be static. | 330 // Native methods that are not intercepted must be static. |
| 331 assert(invariant(member, member.isStatic)); | 331 assert(invariant(member, member.isStatic)); |
| 332 arguments = argumentsBuffer.sublist( | 332 arguments = argumentsBuffer.sublist( |
| 333 0, indexOfLastOptionalArgumentInParameters + 1); | 333 0, indexOfLastOptionalArgumentInParameters + 1); |
| 334 if (nativeData.isJsInteropMethod(member)) { | 334 if (nativeData.isJsInteropMember(member)) { |
| 335 // fixedBackendPath is allowed to have the form foo.bar.baz for | 335 // fixedBackendPath is allowed to have the form foo.bar.baz for |
| 336 // interop. This template is uncached to avoid possibly running out of | 336 // interop. This template is uncached to avoid possibly running out of |
| 337 // memory when Dart2Js is run in server mode. In reality the risk of | 337 // memory when Dart2Js is run in server mode. In reality the risk of |
| 338 // caching these templates causing an issue is very low as each class | 338 // caching these templates causing an issue is very low as each class |
| 339 // and library that uses typed JavaScript interop will create only 1 | 339 // and library that uses typed JavaScript interop will create only 1 |
| 340 // unique template. | 340 // unique template. |
| 341 receiver = js | 341 receiver = js |
| 342 .uncachedExpressionTemplate(namer.fixedBackendMethodPath(member)) | 342 .uncachedExpressionTemplate(namer.fixedBackendMethodPath(member)) |
| 343 .instantiate([]); | 343 .instantiate([]); |
| 344 } else { | 344 } else { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 364 // satisfy a check against [element], in which case an interceptor must be | 364 // satisfy a check against [element], in which case an interceptor must be |
| 365 // used. We should also use an interceptor if the check can't be satisfied | 365 // used. We should also use an interceptor if the check can't be satisfied |
| 366 // by a native class in case we get a native instance that tries to spoof | 366 // by a native class in case we get a native instance that tries to spoof |
| 367 // the type info. i.e the criteria for whether or not to use an interceptor | 367 // the type info. i.e the criteria for whether or not to use an interceptor |
| 368 // is whether the receiver can be native, not the type of the test. | 368 // is whether the receiver can be native, not the type of the test. |
| 369 ClassEntity cls = element; | 369 ClassEntity cls = element; |
| 370 if (nativeData.isNativeOrExtendsNative(cls)) return true; | 370 if (nativeData.isNativeOrExtendsNative(cls)) return true; |
| 371 return isSupertypeOfNativeClass(element); | 371 return isSupertypeOfNativeClass(element); |
| 372 } | 372 } |
| 373 } | 373 } |
| OLD | NEW |