# HG changeset patch # User Robert Clipsham # Date 1245336244 -3600 # Node ID 855f188aab7ae46063713bc905418eda349933dc # Parent 8b9f236dd0515acf26812b4e9bf62e6c1a57acc1 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. diff -r 8b9f236dd051 -r 855f188aab7a gen/declarations.cpp --- a/gen/declarations.cpp Tue Jun 16 15:37:40 2009 +0200 +++ b/gen/declarations.cpp Thu Jun 18 15:44:04 2009 +0100 @@ -96,7 +96,7 @@ // 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 diff -r 8b9f236dd051 -r 855f188aab7a gen/llvmhelpers.cpp --- a/gen/llvmhelpers.cpp Tue Jun 16 15:37:40 2009 +0200 +++ b/gen/llvmhelpers.cpp Thu Jun 18 15:44:04 2009 +0100 @@ -1480,3 +1480,76 @@ } ////////////////////////////////////////////////////////////////////////////////////////// + +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 +} + +////////////////////////////////////////////////////////////////////////////////////////// diff -r 8b9f236dd051 -r 855f188aab7a gen/llvmhelpers.h --- a/gen/llvmhelpers.h Tue Jun 16 15:37:40 2009 +0200 +++ b/gen/llvmhelpers.h Thu Jun 18 15:44:04 2009 +0100 @@ -170,4 +170,6 @@ /// DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* arguments); +Type* stripModifiers(Type* type); + #endif diff -r 8b9f236dd051 -r 855f188aab7a gen/todebug.cpp --- a/gen/todebug.cpp Tue Jun 16 15:37:40 2009 +0200 +++ b/gen/todebug.cpp Thu Jun 18 15:44:04 2009 +0100 @@ -408,7 +408,7 @@ 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 diff -r 8b9f236dd051 -r 855f188aab7a gen/tollvm.cpp --- a/gen/tollvm.cpp Tue Jun 16 15:37:40 2009 +0200 +++ b/gen/tollvm.cpp Thu Jun 18 15:44:04 2009 +0100 @@ -54,9 +54,7 @@ const LLType* DtoType(Type* t) { -#if DMDV2 - t = t->mutableOf(); -#endif + t = stripModifiers( t ); if (t->irtype) {