| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 String arguments = Strings.join(argumentsBuffer, ","); | 340 String arguments = Strings.join(argumentsBuffer, ","); |
| 341 buffer.add(' return this.${namer.getName(member)}($arguments)'); | 341 buffer.add(' return this.${namer.getName(member)}($arguments)'); |
| 342 } | 342 } |
| 343 buffer.add('\n}'); | 343 buffer.add('\n}'); |
| 344 defineInstanceMember(invocationName, buffer.toString()); | 344 defineInstanceMember(invocationName, buffer.toString()); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void addParameterStubs(FunctionElement member, | 347 void addParameterStubs(FunctionElement member, |
| 348 void defineInstanceMember(String invocationName, | 348 void defineInstanceMember(String invocationName, |
| 349 String definition)) { | 349 String definition)) { |
| 350 Set<Selector> selectors = compiler.universe.invokedNames[member.name]; | 350 Set<Selector> selectors = compiler.codegenWorld.invokedNames[member.name]; |
| 351 if (selectors == null) return; | 351 if (selectors == null) return; |
| 352 for (Selector selector in selectors) { | 352 for (Selector selector in selectors) { |
| 353 if (!selector.applies(member, compiler)) continue; | 353 if (!selector.applies(member, compiler)) continue; |
| 354 addParameterStub(member, selector, defineInstanceMember); | 354 addParameterStub(member, selector, defineInstanceMember); |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 | 357 |
| 358 bool instanceFieldNeedsGetter(Element member) { | 358 bool instanceFieldNeedsGetter(Element member) { |
| 359 assert(member.kind === ElementKind.FIELD); | 359 assert(member.kind === ElementKind.FIELD); |
| 360 return compiler.universe.hasGetter(member, compiler); | 360 return compiler.codegenWorld.hasGetter(member, compiler); |
| 361 } | 361 } |
| 362 | 362 |
| 363 bool instanceFieldNeedsSetter(Element member) { | 363 bool instanceFieldNeedsSetter(Element member) { |
| 364 assert(member.kind === ElementKind.FIELD); | 364 assert(member.kind === ElementKind.FIELD); |
| 365 return (member.modifiers === null || !member.modifiers.isFinal()) | 365 return (member.modifiers === null || !member.modifiers.isFinal()) |
| 366 && compiler.universe.hasSetter(member, compiler); | 366 && compiler.codegenWorld.hasSetter(member, compiler); |
| 367 } | 367 } |
| 368 | 368 |
| 369 String compiledFieldName(Element member) { | 369 String compiledFieldName(Element member) { |
| 370 assert(member.kind === ElementKind.FIELD); | 370 assert(member.kind === ElementKind.FIELD); |
| 371 return member.isNative() | 371 return member.isNative() |
| 372 ? member.name.slowToString() | 372 ? member.name.slowToString() |
| 373 : namer.getName(member); | 373 : namer.getName(member); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void addInstanceMember(Element member, | 376 void addInstanceMember(Element member, |
| 377 void defineInstanceMember(String invocationName, | 377 void defineInstanceMember(String invocationName, |
| 378 String definition)) { | 378 String definition)) { |
| 379 // TODO(floitsch): we don't need to deal with members of | 379 // TODO(floitsch): we don't need to deal with members of |
| 380 // uninstantiated classes, that have been overwritten by subclasses. | 380 // uninstantiated classes, that have been overwritten by subclasses. |
| 381 | 381 |
| 382 if (member.kind === ElementKind.FUNCTION | 382 if (member.kind === ElementKind.FUNCTION |
| 383 || member.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY | 383 || member.kind === ElementKind.GENERATIVE_CONSTRUCTOR_BODY |
| 384 || member.kind === ElementKind.GETTER | 384 || member.kind === ElementKind.GETTER |
| 385 || member.kind === ElementKind.SETTER) { | 385 || member.kind === ElementKind.SETTER) { |
| 386 if (member.modifiers !== null && member.modifiers.isAbstract()) return; | 386 if (member.modifiers !== null && member.modifiers.isAbstract()) return; |
| 387 String codeBlock = compiler.universe.generatedCode[member]; | 387 String codeBlock = compiler.codegenWorld.generatedCode[member]; |
| 388 if (codeBlock == null) return; | 388 if (codeBlock == null) return; |
| 389 defineInstanceMember(namer.getName(member), codeBlock); | 389 defineInstanceMember(namer.getName(member), codeBlock); |
| 390 codeBlock = compiler.universe.generatedBailoutCode[member]; | 390 codeBlock = compiler.codegenWorld.generatedBailoutCode[member]; |
| 391 if (codeBlock !== null) { | 391 if (codeBlock !== null) { |
| 392 defineInstanceMember(compiler.namer.getBailoutName(member), codeBlock); | 392 defineInstanceMember(compiler.namer.getBailoutName(member), codeBlock); |
| 393 } | 393 } |
| 394 FunctionElement function = member; | 394 FunctionElement function = member; |
| 395 FunctionSignature parameters = function.computeSignature(compiler); | 395 FunctionSignature parameters = function.computeSignature(compiler); |
| 396 if (!parameters.optionalParameters.isEmpty()) { | 396 if (!parameters.optionalParameters.isEmpty()) { |
| 397 addParameterStubs(member, defineInstanceMember); | 397 addParameterStubs(member, defineInstanceMember); |
| 398 } | 398 } |
| 399 } else if (member.kind !== ElementKind.FIELD) { | 399 } else if (member.kind !== ElementKind.FIELD) { |
| 400 compiler.internalError('unexpected kind: "${member.kind}"', | 400 compiler.internalError('unexpected kind: "${member.kind}"', |
| 401 element: member); | 401 element: member); |
| 402 } | 402 } |
| 403 emitExtraAccessors(member, defineInstanceMember); | 403 emitExtraAccessors(member, defineInstanceMember); |
| 404 } | 404 } |
| 405 | 405 |
| 406 Set<Element> emitClassFields(ClassElement classElement, StringBuffer buffer) { | 406 Set<Element> emitClassFields(ClassElement classElement, StringBuffer buffer) { |
| 407 // If the class is never instantiated we still need to set it up for | 407 // If the class is never instantiated we still need to set it up for |
| 408 // inheritance purposes, but we can simplify its JavaScript constructor. | 408 // inheritance purposes, but we can simplify its JavaScript constructor. |
| 409 bool isInstantiated = | 409 bool isInstantiated = |
| 410 compiler.universe.instantiatedClasses.contains(classElement); | 410 compiler.codegenWorld.instantiatedClasses.contains(classElement); |
| 411 | 411 |
| 412 bool isFirstField = true; | 412 bool isFirstField = true; |
| 413 void addField(ClassElement enclosingClass, Element member) { | 413 void addField(ClassElement enclosingClass, Element member) { |
| 414 assert(!member.isNative()); | 414 assert(!member.isNative()); |
| 415 // See if we can dynamically create getters and setters. | 415 // See if we can dynamically create getters and setters. |
| 416 // We can only generate getters and setters for [classElement] since | 416 // We can only generate getters and setters for [classElement] since |
| 417 // the fields of super classes could be overwritten with getters or | 417 // the fields of super classes could be overwritten with getters or |
| 418 // setters. | 418 // setters. |
| 419 bool needsDynamicGetter = false; | 419 bool needsDynamicGetter = false; |
| 420 bool needsDynamicSetter = false; | 420 bool needsDynamicSetter = false; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 | 515 |
| 516 buffer.add('$defineClassName("$className", "$superName", ['); | 516 buffer.add('$defineClassName("$className", "$superName", ['); |
| 517 emitClassFields(classElement, buffer); | 517 emitClassFields(classElement, buffer); |
| 518 buffer.add('], {'); | 518 buffer.add('], {'); |
| 519 emitInstanceMembers(classElement, buffer); | 519 emitInstanceMembers(classElement, buffer); |
| 520 buffer.add('\n});\n\n'); | 520 buffer.add('\n});\n\n'); |
| 521 } | 521 } |
| 522 | 522 |
| 523 void generateTypeTests(ClassElement cls, | 523 void generateTypeTests(ClassElement cls, |
| 524 void generateTypeTest(ClassElement element)) { | 524 void generateTypeTest(ClassElement element)) { |
| 525 if (compiler.universe.isChecks.contains(cls)) { | 525 if (compiler.codegenWorld.isChecks.contains(cls)) { |
| 526 generateTypeTest(cls); | 526 generateTypeTest(cls); |
| 527 } | 527 } |
| 528 generateInterfacesIsTests(cls, generateTypeTest, new Set<Element>()); | 528 generateInterfacesIsTests(cls, generateTypeTest, new Set<Element>()); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void generateInterfacesIsTests(ClassElement cls, | 531 void generateInterfacesIsTests(ClassElement cls, |
| 532 void generateTypeTest(ClassElement element), | 532 void generateTypeTest(ClassElement element), |
| 533 Set<Element> alreadyGenerated) { | 533 Set<Element> alreadyGenerated) { |
| 534 for (Type interfaceType in cls.interfaces) { | 534 for (Type interfaceType in cls.interfaces) { |
| 535 Element element = interfaceType.element; | 535 Element element = interfaceType.element; |
| 536 if (!alreadyGenerated.contains(element) && | 536 if (!alreadyGenerated.contains(element) && |
| 537 compiler.universe.isChecks.contains(element)) { | 537 compiler.codegenWorld.isChecks.contains(element)) { |
| 538 alreadyGenerated.add(element); | 538 alreadyGenerated.add(element); |
| 539 generateTypeTest(element); | 539 generateTypeTest(element); |
| 540 } | 540 } |
| 541 generateInterfacesIsTests(element, generateTypeTest, alreadyGenerated); | 541 generateInterfacesIsTests(element, generateTypeTest, alreadyGenerated); |
| 542 } | 542 } |
| 543 } | 543 } |
| 544 | 544 |
| 545 void emitClasses(StringBuffer buffer) { | 545 void emitClasses(StringBuffer buffer) { |
| 546 Set<ClassElement> instantiatedClasses = | 546 Set<ClassElement> instantiatedClasses = |
| 547 compiler.universe.instantiatedClasses; | 547 compiler.codegenWorld.instantiatedClasses; |
| 548 Set<ClassElement> neededClasses = | 548 Set<ClassElement> neededClasses = |
| 549 new Set<ClassElement>.from(instantiatedClasses); | 549 new Set<ClassElement>.from(instantiatedClasses); |
| 550 for (ClassElement element in instantiatedClasses) { | 550 for (ClassElement element in instantiatedClasses) { |
| 551 for (ClassElement superclass = element.superclass; | 551 for (ClassElement superclass = element.superclass; |
| 552 superclass !== null; | 552 superclass !== null; |
| 553 superclass = superclass.superclass) { | 553 superclass = superclass.superclass) { |
| 554 if (neededClasses.contains(superclass)) break; | 554 if (neededClasses.contains(superclass)) break; |
| 555 neededClasses.add(superclass); | 555 neededClasses.add(superclass); |
| 556 } | 556 } |
| 557 } | 557 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 585 generatedCode.forEach((Element element, String codeBlock) { | 585 generatedCode.forEach((Element element, String codeBlock) { |
| 586 if (!element.isInstanceMember()) { | 586 if (!element.isInstanceMember()) { |
| 587 String functionName = functionNamer(element); | 587 String functionName = functionNamer(element); |
| 588 buffer.add('$isolateProperties.$functionName = $codeBlock;\n\n'); | 588 buffer.add('$isolateProperties.$functionName = $codeBlock;\n\n'); |
| 589 } | 589 } |
| 590 }); | 590 }); |
| 591 } | 591 } |
| 592 | 592 |
| 593 void emitStaticFunctions(StringBuffer buffer) { | 593 void emitStaticFunctions(StringBuffer buffer) { |
| 594 emitStaticFunctionsWithNamer(buffer, | 594 emitStaticFunctionsWithNamer(buffer, |
| 595 compiler.universe.generatedCode, | 595 compiler.codegenWorld.generatedCode, |
| 596 namer.getName); | 596 namer.getName); |
| 597 emitStaticFunctionsWithNamer(buffer, | 597 emitStaticFunctionsWithNamer(buffer, |
| 598 compiler.universe.generatedBailoutCode, | 598 compiler.codegenWorld.generatedBailoutCode, |
| 599 namer.getBailoutName); | 599 namer.getBailoutName); |
| 600 } | 600 } |
| 601 | 601 |
| 602 void emitStaticFunctionGetters(StringBuffer buffer) { | 602 void emitStaticFunctionGetters(StringBuffer buffer) { |
| 603 Set<FunctionElement> functionsNeedingGetter = | 603 Set<FunctionElement> functionsNeedingGetter = |
| 604 compiler.universe.staticFunctionsNeedingGetter; | 604 compiler.codegenWorld.staticFunctionsNeedingGetter; |
| 605 for (FunctionElement element in functionsNeedingGetter) { | 605 for (FunctionElement element in functionsNeedingGetter) { |
| 606 // The static function does not have the correct name. Since | 606 // The static function does not have the correct name. Since |
| 607 // [addParameterStubs] use the name to create its stubs we simply | 607 // [addParameterStubs] use the name to create its stubs we simply |
| 608 // create a fake element with the correct name. | 608 // create a fake element with the correct name. |
| 609 // Note: the callElement will not have any enclosingElement. | 609 // Note: the callElement will not have any enclosingElement. |
| 610 FunctionElement callElement = | 610 FunctionElement callElement = |
| 611 new ClosureInvocationElement(Namer.CLOSURE_INVOCATION_NAME, element); | 611 new ClosureInvocationElement(Namer.CLOSURE_INVOCATION_NAME, element); |
| 612 String staticName = namer.getName(element); | 612 String staticName = namer.getName(element); |
| 613 int parameterCount = element.parameterCount(compiler); | 613 int parameterCount = element.parameterCount(compiler); |
| 614 String invocationName = | 614 String invocationName = |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 list.fixed$length = true; | 762 list.fixed$length = true; |
| 763 return list; | 763 return list; |
| 764 }; | 764 }; |
| 765 '''); | 765 '''); |
| 766 } | 766 } |
| 767 | 767 |
| 768 void emitExtraAccessors(Element member, | 768 void emitExtraAccessors(Element member, |
| 769 void defineInstanceMember(String invocationName, | 769 void defineInstanceMember(String invocationName, |
| 770 String definition)) { | 770 String definition)) { |
| 771 if (member.kind == ElementKind.GETTER || member.kind == ElementKind.FIELD) { | 771 if (member.kind == ElementKind.GETTER || member.kind == ElementKind.FIELD) { |
| 772 Set<Selector> selectors = compiler.universe.invokedNames[member.name]; | 772 Set<Selector> selectors = compiler.codegenWorld.invokedNames[member.name]; |
| 773 if (selectors !== null && !selectors.isEmpty()) { | 773 if (selectors !== null && !selectors.isEmpty()) { |
| 774 emitCallStubForGetter(member, selectors, defineInstanceMember); | 774 emitCallStubForGetter(member, selectors, defineInstanceMember); |
| 775 } | 775 } |
| 776 } else if (member.kind == ElementKind.FUNCTION) { | 776 } else if (member.kind == ElementKind.FUNCTION) { |
| 777 if (compiler.universe.hasGetter(member, compiler)) { | 777 if (compiler.codegenWorld.hasGetter(member, compiler)) { |
| 778 emitDynamicFunctionGetter(member, defineInstanceMember); | 778 emitDynamicFunctionGetter(member, defineInstanceMember); |
| 779 } | 779 } |
| 780 } | 780 } |
| 781 } | 781 } |
| 782 | 782 |
| 783 void emitNoSuchMethodCalls(void defineInstanceMember(String invocationName, | 783 void emitNoSuchMethodCalls(void defineInstanceMember(String invocationName, |
| 784 String definition)) { | 784 String definition)) { |
| 785 // Do not generate no such method calls if there is no class. | 785 // Do not generate no such method calls if there is no class. |
| 786 if (compiler.universe.instantiatedClasses.isEmpty()) return; | 786 if (compiler.codegenWorld.instantiatedClasses.isEmpty()) return; |
| 787 | 787 |
| 788 ClassElement objectClass = | 788 ClassElement objectClass = |
| 789 compiler.coreLibrary.find(const SourceString('Object')); | 789 compiler.coreLibrary.find(const SourceString('Object')); |
| 790 String runtimeObjectPrototype = | 790 String runtimeObjectPrototype = |
| 791 '${namer.isolateAccess(objectClass)}.prototype'; | 791 '${namer.isolateAccess(objectClass)}.prototype'; |
| 792 String noSuchMethodName = | 792 String noSuchMethodName = |
| 793 namer.instanceMethodName(null, Compiler.NO_SUCH_METHOD, 2); | 793 namer.instanceMethodName(null, Compiler.NO_SUCH_METHOD, 2); |
| 794 Collection<LibraryElement> libraries = | 794 Collection<LibraryElement> libraries = compiler.libraries.getValues(); |
| 795 compiler.universe.libraries.getValues(); | |
| 796 | 795 |
| 797 String generateMethod(String methodName, Selector selector) { | 796 String generateMethod(String methodName, Selector selector) { |
| 798 StringBuffer buffer = new StringBuffer(); | 797 StringBuffer buffer = new StringBuffer(); |
| 799 buffer.add('function'); | 798 buffer.add('function'); |
| 800 StringBuffer args = new StringBuffer(); | 799 StringBuffer args = new StringBuffer(); |
| 801 for (int i = 0; i < selector.argumentCount; i++) { | 800 for (int i = 0; i < selector.argumentCount; i++) { |
| 802 if (i != 0) args.add(', '); | 801 if (i != 0) args.add(', '); |
| 803 args.add('arg$i'); | 802 args.add('arg$i'); |
| 804 } | 803 } |
| 805 // We need to check if the object has a noSuchMethod. If not, it | 804 // We need to check if the object has a noSuchMethod. If not, it |
| 806 // means the object is a native object, and we can just call our | 805 // means the object is a native object, and we can just call our |
| 807 // generic noSuchMethod. Note that when calling this method, the | 806 // generic noSuchMethod. Note that when calling this method, the |
| 808 // 'this' object is not a Dart object. | 807 // 'this' object is not a Dart object. |
| 809 buffer.add(' ($args) {\n'); | 808 buffer.add(' ($args) {\n'); |
| 810 buffer.add(' return this.$noSuchMethodName\n'); | 809 buffer.add(' return this.$noSuchMethodName\n'); |
| 811 buffer.add(" ? this.$noSuchMethodName('$methodName', [$args])\n"); | 810 buffer.add(" ? this.$noSuchMethodName('$methodName', [$args])\n"); |
| 812 buffer.add(" : $runtimeObjectPrototype.$noSuchMethodName.call("); | 811 buffer.add(" : $runtimeObjectPrototype.$noSuchMethodName.call("); |
| 813 buffer.add("this, '$methodName', [$args])\n"); | 812 buffer.add("this, '$methodName', [$args])\n"); |
| 814 buffer.add('}'); | 813 buffer.add('}'); |
| 815 return buffer.toString(); | 814 return buffer.toString(); |
| 816 } | 815 } |
| 817 | 816 |
| 818 compiler.universe.invokedNames.forEach((SourceString methodName, | 817 compiler.codegenWorld.invokedNames.forEach((SourceString methodName, |
| 819 Set<Selector> selectors) { | 818 Set<Selector> selectors) { |
| 820 if (objectClass.lookupLocalMember(methodName) === null | 819 if (objectClass.lookupLocalMember(methodName) === null |
| 821 && methodName != Namer.OPERATOR_EQUALS) { | 820 && methodName != Namer.OPERATOR_EQUALS) { |
| 822 for (Selector selector in selectors) { | 821 for (Selector selector in selectors) { |
| 823 if (methodName.isPrivate()) { | 822 if (methodName.isPrivate()) { |
| 824 for (LibraryElement lib in libraries) { | 823 for (LibraryElement lib in libraries) { |
| 825 String jsName = | 824 String jsName = |
| 826 namer.instanceMethodInvocationName(lib, methodName, selector); | 825 namer.instanceMethodInvocationName(lib, methodName, selector); |
| 827 String method = | 826 String method = |
| 828 generateMethod(methodName.slowToString(), selector); | 827 generateMethod(methodName.slowToString(), selector); |
| 829 defineInstanceMember(jsName, method); | 828 defineInstanceMember(jsName, method); |
| 830 } | 829 } |
| 831 } else { | 830 } else { |
| 832 String jsName = | 831 String jsName = |
| 833 namer.instanceMethodInvocationName(null, methodName, selector); | 832 namer.instanceMethodInvocationName(null, methodName, selector); |
| 834 String method = generateMethod(methodName.slowToString(), selector); | 833 String method = generateMethod(methodName.slowToString(), selector); |
| 835 defineInstanceMember(jsName, method); | 834 defineInstanceMember(jsName, method); |
| 836 } | 835 } |
| 837 } | 836 } |
| 838 } | 837 } |
| 839 }); | 838 }); |
| 840 | 839 |
| 841 compiler.universe.invokedGetters.forEach((SourceString getterName, | 840 compiler.codegenWorld.invokedGetters.forEach((SourceString getterName, |
| 842 Set<Selector> selectors) { | 841 Set<Selector> selectors) { |
| 843 if (getterName.isPrivate()) { | 842 if (getterName.isPrivate()) { |
| 844 for (LibraryElement lib in libraries) { | 843 for (LibraryElement lib in libraries) { |
| 845 String jsName = namer.getterName(lib, getterName); | 844 String jsName = namer.getterName(lib, getterName); |
| 846 String method = generateMethod('get ${getterName.slowToString()}', | 845 String method = generateMethod('get ${getterName.slowToString()}', |
| 847 Selector.GETTER); | 846 Selector.GETTER); |
| 848 defineInstanceMember(jsName, method); | 847 defineInstanceMember(jsName, method); |
| 849 } | 848 } |
| 850 } else { | 849 } else { |
| 851 String jsName = namer.getterName(null, getterName); | 850 String jsName = namer.getterName(null, getterName); |
| 852 String method = generateMethod('get ${getterName.slowToString()}', | 851 String method = generateMethod('get ${getterName.slowToString()}', |
| 853 Selector.GETTER); | 852 Selector.GETTER); |
| 854 defineInstanceMember(jsName, method); | 853 defineInstanceMember(jsName, method); |
| 855 } | 854 } |
| 856 }); | 855 }); |
| 857 | 856 |
| 858 compiler.universe.invokedSetters.forEach((SourceString setterName, | 857 compiler.codegenWorld.invokedSetters.forEach((SourceString setterName, |
| 859 Set<Selector> selectors) { | 858 Set<Selector> selectors) { |
| 860 if (setterName.isPrivate()) { | 859 if (setterName.isPrivate()) { |
| 861 for (LibraryElement lib in libraries) { | 860 for (LibraryElement lib in libraries) { |
| 862 String jsName = namer.setterName(lib, setterName); | 861 String jsName = namer.setterName(lib, setterName); |
| 863 String method = generateMethod('set ${setterName.slowToString()}', | 862 String method = generateMethod('set ${setterName.slowToString()}', |
| 864 Selector.SETTER); | 863 Selector.SETTER); |
| 865 defineInstanceMember(jsName, method); | 864 defineInstanceMember(jsName, method); |
| 866 } | 865 } |
| 867 } else { | 866 } else { |
| 868 String jsName = namer.setterName(null, setterName); | 867 String jsName = namer.setterName(null, setterName); |
| 869 String method = generateMethod('set ${setterName.slowToString()}', | 868 String method = generateMethod('set ${setterName.slowToString()}', |
| 870 Selector.SETTER); | 869 Selector.SETTER); |
| 871 defineInstanceMember(jsName, method); | 870 defineInstanceMember(jsName, method); |
| 872 } | 871 } |
| 873 }); | 872 }); |
| 874 } | 873 } |
| 875 | 874 |
| 876 String buildIsolateSetup(StringBuffer buffer, | 875 String buildIsolateSetup(StringBuffer buffer, |
| 877 Element appMain, | 876 Element appMain, |
| 878 Element isolateMain) { | 877 Element isolateMain) { |
| 879 String mainAccess = "${namer.isolateAccess(appMain)}"; | 878 String mainAccess = "${namer.isolateAccess(appMain)}"; |
| 880 String currentIsolate = "${namer.CURRENT_ISOLATE}"; | 879 String currentIsolate = "${namer.CURRENT_ISOLATE}"; |
| 881 String mainEnsureGetter = ''; | 880 String mainEnsureGetter = ''; |
| 882 // Since we pass the closurized version of the main method to | 881 // Since we pass the closurized version of the main method to |
| 883 // the isolate method, we must make sure that it exists. | 882 // the isolate method, we must make sure that it exists. |
| 884 if (!compiler.universe.staticFunctionsNeedingGetter.contains(appMain)) { | 883 if (!compiler.codegenWorld.staticFunctionsNeedingGetter.contains(appMain)) { |
| 885 String invocationName = | 884 String invocationName = |
| 886 "${namer.closureInvocationName(Selector.INVOCATION_0)}"; | 885 "${namer.closureInvocationName(Selector.INVOCATION_0)}"; |
| 887 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; | 886 mainEnsureGetter = "$mainAccess.$invocationName = $mainAccess"; |
| 888 } | 887 } |
| 889 | 888 |
| 890 // TODO(ngeoffray): These globals are currently required by the isolate | 889 // TODO(ngeoffray): These globals are currently required by the isolate |
| 891 // library, but since leg already generates code on an Isolate object, they | 890 // library, but since leg already generates code on an Isolate object, they |
| 892 // are not really needed. We should remove them once Leg replaces Frog. | 891 // are not really needed. We should remove them once Leg replaces Frog. |
| 893 buffer.add(""" | 892 buffer.add(""" |
| 894 var \$globalThis = $currentIsolate; | 893 var \$globalThis = $currentIsolate; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 mainBuffer.add('function init() {\n'); | 970 mainBuffer.add('function init() {\n'); |
| 972 mainBuffer.add(' $isolateProperties = {};\n'); | 971 mainBuffer.add(' $isolateProperties = {};\n'); |
| 973 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer); | 972 addDefineClassAndFinishClassFunctionsIfNecessary(mainBuffer); |
| 974 emitFinishIsolateConstructor(mainBuffer); | 973 emitFinishIsolateConstructor(mainBuffer); |
| 975 mainBuffer.add('}\n'); | 974 mainBuffer.add('}\n'); |
| 976 compiler.assembledCode = mainBuffer.toString(); | 975 compiler.assembledCode = mainBuffer.toString(); |
| 977 }); | 976 }); |
| 978 return compiler.assembledCode; | 977 return compiler.assembledCode; |
| 979 } | 978 } |
| 980 } | 979 } |
| OLD | NEW |