Skip to content

Commit

Permalink
dmd 2.014
Browse files Browse the repository at this point in the history
  • Loading branch information
braddr committed Jul 3, 2009
1 parent d550a1a commit 8dcd67a
Show file tree
Hide file tree
Showing 32 changed files with 1,272 additions and 263 deletions.
8 changes: 5 additions & 3 deletions src/aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,13 @@ struct AnonymousAggregateDeclaration : AggregateDeclaration
struct StructDeclaration : AggregateDeclaration
{
int zeroInit; // !=0 if initialize with 0 fill
#if V2
int hasIdentityAssign; // !=0 if has identity opAssign
FuncDeclaration *cpctor; // generated copy-constructor, if any

FuncDeclarations postblits; // Array of postblit functions
FuncDeclaration *postblit; // aggregate postblit
#endif

StructDeclaration(Loc loc, Identifier *id);
Dsymbol *syntaxCopy(Dsymbol *s);
Expand All @@ -127,7 +129,7 @@ struct StructDeclaration : AggregateDeclaration

PROT getAccess(Dsymbol *smember); // determine access to smember

void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
void toDt(dt_t **pdt);
void toDebug(); // to symbolic debug info

Expand Down Expand Up @@ -236,7 +238,7 @@ struct ClassDeclaration : AggregateDeclaration
void addLocalClass(ClassDeclarations *);

// Back end
void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
void toDebug();
unsigned baseVtblOffset(BaseClass *bc);
Symbol *toSymbol();
Expand Down Expand Up @@ -266,7 +268,7 @@ struct InterfaceDeclaration : ClassDeclaration
#endif
virtual int isCOMinterface();

void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
Symbol *toSymbol();

InterfaceDeclaration *isInterfaceDeclaration() { return this; }
Expand Down
8 changes: 4 additions & 4 deletions src/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void AttribDeclaration::emitComment(Scope *sc)
}
}

void AttribDeclaration::toObjFile()
void AttribDeclaration::toObjFile(int multiobj)
{
unsigned i;
Array *d = include(NULL, NULL);
Expand All @@ -187,7 +187,7 @@ void AttribDeclaration::toObjFile()
{ Dsymbol *s;

s = (Dsymbol *)d->data[i];
s->toObjFile();
s->toObjFile(multiobj);
}
}
}
Expand Down Expand Up @@ -917,7 +917,7 @@ char *PragmaDeclaration::kind()
return "pragma";
}

void PragmaDeclaration::toObjFile()
void PragmaDeclaration::toObjFile(int multiobj)
{
if (ident == Id::lib)
{
Expand All @@ -943,7 +943,7 @@ void PragmaDeclaration::toObjFile()
Symbol *s = f->toSymbol();
obj_startaddress(s);
}
AttribDeclaration::toObjFile();
AttribDeclaration::toObjFile(multiobj);
}

void PragmaDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
Expand Down
4 changes: 2 additions & 2 deletions src/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct AttribDeclaration : Dsymbol
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
AttribDeclaration *isAttribDeclaration() { return this; }

void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
int cvMember(unsigned char *p);
};

Expand Down Expand Up @@ -119,7 +119,7 @@ struct PragmaDeclaration : AttribDeclaration
int oneMember(Dsymbol **ps);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
char *kind();
void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
};

