mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-12 18:03:13 +01:00
Different fixes for d2
This commit is contained in:
109
gen/typinf.cpp
109
gen/typinf.cpp
@@ -112,43 +112,52 @@ Expression *Type::getInternalTypeInfo(Scope *sc)
|
||||
|
||||
Expression *Type::getTypeInfo(Scope *sc)
|
||||
{
|
||||
Expression *e;
|
||||
Type *t;
|
||||
|
||||
//printf("Type::getTypeInfo() %p, %s\n", this, toChars());
|
||||
t = merge(); // do this since not all Type's are merge'd
|
||||
if (!Type::typeinfo)
|
||||
{
|
||||
error(0, "TypeInfo not found. object.d may be incorrectly installed or corrupt, compile with -v switch");
|
||||
fatal();
|
||||
}
|
||||
|
||||
Expression *e = 0;
|
||||
Type *t = merge2(); // do this since not all Type's are merge'd
|
||||
|
||||
if (!t->vtinfo)
|
||||
{
|
||||
#if DMDV2
|
||||
if (t->isConst())
|
||||
t->vtinfo = new TypeInfoConstDeclaration(t);
|
||||
else if (t->isImmutable())
|
||||
t->vtinfo = new TypeInfoInvariantDeclaration(t);
|
||||
else
|
||||
if (t->isShared())
|
||||
t->vtinfo = new TypeInfoSharedDeclaration(t);
|
||||
else if (t->isConst())
|
||||
t->vtinfo = new TypeInfoConstDeclaration(t);
|
||||
else if (t->isImmutable())
|
||||
t->vtinfo = new TypeInfoInvariantDeclaration(t);
|
||||
else if (t->isWild())
|
||||
t->vtinfo = new TypeInfoWildDeclaration(t);
|
||||
else
|
||||
#endif
|
||||
t->vtinfo = t->getTypeInfoDeclaration();
|
||||
assert(t->vtinfo);
|
||||
t->vtinfo = t->getTypeInfoDeclaration();
|
||||
assert(t->vtinfo);
|
||||
|
||||
/* If this has a custom implementation in std/typeinfo, then
|
||||
* do not generate a COMDAT for it.
|
||||
*/
|
||||
if (!t->builtinTypeInfo())
|
||||
{ // Generate COMDAT
|
||||
if (sc) // if in semantic() pass
|
||||
{ // Find module that will go all the way to an object file
|
||||
Module *m = sc->module->importedFrom;
|
||||
m->members->push(t->vtinfo);
|
||||
}
|
||||
else // if in obj generation pass
|
||||
{
|
||||
/* If this has a custom implementation in std/typeinfo, then
|
||||
* do not generate a COMDAT for it.
|
||||
*/
|
||||
if (!t->builtinTypeInfo())
|
||||
{ // Generate COMDAT
|
||||
if (sc) // if in semantic() pass
|
||||
{ // Find module that will go all the way to an object file
|
||||
Module *m = sc->module->importedFrom;
|
||||
m->members->push(t->vtinfo);
|
||||
}
|
||||
else // if in obj generation pass
|
||||
{
|
||||
#if IN_DMD
|
||||
t->vtinfo->toObjFile(0); // TODO: multiobj
|
||||
t->vtinfo->toObjFile(0); // TODO: multiobj
|
||||
#else
|
||||
t->vtinfo->codegen(sir);
|
||||
t->vtinfo->codegen(sir);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
e = new VarExp(0, t->vtinfo);
|
||||
e = e->addressOf(sc);
|
||||
e->type = t->vtinfo->type; // do this so we don't get redundant dereference
|
||||
@@ -239,7 +248,7 @@ int Type::builtinTypeInfo()
|
||||
int TypeBasic::builtinTypeInfo()
|
||||
{
|
||||
#if DMDV2
|
||||
return !mod;
|
||||
return mod ? 0 : 1;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
@@ -260,7 +269,7 @@ int TypeClass::builtinTypeInfo()
|
||||
* claim it is built in so it isn't regenerated by each module.
|
||||
*/
|
||||
#if IN_DMD
|
||||
return 1;
|
||||
return mod ? 0 : 1;
|
||||
#elif IN_LLVM
|
||||
// FIXME if I enable this, the way LDC does typeinfo will cause a bunch
|
||||
// of linker errors to missing class typeinfo definitions.
|
||||
@@ -673,8 +682,24 @@ void TypeInfoStructDeclaration::llvmDefine()
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#if DMDV2
|
||||
void TypeInfoClassDeclaration::codegen(Ir*i)
|
||||
{
|
||||
|
||||
IrGlobal* irg = new IrGlobal(this);
|
||||
ir.irGlobal = irg;
|
||||
assert(tinfo->ty == Tclass);
|
||||
TypeClass *tc = (TypeClass *)tinfo;
|
||||
tc->sym->codegen(Type::sir); // make sure class is resolved
|
||||
irg->value = tc->sym->ir.irStruct->getClassInfoSymbol();
|
||||
}
|
||||
#endif
|
||||
|
||||
void TypeInfoClassDeclaration::llvmDefine()
|
||||
{
|
||||
#if DMDV2
|
||||
assert(0);
|
||||
#endif
|
||||
Logger::println("TypeInfoClassDeclaration::llvmDefine() %s", toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
@@ -779,4 +804,32 @@ void TypeInfoInvariantDeclaration::llvmDefine()
|
||||
b.finalize(ir.irGlobal);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
void TypeInfoSharedDeclaration::llvmDefine()
|
||||
{
|
||||
Logger::println("TypeInfoSharedDeclaration::llvmDefine() %s", toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
RTTIBuilder b(Type::typeinfoshared);
|
||||
// TypeInfo base
|
||||
b.push_typeinfo(tinfo->unSharedOf()->merge());
|
||||
// finish
|
||||
b.finalize(ir.irGlobal);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
void TypeInfoWildDeclaration::llvmDefine()
|
||||
{
|
||||
Logger::println("TypeInfoWildDeclaration::llvmDefine() %s", toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
RTTIBuilder b(Type::typeinfowild);
|
||||
// TypeInfo base
|
||||
b.push_typeinfo(tinfo->mutableOf()->merge());
|
||||
// finish
|
||||
b.finalize(ir.irGlobal);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user