Skip to content

Commit

Permalink
dmd 2.027
Browse files Browse the repository at this point in the history
  • Loading branch information
braddr committed Jul 3, 2009
1 parent 00337ef commit f77efd1
Show file tree
Hide file tree
Showing 78 changed files with 2,418 additions and 694 deletions.
18 changes: 10 additions & 8 deletions src/aggregate.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ struct AggregateDeclaration : ScopeDsymbol
NewDeclaration *aggNew; // allocator
DeleteDeclaration *aggDelete; // deallocator

#if V2
CtorDeclaration *ctor;
#if DMDV2
//CtorDeclaration *ctor;
Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration
CtorDeclaration *defaultCtor; // default constructor
Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
#endif

FuncDeclarations dtors; // Array of destructors
Expand Down Expand Up @@ -116,7 +118,7 @@ struct AnonymousAggregateDeclaration : AggregateDeclaration
struct StructDeclaration : AggregateDeclaration
{
int zeroInit; // !=0 if initialize with 0 fill
#if V2
#if DMDV2
int hasIdentityAssign; // !=0 if has identity opAssign
FuncDeclaration *cpctor; // generated copy-constructor, if any

Expand Down Expand Up @@ -175,7 +177,7 @@ struct BaseClass
void copyBaseInterfaces(BaseClasses *);
};

#if V2
#if DMDV2
#define CLASSINFO_SIZE (0x3C+16) // value of ClassInfo.size
#else
#define CLASSINFO_SIZE (0x3C+12) // value of ClassInfo.size
Expand Down Expand Up @@ -220,14 +222,14 @@ struct ClassDeclaration : AggregateDeclaration
virtual int isBaseOf(ClassDeclaration *cd, int *poffset);

Dsymbol *search(Loc, Identifier *ident, int flags);
#if V2
#if DMDV2
int isFuncHidden(FuncDeclaration *fd);
#endif
FuncDeclaration *findFunc(Identifier *ident, TypeFunction *tf);
void interfaceSemantic(Scope *sc);
int isCOMclass();
virtual int isCOMinterface();
#if V2
#if DMDV2
virtual int isCPPinterface();
#endif
int isAbstract();
Expand Down Expand Up @@ -256,7 +258,7 @@ struct ClassDeclaration : AggregateDeclaration

struct InterfaceDeclaration : ClassDeclaration
{
#if V2
#if DMDV2
int cpp; // !=0 if this is a C++ interface
#endif
InterfaceDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses);
Expand All @@ -266,7 +268,7 @@ struct InterfaceDeclaration : ClassDeclaration
int isBaseOf(BaseClass *bc, int *poffset);
const char *kind();
int vtblOffset();
#if V2
#if DMDV2
int isCPPinterface();
#endif
virtual int isCOMinterface();
Expand Down
72 changes: 72 additions & 0 deletions src/aliasthis.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

// Compiler implementation of the D programming language
// Copyright (c) 2009-2009 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
// License for redistribution is by either the Artistic License
// in artistic.txt, or the GNU General Public License in gnu.txt.
// See the included readme.txt for details.

#include <stdio.h>
#include <assert.h>

#include "mars.h"
#include "identifier.h"
#include "aliasthis.h"
#include "scope.h"
#include "aggregate.h"
#include "dsymbol.h"

#if DMDV2


AliasThis::AliasThis(Loc loc, Identifier *ident)
: Dsymbol(NULL) // it's anonymous (no identifier)
{
this->loc = loc;
this->ident = ident;
}

Dsymbol *AliasThis::syntaxCopy(Dsymbol *s)
{
assert(!s);
/* Since there is no semantic information stored here,
* we don't need to copy it.
*/
return this;
}

void AliasThis::semantic(Scope *sc)
{
Dsymbol *parent = sc->parent;
if (parent)
parent = parent->pastMixin();
AggregateDeclaration *ad = NULL;
if (parent)
ad = parent->isAggregateDeclaration();
if (ad)
{
if (ad->aliasthis)
error("there can be only one alias this");
assert(ad->members);
Dsymbol *s = ad->search(loc, ident, 0);
ad->aliasthis = s;
}
else
error("alias this can only appear in struct or class declaration, not %s", parent ? parent->toChars() : "nowhere");
}

const char *AliasThis::kind()
{
return "alias this";
}

void AliasThis::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{
buf->writestring("alias ");
buf->writestring(ident->toChars());
buf->writestring(" this;\n");
}

#endif
41 changes: 41 additions & 0 deletions src/aliasthis.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

// Compiler implementation of the D programming language
// Copyright (c) 2009-2009 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
// License for redistribution is by either the Artistic License
// in artistic.txt, or the GNU General Public License in gnu.txt.
// See the included readme.txt for details.

#ifndef DMD_ALIASTHIS_H
#define DMD_ALIASTHIS_H

#ifdef __DMC__
#pragma once
#endif /* __DMC__ */

#include "mars.h"
#include "dsymbol.h"

/**************************************************************/

#if DMDV2

struct AliasThis : Dsymbol
{
// alias Identifier this;
Identifier *ident;

AliasThis(Loc loc, Identifier *ident);

Dsymbol *syntaxCopy(Dsymbol *);
void semantic(Scope *sc);
const char *kind();
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
AliasThis *isAliasThis() { return this; }
};

#endif

#endif
4 changes: 2 additions & 2 deletions src/arrayop.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Expression *BinExp::arrayOp(Scope *sc)

