Mercurial > projects > ldc
diff gen/functions.cpp @ 108:288fe1029e1f trunk
[svn r112] Fixed 'case 1,2,3:' style case statements.
Fixed a bunch of bugs with return/break/continue in loops.
Fixed support for the DMDFE hidden implicit return value variable. This can be needed for some foreach statements where the loop body is converted to a nested delegate, but also possibly returns from the function.
Added std.math to phobos.
Added AA runtime support code, done ground work for implementing AAs.
Several other bugfixes.
author | lindquist |
---|---|
date | Tue, 20 Nov 2007 05:29:20 +0100 |
parents | 027b8d8b71ec |
children | 5ab8e92611f9 |
line wrap: on
line diff
--- a/gen/functions.cpp Tue Nov 20 00:02:35 2007 +0100 +++ b/gen/functions.cpp Tue Nov 20 05:29:20 2007 +0100 @@ -378,6 +378,8 @@ } if (f->llvmUsesThis) { iarg->setName("this"); + fdecl->llvmThisVar = iarg; + assert(fdecl->llvmThisVar); ++iarg; } int varargs = -1; @@ -426,6 +428,8 @@ if (fd->llvmDefined) return; fd->llvmDefined = true; + assert(fd->llvmDeclared); + Logger::println("DtoDefineFunc(%s)", fd->toPrettyChars()); LOG_SCOPE; @@ -474,6 +478,7 @@ assert(fd->llvmIRFunc); gIR->functions.push_back(fd->llvmIRFunc); + /* // moved to declaration // this handling if (f->llvmUsesThis) { Logger::println("uses this"); @@ -483,6 +488,7 @@ fd->llvmThisVar = func->arg_begin(); assert(fd->llvmThisVar != 0); } + */ if (fd->isMain()) gIR->emitMain = true; @@ -497,6 +503,12 @@ f->llvmAllocaPoint = new llvm::BitCastInst(llvm::ConstantInt::get(llvm::Type::Int32Ty,0,false),llvm::Type::Int32Ty,"alloca point",gIR->scopebb()); gIR->func()->allocapoint = f->llvmAllocaPoint; + // need result variable? (not nested) + if (fd->vresult && !fd->vresult->nestedref) { + Logger::println("non-nested vresult value"); + fd->vresult->llvmValue = new llvm::AllocaInst(DtoType(fd->vresult->type),"function_vresult",f->llvmAllocaPoint); + } + // give arguments storage size_t n = Argument::dim(f->parameters); for (int i=0; i < n; ++i) { @@ -524,7 +536,14 @@ llvm::Value* parentNested = NULL; if (FuncDeclaration* fd2 = fd->toParent()->isFuncDeclaration()) { - parentNested = fd2->llvmNested; + if (!fd->isStatic()) + parentNested = fd2->llvmNested; + } + + // need result variable? (nested) + if (fd->vresult && fd->vresult->nestedref) { + Logger::println("nested vresult value: %s", fd->vresult->toChars()); + fd->llvmNestedVars.insert(fd->vresult); } // construct nested variables struct