Mercurial > projects > ldc
comparison gen/functions.cpp @ 838:94ba810ea2b0
Fixed problem with nested function inside static nested function. see mini/compile_nested2.d. fixes #143 .
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 09 Dec 2008 14:57:01 +0100 |
parents | 331a176c1f4f |
children | 545f54041d91 |
comparison
equal
deleted
inserted
replaced
837:331a176c1f4f | 838:94ba810ea2b0 |
---|---|
769 | 769 |
770 // construct nested variables array | 770 // construct nested variables array |
771 if (!fd->nestedVars.empty()) | 771 if (!fd->nestedVars.empty()) |
772 { | 772 { |
773 Logger::println("has nested frame"); | 773 Logger::println("has nested frame"); |
774 // start with add all enclosing parent frames | 774 // start with adding all enclosing parent frames until a static parent is reached |
775 int nparelems = 0; | 775 int nparelems = 0; |
776 Dsymbol* par = fd->toParent2(); | 776 if (!fd->isStatic()) |
777 while (par) | 777 { |
778 { | 778 Dsymbol* par = fd->toParent2(); |
779 if (FuncDeclaration* parfd = par->isFuncDeclaration()) | 779 while (par) |
780 { | 780 { |
781 nparelems += parfd->nestedVars.size(); | 781 if (FuncDeclaration* parfd = par->isFuncDeclaration()) |
782 { | |
783 nparelems += parfd->nestedVars.size(); | |
784 // stop at first static | |
785 if (parfd->isStatic()) | |
786 break; | |
787 } | |
788 else if (ClassDeclaration* parcd = par->isClassDeclaration()) | |
789 { | |
790 // nothing needed | |
791 } | |
792 else | |
793 { | |
794 break; | |
795 } | |
796 | |
797 par = par->toParent2(); | |
782 } | 798 } |
783 else if (ClassDeclaration* parcd = par->isClassDeclaration()) | |
784 { | |
785 // nothing needed | |
786 } | |
787 else | |
788 { | |
789 break; | |
790 } | |
791 par = par->toParent2(); | |
792 } | 799 } |
793 int nelems = fd->nestedVars.size() + nparelems; | 800 int nelems = fd->nestedVars.size() + nparelems; |
794 | 801 |
795 // make array type for nested vars | 802 // make array type for nested vars |
796 const LLType* nestedVarsTy = LLArrayType::get(getVoidPtrType(), nelems); | 803 const LLType* nestedVarsTy = LLArrayType::get(getVoidPtrType(), nelems); |