Skip to content

Commit

Permalink
dmd 2.016
Browse files Browse the repository at this point in the history
  • Loading branch information
braddr committed Jul 3, 2009
1 parent 939fedf commit b35589b
Show file tree
Hide file tree
Showing 43 changed files with 807 additions and 203 deletions.
8 changes: 4 additions & 4 deletions src/aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ struct StructDeclaration : AggregateDeclaration
void semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
char *mangle();
char *kind();
const char *kind();
int needOpAssign();
FuncDeclaration *buildOpAssign(Scope *sc);
FuncDeclaration *buildPostBlit(Scope *sc);
Expand All @@ -140,7 +140,7 @@ struct UnionDeclaration : StructDeclaration
{
UnionDeclaration(Loc loc, Identifier *id);
Dsymbol *syntaxCopy(Dsymbol *s);
char *kind();
const char *kind();

UnionDeclaration *isUnionDeclaration() { return this; }
};
Expand Down Expand Up @@ -229,7 +229,7 @@ struct ClassDeclaration : AggregateDeclaration
#endif
int isAbstract();
virtual int vtblOffset();
char *kind();
const char *kind();
char *mangle();
void toDocBuffer(OutBuffer *buf);

Expand Down Expand Up @@ -261,7 +261,7 @@ struct InterfaceDeclaration : ClassDeclaration
void semantic(Scope *sc);
int isBaseOf(ClassDeclaration *cd, int *poffset);
int isBaseOf(BaseClass *bc, int *poffset);
char *kind();
const char *kind();
int vtblOffset();
#if V2
int isCPPinterface();
Expand Down
18 changes: 10 additions & 8 deletions src/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ int AttribDeclaration::hasPointers()
return 0;
}

char *AttribDeclaration::kind()
const char *AttribDeclaration::kind()
{
return "attribute";
}
Expand Down Expand Up @@ -703,9 +703,9 @@ void AnonDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
buf->writestring("}\n");
}

char *AnonDeclaration::kind()
const char *AnonDeclaration::kind()
{
return (char *)(isunion ? "anonymous union" : "anonymous struct");
return (isunion ? "anonymous union" : "anonymous struct");
}

/********************************* PragmaDeclaration ****************************/
Expand Down Expand Up @@ -883,7 +883,7 @@ int PragmaDeclaration::oneMember(Dsymbol **ps)
return TRUE;
}

char *PragmaDeclaration::kind()
const char *PragmaDeclaration::kind()
{
return "pragma";
}
Expand Down Expand Up @@ -1123,7 +1123,7 @@ void StaticIfDeclaration::semantic(Scope *sc)
}
}

char *StaticIfDeclaration::kind()
const char *StaticIfDeclaration::kind()
{
return "static if";
}
Expand All @@ -1134,6 +1134,8 @@ char *StaticIfDeclaration::kind()
CompileDeclaration::CompileDeclaration(Loc loc, Expression *exp)
: AttribDeclaration(NULL)
{
//printf("CompileDeclaration(loc = %d)\n", loc.linnum);
this->loc = loc;
this->exp = exp;
this->sd = NULL;
this->compiled = 0;
Expand Down Expand Up @@ -1162,12 +1164,12 @@ int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)

void CompileDeclaration::compileIt(Scope *sc)
{
//printf("CompileDeclaration::compileIt()\n");
//printf("CompileDeclaration::compileIt(loc = %d)\n", loc.linnum);
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());
{ exp->error("argument to mixin must be a string, not (%s)", exp->toChars());
}
else
{
Expand All @@ -1178,7 +1180,7 @@ void CompileDeclaration::compileIt(Scope *sc)
p.nextToken();
decl = p.parseDeclDefs(0);
if (p.token.value != TOKeof)
error("incomplete mixin declaration (%s)", se->toChars());
exp->error("incomplete mixin declaration (%s)", se->toChars());
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct AttribDeclaration : Dsymbol
void inlineScan();
void addComment(unsigned char *comment);
void emitComment(Scope *sc);
char *kind();
const char *kind();
int oneMember(Dsymbol **ps);
int hasPointers();
void checkCtorConstInit();
Expand Down Expand Up @@ -106,7 +106,7 @@ struct AnonDeclaration : AttribDeclaration
Dsymbol *syntaxCopy(Dsymbol *s);
void semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
char *kind();
const char *kind();
};

