Skip to content

Commit

Permalink
dmd 2.015
Browse files Browse the repository at this point in the history
  • Loading branch information
braddr committed Jul 3, 2009
1 parent 8dcd67a commit 939fedf
Show file tree
Hide file tree
Showing 27 changed files with 1,346 additions and 597 deletions.
119 changes: 55 additions & 64 deletions src/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,13 @@ Array *AttribDeclaration::include(Scope *sc, ScopeDsymbol *sd)

int AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
{
unsigned i;
int m = 0;
Array *d = include(sc, sd);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
m |= s->addMember(sc, sd, m | memnum);
}
}
Expand All @@ -70,7 +67,7 @@ void AttribDeclaration::semantic(Scope *sc)
{
Array *d = include(sc, NULL);

//printf("\tAttribDeclaration::semantic '%s'\n",toChars());
//printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d);
if (d)
{
for (unsigned i = 0; i < d->dim; i++)
Expand All @@ -84,47 +81,38 @@ void AttribDeclaration::semantic(Scope *sc)

void AttribDeclaration::semantic2(Scope *sc)
{
unsigned i;
Array *d = include(sc, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
s->semantic2(sc);
}
}
}

void AttribDeclaration::semantic3(Scope *sc)
{
unsigned i;
Array *d = include(sc, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
s->semantic3(sc);
}
}
}

void AttribDeclaration::inlineScan()
{
unsigned i;
Array *d = include(NULL, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
//printf("AttribDeclaration::inlineScan %s\n", s->toChars());
s->inlineScan();
}
Expand All @@ -135,15 +123,12 @@ void AttribDeclaration::addComment(unsigned char *comment)
{
if (comment)
{
unsigned i;
Array *d = include(NULL, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
//printf("AttribDeclaration::addComment %s\n", s->toChars());
s->addComment(comment);
}
Expand All @@ -161,15 +146,12 @@ void AttribDeclaration::emitComment(Scope *sc)
// if (sc->docbuf)
// return;

unsigned i;
Array *d = include(NULL, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
//printf("AttribDeclaration::emitComment %s\n", s->toChars());
s->emitComment(sc);
}
Expand All @@ -178,33 +160,27 @@ void AttribDeclaration::emitComment(Scope *sc)

void AttribDeclaration::toObjFile(int multiobj)
{
unsigned i;
Array *d = include(NULL, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
s->toObjFile(multiobj);
}
}
}

int AttribDeclaration::cvMember(unsigned char *p)
{
unsigned i;
int nwritten = 0;
int n;
Array *d = include(NULL, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
n = s->cvMember(p);
if (p)
p += n;
Expand Down Expand Up @@ -244,15 +220,12 @@ int AttribDeclaration::oneMember(Dsymbol **ps)

void AttribDeclaration::checkCtorConstInit()
{
unsigned i;
Array *d = include(NULL, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
s->checkCtorConstInit();
}
}
Expand All @@ -262,15 +235,13 @@ void AttribDeclaration::checkCtorConstInit()
*/

void AttribDeclaration::addLocalClass(ClassDeclarations *aclasses)
{ unsigned i;
{
Array *d = include(NULL, NULL);

if (d)
{
for (i = 0; i < d->dim; i++)
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
for (unsigned i = 0; i < d->dim; i++)
{ Dsymbol *s = (Dsymbol *)d->data[i];
s->addLocalClass(aclasses);
}
}
Expand Down Expand Up @@ -1108,6 +1079,7 @@ Dsymbol *StaticIfDeclaration::syntaxCopy(Dsymbol *s)

int StaticIfDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
{
//printf("StaticIfDeclaration::addMember() '%s'\n",toChars());
/* This is deferred until semantic(), so that
* expressions in the condition can refer to declarations
* in the same scope, such as:
Expand All @@ -1134,7 +1106,7 @@ void StaticIfDeclaration::semantic(Scope *sc)
{
Array *d = include(sc, sd);

//printf("\tStaticIfDeclaration::semantic '%s'\n",toChars());
//printf("\tStaticIfDeclaration::semantic '%s', d = %p\n",toChars(), d);
if (d)
{
if (!addisdone)
Expand Down Expand Up @@ -1164,6 +1136,7 @@ CompileDeclaration::CompileDeclaration(Loc loc, Expression *exp)
{
this->exp = exp;
this->sd = NULL;
this->compiled = 0;
}

Dsymbol *CompileDeclaration::syntaxCopy(Dsymbol *s)
Expand All @@ -1175,32 +1148,50 @@ Dsymbol *CompileDeclaration::syntaxCopy(Dsymbol *s)

int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
{
//printf("CompileDeclaration::addMember(sc = %p)\n", sc);
this->sd = sd;
if (memnum == 0)
{ /* No members yet, so parse the mixin now
*/
compileIt(sc);
memnum |= AttribDeclaration::addMember(sc, sd, memnum);
compiled = 1;
}
return memnum;
}

void CompileDeclaration::semantic(Scope *sc)
void CompileDeclaration::compileIt(Scope *sc)
{
//printf("CompileDeclaration::semantic()\n");
//printf("CompileDeclaration::compileIt()\n");
exp = exp->semantic(sc);
exp = resolveProperties(sc, exp);
exp = exp->optimize(WANTvalue | WANTinterpret);
if (exp->op != TOKstring)
{ error("argument to mixin must be a string, not (%s)", exp->toChars());
return;
}
StringExp *se = (StringExp *)exp;
se = se->toUTF8(sc);
Parser p(sc->module, (unsigned char *)se->string, se->len, 0);
p.loc = loc;
p.nextToken();
decl = p.parseDeclDefs(0);
if (p.token.value != TOKeof)
else
{
error("incomplete mixin declaration (%s)", se->toChars());
StringExp *se = (StringExp *)exp;
se = se->toUTF8(sc);
Parser p(sc->module, (unsigned char *)se->string, se->len, 0);
p.loc = loc;
p.nextToken();
decl = p.parseDeclDefs(0);
if (p.token.value != TOKeof)
error("incomplete mixin declaration (%s)", se->toChars());
}
}

void CompileDeclaration::semantic(Scope *sc)
{
//printf("CompileDeclaration::semantic()\n");

AttribDeclaration::addMember(sc, sd, 0);
if (!compiled)
{
compileIt(sc);
AttribDeclaration::addMember(sc, sd, 0);
compiled = 1;
}
AttribDeclaration::semantic(sc);
}

Expand Down
2 changes: 2 additions & 0 deletions src/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,12 @@ struct CompileDeclaration : AttribDeclaration
Expression *exp;

ScopeDsymbol *sd;
int compiled;

CompileDeclaration(Loc loc, Expression *exp);
Dsymbol *syntaxCopy(Dsymbol *s);
int addMember(Scope *sc, ScopeDsymbol *sd, int memnum);
void compileIt(Scope *sc);
void semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
};
Expand Down
Loading

0 comments on commit 939fedf

Please sign in to comment.