mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-11 22:39:02 +02:00
[svn r226] Fixed: deleting interface.
Removed: unused util function for calling class destructors.
This commit is contained in:
@@ -919,19 +919,6 @@ DValue* DtoCallClassCtor(TypeClass* type, CtorDeclaration* ctor, Array* argument
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DtoCallClassDtors(TypeClass* tc, llvm::Value* instance)
|
||||
{
|
||||
Array* arr = &tc->sym->dtors;
|
||||
for (size_t i=0; i<arr->dim; i++)
|
||||
{
|
||||
FuncDeclaration* fd = (FuncDeclaration*)arr->data[i];
|
||||
assert(fd->ir.irFunc->func);
|
||||
llvm::CallInst::Create(fd->ir.irFunc->func, instance, "", gIR->scopebb());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void DtoFinalizeClass(llvm::Value* inst)
|
||||
{
|
||||
// get runtime function
|
||||
|
||||
@@ -27,7 +27,6 @@ void DtoDefineClassInfo(ClassDeclaration* cd);
|
||||
DValue* DtoNewClass(TypeClass* type, NewExp* newexp);
|
||||
void DtoInitClass(TypeClass* tc, llvm::Value* dst);
|
||||
DValue* DtoCallClassCtor(TypeClass* type, CtorDeclaration* ctor, Array* arguments, llvm::Value* mem);
|
||||
void DtoCallClassDtors(TypeClass* tc, llvm::Value* instance);
|
||||
void DtoFinalizeClass(llvm::Value* inst);
|
||||
|
||||
DValue* DtoCastClass(DValue* val, Type* to);
|
||||
|
||||
11
gen/toir.cpp
11
gen/toir.cpp
@@ -2009,9 +2009,14 @@ DValue* DeleteExp::toElem(IRState* p)
|
||||
else if (et->ty == Tclass)
|
||||
{
|
||||
bool onstack = false;
|
||||
if (DVarValue* vv = dval->isVar()) {
|
||||
TypeClass* tc = (TypeClass*)et;
|
||||
if (tc->sym->isInterfaceDeclaration())
|
||||
{
|
||||
DtoDeleteInterface(dval->getRVal());
|
||||
onstack = true;
|
||||
}
|
||||
else if (DVarValue* vv = dval->isVar()) {
|
||||
if (vv->var && vv->var->onstack) {
|
||||
TypeClass* tc = (TypeClass*)et;
|
||||
if (tc->sym->dtors.dim > 0) {
|
||||
DtoFinalizeClass(dval->getRVal());
|
||||
onstack = true;
|
||||
@@ -2022,7 +2027,7 @@ DValue* DeleteExp::toElem(IRState* p)
|
||||
llvm::Value* rval = dval->getRVal();
|
||||
DtoDeleteClass(rval);
|
||||
}
|
||||
if (dval->isVar() && dval->isVar()->lval) {
|
||||
if (!dval->isThis() && dval->isVar() && dval->isVar()->lval) {
|
||||
llvm::Value* lval = dval->getLVal();
|
||||
DtoStore(llvm::Constant::getNullValue(lval->getType()->getContainedType(0)), lval);
|
||||
}
|
||||
|
||||
@@ -725,6 +725,17 @@ void DtoDeleteClass(llvm::Value* inst)
|
||||
llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb());
|
||||
}
|
||||
|
||||
void DtoDeleteInterface(llvm::Value* inst)
|
||||
{
|
||||
// get runtime function
|
||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_delinterface");
|
||||
// build args
|
||||
llvm::SmallVector<llvm::Value*,1> arg;
|
||||
arg.push_back(DtoBitCast(inst, fn->getFunctionType()->getParamType(0), ".tmp"));
|
||||
// call
|
||||
llvm::CallInst::Create(fn, arg.begin(), arg.end(), "", gIR->scopebb());
|
||||
}
|
||||
|
||||
void DtoDeleteArray(DValue* arr)
|
||||
{
|
||||
// get runtime function
|
||||
|
||||
@@ -63,6 +63,7 @@ llvm::Value* DtoGEPi(llvm::Value* ptr, unsigned i0, unsigned i1, const std::stri
|
||||
llvm::Value* DtoNew(Type* newtype);
|
||||
void DtoDeleteMemory(llvm::Value* ptr);
|
||||
void DtoDeleteClass(llvm::Value* inst);
|
||||
void DtoDeleteInterface(llvm::Value* inst);
|
||||
void DtoDeleteArray(DValue* arr);
|
||||
|
||||
// assertion generator
|
||||
|
||||
Reference in New Issue
Block a user