Renamed IrType::get/IrType::getD, treat classes as the special case they are.

This commit is contained in:
David Nadlinger
2012-12-20 06:23:27 +01:00
parent aa4543465d
commit 464c695814
8 changed files with 35 additions and 17 deletions

View File

@@ -78,9 +78,9 @@ LLGlobalVariable * IrStruct::getClassInfoSymbol()
IrTypeClass* tc = stripModifiers(cinfo->type)->irtype->isClass();
assert(tc && "invalid ClassInfo type");
// classinfos cannot be constants since they're used a locks for synchronized
// classinfos cannot be constants since they're used as locks for synchronized
classInfo = new llvm::GlobalVariable(
*gIR->module, tc->getType(), false, _linkage, NULL, initname);
*gIR->module, tc->getMemoryLLType(), false, _linkage, NULL, initname);
#if USE_METADATA
// Generate some metadata on this ClassInfo if it's for a class.

View File

@@ -71,11 +71,9 @@ public:
#endif
///
Type* getD() { return dtype; }
Type* getDType() { return dtype; }
///
virtual llvm::Type* get() { return type; }
///
llvm::Type* getType() { return type; }
virtual llvm::Type* getLLType() { return type; }
///
virtual llvm::Type* buildType() = 0;

View File

@@ -279,7 +279,7 @@ llvm::Type* IrTypeClass::buildType()
IF_LOG Logger::cout() << "class type: " << *type << std::endl;
return get();
return getLLType();
}
//////////////////////////////////////////////////////////////////////////////
@@ -349,13 +349,20 @@ std::vector<llvm::Type*> IrTypeClass::buildVtblType(Type* first, Array* vtbl_arr
//////////////////////////////////////////////////////////////////////////////
llvm::Type * IrTypeClass::get()
llvm::Type * IrTypeClass::getLLType()
{
return llvm::PointerType::get(type, 0);
}
//////////////////////////////////////////////////////////////////////////////
llvm::Type * IrTypeClass::getMemoryLLType()
{
return type;
}
//////////////////////////////////////////////////////////////////////////////
size_t IrTypeClass::getInterfaceIndex(ClassDeclaration * inter)
{
ClassIndexMap::iterator it = interfaceMap.find(inter);

View File

@@ -31,7 +31,11 @@ public:
llvm::Type* buildType();
///
llvm::Type* get();
llvm::Type* getLLType();
/// Returns the actual storage type, i.e. without the indirection
/// for the class reference.
llvm::Type* getMemoryLLType();
/// Returns the vtable type for this class.
llvm::Type* getVtbl() { return vtbl_type; }