Added a stripModifiers() function to remove shared|const|immutable storage classes in D2 (should eventually be moved to a dhelpers file rather than llvm helpers).

Replaced a few occurances of STCinvariant with STCimmutable.
This commit is contained in:
Robert Clipsham 2009-06-18 15:44:04 +01:00
parent 348192e7e7
commit f13c5e82f5
5 changed files with 78 additions and 5 deletions

View file

@ -96,7 +96,7 @@ void VarDeclaration::codegen(Ir* p)
// global variable
#if DMDV2
// taken from dmd2/structs
if (isDataseg() || (storage_class & (STCconst | STCinvariant) && init))
if (isDataseg() || (storage_class & (STCconst | STCimmutable) && init))
#else
if (isDataseg())
#endif

View file

@ -1480,3 +1480,76 @@ size_t realignOffset(size_t offset, Type* type)
}
//////////////////////////////////////////////////////////////////////////////////////////
Type * stripModifiers( Type * type )
{
#if DMDV2
Type *t = type;
while (t->mod)
{
switch (t->mod)
{
case MODconst:
t = type->cto;
break;
case MODshared:
t = type->sto;
break;
case MODinvariant:
t = type->ito;
break;
case MODshared | MODconst:
t = type->scto;
break;
default:
assert(0 && "Unhandled type modifier");
}
if (!t)
{
unsigned sz = type->sizeTy[type->ty];
t = (Type *)malloc(sz);
memcpy(t, type, sz);
t->mod = 0;
t->deco = NULL;
t->arrayof = NULL;
t->pto = NULL;
t->rto = NULL;
t->cto = NULL;
t->ito = NULL;
t->sto = NULL;
t->scto = NULL;
t->vtinfo = NULL;
t = t->merge();
t->fixTo(type);
switch (type->mod)
{
case MODconst:
t->cto = type;
break;
case MODinvariant:
t->ito = type;
break;
case MODshared:
t->sto = type;
break;
case MODshared | MODconst:
t->scto = type;
break;
default:
assert(0);
}
}
}
return t;
#else
return type;
#endif
}
//////////////////////////////////////////////////////////////////////////////////////////

View file

@ -170,4 +170,6 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, llvm::AttrListPtr& palist,
///
DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* arguments);
Type* stripModifiers(Type* type);
#endif

View file

@ -408,7 +408,7 @@ static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit
static llvm::DIGlobalVariable dwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd)
{
#if DMDV2
assert(vd->isDataseg() || (vd->storage_class & (STCconst | STCinvariant) && vd->init));
assert(vd->isDataseg() || (vd->storage_class & (STCconst | STCimmutable) && vd->init));
#else
assert(vd->isDataseg());
#endif

View file

@ -54,9 +54,7 @@ unsigned DtoShouldExtend(Type* type)
const LLType* DtoType(Type* t)
{
#if DMDV2
t = t->mutableOf();
#endif
t = stripModifiers( t );
if (t->irtype)
{