struct ConditionalDeclaration : AttribDeclaration
Expand Down
63 changes: 42 additions & 21 deletions src/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1514,31 +1514,52 @@ Expression *BinExp::typeCombine(Scope *sc)
goto Lagain;
}
else if (t1->ty == Tclass || t2->ty == Tclass)
{ int i1;
int i2;
{
while (1)
{
int i1 = e2->implicitConvTo(t1);
int i2 = e1->implicitConvTo(t2);

i1 = e2->implicitConvTo(t1);
i2 = e1->implicitConvTo(t2);
if (i1 && i2)
{
// We have the case of class vs. void*, so pick class
if (t1->ty == Tpointer)
i1 = 0;
else if (t2->ty == Tpointer)
i2 = 0;
}

if (i1 && i2)
{
// We have the case of class vs. void*, so pick class
if (t1->ty == Tpointer)
i1 = 0;
else if (t2->ty == Tpointer)
i2 = 0;
}
if (i2)
{
goto Lt2;
}
else if (i1)
{
goto Lt1;
}
else if (t1->ty == Tclass && t2->ty == Tclass)
{ TypeClass *tc1 = (TypeClass *)t1;
TypeClass *tc2 = (TypeClass *)t2;

if (i2)
{
goto Lt2;
}
else if (i1)
{
goto Lt1;
/* Pick 'tightest' type
*/
ClassDeclaration *cd1 = tc1->sym->baseClass;
ClassDeclaration *cd2 = tc1->sym->baseClass;

if (cd1 && cd2)
{ t1 = cd1->type;
t2 = cd2->type;
}
else if (cd1)
t1 = cd1->type;
else if (cd2)
t2 = cd2->type;
else
goto Lincompatible;
}
else
goto Lincompatible;
}
else
goto Lincompatible;
}
else if (t1->ty == Tstruct && t2->ty == Tstruct)
{
Expand Down
16 changes: 8 additions & 8 deletions src/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,10 +947,6 @@ void VarDeclaration::semantic(Scope *sc)
if (fd && !isStatic() && !(storage_class & STCmanifest) &&
!init->isVoidInitializer())
{
Expression *e1;
Type *t;
int dim;

//printf("fd = '%s', var = '%s'\n", fd->toChars(), toChars());
if (!ei)
{
Expand All @@ -968,15 +964,15 @@ void VarDeclaration::semantic(Scope *sc)
init = ei;
}

e1 = new VarExp(loc, this);
Expression *e1 = new VarExp(loc, this);

t = type->toBasetype();
Type *t = type->toBasetype();
if (t->ty == Tsarray)
{
ei->exp = ei->exp->semantic(sc);
if (!ei->exp->implicitConvTo(type))
{
dim = ((TypeSArray *)t)->dim->toInteger();
int dim = ((TypeSArray *)t)->dim->toInteger();
// If multidimensional static array, treat as one large array
while (1)
{
Expand All @@ -993,7 +989,11 @@ void VarDeclaration::semantic(Scope *sc)
{
ei->exp = ei->exp->semantic(sc);
if (!ei->exp->implicitConvTo(type))
ei->exp = new CastExp(loc, ei->exp, type);
{ Type *ti = ei->exp->type->toBasetype();
// Don't cast away invariant or mutability in initializer
if (!(ti->ty == Tstruct && t->toDsymbol(sc) == ti->toDsymbol(sc)))
ei->exp = new CastExp(loc, ei->exp, type);
}
}
ei->exp = new AssignExp(loc, e1, ei->exp);
ei->exp->op = op;
Expand Down
8 changes: 4 additions & 4 deletions src/declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct TypedefDeclaration : Declaration

void toDocBuffer(OutBuffer *buf);

void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
void toDebug();
int cvMember(unsigned char *p);

Expand Down Expand Up @@ -257,7 +257,7 @@ struct VarDeclaration : Declaration
Dsymbol *toAlias();

Symbol *toSymbol();
void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
int cvMember(unsigned char *p);

// Eliminate need for dynamic_cast
Expand Down Expand Up @@ -319,7 +319,7 @@ struct TypeInfoDeclaration : VarDeclaration
void emitComment(Scope *sc);

Symbol *toSymbol();
void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
virtual void toDt(dt_t **pdt);
};

Expand Down Expand Up @@ -568,7 +568,7 @@ struct FuncDeclaration : Declaration

Symbol *toSymbol();
Symbol *toThunkSymbol(int offset); // thunk version
void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
int cvMember(unsigned char *p);
void buildClosure(IRState *irs);

Expand Down
2 changes: 1 addition & 1 deletion src/dsymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ struct Dsymbol : Object
// Backend

virtual Symbol *toSymbol(); // to backend symbol
virtual void toObjFile(); // compile to .obj file
virtual void toObjFile(int multiobj); // compile to .obj file
virtual int cvMember(unsigned char *p); // emit cv debug info for member

Symbol *toImport(); // to backend import symbol
Expand Down
5 changes: 1 addition & 4 deletions src/e2ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ elem *Dsymbol_toElem(Dsymbol *s, IRState *irs)
if (s != vd)
return Dsymbol_toElem(s, irs);
if (vd->isStatic() || vd->storage_class & STCextern)
vd->toObjFile();
vd->toObjFile(0);
else
{
sp = s->toSymbol();
Expand All @@ -1073,18 +1073,15 @@ elem *Dsymbol_toElem(Dsymbol *s, IRState *irs)
else if ((cd = s->isClassDeclaration()) != NULL)
{
irs->deferToObj->push(s);
//sd->toObjFile();
}
else if ((sd = s->isStructDeclaration()) != NULL)
{
irs->deferToObj->push(sd);
//sd->toObjFile();
}
else if ((fd = s->isFuncDeclaration()) != NULL)
{
//printf("function %s\n", fd->toChars());
irs->deferToObj->push(fd);
//fd->toObjFile();
}
else if ((tm = s->isTemplateMixin()) != NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion src/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct EnumDeclaration : ScopeDsymbol

EnumDeclaration *isEnumDeclaration() { return this; }

void toObjFile(); // compile to .obj file
void toObjFile(int multiobj); // compile to .obj file
void toDebug();
int cvMember(unsigned char *p);

Expand Down
Loading

0 comments on commit 8dcd67a

Please sign in to comment.