Mercurial > projects > ldc
diff dmd/mtype.c @ 1367:8026319762be
Merged DMD 1.045 !!!
author | Tomas Lindquist Olsen <tomas.l.olsen gmail com> |
---|---|
date | Sat, 16 May 2009 22:21:31 +0200 |
parents | 680b4df0ea36 |
children | 04177061f98d |
line wrap: on
line diff
--- a/dmd/mtype.c Sat May 16 18:37:16 2009 +0200 +++ b/dmd/mtype.c Sat May 16 22:21:31 2009 +0200 @@ -72,11 +72,16 @@ */ int PTRSIZE = 4; + +/* REALSIZE = size a real consumes in memory + * REALPAD = 'padding' added to the CPU real size to bring it up to REALSIZE + * REALALIGNSIZE = alignment for reals + */ #if TARGET_OSX int REALSIZE = 16; int REALPAD = 6; int REALALIGNSIZE = 16; -#elif TARGET_LINUX || TARGET_FREEBSD +#elif TARGET_LINUX || TARGET_FREEBSD || TARGET_SOLARIS int REALSIZE = 12; int REALPAD = 2; int REALALIGNSIZE = 4; @@ -85,6 +90,7 @@ int REALPAD = 0; int REALALIGNSIZE = 2; #endif + int Tsize_t = Tuns32; int Tptrdiff_t = Tint32; @@ -405,7 +411,7 @@ void Type::toCBuffer3(OutBuffer *buf, HdrGenState *hgs, int mod) { if (mod != this->mod) - { char *p; + { const char *p; switch (this->mod) { @@ -432,20 +438,18 @@ */ Type *Type::merge() -{ Type *t; - +{ //printf("merge(%s)\n", toChars()); - t = this; + Type *t = this; assert(t); if (!deco) { - OutBuffer buf; - StringValue *sv; - if (next) next = next->merge(); + + OutBuffer buf; toDecoBuffer(&buf, false); - sv = stringtable.update((char *)buf.data, buf.offset); + StringValue *sv = stringtable.update((char *)buf.data, buf.offset); if (sv->ptrvalue) { t = (Type *) sv->ptrvalue; assert(t->deco); @@ -477,6 +481,28 @@ return t; } +/************************************* + * This version does a merge even if the deco is already computed. + * Necessary for types that have a deco, but are not merged. + */ +Type *Type::merge2() +{ + //printf("merge2(%s)\n", toChars()); + Type *t = this; + assert(t); + if (!t->deco) + return t->merge(); + + StringValue *sv = deco_stringtable.lookup((char *)t->deco, strlen(t->deco)); + if (sv && sv->ptrvalue) + { t = (Type *) sv->ptrvalue; + assert(t->deco); + } + else + assert(0); + return t; +} + int Type::isbit() { return FALSE; @@ -563,7 +589,7 @@ return NULL; } -int Type::isZeroInit() +int Type::isZeroInit(Loc loc) { return 0; // assume not } @@ -625,9 +651,14 @@ e = defaultInit(loc); } else if (ident == Id::mangleof) - { - assert(deco); - e = new StringExp(loc, deco, strlen(deco), 'c'); + { const char *s; + if (!deco) + { s = toChars(); + error(loc, "forward reference of type %s.mangleof", s); + } + else + s = deco; + e = new StringExp(loc, (char *)s, strlen(s), 'c'); Scope sc; e = e->semantic(&sc); } @@ -1049,6 +1080,17 @@ if (ty == Tvoid) return 1; return GetTypeAlignment(sir, this); +#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS + case Tint64: + case Tuns64: + case Tfloat64: + case Timaginary64: + case Tcomplex32: + case Tcomplex64: + sz = 4; + break; +#endif + } @@ -1089,7 +1131,7 @@ case Tfloat64: fvalue = DBL_MAX; goto Lfvalue; case Tcomplex80: case Timaginary80: - case Tfloat80: fvalue = LDBL_MAX; goto Lfvalue; + case Tfloat80: fvalue = Port::ldbl_max; goto Lfvalue; } } else if (ident == Id::min) @@ -1402,7 +1444,7 @@ return new IntegerExp(loc, value, this); } -int TypeBasic::isZeroInit() +int TypeBasic::isZeroInit(Loc loc) { switch (ty) { @@ -2050,9 +2092,9 @@ return next->defaultInit(loc); } -int TypeSArray::isZeroInit() -{ - return next->isZeroInit(); +int TypeSArray::isZeroInit(Loc loc) +{ + return next->isZeroInit(loc); } @@ -2209,7 +2251,7 @@ return e; } -int TypeDArray::isZeroInit() +int TypeDArray::isZeroInit(Loc loc) { return 1; } @@ -2481,7 +2523,7 @@ return e; } -int TypeAArray::isZeroInit() +int TypeAArray::isZeroInit(Loc loc) { return TRUE; } @@ -2594,7 +2636,7 @@ return e; } -int TypePointer::isZeroInit() +int TypePointer::isZeroInit(Loc loc) { return 1; } @@ -2660,7 +2702,7 @@ return e; } -int TypeReference::isZeroInit() +int TypeReference::isZeroInit(Loc loc) { return 1; } @@ -2841,7 +2883,7 @@ void TypeFunction::toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs) { - char *p = NULL; + const char *p = NULL; if (inuse) { inuse = 2; // flag error to caller @@ -2880,7 +2922,7 @@ void TypeFunction::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod) { - char *p = NULL; + const char *p = NULL; if (inuse) { inuse = 2; // flag error to caller @@ -3223,7 +3265,7 @@ return e; } -int TypeDelegate::isZeroInit() +int TypeDelegate::isZeroInit(Loc loc) { return 1; } @@ -3865,6 +3907,8 @@ error(loc, "expression (%s) has no type", exp->toChars()); goto Lerr; } + if (t->ty == Ttypeof) + error(loc, "forward reference to %s", toChars()); } if (idents.dim) @@ -3966,7 +4010,7 @@ printf("2: "); #endif error(sym->loc, "enum %s is forward referenced", sym->toChars()); - return tint32; + return terror; } return sym->memtype->toBasetype(); } @@ -4020,8 +4064,8 @@ return em; Lfwd: - error(e->loc, "forward reference of %s.%s", toChars(), ident->toChars()); - return new IntegerExp(0, 0, this); + error(e->loc, "forward reference of enum %s.%s", toChars(), ident->toChars()); + return new IntegerExp(0, 0, Type::terror); } Expression *TypeEnum::getProperty(Loc loc, Identifier *ident) @@ -4109,7 +4153,7 @@ return e; } -int TypeEnum::isZeroInit() +int TypeEnum::isZeroInit(Loc loc) { return (sym->defaultval == 0); } @@ -4300,7 +4344,7 @@ return e; } -int TypeTypedef::isZeroInit() +int TypeTypedef::isZeroInit(Loc loc) { if (sym->init) { @@ -4317,7 +4361,7 @@ sym->basetype = Type::terror; } sym->inuse = 1; - int result = sym->basetype->isZeroInit(); + int result = sym->basetype->isZeroInit(loc); sym->inuse = 0; return result; } @@ -4613,7 +4657,7 @@ return new VarExp(sym->loc, d); } -int TypeStruct::isZeroInit() +int TypeStruct::isZeroInit(Loc loc) { return sym->zeroInit; } @@ -5074,7 +5118,7 @@ return e; } -int TypeClass::isZeroInit() +int TypeClass::isZeroInit(Loc loc) { return 1; }