Mercurial > projects > ldc
diff gen/llvmhelpers.cpp @ 1504:855f188aab7a
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.
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Thu, 18 Jun 2009 15:44:04 +0100 |
parents | c3c46399bcf1 |
children | e07f15c4ab4d |
line wrap: on
line diff
--- 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 +} + +//////////////////////////////////////////////////////////////////////////////////////////