struct PragmaDeclaration : AttribDeclaration
Expand All @@ -118,7 +118,7 @@ struct PragmaDeclaration : AttribDeclaration
void semantic(Scope *sc);
int oneMember(Dsymbol **ps);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
char *kind();
const char *kind();
void toObjFile(int multiobj); // compile to .obj file
};

Expand All @@ -145,7 +145,7 @@ struct StaticIfDeclaration : ConditionalDeclaration
Dsymbol *syntaxCopy(Dsymbol *s);
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
void semantic(Scope *sc);
char *kind();
const char *kind();
};

// Mixin declarations
Expand Down
10 changes: 5 additions & 5 deletions src/class.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ void ClassDeclaration::semantic(Scope *sc)
// sc->offset += PTRSIZE; // room for uplevel context pointer
}
else
{ sc->offset = 8; // allow room for vptr[] and monitor
{ sc->offset = PTRSIZE * 2; // allow room for __vptr and __monitor
alignsize = 4;
}
structsize = sc->offset;
Expand Down Expand Up @@ -609,7 +609,7 @@ void ClassDeclaration::semantic(Scope *sc)
if (!ctor && baseClass && baseClass->ctor)
{
//printf("Creating default this(){} for class %s\n", toChars());
ctor = new CtorDeclaration(0, 0, NULL, 0);
ctor = new CtorDeclaration(loc, 0, NULL, 0);
ctor->fbody = new CompoundStatement(0, new Statements());
members->push(ctor);
ctor->addMember(sc, this, 1);
Expand Down Expand Up @@ -971,7 +971,7 @@ int ClassDeclaration::vtblOffset()
/****************************************
*/

char *ClassDeclaration::kind()
const char *ClassDeclaration::kind()
{
return "class";
}
Expand Down Expand Up @@ -1179,7 +1179,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
sc->linkage = LINKcpp;
sc->structalign = 8;
structalign = sc->structalign;
sc->offset = 8;
sc->offset = PTRSIZE * 2;
inuse++;
for (i = 0; i < members->dim; i++)
{
Expand Down Expand Up @@ -1292,7 +1292,7 @@ int InterfaceDeclaration::isCPPinterface()
/*******************************************
*/

char *InterfaceDeclaration::kind()
const char *InterfaceDeclaration::kind()
{
return "interface";
}
Expand Down
27 changes: 11 additions & 16 deletions src/constfold.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ Expression *Div(Type *type, Expression *e1, Expression *e2)
n2 = e2->toInteger();
if (n2 == 0)
{ e2->error("divide by 0");
e2 = new IntegerExp(0, 1, e2->type);
e2 = new IntegerExp(loc, 1, e2->type);
n2 = 1;
}
if (e1->type->isunsigned() || e2->type->isunsigned())
Expand Down Expand Up @@ -523,7 +523,7 @@ Expression *Mod(Type *type, Expression *e1, Expression *e2)
n2 = e2->toInteger();
if (n2 == 0)
{ e2->error("divide by 0");
e2 = new IntegerExp(0, 1, e2->type);
e2 = new IntegerExp(loc, 1, e2->type);
n2 = 1;
}
if (e1->type->isunsigned() || e2->type->isunsigned())
Expand Down Expand Up @@ -632,26 +632,21 @@ Expression *Ushr(Type *type, Expression *e1, Expression *e2)
}

Expression *And(Type *type, Expression *e1, Expression *e2)
{ Expression *e;
Loc loc = e1->loc;

e = new IntegerExp(loc, e1->toInteger() & e2->toInteger(), type);
{
Expression *e;
e = new IntegerExp(e1->loc, e1->toInteger() & e2->toInteger(), type);
return e;
}

Expression *Or(Type *type, Expression *e1, Expression *e2)
{ Expression *e;
Loc loc = e1->loc;

e = new IntegerExp(loc, e1->toInteger() | e2->toInteger(), type);
e = new IntegerExp(e1->loc, e1->toInteger() | e2->toInteger(), type);
return e;
}

Expression *Xor(Type *type, Expression *e1, Expression *e2)
{ Expression *e;
Loc loc = e1->loc;

e = new IntegerExp(loc, e1->toInteger() ^ e2->toInteger(), type);
e = new IntegerExp(e1->loc, e1->toInteger() ^ e2->toInteger(), type);
return e;
}

Expand Down Expand Up @@ -1166,7 +1161,7 @@ Expression *Cast(Type *type, Type *to, Expression *e1)
else
{
error(loc, "cannot cast %s to %s", e1->type->toChars(), type->toChars());
e = new IntegerExp(loc, 0, type);
e = new IntegerExp(loc, 0, Type::tint32);
}
return e;
}
Expand Down Expand Up @@ -1472,7 +1467,7 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2)

if (type->toBasetype()->ty == Tsarray)
{
e->type = new TypeSArray(t1->nextOf(), new IntegerExp(0, es1->elements->dim, Type::tindex));
e->type = new TypeSArray(t1->nextOf(), new IntegerExp(loc, es1->elements->dim, Type::tindex));
e->type = e->type->semantic(loc, NULL);
}
else
Expand All @@ -1495,7 +1490,7 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2)

