mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-19 06:13:14 +01:00
[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.
This commit is contained in:
@@ -396,9 +396,16 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||
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 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
20
gen/toir.cpp
20
gen/toir.cpp
@@ -2088,17 +2088,31 @@ DValue* DelegateExp::toElem(IRState* p)
|
||||
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);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -323,6 +323,8 @@ test/bug70.d
|
||||
test/bug71.d
|
||||
test/bug72.d
|
||||
test/bug73.d
|
||||
test/bug74.d
|
||||
test/bug75.d
|
||||
test/bug8.d
|
||||
test/bug9.d
|
||||
test/c.d
|
||||
|
||||
@@ -3,6 +3,7 @@ module phobos;
|
||||
import
|
||||
std.array,
|
||||
std.ctype,
|
||||
std.format,
|
||||
std.intrinsic,
|
||||
std.math,
|
||||
std.moduleinit,
|
||||
@@ -10,12 +11,10 @@ std.outofmemory,
|
||||
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,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
// cdouble
|
||||
|
||||
module std.typeinfo.ti_cdouble;
|
||||
module typeinfo1.ti_cdouble;
|
||||
|
||||
class TypeInfo_r : TypeInfo
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
// cfloat
|
||||
|
||||
module std.typeinfo.ti_cfloat;
|
||||
module typeinfo1.ti_cfloat;
|
||||
|
||||
class TypeInfo_q : TypeInfo
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
// creal
|
||||
|
||||
module std.typeinfo.ti_creal;
|
||||
module typeinfo1.ti_creal;
|
||||
|
||||
class TypeInfo_c : TypeInfo
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module std.typeinfo.ti_AC;
|
||||
module typeinfo2.ti_AC;
|
||||
|
||||
// Object[]
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* distribution.
|
||||
*/
|
||||
|
||||
module std.typeinfo.ti_C;
|
||||
module typeinfo2.ti_C;
|
||||
|
||||
// Object
|
||||
|
||||
|
||||
12
test/bug74.d
Normal file
12
test/bug74.d
Normal file
@@ -0,0 +1,12 @@
|
||||
module bug74;
|
||||
|
||||
char[] sformat(char[] s, ...)
|
||||
{
|
||||
TypeInfo[] ti = _arguments;
|
||||
void* args = _argptr;
|
||||
return "";
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
}
|
||||
13
test/bug75.d
Normal file
13
test/bug75.d
Normal file
@@ -0,0 +1,13 @@
|
||||
module bug75;
|
||||
|
||||
void func(void delegate() dg)
|
||||
{
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
void nested() {
|
||||
}
|
||||
//func(&nested);
|
||||
void delegate() dg = &nested;
|
||||
}
|
||||
Reference in New Issue
Block a user