From e9d7c10109abd19b3d441a9b5889495f12b0ad9a Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sat, 15 Jun 2013 15:11:17 +0200 Subject: [PATCH] Align our copy of TypeInfo code to upstream DMD version. --- gen/typinf.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 68b4261e..0d07ab7f 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -77,15 +77,15 @@ Expression *Type::getInternalTypeInfo(Scope *sc) break; case Tclass: - if (static_cast(t)->sym->isInterfaceDeclaration()) - break; + if (((TypeClass *)t)->sym->isInterfaceDeclaration()) + break; goto Linternal; case Tarray: // convert to corresponding dynamic array type t = t->nextOf()->mutableOf()->arrayOf(); if (t->nextOf()->ty != Tclass) - break; + break; goto Linternal; case Tfunction: @@ -95,11 +95,11 @@ Expression *Type::getInternalTypeInfo(Scope *sc) tid = internalTI[t->ty]; if (!tid) { tid = new TypeInfoDeclaration(t, 1); - internalTI[t->ty] = tid; + internalTI[t->ty] = tid; } e = new VarExp(Loc(), tid); e = e->addressOf(sc); - e->type = tid->type; // do this so we don't get redundant dereference + e->type = tid->type; // do this so we don't get redundant dereference return e; default: @@ -122,12 +122,10 @@ Expression *Type::getTypeInfo(Scope *sc) fatal(); } - Expression *e = 0; Type *t = merge2(); // do this since not all Type's are merge'd - if (!t->vtinfo) { - if (t->isShared()) + if (t->isShared()) // does both 'shared' and 'shared const' t->vtinfo = new TypeInfoSharedDeclaration(t); else if (t->isConst()) t->vtinfo = new TypeInfoConstDeclaration(t); @@ -138,30 +136,29 @@ Expression *Type::getTypeInfo(Scope *sc) else t->vtinfo = t->getTypeInfoDeclaration(); assert(t->vtinfo); + vtinfo = 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 + 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 + else // if in obj generation pass { -#if IN_DMD - t->vtinfo->toObjFile(0); // TODO: multiobj -#else t->vtinfo->codegen(sir); -#endif } } } - e = new VarExp(Loc(), t->vtinfo); + if (!vtinfo) + vtinfo = t->vtinfo; // Types aren't merged, but we can share the vtinfo's + Expression *e = new VarExp(Loc(), t->vtinfo); e = e->addressOf(sc); - e->type = t->vtinfo->type; // do this so we don't get redundant dereference + e->type = t->vtinfo->type; // do this so we don't get redundant dereference return e; }