# HG changeset patch # User lindquist # Date 1196055913 -3600 # Node ID 79c9ac745fbcad584accc7e995fa1d1a433c036a # Parent d580b95cce2ba911413c5a1d589de9e0086db58d [svn r123] Fixed some typeinfo module name mismatches. Fixed D-style varargs returning through pointer. Fixed converting nested function to delegate. Added std.string and std.format to Phobos. diff -r d580b95cce2b -r 79c9ac745fbc gen/functions.cpp --- a/gen/functions.cpp Mon Nov 26 05:50:33 2007 +0100 +++ b/gen/functions.cpp Mon Nov 26 06:45:13 2007 +0100 @@ -396,9 +396,16 @@ assert(fdecl->llvmThisVar); ++iarg; } - int varargs = -1; - if (f->linkage == LINKd && f->varargs == 1) - varargs = 0; + + if (f->linkage == LINKd && f->varargs == 1) { + iarg->setName("_arguments"); + fdecl->llvmArguments = iarg; + ++iarg; + iarg->setName("_argptr"); + fdecl->llvmArgPtr = iarg; + ++iarg; + } + for (; iarg != func->arg_end(); ++iarg) { Argument* arg = Argument::getNth(f->parameters, k++); @@ -410,19 +417,6 @@ } iarg->setName(arg->ident->toChars()); } - else if (!arg && varargs >= 0) { - if (varargs == 0) { - iarg->setName("_arguments"); - fdecl->llvmArguments = iarg; - } - else if (varargs == 1) { - iarg->setName("_argptr"); - fdecl->llvmArgPtr = iarg; - } - else - assert(0); - varargs++; - } else { iarg->setName("unnamed"); } diff -r d580b95cce2b -r 79c9ac745fbc gen/toir.cpp --- a/gen/toir.cpp Mon Nov 26 05:50:33 2007 +0100 +++ b/gen/toir.cpp Mon Nov 26 06:45:13 2007 +0100 @@ -2088,17 +2088,31 @@ lval = new llvm::AllocaInst(DtoType(type), "tmpdelegate", p->topallocapoint()); } + llvm::Value* uval; + if (DFuncValue* f = u->isFunc()) { + //assert(f->vthis); + //uval = f->vthis; + llvm::Value* nestvar = p->func()->decl->llvmNested; + if (nestvar) + uval = nestvar; + else + uval = llvm::ConstantPointerNull::get(llvm::PointerType::get(llvm::Type::Int8Ty)); + } + else { + uval = u->getRVal(); + } + llvm::Value* context = DtoGEP(lval,zero,zero,"tmp",p->scopebb()); - llvm::Value* castcontext = new llvm::BitCastInst(u->getRVal(),int8ptrty,"tmp",p->scopebb()); + llvm::Value* castcontext = DtoBitCast(uval,int8ptrty); new llvm::StoreInst(castcontext, context, p->scopebb()); llvm::Value* fptr = DtoGEP(lval,zero,one,"tmp",p->scopebb()); assert(func->llvmValue); - llvm::Value* castfptr = new llvm::BitCastInst(func->llvmValue,fptr->getType()->getContainedType(0),"tmp",p->scopebb()); + llvm::Value* castfptr = DtoBitCast(func->llvmValue,fptr->getType()->getContainedType(0)); new llvm::StoreInst(castfptr, fptr, p->scopebb()); - return new DImValue(type, u->getRVal(), true); + return new DVarValue(type, lval, true); } ////////////////////////////////////////////////////////////////////////////////////////// diff -r d580b95cce2b -r 79c9ac745fbc llvmdc.kdevelop.filelist --- a/llvmdc.kdevelop.filelist Mon Nov 26 05:50:33 2007 +0100 +++ b/llvmdc.kdevelop.filelist Mon Nov 26 06:45:13 2007 +0100 @@ -323,6 +323,8 @@ test/bug71.d test/bug72.d test/bug73.d +test/bug74.d +test/bug75.d test/bug8.d test/bug9.d test/c.d diff -r d580b95cce2b -r 79c9ac745fbc lphobos/phobos.d --- a/lphobos/phobos.d Mon Nov 26 05:50:33 2007 +0100 +++ b/lphobos/phobos.d Mon Nov 26 06:45:13 2007 +0100 @@ -3,6 +3,7 @@ import std.array, std.ctype, +std.format, std.intrinsic, std.math, std.moduleinit, @@ -10,12 +11,10 @@ std.stdint, std.stdio, std.stdarg, +std.string, std.uni, std.utf, -//std.format, -//std.string, - std.c.fenv, std.c.locale, std.c.math, diff -r d580b95cce2b -r 79c9ac745fbc lphobos/typeinfo1/ti_cdouble.d --- a/lphobos/typeinfo1/ti_cdouble.d Mon Nov 26 05:50:33 2007 +0100 +++ b/lphobos/typeinfo1/ti_cdouble.d Mon Nov 26 06:45:13 2007 +0100 @@ -1,7 +1,7 @@ // cdouble -module std.typeinfo.ti_cdouble; +module typeinfo1.ti_cdouble; class TypeInfo_r : TypeInfo { diff -r d580b95cce2b -r 79c9ac745fbc lphobos/typeinfo1/ti_cfloat.d --- a/lphobos/typeinfo1/ti_cfloat.d Mon Nov 26 05:50:33 2007 +0100 +++ b/lphobos/typeinfo1/ti_cfloat.d Mon Nov 26 06:45:13 2007 +0100 @@ -1,7 +1,7 @@ // cfloat -module std.typeinfo.ti_cfloat; +module typeinfo1.ti_cfloat; class TypeInfo_q : TypeInfo { diff -r d580b95cce2b -r 79c9ac745fbc lphobos/typeinfo1/ti_creal.d --- a/lphobos/typeinfo1/ti_creal.d Mon Nov 26 05:50:33 2007 +0100 +++ b/lphobos/typeinfo1/ti_creal.d Mon Nov 26 06:45:13 2007 +0100 @@ -1,7 +1,7 @@ // creal -module std.typeinfo.ti_creal; +module typeinfo1.ti_creal; class TypeInfo_c : TypeInfo { diff -r d580b95cce2b -r 79c9ac745fbc lphobos/typeinfo2/ti_AC.d --- a/lphobos/typeinfo2/ti_AC.d Mon Nov 26 05:50:33 2007 +0100 +++ b/lphobos/typeinfo2/ti_AC.d Mon Nov 26 06:45:13 2007 +0100 @@ -1,4 +1,4 @@ -module std.typeinfo.ti_AC; +module typeinfo2.ti_AC; // Object[] diff -r d580b95cce2b -r 79c9ac745fbc lphobos/typeinfo2/ti_C.d --- a/lphobos/typeinfo2/ti_C.d Mon Nov 26 05:50:33 2007 +0100 +++ b/lphobos/typeinfo2/ti_C.d Mon Nov 26 06:45:13 2007 +0100 @@ -21,7 +21,7 @@ * distribution. */ -module std.typeinfo.ti_C; +module typeinfo2.ti_C; // Object diff -r d580b95cce2b -r 79c9ac745fbc test/bug74.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug74.d Mon Nov 26 06:45:13 2007 +0100 @@ -0,0 +1,12 @@ +module bug74; + +char[] sformat(char[] s, ...) +{ + TypeInfo[] ti = _arguments; + void* args = _argptr; + return ""; +} + +void main() +{ +} diff -r d580b95cce2b -r 79c9ac745fbc test/bug75.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug75.d Mon Nov 26 06:45:13 2007 +0100 @@ -0,0 +1,13 @@ +module bug75; + +void func(void delegate() dg) +{ +} + +void main() +{ + void nested() { + } + //func(&nested); + void delegate() dg = &nested; +}