mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-03 08:30:47 +03:00
Prefer more specific functions to DtoResolveDsymbol.
The remaining ones should also be easy to remove with a closer look at the situation. Ideally, we would get rid of all of them at some point and use safe wrapper functions for accessing the IrDsymbol associated with a given declaration (which would emit the declarations on the fly if not already present).
This commit is contained in:
parent
48b7710d22
commit
4fee629c4d
6 changed files with 11 additions and 10 deletions
|
@ -98,7 +98,7 @@ DValue* DtoNewClass(Loc loc, TypeClass* tc, NewExp* newexp)
|
||||||
// custom allocator
|
// custom allocator
|
||||||
else if (newexp->allocator)
|
else if (newexp->allocator)
|
||||||
{
|
{
|
||||||
DtoResolveDsymbol(newexp->allocator);
|
DtoResolveFunction(newexp->allocator);
|
||||||
DFuncValue dfn(newexp->allocator, newexp->allocator->ir.irFunc->func);
|
DFuncValue dfn(newexp->allocator, newexp->allocator->ir.irFunc->func);
|
||||||
DValue* res = DtoCallFunction(newexp->loc, NULL, &dfn, newexp->newargs);
|
DValue* res = DtoCallFunction(newexp->loc, NULL, &dfn, newexp->newargs);
|
||||||
mem = DtoBitCast(res->getRVal(), DtoType(tc), ".newclass_custom");
|
mem = DtoBitCast(res->getRVal(), DtoType(tc), ".newclass_custom");
|
||||||
|
@ -139,7 +139,7 @@ DValue* DtoNewClass(Loc loc, TypeClass* tc, NewExp* newexp)
|
||||||
{
|
{
|
||||||
Logger::println("Calling constructor");
|
Logger::println("Calling constructor");
|
||||||
assert(newexp->arguments != NULL);
|
assert(newexp->arguments != NULL);
|
||||||
DtoResolveDsymbol(newexp->member);
|
DtoResolveFunction(newexp->member);
|
||||||
DFuncValue dfn(newexp->member, newexp->member->ir.irFunc->func, mem);
|
DFuncValue dfn(newexp->member, newexp->member->ir.irFunc->func, mem);
|
||||||
return DtoCallFunction(newexp->loc, tc, &dfn, newexp->arguments);
|
return DtoCallFunction(newexp->loc, tc, &dfn, newexp->arguments);
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,7 @@ static LLConstant* build_class_dtor(ClassDeclaration* cd)
|
||||||
if (!dtor)
|
if (!dtor)
|
||||||
return getNullPtr(getVoidPtrType());
|
return getNullPtr(getVoidPtrType());
|
||||||
|
|
||||||
DtoResolveDsymbol(dtor);
|
DtoResolveFunction(dtor);
|
||||||
return llvm::ConstantExpr::getBitCast(dtor->ir.irFunc->func, getPtrToType(LLType::getInt8Ty(gIR->context())));
|
return llvm::ConstantExpr::getBitCast(dtor->ir.irFunc->func, getPtrToType(LLType::getInt8Ty(gIR->context())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ void InterfaceDeclaration::codegen(Ir* p)
|
||||||
|
|
||||||
if (members && symtab)
|
if (members && symtab)
|
||||||
{
|
{
|
||||||
DtoResolveDsymbol(this);
|
DtoResolveClass(this);
|
||||||
|
|
||||||
// Emit any members (e.g. final functions).
|
// Emit any members (e.g. final functions).
|
||||||
for (ArrayIter<Dsymbol> it(members); !it.done(); it.next())
|
for (ArrayIter<Dsymbol> it(members); !it.done(); it.next())
|
||||||
|
|
|
@ -1178,7 +1178,7 @@ llvm::FunctionType* DtoBaseFunctionType(FuncDeclaration* fdecl)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DtoResolveDsymbol(f);
|
DtoResolveFunction(f);
|
||||||
return llvm::cast<llvm::FunctionType>(DtoType(f->type));
|
return llvm::cast<llvm::FunctionType>(DtoType(f->type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1879,7 +1879,7 @@ DValue* DtoSymbolAddress(const Loc& loc, Type* type, Declaration* decl)
|
||||||
// take care of forward references of global variables
|
// take care of forward references of global variables
|
||||||
const bool isGlobal = vd->isDataseg() || (vd->storage_class & STCextern);
|
const bool isGlobal = vd->isDataseg() || (vd->storage_class & STCextern);
|
||||||
if (isGlobal)
|
if (isGlobal)
|
||||||
DtoResolveDsymbol(vd);
|
DtoResolveVariable(vd);
|
||||||
|
|
||||||
assert(vd->ir.isSet() && "Variable not resolved.");
|
assert(vd->ir.isSet() && "Variable not resolved.");
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "aggregate.h"
|
#include "aggregate.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "gen/arrays.h"
|
#include "gen/arrays.h"
|
||||||
|
#include "gen/functions.h"
|
||||||
#include "gen/irstate.h"
|
#include "gen/irstate.h"
|
||||||
#include "gen/linkage.h"
|
#include "gen/linkage.h"
|
||||||
#include "gen/llvm.h"
|
#include "gen/llvm.h"
|
||||||
|
@ -135,7 +136,7 @@ void RTTIBuilder::push_funcptr(FuncDeclaration* fd, Type* castto)
|
||||||
{
|
{
|
||||||
if (fd)
|
if (fd)
|
||||||
{
|
{
|
||||||
DtoResolveDsymbol(fd);
|
DtoResolveFunction(fd);
|
||||||
LLConstant* F = fd->ir.irFunc->func;
|
LLConstant* F = fd->ir.irFunc->func;
|
||||||
if (castto)
|
if (castto)
|
||||||
F = DtoBitCast(F, DtoType(castto));
|
F = DtoBitCast(F, DtoType(castto));
|
||||||
|
|
|
@ -1585,7 +1585,7 @@ DValue* DotVarExp::toElem(IRState* p)
|
||||||
}
|
}
|
||||||
else if (FuncDeclaration* fdecl = var->isFuncDeclaration())
|
else if (FuncDeclaration* fdecl = var->isFuncDeclaration())
|
||||||
{
|
{
|
||||||
DtoResolveDsymbol(fdecl);
|
DtoResolveFunction(fdecl);
|
||||||
|
|
||||||
// This is a bit more convoluted than it would need to be, because it
|
// This is a bit more convoluted than it would need to be, because it
|
||||||
// has to take templated interface methods into account, for which
|
// has to take templated interface methods into account, for which
|
||||||
|
@ -2122,7 +2122,7 @@ DValue* NewExp::toElem(IRState* p)
|
||||||
if (allocator)
|
if (allocator)
|
||||||
{
|
{
|
||||||
// custom allocator
|
// custom allocator
|
||||||
DtoResolveDsymbol(allocator);
|
DtoResolveFunction(allocator);
|
||||||
DFuncValue dfn(allocator, allocator->ir.irFunc->func);
|
DFuncValue dfn(allocator, allocator->ir.irFunc->func);
|
||||||
DValue* res = DtoCallFunction(loc, NULL, &dfn, newargs);
|
DValue* res = DtoCallFunction(loc, NULL, &dfn, newargs);
|
||||||
mem = DtoBitCast(res->getRVal(), DtoType(ntype->pointerTo()), ".newstruct_custom");
|
mem = DtoBitCast(res->getRVal(), DtoType(ntype->pointerTo()), ".newstruct_custom");
|
||||||
|
@ -2149,7 +2149,7 @@ DValue* NewExp::toElem(IRState* p)
|
||||||
{
|
{
|
||||||
Logger::println("Calling constructor");
|
Logger::println("Calling constructor");
|
||||||
assert(arguments != NULL);
|
assert(arguments != NULL);
|
||||||
DtoResolveDsymbol(member);
|
DtoResolveFunction(member);
|
||||||
DFuncValue dfn(member, member->ir.irFunc->func, mem);
|
DFuncValue dfn(member, member->ir.irFunc->func, mem);
|
||||||
DtoCallFunction(loc, ts, &dfn, arguments);
|
DtoCallFunction(loc, ts, &dfn, arguments);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue