Skip to content

Commit

Permalink
dmd 2.013
Browse files Browse the repository at this point in the history
  • Loading branch information
braddr committed Jul 3, 2009
1 parent 2633f35 commit d550a1a
Show file tree
Hide file tree
Showing 34 changed files with 842 additions and 311 deletions.
2 changes: 2 additions & 0 deletions src/aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ struct ClassDeclaration : AggregateDeclaration
int isnested; // !=0 if is nested
VarDeclaration *vthis; // 'this' parameter if this class is nested

int inuse; // to prevent recursive attempts

ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses);
Dsymbol *syntaxCopy(Dsymbol *s);
void semantic(Scope *sc);
Expand Down
49 changes: 38 additions & 11 deletions src/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ void StorageClassDeclaration::semantic(Scope *sc)
*/
if (stc & (STCauto | STCscope | STCstatic | STCextern | STCmanifest))
sc->stc &= ~(STCauto | STCscope | STCstatic | STCextern | STCmanifest);
if (stc & (STCauto | STCscope | STCstatic | STCtls | STCmanifest))
sc->stc &= ~(STCauto | STCscope | STCstatic | STCtls | STCmanifest);
if (stc & (STCconst | STCinvariant | STCmanifest))
sc->stc &= ~(STCconst | STCinvariant | STCmanifest);
sc->stc |= stc;
Expand Down Expand Up @@ -361,6 +363,9 @@ void StorageClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{ STCsynchronized, TOKsynchronized },
{ STCdeprecated, TOKdeprecated },
{ STCoverride, TOKoverride },
{ STCnothrow, TOKnothrow },
{ STCpure, TOKpure },
{ STCtls, TOKtls },
};

int written = 0;
Expand Down Expand Up @@ -625,7 +630,7 @@ void AnonDeclaration::semantic(Scope *sc)

sc = sc->push();
sc->anonAgg = &aad;
sc->stc &= ~(STCauto | STCscope | STCstatic);
sc->stc &= ~(STCauto | STCscope | STCstatic | STCtls);
sc->inunion = isunion;
sc->offset = 0;
sc->flags = 0;
Expand Down Expand Up @@ -855,6 +860,33 @@ void PragmaDeclaration::semantic(Scope *sc)
}
goto Lnodecl;
}
else if (global.params.ignoreUnsupportedPragmas)
{
if (global.params.verbose)
{
/* Print unrecognized pragmas
*/
printf("pragma %s", ident->toChars());
if (args)
{
for (size_t i = 0; i < args->dim; i++)
{
Expression *e = (Expression *)args->data[i];
e = e->semantic(sc);
e = e->optimize(WANTvalue | WANTinterpret);
if (i == 0)
printf(" (");
else
printf(",");
printf("%s", e->toChars());
}
if (args->dim)
printf(")");
}
printf("\n");
}
goto Lnodecl;
}
else
error("unrecognized pragma(%s)", ident->toChars());

Expand Down Expand Up @@ -916,18 +948,13 @@ void PragmaDeclaration::toObjFile()

void PragmaDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{
buf->printf("pragma(%s", ident->toChars());
if (args)
buf->printf("pragma (%s", ident->toChars());
if (args && args->dim)
{
for (size_t i = 0; i < args->dim; i++)
{
Expression *e = (Expression *)args->data[i];

buf->writestring(", ");
e->toCBuffer(buf, hgs);
}
buf->writestring(", ");
argsToCBuffer(buf, args, hgs);
}
buf->writestring(")");
buf->writeByte(')');
AttribDeclaration::toCBuffer(buf, hgs);
}

Expand Down
12 changes: 6 additions & 6 deletions src/cast.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Copyright (c) 1999-2007 by Digital Mars
// Copyright (c) 1999-2008 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
Expand Down Expand Up @@ -31,8 +31,7 @@

Expression *Expression::implicitCastTo(Scope *sc, Type *t)
{
//printf("Expression::implicitCastTo(%s) => %s\n", type->toChars(), t->toChars());
//printf("%s\n", toChars());
//printf("Expression::implicitCastTo(%s of type %s) => %s\n", toChars(), type->toChars(), t->toChars());

MATCH match = implicitConvTo(t);
if (match)
Expand Down Expand Up @@ -103,7 +102,7 @@ MATCH Expression::implicitConvTo(Type *t)
printf("Expression::implicitConvTo(this=%s, type=%s, t=%s)\n",
toChars(), type->toChars(), t->toChars());
#endif
//static int nest; if (++nest == 50) halt();
//static int nest; if (++nest == 10) halt();
if (!type)
{ error("%s is not an expression", toChars());
type = Type::terror;
Expand Down Expand Up @@ -1086,7 +1085,7 @@ Expression *TupleExp::castTo(Scope *sc, Type *t)
Expression *ArrayLiteralExp::castTo(Scope *sc, Type *t)
{
#if 0
printf("ArrayLiteralExp::castTo(this=%s, type=%s, t=%s)\n",
printf("ArrayLiteralExp::castTo(this=%s, type=%s, => %s)\n",
toChars(), type->toChars(), t->toChars());
#endif
if (type == t)
Expand All @@ -1096,7 +1095,8 @@ Expression *ArrayLiteralExp::castTo(Scope *sc, Type *t)
Type *tb = t->toBasetype();
if ((tb->ty == Tarray || tb->ty == Tsarray) &&
(typeb->ty == Tarray || typeb->ty == Tsarray) &&
tb->nextOf()->toBasetype()->ty != Tvoid)
// Not trying to convert non-void[] to void[]
!(tb->nextOf()->toBasetype()->ty == Tvoid && typeb->nextOf()->toBasetype()->ty != Tvoid))
{
if (tb->ty == Tsarray)
{ TypeSArray *tsa = (TypeSArray *)tb;
Expand Down
13 changes: 9 additions & 4 deletions src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *basecla
isabstract = 0;
isnested = 0;
vthis = NULL;
inuse = 0;
}

Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s)
Expand Down Expand Up @@ -529,7 +530,7 @@ void ClassDeclaration::semantic(Scope *sc)

sc = sc->push(this);
sc->stc &= ~(STCfinal | STCauto | STCscope | STCstatic |
STCabstract | STCdeprecated | STCconst | STCinvariant);
STCabstract | STCdeprecated | STCconst | STCinvariant | STCtls);
sc->stc |= storage_class & (STCconst | STCinvariant);
sc->parent = this;
sc->inunion = 0;
Expand Down Expand Up @@ -574,7 +575,7 @@ void ClassDeclaration::semantic(Scope *sc)
scope->setNoFree();
scope->module->addDeferredSemantic(this);

//printf("\tsemantic('%s') failed\n", toChars());
//printf("\tsemantic('%s') failed due to forward references\n", toChars());
return;
}

Expand Down Expand Up @@ -1013,6 +1014,8 @@ void InterfaceDeclaration::semantic(Scope *sc)
{ int i;

//printf("InterfaceDeclaration::semantic(%s), type = %p\n", toChars(), type);
if (inuse)
return;
if (!scope)
{ type = type->semantic(loc, sc);
handle = handle->semantic(loc, sc);
Expand Down Expand Up @@ -1100,7 +1103,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
baseclasses.remove(i);
continue;
}
if (!b->base->symtab || b->base->scope)
if (!b->base->symtab || b->base->scope || b->base->inuse)
{
//error("forward reference of base class %s", baseClass->toChars());
// Forward reference of base, try again later
Expand Down Expand Up @@ -1167,7 +1170,7 @@ void InterfaceDeclaration::semantic(Scope *sc)

sc = sc->push(this);
sc->stc &= ~(STCfinal | STCauto | STCscope | STCstatic |
STCabstract | STCdeprecated | STCconst | STCinvariant);
STCabstract | STCdeprecated | STCconst | STCinvariant | STCtls);
sc->stc |= storage_class & (STCconst | STCinvariant);
sc->parent = this;
if (isCOMinterface())
Expand All @@ -1177,11 +1180,13 @@ void InterfaceDeclaration::semantic(Scope *sc)
sc->structalign = 8;
structalign = sc->structalign;
sc->offset = 8;
inuse++;
for (i = 0; i < members->dim; i++)
{
Dsymbol *s = (Dsymbol *)members->data[i];
s->semantic(sc);
}
inuse--;
//members->print();
sc->pop();
//printf("-InterfaceDeclaration::semantic(%s), type = %p\n", toChars(), type);
Expand Down
10 changes: 6 additions & 4 deletions src/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ void VarDeclaration::semantic(Scope *sc)
error("final cannot be applied to variable");
}

if (storage_class & (STCstatic | STCextern | STCmanifest | STCtemplateparameter))
if (storage_class & (STCstatic | STCextern | STCmanifest | STCtemplateparameter | STCtls))
{
}
else
Expand All @@ -810,7 +810,7 @@ void VarDeclaration::semantic(Scope *sc)
if (!aad)
aad = parent->isAggregateDeclaration();
if (aad)
{ assert(!(storage_class & (STCextern | STCstatic)));
{ assert(!(storage_class & (STCextern | STCstatic | STCtls)));

if (storage_class & (STCconst | STCinvariant) && init)
{
Expand Down Expand Up @@ -852,7 +852,7 @@ void VarDeclaration::semantic(Scope *sc)

if (type->isauto() && !noauto)
{
if (storage_class & (STCfield | STCout | STCref | STCstatic | STCmanifest) || !fd)
if (storage_class & (STCfield | STCout | STCref | STCstatic | STCmanifest | STCtls) || !fd)
{
error("globals, statics, fields, manifest constants, ref and out parameters cannot be auto");
}
Expand Down Expand Up @@ -1111,6 +1111,8 @@ void VarDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
buf->writestring("manifest ");
if (storage_class & STCstatic)
buf->writestring("static ");
if (storage_class & STCtls)
buf->writestring("__tls ");
if (storage_class & STCconst)
buf->writestring("const ");
if (storage_class & STCinvariant)
Expand Down Expand Up @@ -1282,7 +1284,7 @@ int VarDeclaration::isDataseg()
return 0;
}
return canTakeAddressOf() &&
(storage_class & (STCstatic | STCextern) ||
(storage_class & (STCstatic | STCextern | STCtls) ||
toParent()->isModule() ||
toParent()->isTemplateInstance());
}
Expand Down
6 changes: 5 additions & 1 deletion src/declaration.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Compiler implementation of the D programming language
// Copyright (c) 1999-2007 by Digital Mars
// Copyright (c) 1999-2008 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
Expand Down Expand Up @@ -67,6 +67,8 @@ enum STC
STCmanifest = 0x800000, // manifest constant
STCnodtor = 0x1000000, // don't run destructor
STCnothrow = 0x2000000, // never throws exceptions
STCpure = 0x4000000, // pure function
STCtls = 0x8000000, // thread local
};

struct Match
Expand Down Expand Up @@ -525,9 +527,11 @@ struct FuncDeclaration : Declaration
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs);
int overrides(FuncDeclaration *fd);
int findVtblIndex(Array *vtbl, int dim);
int overloadInsert(Dsymbol *s);
FuncDeclaration *overloadExactMatch(Type *t);
FuncDeclaration *overloadResolve(Loc loc, Expression *ethis, Expressions *arguments, int flags = 0);
MATCH leastAsSpecialized(FuncDeclaration *g);
LabelDsymbol *searchLabel(Identifier *ident);
AggregateDeclaration *isThis();
AggregateDeclaration *isMember2();
Expand Down
10 changes: 7 additions & 3 deletions src/e2ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -4114,7 +4114,7 @@ elem *IndexExp::toElem(IRState *irs)
if (t1->ty == Taarray)
{
// set to:
// *aaGet(aa, keyti, valuesize, value);
// *aaGet(aa, keyti, valuesize, index);

TypeAArray *taa = (TypeAArray *)t1;
elem *keyti;
Expand All @@ -4123,14 +4123,17 @@ elem *IndexExp::toElem(IRState *irs)
elem *valuesize;
Symbol *s;

// n2 becomes the index, also known as the key
n2 = e2->toElem(irs);
if (n2->Ety == TYstruct)
if (n2->Ety == TYstruct || n2->Ety == TYarray)
{
n2 = el_una(OPstrpar, TYstruct, n2);
n2->Enumbytes = n2->E1->Enumbytes;
//printf("numbytes = %d\n", n2->Enumbytes);
assert(n2->Enumbytes);
}
valuesize = el_long(TYuint, vsize); // BUG: should be TYsize_t
//printf("valuesize: "); elem_print(valuesize);
if (modifiable)
{
n1 = el_una(OPaddr, TYnptr, n1);
Expand All @@ -4140,8 +4143,9 @@ elem *IndexExp::toElem(IRState *irs)
{
s = taa->aaGetSymbol("GetRvalue", 1);
}
//printf("taa->key = %s\n", taa->key->toChars());
//printf("taa->index = %s\n", taa->index->toChars());
keyti = taa->index->getInternalTypeInfo(NULL)->toElem(irs);
//keyti = taa->index->getTypeInfo(NULL)->toElem(irs);
//printf("keyti:\n");
//elem_print(keyti);
ep = el_params(n2, valuesize, keyti, n1, NULL);
Expand Down
Loading

0 comments on commit d550a1a

Please sign in to comment.