mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-08 11:56:12 +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)
|
void ReturnStatement::toIR(IRState* p)
|
||||||
{
|
{
|
||||||
Logger::println("ReturnStatement::toIR(): %s", loc.toChars());
|
Logger::println("ReturnStatement::toIR(): %s", loc.toChars());
|
||||||
|
@ -77,22 +95,9 @@ void ReturnStatement::toIR(IRState* p)
|
||||||
// store return value
|
// store return value
|
||||||
DtoAssign(loc, rvar, e);
|
DtoAssign(loc, rvar, e);
|
||||||
|
|
||||||
#if DMDV2
|
// call postblit if necessary
|
||||||
// Call postBlit()
|
if (e->isLVal())
|
||||||
Type *tb = exp->type->toBasetype();
|
callPostblitHelper(loc, exp, e->getLVal());
|
||||||
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
|
|
||||||
|
|
||||||
// emit scopes
|
// emit scopes
|
||||||
DtoEnclosingHandlers(loc, NULL);
|
DtoEnclosingHandlers(loc, NULL);
|
||||||
|
@ -123,6 +128,9 @@ void ReturnStatement::toIR(IRState* p)
|
||||||
if (Logger::enabled())
|
if (Logger::enabled())
|
||||||
Logger::cout() << "return value is '" <<*v << "'\n";
|
Logger::cout() << "return value is '" <<*v << "'\n";
|
||||||
|
|
||||||
|
// call postblit if necessary
|
||||||
|
callPostblitHelper(loc, exp, v);
|
||||||
|
|
||||||
IrFunction* f = p->func();
|
IrFunction* f = p->func();
|
||||||
// Hack around LDC assuming structs and static arrays are in memory:
|
// Hack around LDC assuming structs and static arrays are in memory:
|
||||||
// If the function returns a struct or a static array, and the return
|
// 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';
|
Logger::cout() << "return value after cast: " << *v << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// emit scopes
|
||||||
DtoEnclosingHandlers(loc, NULL);
|
DtoEnclosingHandlers(loc, NULL);
|
||||||
|
|
||||||
#ifndef DISABLE_DEBUG_INFO
|
#ifndef DISABLE_DEBUG_INFO
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue