mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-17 05:13:14 +01:00
[svn r75] Fixed the init member in custom enum typeinfo. I don't see any way this could actually need emmision though :/
This commit is contained in:
20
gen/typinf.c
20
gen/typinf.c
@@ -414,9 +414,23 @@ void TypeInfoEnumDeclaration::toDt(dt_t **pdt)
|
||||
assert(sinits.back()->getType() == initZ->getOperand(2)->getType());
|
||||
|
||||
// void[] init
|
||||
//const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty);
|
||||
//sinits.push_back(LLVM_DtoConstantSlice(LLVM_DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt)));
|
||||
sinits.push_back(initZ->getOperand(3));
|
||||
const llvm::PointerType* initpt = llvm::PointerType::get(llvm::Type::Int8Ty);
|
||||
if (tinfo->isZeroInit() || !sd->defaultval) // 0 initializer, or the same as the base type
|
||||
{
|
||||
sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(0), llvm::ConstantPointerNull::get(initpt)));
|
||||
//sinits.push_back(initZ->getOperand(3));
|
||||
}
|
||||
else
|
||||
{
|
||||
const llvm::Type* memty = LLVM_DtoType(sd->memtype);
|
||||
llvm::Constant* ci = llvm::ConstantInt::get(memty, sd->defaultval, !sd->memtype->isunsigned());
|
||||
std::string ciname(sd->mangle());
|
||||
ciname.append("__init");
|
||||
llvm::GlobalVariable* civar = new llvm::GlobalVariable(memty,true,llvm::GlobalValue::InternalLinkage,ci,ciname,gIR->module);
|
||||
llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(civar, initpt);
|
||||
size_t cisize = gTargetData->getTypeSize(memty);
|
||||
sinits.push_back(LLVM_DtoConstSlice(LLVM_DtoConstSize_t(cisize), cicast));
|
||||
}
|
||||
|
||||
// create the symbol
|
||||
llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
|
||||
|
||||
@@ -7,4 +7,5 @@ void main()
|
||||
}
|
||||
auto ti = typeid(E);
|
||||
assert(ti.next() is typeid(uint));
|
||||
assert(ti.init is null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user