| 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 dart2js.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 class NativeEmitter { | 7 class NativeEmitter { |
| 8 | 8 |
| 9 final Map<Element, ClassBuilder> cachedBuilders; | 9 final Map<Element, ClassBuilder> cachedBuilders; |
| 10 | 10 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 326 |
| 327 String target; | 327 String target; |
| 328 jsAst.Expression receiver; | 328 jsAst.Expression receiver; |
| 329 List<jsAst.Expression> arguments; | 329 List<jsAst.Expression> arguments; |
| 330 | 330 |
| 331 assert(invariant(member, nativeMethods.contains(member))); | 331 assert(invariant(member, nativeMethods.contains(member))); |
| 332 // When calling a JS method, we call it with the native name, and only the | 332 // When calling a JS method, we call it with the native name, and only the |
| 333 // arguments up until the last one provided. | 333 // arguments up until the last one provided. |
| 334 target = member.fixedBackendName; | 334 target = member.fixedBackendName; |
| 335 | 335 |
| 336 if (isInterceptedMethod) { | 336 assert(invariant(member, isInterceptedMethod)); |
| 337 receiver = argumentsBuffer[0]; | 337 receiver = argumentsBuffer[0]; |
| 338 arguments = argumentsBuffer.sublist(1, | 338 arguments = argumentsBuffer.sublist(1, |
| 339 indexOfLastOptionalArgumentInParameters + 1); | 339 indexOfLastOptionalArgumentInParameters + 1); |
| 340 } else { | |
| 341 receiver = js('this'); | |
| 342 arguments = argumentsBuffer.sublist(0, | |
| 343 indexOfLastOptionalArgumentInParameters + 1); | |
| 344 } | |
| 345 statements.add( | 340 statements.add( |
| 346 js.statement('return #.#(#)', [receiver, target, arguments])); | 341 js.statement('return #.#(#)', [receiver, target, arguments])); |
| 347 | 342 |
| 348 return statements; | 343 return statements; |
| 349 } | 344 } |
| 350 | 345 |
| 351 bool isSupertypeOfNativeClass(Element element) { | 346 bool isSupertypeOfNativeClass(Element element) { |
| 352 if (element.isTypeVariable) { | 347 if (element.isTypeVariable) { |
| 353 compiler.internalError(element, "Is check for type variable."); | 348 compiler.internalError(element, "Is check for type variable."); |
| 354 return false; | 349 return false; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 } | 464 } |
| 470 ''', {'info': infoAccess, | 465 ''', {'info': infoAccess, |
| 471 'constructor': constructorAccess, | 466 'constructor': constructorAccess, |
| 472 'subclassRead': subclassRead, | 467 'subclassRead': subclassRead, |
| 473 'interceptorsByTagAccess': interceptorsByTagAccess, | 468 'interceptorsByTagAccess': interceptorsByTagAccess, |
| 474 'leafTagsAccess': leafTagsAccess, | 469 'leafTagsAccess': leafTagsAccess, |
| 475 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, | 470 'nativeSuperclassTagName': embeddedNames.NATIVE_SUPERCLASS_TAG_NAME, |
| 476 'allowNativesSubclassing': true}); | 471 'allowNativesSubclassing': true}); |
| 477 } | 472 } |
| 478 } | 473 } |
| OLD | NEW |