From 20b2b4b7f5bd6ce289b58c7843788182488bc5ee Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Thu, 4 Nov 2010 12:50:19 +0300 Subject: [PATCH] Added missing calls of postBlit --- gen/statements.cpp | 17 +++++++++++++++++ gen/toir.cpp | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/gen/statements.cpp b/gen/statements.cpp index 80e32ce1..78e08c87 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -77,6 +77,23 @@ 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 + // emit scopes DtoEnclosingHandlers(loc, NULL); diff --git a/gen/toir.cpp b/gen/toir.cpp index 9bf81e0a..3bea4b55 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -2592,6 +2592,24 @@ DValue* StructLiteralExp::toElem(IRState* p) // store the initializer there DtoAssign(loc, &field, val); + +#if DMDV2 + Type *tb = vd->type->toBasetype(); + if (tb->ty == Tstruct) + { + // Call postBlit() + 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->getLVal()); + DtoCallFunction(loc, Type::basic[Tvoid], &dfn, &args); + } + } +#endif + } // initialize trailing padding if (sd->structsize != offset)