Mercurial > projects > ldc
diff gen/functions.cpp @ 758:f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 11 Nov 2008 01:38:48 +0100 |
parents | 2d7bcfa68128 |
children | 340acf1535d0 |
line wrap: on
line diff
--- a/gen/functions.cpp Mon Nov 10 20:55:24 2008 +0100 +++ b/gen/functions.cpp Tue Nov 11 01:38:48 2008 +0100 @@ -32,12 +32,12 @@ return llvm::cast<llvm::FunctionType>(type->ir.type->get()); } - bool typesafeVararg = false; + bool dVararg = false; bool arrayVararg = false; if (f->linkage == LINKd) { if (f->varargs == 1) - typesafeVararg = true; + dVararg = true; else if (f->varargs == 2) arrayVararg = true; } @@ -96,7 +96,7 @@ usesnest = true; } - if (typesafeVararg) { + if (dVararg) { ClassDeclaration* ti = Type::typeinfo; ti->toObjFile(0); // TODO: multiobj DtoForceConstInitDsymbol(ti); @@ -119,7 +119,7 @@ // more than one formal arg, // extern(D) linkage // not a D-style vararg - if (n > 1 && f->linkage == LINKd && !typesafeVararg) + if (n > 1 && f->linkage == LINKd && !dVararg) { f->reverseParams = true; f->reverseIndex = paramvec.size(); @@ -189,7 +189,7 @@ } // construct function type - bool isvararg = !(typesafeVararg || arrayVararg) && f->varargs; + bool isvararg = !(dVararg || arrayVararg) && f->varargs; llvm::FunctionType* functype = llvm::FunctionType::get(actualRettype, paramvec, isvararg); #if X86_PASS_IN_EAX @@ -720,9 +720,15 @@ if (global.params.symdebug) DtoDwarfLocalVariable(thismem, fd->vthis); - + + #if DMDV2 + if (fd->vthis->nestedrefs.dim) + #else if (fd->vthis->nestedref) + #endif + { fd->nestedVars.insert(fd->vthis); + } } // give arguments storage @@ -735,9 +741,15 @@ Dsymbol* argsym = (Dsymbol*)fd->parameters->data[i]; VarDeclaration* vd = argsym->isVarDeclaration(); assert(vd); - + + #if DMDV2 + if (vd->nestedrefs.dim) + #else if (vd->nestedref) + #endif + { fd->nestedVars.insert(vd); + } IrLocal* irloc = vd->ir.irLocal; assert(irloc); @@ -757,8 +769,12 @@ } } - // need result variable? (nested) +// need result variable? (nested) +#if DMDV2 + if (fd->vresult && fd->vresult->nestedrefs.dim) { +#else if (fd->vresult && fd->vresult->nestedref) { +#endif Logger::println("nested vresult value: %s", fd->vresult->toChars()); fd->nestedVars.insert(fd->vresult); } @@ -836,9 +852,13 @@ vd->ir.irLocal->nestedIndex = idx++; } - + // fixup nested result variable + #if DMDV2 + if (fd->vresult && fd->vresult->nestedrefs.dim) { + #else if (fd->vresult && fd->vresult->nestedref) { + #endif Logger::println("nested vresult value: %s", fd->vresult->toChars()); LLValue* gep = DtoGEPi(nestedVars, 0, fd->vresult->ir.irLocal->nestedIndex); LLValue* val = DtoBitCast(fd->vresult->ir.irLocal->value, getVoidPtrType());