| 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 /** | 5 /** |
| 6 * A function element that represents a closure call. The signature is copied | 6 * A function element that represents a closure call. The signature is copied |
| 7 * from the given element. | 7 * from the given element. |
| 8 */ | 8 */ |
| 9 class ClosureInvocationElement extends FunctionElement { | 9 class ClosureInvocationElement extends FunctionElement { |
| 10 ClosureInvocationElement(SourceString name, | 10 ClosureInvocationElement(SourceString name, |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 compiler.emitter.emitDynamicFunctionGetter( | 543 compiler.emitter.emitDynamicFunctionGetter( |
| 544 buffer, attachTo, member); | 544 buffer, attachTo, member); |
| 545 } | 545 } |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 void emitNoSuchMethodCalls(StringBuffer buffer) { | 549 void emitNoSuchMethodCalls(StringBuffer buffer) { |
| 550 // Do not generate no such method calls if there is no class. | 550 // Do not generate no such method calls if there is no class. |
| 551 if (compiler.universe.instantiatedClasses.isEmpty()) return; | 551 if (compiler.universe.instantiatedClasses.isEmpty()) return; |
| 552 | 552 |
| 553 // TODO(ngeoffray): We don't need to generate these methods if | |
| 554 // nobody overwrites noSuchMethod. | |
| 555 | |
| 556 ClassElement objectClass = | 553 ClassElement objectClass = |
| 557 compiler.coreLibrary.find(const SourceString('Object')); | 554 compiler.coreLibrary.find(const SourceString('Object')); |
| 558 String className = namer.isolatePropertyAccess(objectClass); | 555 String className = namer.isolatePropertyAccess(objectClass); |
| 559 String prototype = '$className.prototype'; | 556 String prototype = '$className.prototype'; |
| 560 String noSuchMethodName = | 557 String noSuchMethodName = |
| 561 namer.instanceMethodName(Compiler.NO_SUCH_METHOD, 2); | 558 namer.instanceMethodName(Compiler.NO_SUCH_METHOD, 2); |
| 562 | 559 |
| 563 void generateMethod(String methodName, String jsName, Selector selector) { | 560 void generateMethod(String methodName, String jsName, Selector selector) { |
| 564 buffer.add('$prototype.$jsName = function'); | 561 buffer.add('$prototype.$jsName = function'); |
| 565 StringBuffer args = new StringBuffer(); | 562 StringBuffer args = new StringBuffer(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 emitStaticFinalFieldInitializations(buffer); | 614 emitStaticFinalFieldInitializations(buffer); |
| 618 nativeEmitter.emitDynamicDispatchMetadata(buffer); | 615 nativeEmitter.emitDynamicDispatchMetadata(buffer); |
| 619 buffer.add('var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n'); | 616 buffer.add('var ${namer.CURRENT_ISOLATE} = new ${namer.ISOLATE}();\n'); |
| 620 Element main = compiler.mainApp.find(Compiler.MAIN); | 617 Element main = compiler.mainApp.find(Compiler.MAIN); |
| 621 buffer.add('${namer.isolateAccess(main)}();\n'); | 618 buffer.add('${namer.isolateAccess(main)}();\n'); |
| 622 compiler.assembledCode = buffer.toString(); | 619 compiler.assembledCode = buffer.toString(); |
| 623 }); | 620 }); |
| 624 return compiler.assembledCode; | 621 return compiler.assembledCode; |
| 625 } | 622 } |
| 626 } | 623 } |
| OLD | NEW |