if (type->toBasetype()->ty == Tsarray)
{
e->type = new TypeSArray(e2->type, new IntegerExp(0, es1->elements->dim, Type::tindex));
e->type = new TypeSArray(e2->type, new IntegerExp(loc, es1->elements->dim, Type::tindex));
e->type = e->type->semantic(loc, NULL);
}
else
Expand All @@ -1512,7 +1507,7 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2)

if (type->toBasetype()->ty == Tsarray)
{
e->type = new TypeSArray(e1->type, new IntegerExp(0, es2->elements->dim, Type::tindex));
e->type = new TypeSArray(e1->type, new IntegerExp(loc, es2->elements->dim, Type::tindex));
e->type = e->type->semantic(loc, NULL);
}
else
Expand Down
13 changes: 7 additions & 6 deletions src/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void Declaration::semantic(Scope *sc)
{
}

char *Declaration::kind()
const char *Declaration::kind()
{
return "declaration";
}
Expand Down Expand Up @@ -167,7 +167,7 @@ Dsymbol *TupleDeclaration::syntaxCopy(Dsymbol *s)
return NULL;
}

char *TupleDeclaration::kind()
const char *TupleDeclaration::kind()
{
return "tuple";
}
Expand Down Expand Up @@ -301,6 +301,7 @@ void TypedefDeclaration::semantic(Scope *sc)
type = type->semantic(loc, sc);
if (sc->parent->isFuncDeclaration() && init)
semantic2(sc);
storage_class |= sc->stc & STCdeprecated;
}
else if (sem == 1)
{
Expand All @@ -327,7 +328,7 @@ void TypedefDeclaration::semantic2(Scope *sc)
}
}

char *TypedefDeclaration::kind()
const char *TypedefDeclaration::kind()
{
return "typedef";
}
Expand Down Expand Up @@ -531,7 +532,7 @@ int AliasDeclaration::overloadInsert(Dsymbol *s)
}
}

char *AliasDeclaration::kind()
const char *AliasDeclaration::kind()
{
return "alias";
}
Expand Down Expand Up @@ -1096,7 +1097,7 @@ void VarDeclaration::semantic2(Scope *sc)
}
}

char *VarDeclaration::kind()
const char *VarDeclaration::kind()
{
return "variable";
}
Expand Down Expand Up @@ -1217,7 +1218,7 @@ ExpInitializer *VarDeclaration::getExpInitializer()
ei = init->isExpInitializer();
else
{
Expression *e = type->defaultInit();
Expression *e = type->defaultInit(loc);
if (e)
ei = new ExpInitializer(loc, e);
else
Expand Down
Loading

0 comments on commit b35589b

Please sign in to comment.