/* Append deco of array element type
*/
#if V2
#if DMDV2
buf.writestring(type->toBasetype()->nextOf()->toBasetype()->mutableOf()->deco);
#else
buf.writestring(type->toBasetype()->nextOf()->toBasetype()->deco);
Expand Down Expand Up @@ -254,7 +254,7 @@ Expression *BinExp::arrayOp(Scope *sc)
Arguments *fparams = new Arguments();
Expression *loopbody = buildArrayLoop(fparams);
Argument *p = (Argument *)fparams->data[0 /*fparams->dim - 1*/];
#if V1
#if DMDV1
// for (size_t i = 0; i < p.length; i++)
Initializer *init = new ExpInitializer(0, new IntegerExp(0, 0, Type::tsize_t));
Dsymbol *d = new VarDeclaration(0, Type::tsize_t, Id::p, init);
Expand Down
19 changes: 13 additions & 6 deletions src/attrib.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Compiler implementation of the D programming language
// Copyright (c) 1999-2008 by Digital Mars
// Copyright (c) 1999-2009 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
Expand Down Expand Up @@ -311,7 +311,7 @@ void StorageClassDeclaration::semantic(Scope *sc)
sc->stc = stc;
}

void StorageClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
void StorageClassDeclaration::stcToCBuffer(OutBuffer *buf, int stc)
{
struct SCstring
{
Expand All @@ -337,20 +337,25 @@ void StorageClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{ STCpure, TOKpure },
{ STCref, TOKref },
{ STCtls, TOKtls },
{ STClazy, TOKlazy },
{ STCalias, TOKalias },
{ STCout, TOKout },
{ STCin, TOKin },
};

int written = 0;
for (int i = 0; i < sizeof(table)/sizeof(table[0]); i++)
{
if (stc & table[i].stc)
{
if (written)
buf->writeByte(' ');
written = 1;
buf->writestring(Token::toChars(table[i].tok));
buf->writeByte(' ');
}
}
}

void StorageClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
{
stcToCBuffer(buf, stc);
AttribDeclaration::toCBuffer(buf, hgs);
}

Expand Down Expand Up @@ -919,6 +924,7 @@ void PragmaDeclaration::toObjFile(int multiobj)
error("pragma lib not supported");
#endif
}
#if DMDV2
else if (ident == Id::startaddress)
{
assert(args && args->dim == 1);
Expand All @@ -929,6 +935,7 @@ void PragmaDeclaration::toObjFile(int multiobj)
Symbol *s = f->toSymbol();
obj_startaddress(s);
}
#endif
AttribDeclaration::toObjFile(multiobj);
}

Expand Down
2 changes: 2 additions & 0 deletions src/attrib.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ struct StorageClassDeclaration: AttribDeclaration
Dsymbol *syntaxCopy(Dsymbol *s);
void semantic(Scope *sc);
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);

static void stcToCBuffer(OutBuffer *buf, int stc);
};

struct LinkDeclaration : AttribDeclaration
Expand Down
2 changes: 1 addition & 1 deletion src/backend/blockopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,6 @@ STATIC void block_check()

STATIC void brtailrecursion()
{ block *b;
block *bn;
block *bs;
list_t bl;
elem **pe;
Expand Down Expand Up @@ -1888,6 +1887,7 @@ STATIC void brtailrecursion()
if (b->BC == BC_try)
return;
pe = &b->Belem;
block *bn = NULL;
if (*pe &&
(b->BC == BCret ||
b->BC == BCretexp ||
Expand Down
12 changes: 8 additions & 4 deletions src/backend/cgcod.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void stackoffsets(int flags)
targ_size_t Amax,sz;
int offi;
targ_size_t offstack[20];
vec_t tbl;
vec_t tbl = NULL;


//printf("stackoffsets()\n");
Expand Down Expand Up @@ -752,7 +752,7 @@ STATIC void blcodgen(block *bl)
list_t bpl;
int refparamsave;
regm_t mfuncregsave = mfuncreg;
char *sflsave;
char *sflsave = NULL;
int anyspill;

//dbg_printf("blcodgen(%p)\n",bl);
Expand Down Expand Up @@ -2086,6 +2086,7 @@ void cssave(elem *e,regm_t regm,unsigned opsflag)
/*if (e->Ecount && e->Ecount == e->Ecomsub)*/
if (e->Ecount && e->Ecomsub)
{
//printf("cssave(e = %p, regm = x%x, opsflag = %d)\n", e, regm, opsflag);
if (!opsflag && pass != PASSfinal && I32)
return;

Expand Down Expand Up @@ -2373,7 +2374,7 @@ if (regcon.cse.mval & 1) elem_print(regcon.cse.value[i]);
if (!regm)
regm = mLSW;
c = cat(c,allocreg(&regm,&lsreg,TYint));
c = cat(c,loadcse(e,lsreg,mLSW));
c = cat(c,loadcse(e,lsreg,mLSW | mBP));
}

regm = mask[msreg] | mask[lsreg]; /* mask of result */
Expand Down Expand Up @@ -2444,7 +2445,9 @@ STATIC code * loadcse(elem *e,unsigned reg,regm_t regm)
code *c;

for (i = cstop; i--;)
{ if (csextab[i].e == e && csextab[i].regm & regm)
{
//printf("csextab[%d] = %p, regm = x%x\n", i, csextab[i].e, csextab[i].regm);
if (csextab[i].e == e && csextab[i].regm & regm)
{
reflocal = TRUE;
csextab[i].flags |= CSEload; /* it was loaded */
Expand All @@ -2461,6 +2464,7 @@ STATIC code * loadcse(elem *e,unsigned reg,regm_t regm)
}
#if DEBUG
printf("loadcse(e = x%p, reg = %d, regm = x%x)\n",e,reg,regm);
elem_print(e);
#endif
assert(0);
/* NOTREACHED */
Expand Down
Loading

0 comments on commit f77efd1

Please sign in to comment.