mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 11:26:02 +03:00
Add missing postblit call
This commit is contained in:
parent
5fb97f3d3f
commit
28aa0e2bf3
1 changed files with 26 additions and 17 deletions
|
@ -45,9 +45,27 @@ void CompoundStatement::toIR(IRState* p)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void callPostblitHelper(Loc &loc, Expression *exp, LLValue *val)
|
||||
{
|
||||
#if DMDV2
|
||||
Type *tb = exp->type->toBasetype();
|
||||
if ((exp->op == TOKvar || exp->op == TOKdotvar || exp->op == TOKstar) &&
|
||||
tb->ty == Tstruct)
|
||||
{ StructDeclaration *sd = ((TypeStruct *)tb)->sym;
|
||||
if (sd->postblit)
|
||||
{
|
||||
FuncDeclaration *fd = sd->postblit;
|
||||
fd->codegen(Type::sir);
|
||||
Expressions args;
|
||||
DFuncValue dfn(fd, fd->ir.irFunc->func, val);
|
||||
DtoCallFunction(loc, Type::basic[Tvoid], &dfn, &args);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ReturnStatement::toIR(IRState* p)
|
||||
{
|
||||
Logger::println("ReturnStatement::toIR(): %s", loc.toChars());
|
||||
|
@ -77,22 +95,9 @@ void ReturnStatement::toIR(IRState* p)
|
|||
// store return value
|
||||
DtoAssign(loc, rvar, e);
|
||||
|
||||
#if DMDV2
|
||||
// Call postBlit()
|
||||
Type *tb = exp->type->toBasetype();
|
||||
if ((exp->op == TOKvar || exp->op == TOKdotvar || exp->op == TOKstar) &&
|
||||
tb->ty == Tstruct)
|
||||
{ StructDeclaration *sd = ((TypeStruct *)tb)->sym;
|
||||
if (sd->postblit)
|
||||
{
|
||||
FuncDeclaration *fd = sd->postblit;
|
||||
fd->codegen(Type::sir);
|
||||
Expressions args;
|
||||
DFuncValue dfn(fd, fd->ir.irFunc->func, e->getLVal());
|
||||
DtoCallFunction(loc, Type::basic[Tvoid], &dfn, &args);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// call postblit if necessary
|
||||
if (e->isLVal())
|
||||
callPostblitHelper(loc, exp, e->getLVal());
|
||||
|
||||
// emit scopes
|
||||
DtoEnclosingHandlers(loc, NULL);
|
||||
|
@ -123,6 +128,9 @@ void ReturnStatement::toIR(IRState* p)
|
|||
if (Logger::enabled())
|
||||
Logger::cout() << "return value is '" <<*v << "'\n";
|
||||
|
||||
// call postblit if necessary
|
||||
callPostblitHelper(loc, exp, v);
|
||||
|
||||
IrFunction* f = p->func();
|
||||
// Hack around LDC assuming structs and static arrays are in memory:
|
||||
// If the function returns a struct or a static array, and the return
|
||||
|
@ -157,6 +165,7 @@ void ReturnStatement::toIR(IRState* p)
|
|||
Logger::cout() << "return value after cast: " << *v << '\n';
|
||||
}
|
||||
|
||||
// emit scopes
|
||||
DtoEnclosingHandlers(loc, NULL);
|
||||
|
||||
#ifndef DISABLE_DEBUG_INFO
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue