mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 08:01:11 +03:00
Rename Type::irtype to ctype for consistency with dmd and gdc
This commit is contained in:
parent
0f7a3b64c5
commit
66a392a5c2
14 changed files with 46 additions and 66 deletions
10
dmd2/mtype.c
10
dmd2/mtype.c
|
@ -147,13 +147,7 @@ Type::Type(TY ty)
|
|||
this->rto = NULL;
|
||||
this->arrayof = NULL;
|
||||
this->vtinfo = NULL;
|
||||
#if IN_DMD
|
||||
this->ctype = NULL;
|
||||
#endif
|
||||
|
||||
#if IN_LLVM
|
||||
this->irtype = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *Type::kind()
|
||||
|
@ -419,9 +413,7 @@ Type *Type::nullAttributes()
|
|||
t->swto = NULL;
|
||||
t->swcto = NULL;
|
||||
t->vtinfo = NULL;
|
||||
#if !IN_LLVM
|
||||
t->ctype = NULL;
|
||||
#endif
|
||||
if (t->ty == Tstruct) ((TypeStruct *)t)->att = RECfwdref;
|
||||
if (t->ty == Tclass) ((TypeClass *)t)->att = RECfwdref;
|
||||
return t;
|
||||
|
@ -596,9 +588,7 @@ Type *Type::unSharedOf()
|
|||
{
|
||||
t = this->nullAttributes();
|
||||
t->mod = mod & ~MODshared;
|
||||
#if !IN_LLVM
|
||||
t->ctype = ctype;
|
||||
#endif
|
||||
t = t->merge();
|
||||
|
||||
t->fixTo(this);
|
||||
|
|
12
dmd2/mtype.h
12
dmd2/mtype.h
|
@ -23,12 +23,7 @@
|
|||
#include "expression.h"
|
||||
//#include "visitor.h"
|
||||
|
||||
#if IN_LLVM
|
||||
#include "../ir/irfuncty.h"
|
||||
namespace llvm { class Type; }
|
||||
class IrType;
|
||||
#endif
|
||||
|
||||
struct Scope;
|
||||
class Identifier;
|
||||
class Expression;
|
||||
|
@ -52,6 +47,7 @@ class Parameter;
|
|||
#ifdef IN_GCC
|
||||
typedef union tree_node type;
|
||||
#elif IN_LLVM
|
||||
typedef class IrType type;
|
||||
#else
|
||||
typedef struct TYPE type;
|
||||
#endif
|
||||
|
@ -169,9 +165,7 @@ public:
|
|||
Type *arrayof; // array of this type
|
||||
TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type
|
||||
|
||||
#if IN_DMD
|
||||
type *ctype; // for back end
|
||||
#endif
|
||||
|
||||
static Type *tvoid;
|
||||
static Type *tint8;
|
||||
|
@ -374,10 +368,6 @@ public:
|
|||
// For eliminating dynamic_cast
|
||||
virtual TypeBasic *isTypeBasic();
|
||||
virtual void accept(Visitor *v) { v->visit(this); }
|
||||
|
||||
#if IN_LLVM
|
||||
IrType* irtype;
|
||||
#endif
|
||||
};
|
||||
|
||||
class TypeError : public Type
|
||||
|
|
|
@ -254,7 +254,7 @@ DValue* DtoCastClass(Loc& loc, DValue* val, Type* _to)
|
|||
// get the from class
|
||||
ClassDeclaration* cd = fc->sym->isClassDeclaration();
|
||||
DtoResolveClass(cd); // add this
|
||||
IrTypeClass* typeclass = stripModifiers(fc)->irtype->isClass();
|
||||
IrTypeClass* typeclass = stripModifiers(fc)->ctype->isClass();
|
||||
|
||||
// find interface impl
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ llvm::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
|||
// Use the actual type associated with the declaration, ignoring any
|
||||
// const/wrappers.
|
||||
LLType *T = DtoType(sd->type);
|
||||
IrTypeAggr *ir = sd->type->irtype->isAggr();
|
||||
IrTypeAggr *ir = sd->type->ctype->isAggr();
|
||||
assert(ir);
|
||||
|
||||
if (static_cast<llvm::MDNode *>(ir->diCompositeType) != 0)
|
||||
|
|
|
@ -1047,7 +1047,7 @@ void DtoDefineFunction(FuncDeclaration* fd)
|
|||
|
||||
Type* t = fd->type->toBasetype();
|
||||
TypeFunction* f = static_cast<TypeFunction*>(t);
|
||||
// assert(f->irtype);
|
||||
// assert(f->ctype);
|
||||
|
||||
llvm::Function* func = irFunc->func;
|
||||
|
||||
|
|
|
@ -719,8 +719,8 @@ void Module::genmoduleinfo()
|
|||
RTTIBuilder b(moduleinfo);
|
||||
|
||||
// some types
|
||||
LLType* moduleinfoTy = moduleinfo->type->irtype->getLLType();
|
||||
LLType* classinfoTy = Type::typeinfoclass->type->irtype->getLLType();
|
||||
LLType* moduleinfoTy = moduleinfo->type->ctype->getLLType();
|
||||
LLType* classinfoTy = Type::typeinfoclass->type->ctype->getLLType();
|
||||
|
||||
// importedModules[]
|
||||
std::vector<LLConstant*> importInits;
|
||||
|
|
|
@ -324,7 +324,7 @@ public:
|
|||
if (InterfaceDeclaration* it = static_cast<TypeClass*>(tb)->sym->isInterfaceDeclaration()) {
|
||||
assert(it->isBaseOf(cd, NULL));
|
||||
|
||||
IrTypeClass* typeclass = cd->type->irtype->isClass();
|
||||
IrTypeClass* typeclass = cd->type->ctype->isClass();
|
||||
|
||||
// find interface impl
|
||||
size_t i_index = typeclass->getInterfaceIndex(it);
|
||||
|
@ -624,7 +624,7 @@ public:
|
|||
else
|
||||
{
|
||||
value->globalVar = new llvm::GlobalVariable(*p->module,
|
||||
origClass->type->irtype->isClass()->getMemoryLLType(),
|
||||
origClass->type->ctype->isClass()->getMemoryLLType(),
|
||||
false, llvm::GlobalValue::InternalLinkage, 0, ".classref");
|
||||
|
||||
std::map<VarDeclaration*, llvm::Constant*> varInits;
|
||||
|
@ -683,7 +683,7 @@ public:
|
|||
if (InterfaceDeclaration* it = targetClass->isInterfaceDeclaration()) {
|
||||
assert(it->isBaseOf(origClass, NULL));
|
||||
|
||||
IrTypeClass* typeclass = origClass->type->irtype->isClass();
|
||||
IrTypeClass* typeclass = origClass->type->ctype->isClass();
|
||||
|
||||
// find interface impl
|
||||
size_t i_index = typeclass->getInterfaceIndex(it);
|
||||
|
|
|
@ -107,9 +107,9 @@ LLType* DtoType(Type* t)
|
|||
{
|
||||
t = stripModifiers( t );
|
||||
|
||||
if (t->irtype)
|
||||
if (t->ctype)
|
||||
{
|
||||
return t->irtype->getLLType();
|
||||
return t->ctype->getLLType();
|
||||
}
|
||||
|
||||
IF_LOG Logger::println("Building type: %s", t->toChars());
|
||||
|
@ -168,26 +168,26 @@ LLType* DtoType(Type* t)
|
|||
case Tstruct:
|
||||
{
|
||||
TypeStruct* ts = static_cast<TypeStruct*>(t);
|
||||
if (ts->sym->type->irtype)
|
||||
if (ts->sym->type->ctype)
|
||||
{
|
||||
// This should not happen, but the frontend seems to be buggy. Not
|
||||
// sure if this is the best way to handle the situation, but we
|
||||
// certainly don't want to override ts->sym->type->irtype.
|
||||
// certainly don't want to override ts->sym->type->ctype.
|
||||
IF_LOG Logger::cout() << "Struct with multiple Types detected: " <<
|
||||
ts->toChars() << " (" << ts->sym->locToChars() << ")" << std::endl;
|
||||
return ts->sym->type->irtype->getLLType();
|
||||
return ts->sym->type->ctype->getLLType();
|
||||
}
|
||||
return IrTypeStruct::get(ts->sym)->getLLType();
|
||||
}
|
||||
case Tclass:
|
||||
{
|
||||
TypeClass* tc = static_cast<TypeClass*>(t);
|
||||
if (tc->sym->type->irtype)
|
||||
if (tc->sym->type->ctype)
|
||||
{
|
||||
// See Tstruct case.
|
||||
IF_LOG Logger::cout() << "Class with multiple Types detected: " <<
|
||||
tc->toChars() << " (" << tc->sym->locToChars() << ")" << std::endl;
|
||||
return tc->sym->type->irtype->getLLType();
|
||||
return tc->sym->type->ctype->getLLType();
|
||||
}
|
||||
return IrTypeClass::get(tc->sym)->getLLType();
|
||||
}
|
||||
|
|
|
@ -822,7 +822,7 @@ void TypeInfoDeclaration_codegen(TypeInfoDeclaration *decl, IRState* p)
|
|||
assert(irg->type->isStructTy());
|
||||
} else {
|
||||
if (decl->tinfo->builtinTypeInfo()) // this is a declaration of a builtin __initZ var
|
||||
irg->type = Type::dtypeinfo->type->irtype->isClass()->getMemoryLLType();
|
||||
irg->type = Type::dtypeinfo->type->ctype->isClass()->getMemoryLLType();
|
||||
else
|
||||
irg->type = LLStructType::create(gIR->context(), decl->toPrettyChars());
|
||||
irg->value = new llvm::GlobalVariable(*gIR->module, irg->type, true,
|
||||
|
|
|
@ -51,7 +51,7 @@ LLGlobalVariable * IrAggr::getVtblSymbol()
|
|||
initname.append(mangle(aggrdecl));
|
||||
initname.append("6__vtblZ");
|
||||
|
||||
LLType* vtblTy = stripModifiers(type)->irtype->isClass()->getVtbl();
|
||||
LLType* vtblTy = stripModifiers(type)->ctype->isClass()->getVtbl();
|
||||
|
||||
vtbl = getOrCreateGlobal(aggrdecl->loc,
|
||||
*gIR->module, vtblTy, true, llvm::GlobalValue::ExternalLinkage, NULL, initname);
|
||||
|
@ -80,7 +80,7 @@ LLGlobalVariable * IrAggr::getClassInfoSymbol()
|
|||
// member.
|
||||
ClassDeclaration* cinfo = Type::typeinfoclass;
|
||||
DtoType(cinfo->type);
|
||||
IrTypeClass* tc = stripModifiers(cinfo->type)->irtype->isClass();
|
||||
IrTypeClass* tc = stripModifiers(cinfo->type)->ctype->isClass();
|
||||
assert(tc && "invalid ClassInfo type");
|
||||
|
||||
// classinfos cannot be constants since they're used as locks for synchronized
|
||||
|
@ -121,7 +121,7 @@ LLGlobalVariable * IrAggr::getInterfaceArraySymbol()
|
|||
|
||||
ClassDeclaration* cd = aggrdecl->isClassDeclaration();
|
||||
|
||||
size_t n = stripModifiers(type)->irtype->isClass()->getNumInterfaceVtbls();
|
||||
size_t n = stripModifiers(type)->ctype->isClass()->getNumInterfaceVtbls();
|
||||
assert(n > 0 && "getting ClassInfo.interfaces storage symbol, but we "
|
||||
"don't implement any interfaces");
|
||||
|
||||
|
@ -223,12 +223,12 @@ LLConstant * IrAggr::getVtblInit()
|
|||
}
|
||||
|
||||
// build the constant struct
|
||||
LLType* vtblTy = stripModifiers(type)->irtype->isClass()->getVtbl();
|
||||
LLType* vtblTy = stripModifiers(type)->ctype->isClass()->getVtbl();
|
||||
constVtbl = LLConstantStruct::get(isaStruct(vtblTy), constants);
|
||||
|
||||
#if 0
|
||||
IF_LOG Logger::cout() << "constVtbl type: " << *constVtbl->getType() << std::endl;
|
||||
IF_LOG Logger::cout() << "vtbl type: " << *stripModifiers(type)->irtype->isClass()->getVtbl() << std::endl;
|
||||
IF_LOG Logger::cout() << "vtbl type: " << *stripModifiers(type)->ctype->isClass()->getVtbl() << std::endl;
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
@ -248,7 +248,7 @@ LLConstant * IrAggr::getVtblInit()
|
|||
|
||||
#endif
|
||||
|
||||
assert(constVtbl->getType() == stripModifiers(type)->irtype->isClass()->getVtbl() &&
|
||||
assert(constVtbl->getType() == stripModifiers(type)->ctype->isClass()->getVtbl() &&
|
||||
"vtbl initializer type mismatch");
|
||||
|
||||
return constVtbl;
|
||||
|
@ -411,7 +411,7 @@ LLConstant * IrAggr::getClassInfoInterfaces()
|
|||
assert(cd);
|
||||
|
||||
size_t n = interfacesWithVtbls.size();
|
||||
assert(stripModifiers(type)->irtype->isClass()->getNumInterfaceVtbls() == n &&
|
||||
assert(stripModifiers(type)->ctype->isClass()->getNumInterfaceVtbls() == n &&
|
||||
"inconsistent number of interface vtables in this class");
|
||||
|
||||
VarDeclaration *interfaces_idx = Type::typeinfoclass->fields[3];
|
||||
|
@ -446,7 +446,7 @@ LLConstant * IrAggr::getClassInfoInterfaces()
|
|||
|
||||
IrAggr* irinter = getIrAggr(it->base);
|
||||
assert(irinter && "interface has null IrStruct");
|
||||
IrTypeClass* itc = stripModifiers(irinter->type)->irtype->isClass();
|
||||
IrTypeClass* itc = stripModifiers(irinter->type)->ctype->isClass();
|
||||
assert(itc && "null interface IrTypeClass");
|
||||
|
||||
// classinfo
|
||||
|
|
|
@ -32,7 +32,7 @@ IrType::IrType(Type* dt, LLType* lt)
|
|||
{
|
||||
assert(dt && "null D Type");
|
||||
assert(lt && "null LLVM Type");
|
||||
assert(!dt->irtype && "already has IrType");
|
||||
assert(!dt->ctype && "already has IrType");
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -49,7 +49,7 @@ IrTypeBasic::IrTypeBasic(Type * dt)
|
|||
IrTypeBasic* IrTypeBasic::get(Type* dt)
|
||||
{
|
||||
IrTypeBasic* t = new IrTypeBasic(dt);
|
||||
dt->irtype = t;
|
||||
dt->ctype = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ IrTypePointer::IrTypePointer(Type* dt, LLType* lt)
|
|||
|
||||
IrTypePointer* IrTypePointer::get(Type* dt)
|
||||
{
|
||||
assert(!dt->irtype);
|
||||
assert(!dt->ctype);
|
||||
assert((dt->ty == Tpointer || dt->ty == Tnull) && "not pointer/null type");
|
||||
|
||||
LLType* elemType;
|
||||
|
@ -170,12 +170,12 @@ IrTypePointer* IrTypePointer::get(Type* dt)
|
|||
|
||||
// DtoType could have already created the same type, e.g. for
|
||||
// dt == Node* in struct Node { Node* n; }.
|
||||
if (dt->irtype)
|
||||
return dt->irtype->isPointer();
|
||||
if (dt->ctype)
|
||||
return dt->ctype->isPointer();
|
||||
}
|
||||
|
||||
IrTypePointer* t = new IrTypePointer(dt, llvm::PointerType::get(elemType, 0));
|
||||
dt->irtype = t;
|
||||
dt->ctype = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ IrTypeSArray::IrTypeSArray(Type * dt)
|
|||
IrTypeSArray* IrTypeSArray::get(Type* dt)
|
||||
{
|
||||
IrTypeSArray* t = new IrTypeSArray(dt);
|
||||
dt->irtype = t;
|
||||
dt->ctype = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -221,21 +221,21 @@ IrTypeArray::IrTypeArray(Type* dt, LLType* lt)
|
|||
|
||||
IrTypeArray* IrTypeArray::get(Type* dt)
|
||||
{
|
||||
assert(!dt->irtype);
|
||||
assert(!dt->ctype);
|
||||
assert(dt->ty == Tarray && "not dynamic array type");
|
||||
|
||||
LLType* elemType = i1ToI8(voidToI8(DtoType(dt->nextOf())));
|
||||
|
||||
// Could have already built the type as part of a struct forward reference,
|
||||
// just as for pointers.
|
||||
if (!dt->irtype)
|
||||
if (!dt->ctype)
|
||||
{
|
||||
llvm::Type *types[] = { DtoSize_t(), llvm::PointerType::get(elemType, 0) };
|
||||
LLType* at = llvm::StructType::get(llvm::getGlobalContext(), types, false);
|
||||
dt->irtype = new IrTypeArray(dt, at);
|
||||
dt->ctype = new IrTypeArray(dt, at);
|
||||
}
|
||||
|
||||
return dt->irtype->isArray();
|
||||
return dt->ctype->isArray();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -252,7 +252,7 @@ IrTypeVector::IrTypeVector(Type* dt)
|
|||
IrTypeVector* IrTypeVector::get(Type* dt)
|
||||
{
|
||||
IrTypeVector* t = new IrTypeVector(dt);
|
||||
dt->irtype = t;
|
||||
dt->ctype = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
|
@ -232,7 +232,7 @@ void IrTypeClass::addBaseClassData(
|
|||
IrTypeClass* IrTypeClass::get(ClassDeclaration* cd)
|
||||
{
|
||||
IrTypeClass* t = new IrTypeClass(cd);
|
||||
cd->type->irtype = t;
|
||||
cd->type->ctype = t;
|
||||
|
||||
IF_LOG Logger::println("Building class type %s @ %s", cd->toPrettyChars(), cd->loc.toChars());
|
||||
LOG_SCOPE;
|
||||
|
|
|
@ -27,15 +27,15 @@ IrTypeFunction::IrTypeFunction(Type* dt, LLType* lt)
|
|||
|
||||
IrTypeFunction* IrTypeFunction::get(Type* dt, Type* nestedContextOverride)
|
||||
{
|
||||
assert(!dt->irtype);
|
||||
assert(!dt->ctype);
|
||||
assert(dt->ty == Tfunction);
|
||||
|
||||
TypeFunction* tf = static_cast<TypeFunction*>(dt);
|
||||
llvm::Type* lt = DtoFunctionType(tf, tf->irFty, NULL, nestedContextOverride);
|
||||
|
||||
if (!dt->irtype)
|
||||
dt->irtype = new IrTypeFunction(dt, lt);
|
||||
return dt->irtype->isFunction();
|
||||
dt->ctype = new IrTypeFunction(dt, lt);
|
||||
return dt->ctype->isFunction();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -47,13 +47,13 @@ IrTypeDelegate::IrTypeDelegate(Type * dt, LLType* lt)
|
|||
|
||||
IrTypeDelegate* IrTypeDelegate::get(Type* t)
|
||||
{
|
||||
assert(!t->irtype);
|
||||
assert(!t->ctype);
|
||||
assert(t->ty == Tdelegate);
|
||||
assert(t->nextOf()->ty == Tfunction);
|
||||
|
||||
TypeDelegate *dt = (TypeDelegate*)t;
|
||||
|
||||
if (!dt->irtype)
|
||||
if (!dt->ctype)
|
||||
{
|
||||
TypeFunction* tf = static_cast<TypeFunction*>(dt->nextOf());
|
||||
llvm::Type* ltf = DtoFunctionType(tf, dt->irFty, NULL, Type::tvoid->pointerTo());
|
||||
|
@ -61,8 +61,8 @@ IrTypeDelegate* IrTypeDelegate::get(Type* t)
|
|||
llvm::Type *types[] = { getVoidPtrType(),
|
||||
getPtrToType(ltf) };
|
||||
LLStructType* lt = LLStructType::get(gIR->context(), types, false);
|
||||
dt->irtype = new IrTypeDelegate(dt, lt);
|
||||
dt->ctype = new IrTypeDelegate(dt, lt);
|
||||
}
|
||||
|
||||
return dt->irtype->isDelegate();
|
||||
return dt->ctype->isDelegate();
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ bool var_offset_sort_cb(const VarDeclaration* v1, const VarDeclaration* v2)
|
|||
IrTypeStruct* IrTypeStruct::get(StructDeclaration* sd)
|
||||
{
|
||||
IrTypeStruct* t = new IrTypeStruct(sd);
|
||||
sd->type->irtype = t;
|
||||
sd->type->ctype = t;
|
||||
|
||||
IF_LOG Logger::println("Building struct type %s @ %s",
|
||||
sd->toPrettyChars(), sd->loc.toChars());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue