Changeset 371
- Timestamp:
- 02/06/10 03:53:22 (15 years ago)
- Files:
-
- branches/dmd-1.x/src/func.c (modified) (1 diff)
- trunk/src/func.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dmd-1.x/src/func.c
r366 r371 715 715 sc2->parent = this; 716 716 sc2->callSuper = 0; 717 717 sc2->sbreak = NULL; 718 718 sc2->scontinue = NULL; 719 719 sc2->sw = NULL; 720 720 sc2->fes = fes; 721 721 sc2->linkage = LINKd; 722 722 sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract | STCdeprecated | STCfinal); 723 723 sc2->protection = PROTpublic; 724 724 sc2->explicitProtection = 0; 725 725 sc2->structalign = 8; 726 726 sc2->incontract = 0; 727 727 sc2->tf = NULL; 728 728 sc2->noctor = 0; 729 729 730 730 // Declare 'this' 731 731 AggregateDeclaration *ad = isThis(); 732 732 if (ad) 733 733 { VarDeclaration *v; 734 734 735 if (isFuncLiteralDeclaration() && isNested() )735 if (isFuncLiteralDeclaration() && isNested() && !sc->intypeof) 736 736 { 737 error(" literals cannot be class members");737 error("function literals cannot be class members"); 738 738 return; 739 739 } 740 740 else 741 741 { 742 assert(!isNested() ); // can't be both member and nested742 assert(!isNested() || sc->intypeof); // can't be both member and nested 743 743 assert(ad->handle); 744 744 v = new ThisDeclaration(loc, ad->handle); 745 745 v->storage_class |= STCparameter | STCin; 746 746 v->semantic(sc2); 747 747 if (!sc2->insert(v)) 748 748 assert(0); 749 749 v->parent = this; 750 750 vthis = v; 751 751 } 752 752 } 753 753 else if (isNested()) 754 754 { 755 755 /* The 'this' for a nested function is the link to the 756 756 * enclosing function's stack frame. 757 757 * Note that nested functions and member functions are disjoint. 758 758 */ 759 759 VarDeclaration *v = new ThisDeclaration(loc, Type::tvoid->pointerTo()); 760 760 v->storage_class |= STCparameter | STCin; 761 761 v->semantic(sc2); 762 762 if (!sc2->insert(v)) trunk/src/func.c
r366 r371 824 824 sc2->sbreak = NULL; 825 825 sc2->scontinue = NULL; 826 826 sc2->sw = NULL; 827 827 sc2->fes = fes; 828 828 sc2->linkage = LINKd; 829 829 sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract | STCdeprecated | 830 830 STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref | 831 831 STCproperty | STCsafe | STCtrusted | STCsystem); 832 832 sc2->protection = PROTpublic; 833 833 sc2->explicitProtection = 0; 834 834 sc2->structalign = 8; 835 835 sc2->incontract = 0; 836 836 sc2->tf = NULL; 837 837 sc2->noctor = 0; 838 838 839 839 // Declare 'this' 840 840 AggregateDeclaration *ad = isThis(); 841 841 if (ad) 842 842 { VarDeclaration *v; 843 843 844 if (isFuncLiteralDeclaration() && isNested() )844 if (isFuncLiteralDeclaration() && isNested() && !sc->intypeof) 845 845 { 846 error(" literals cannot be class members");846 error("function literals cannot be class members"); 847 847 return; 848 848 } 849 849 else 850 850 { 851 assert(!isNested() ); // can't be both member and nested851 assert(!isNested() || sc->intypeof); // can't be both member and nested 852 852 assert(ad->handle); 853 853 Type *thandle = ad->handle; 854 854 #if STRUCTTHISREF 855 855 thandle = thandle->addMod(type->mod); 856 856 thandle = thandle->addStorageClass(storage_class); 857 857 if (isPure()) 858 858 thandle = thandle->addMod(MODconst); 859 859 #else 860 860 if (storage_class & STCconst || type->isConst()) 861 861 { 862 862 assert(0); // BUG: shared not handled 863 863 if (thandle->ty == Tclass) 864 864 thandle = thandle->constOf(); 865 865 else 866 866 { assert(thandle->ty == Tpointer); 867 867 thandle = thandle->nextOf()->constOf()->pointerTo(); 868 868 } 869 869 } 870 870 else if (storage_class & STCimmutable || type->isImmutable()) 871 871 {
