mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
fixes #426 :: detab'ing the DMDFE source; kudos SiegeLord
This commit is contained in:
302
dmd/access.c
302
dmd/access.c
@@ -49,15 +49,15 @@ enum PROT StructDeclaration::getAccess(Dsymbol *smember)
|
||||
|
||||
#if LOG
|
||||
printf("+StructDeclaration::getAccess(this = '%s', smember = '%s')\n",
|
||||
toChars(), smember->toChars());
|
||||
toChars(), smember->toChars());
|
||||
#endif
|
||||
if (smember->toParent() == this)
|
||||
{
|
||||
access_ret = smember->prot();
|
||||
access_ret = smember->prot();
|
||||
}
|
||||
else if (smember->isDeclaration()->isStatic())
|
||||
{
|
||||
access_ret = smember->prot();
|
||||
access_ret = smember->prot();
|
||||
}
|
||||
return access_ret;
|
||||
}
|
||||
@@ -68,56 +68,56 @@ enum PROT ClassDeclaration::getAccess(Dsymbol *smember)
|
||||
|
||||
#if LOG
|
||||
printf("+ClassDeclaration::getAccess(this = '%s', smember = '%s')\n",
|
||||
toChars(), smember->toChars());
|
||||
toChars(), smember->toChars());
|
||||
#endif
|
||||
if (smember->toParent() == this)
|
||||
{
|
||||
access_ret = smember->prot();
|
||||
access_ret = smember->prot();
|
||||
}
|
||||
else
|
||||
{
|
||||
enum PROT access;
|
||||
int i;
|
||||
enum PROT access;
|
||||
int i;
|
||||
|
||||
if (smember->isDeclaration()->isStatic())
|
||||
{
|
||||
access_ret = smember->prot();
|
||||
}
|
||||
if (smember->isDeclaration()->isStatic())
|
||||
{
|
||||
access_ret = smember->prot();
|
||||
}
|
||||
|
||||
for (i = 0; i < baseclasses.dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)baseclasses.data[i];
|
||||
for (i = 0; i < baseclasses.dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)baseclasses.data[i];
|
||||
|
||||
access = b->base->getAccess(smember);
|
||||
switch (access)
|
||||
{
|
||||
case PROTnone:
|
||||
break;
|
||||
access = b->base->getAccess(smember);
|
||||
switch (access)
|
||||
{
|
||||
case PROTnone:
|
||||
break;
|
||||
|
||||
case PROTprivate:
|
||||
access = PROTnone; // private members of base class not accessible
|
||||
break;
|
||||
case PROTprivate:
|
||||
access = PROTnone; // private members of base class not accessible
|
||||
break;
|
||||
|
||||
case PROTpackage:
|
||||
case PROTprotected:
|
||||
case PROTpublic:
|
||||
case PROTexport:
|
||||
// If access is to be tightened
|
||||
if (b->protection < access)
|
||||
access = b->protection;
|
||||
case PROTpackage:
|
||||
case PROTprotected:
|
||||
case PROTpublic:
|
||||
case PROTexport:
|
||||
// If access is to be tightened
|
||||
if (b->protection < access)
|
||||
access = b->protection;
|
||||
|
||||
// Pick path with loosest access
|
||||
if (access > access_ret)
|
||||
access_ret = access;
|
||||
break;
|
||||
// Pick path with loosest access
|
||||
if (access > access_ret)
|
||||
access_ret = access;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#if LOG
|
||||
printf("-ClassDeclaration::getAccess(this = '%s', smember = '%s') = %d\n",
|
||||
toChars(), smember->toChars(), access_ret);
|
||||
toChars(), smember->toChars(), access_ret);
|
||||
#endif
|
||||
return access_ret;
|
||||
}
|
||||
@@ -125,63 +125,63 @@ enum PROT ClassDeclaration::getAccess(Dsymbol *smember)
|
||||
/********************************************************
|
||||
* Helper function for ClassDeclaration::accessCheck()
|
||||
* Returns:
|
||||
* 0 no access
|
||||
* 1 access
|
||||
* 0 no access
|
||||
* 1 access
|
||||
*/
|
||||
|
||||
static int accessCheckX(
|
||||
Dsymbol *smember,
|
||||
Dsymbol *sfunc,
|
||||
AggregateDeclaration *dthis,
|
||||
AggregateDeclaration *cdscope)
|
||||
Dsymbol *smember,
|
||||
Dsymbol *sfunc,
|
||||
AggregateDeclaration *dthis,
|
||||
AggregateDeclaration *cdscope)
|
||||
{
|
||||
assert(dthis);
|
||||
|
||||
#if 0
|
||||
printf("accessCheckX for %s.%s in function %s() in scope %s\n",
|
||||
dthis->toChars(), smember->toChars(),
|
||||
sfunc ? sfunc->toChars() : "NULL",
|
||||
cdscope ? cdscope->toChars() : "NULL");
|
||||
dthis->toChars(), smember->toChars(),
|
||||
sfunc ? sfunc->toChars() : "NULL",
|
||||
cdscope ? cdscope->toChars() : "NULL");
|
||||
#endif
|
||||
if (dthis->hasPrivateAccess(sfunc) ||
|
||||
dthis->isFriendOf(cdscope))
|
||||
dthis->isFriendOf(cdscope))
|
||||
{
|
||||
if (smember->toParent() == dthis)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
ClassDeclaration *cdthis = dthis->isClassDeclaration();
|
||||
if (cdthis)
|
||||
{
|
||||
for (int i = 0; i < cdthis->baseclasses.dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)cdthis->baseclasses.data[i];
|
||||
enum PROT access;
|
||||
if (smember->toParent() == dthis)
|
||||
return 1;
|
||||
else
|
||||
{
|
||||
ClassDeclaration *cdthis = dthis->isClassDeclaration();
|
||||
if (cdthis)
|
||||
{
|
||||
for (int i = 0; i < cdthis->baseclasses.dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)cdthis->baseclasses.data[i];
|
||||
enum PROT access;
|
||||
|
||||
access = b->base->getAccess(smember);
|
||||
if (access >= PROTprotected ||
|
||||
accessCheckX(smember, sfunc, b->base, cdscope)
|
||||
)
|
||||
return 1;
|
||||
access = b->base->getAccess(smember);
|
||||
if (access >= PROTprotected ||
|
||||
accessCheckX(smember, sfunc, b->base, cdscope)
|
||||
)
|
||||
return 1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (smember->toParent() != dthis)
|
||||
{
|
||||
ClassDeclaration *cdthis = dthis->isClassDeclaration();
|
||||
if (cdthis)
|
||||
{
|
||||
for (int i = 0; i < cdthis->baseclasses.dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)cdthis->baseclasses.data[i];
|
||||
if (smember->toParent() != dthis)
|
||||
{
|
||||
ClassDeclaration *cdthis = dthis->isClassDeclaration();
|
||||
if (cdthis)
|
||||
{
|
||||
for (int i = 0; i < cdthis->baseclasses.dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)cdthis->baseclasses.data[i];
|
||||
|
||||
if (accessCheckX(smember, sfunc, b->base, cdscope))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (accessCheckX(smember, sfunc, b->base, cdscope))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -201,58 +201,58 @@ void AggregateDeclaration::accessCheck(Loc loc, Scope *sc, Dsymbol *smember)
|
||||
|
||||
#if LOG
|
||||
printf("AggregateDeclaration::accessCheck() for %s.%s in function %s() in scope %s\n",
|
||||
toChars(), smember->toChars(),
|
||||
f ? f->toChars() : NULL,
|
||||
cdscope ? cdscope->toChars() : NULL);
|
||||
toChars(), smember->toChars(),
|
||||
f ? f->toChars() : NULL,
|
||||
cdscope ? cdscope->toChars() : NULL);
|
||||
#endif
|
||||
|
||||
Dsymbol *smemberparent = smember->toParent();
|
||||
if (!smemberparent || !smemberparent->isAggregateDeclaration())
|
||||
{
|
||||
#if LOG
|
||||
printf("not an aggregate member\n");
|
||||
printf("not an aggregate member\n");
|
||||
#endif
|
||||
return; // then it is accessible
|
||||
return; // then it is accessible
|
||||
}
|
||||
|
||||
// BUG: should enable this check
|
||||
//assert(smember->parent->isBaseOf(this, NULL));
|
||||
|
||||
if (smemberparent == this)
|
||||
{ enum PROT access = smember->prot();
|
||||
{ enum PROT access = smember->prot();
|
||||
|
||||
result = access >= PROTpublic ||
|
||||
hasPrivateAccess(f) ||
|
||||
isFriendOf(cdscope) ||
|
||||
(access == PROTpackage && hasPackageAccess(sc, this));
|
||||
result = access >= PROTpublic ||
|
||||
hasPrivateAccess(f) ||
|
||||
isFriendOf(cdscope) ||
|
||||
(access == PROTpackage && hasPackageAccess(sc, this));
|
||||
#if LOG
|
||||
printf("result1 = %d\n", result);
|
||||
printf("result1 = %d\n", result);
|
||||
#endif
|
||||
}
|
||||
else if ((access = this->getAccess(smember)) >= PROTpublic)
|
||||
{
|
||||
result = 1;
|
||||
result = 1;
|
||||
#if LOG
|
||||
printf("result2 = %d\n", result);
|
||||
printf("result2 = %d\n", result);
|
||||
#endif
|
||||
}
|
||||
else if (access == PROTpackage && hasPackageAccess(sc, this))
|
||||
{
|
||||
result = 1;
|
||||
result = 1;
|
||||
#if LOG
|
||||
printf("result3 = %d\n", result);
|
||||
printf("result3 = %d\n", result);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
result = accessCheckX(smember, f, this, cdscope);
|
||||
result = accessCheckX(smember, f, this, cdscope);
|
||||
#if LOG
|
||||
printf("result4 = %d\n", result);
|
||||
printf("result4 = %d\n", result);
|
||||
#endif
|
||||
}
|
||||
if (!result)
|
||||
{
|
||||
error(loc, "member %s is not accessible", smember->toChars());
|
||||
error(loc, "member %s is not accessible", smember->toChars());
|
||||
halt();
|
||||
}
|
||||
}
|
||||
@@ -267,16 +267,16 @@ int AggregateDeclaration::isFriendOf(AggregateDeclaration *cd)
|
||||
printf("AggregateDeclaration::isFriendOf(this = '%s', cd = '%s')\n", toChars(), cd ? cd->toChars() : "null");
|
||||
#endif
|
||||
if (this == cd)
|
||||
return 1;
|
||||
return 1;
|
||||
|
||||
// Friends if both are in the same module
|
||||
//if (toParent() == cd->toParent())
|
||||
if (cd && getModule() == cd->getModule())
|
||||
{
|
||||
#if LOG
|
||||
printf("\tin same module\n");
|
||||
printf("\tin same module\n");
|
||||
#endif
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if LOG
|
||||
@@ -297,20 +297,20 @@ int hasPackageAccess(Scope *sc, Dsymbol *s)
|
||||
|
||||
for (; s; s = s->parent)
|
||||
{
|
||||
if (s->isPackage() && !s->isModule())
|
||||
break;
|
||||
if (s->isPackage() && !s->isModule())
|
||||
break;
|
||||
}
|
||||
#if LOG
|
||||
if (s)
|
||||
printf("\tthis is in package '%s'\n", s->toChars());
|
||||
printf("\tthis is in package '%s'\n", s->toChars());
|
||||
#endif
|
||||
|
||||
if (s && s == sc->module->parent)
|
||||
{
|
||||
#if LOG
|
||||
printf("\ts is in same package as sc\n");
|
||||
printf("\ts is in same package as sc\n");
|
||||
#endif
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -327,46 +327,46 @@ int hasPackageAccess(Scope *sc, Dsymbol *s)
|
||||
int AggregateDeclaration::hasPrivateAccess(Dsymbol *smember)
|
||||
{
|
||||
if (smember)
|
||||
{ AggregateDeclaration *cd = NULL;
|
||||
Dsymbol *smemberparent = smember->toParent();
|
||||
if (smemberparent)
|
||||
cd = smemberparent->isAggregateDeclaration();
|
||||
{ AggregateDeclaration *cd = NULL;
|
||||
Dsymbol *smemberparent = smember->toParent();
|
||||
if (smemberparent)
|
||||
cd = smemberparent->isAggregateDeclaration();
|
||||
|
||||
#if LOG
|
||||
printf("AggregateDeclaration::hasPrivateAccess(class %s, member %s)\n",
|
||||
toChars(), smember->toChars());
|
||||
printf("AggregateDeclaration::hasPrivateAccess(class %s, member %s)\n",
|
||||
toChars(), smember->toChars());
|
||||
#endif
|
||||
|
||||
if (this == cd) // smember is a member of this class
|
||||
{
|
||||
if (this == cd) // smember is a member of this class
|
||||
{
|
||||
#if LOG
|
||||
printf("\tyes 1\n");
|
||||
printf("\tyes 1\n");
|
||||
#endif
|
||||
return 1; // so we get private access
|
||||
}
|
||||
return 1; // so we get private access
|
||||
}
|
||||
|
||||
// If both are members of the same module, grant access
|
||||
while (1)
|
||||
{ Dsymbol *sp = smember->toParent();
|
||||
if (sp->isFuncDeclaration() && smember->isFuncDeclaration())
|
||||
smember = sp;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!cd && toParent() == smember->toParent())
|
||||
{
|
||||
// If both are members of the same module, grant access
|
||||
while (1)
|
||||
{ Dsymbol *sp = smember->toParent();
|
||||
if (sp->isFuncDeclaration() && smember->isFuncDeclaration())
|
||||
smember = sp;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!cd && toParent() == smember->toParent())
|
||||
{
|
||||
#if LOG
|
||||
printf("\tyes 2\n");
|
||||
printf("\tyes 2\n");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
if (!cd && getModule() == smember->getModule())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!cd && getModule() == smember->getModule())
|
||||
{
|
||||
#if LOG
|
||||
printf("\tyes 3\n");
|
||||
printf("\tyes 3\n");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#if LOG
|
||||
printf("\tno\n");
|
||||
@@ -382,43 +382,43 @@ void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d)
|
||||
{
|
||||
#if LOG
|
||||
if (e)
|
||||
{ printf("accessCheck(%s . %s)\n", e->toChars(), d->toChars());
|
||||
printf("\te->type = %s\n", e->type->toChars());
|
||||
{ printf("accessCheck(%s . %s)\n", e->toChars(), d->toChars());
|
||||
printf("\te->type = %s\n", e->type->toChars());
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("accessCheck(%s)\n", d->toChars());
|
||||
//printf("accessCheck(%s)\n", d->toChars());
|
||||
}
|
||||
#endif
|
||||
if (!e)
|
||||
{
|
||||
if (d->prot() == PROTprivate && d->getModule() != sc->module ||
|
||||
d->prot() == PROTpackage && !hasPackageAccess(sc, d))
|
||||
if (d->prot() == PROTprivate && d->getModule() != sc->module ||
|
||||
d->prot() == PROTpackage && !hasPackageAccess(sc, d))
|
||||
|
||||
error(loc, "%s %s.%s is not accessible from %s",
|
||||
d->kind(), d->getModule()->toChars(), d->toChars(), sc->module->toChars());
|
||||
error(loc, "%s %s.%s is not accessible from %s",
|
||||
d->kind(), d->getModule()->toChars(), d->toChars(), sc->module->toChars());
|
||||
}
|
||||
else if (e->type->ty == Tclass)
|
||||
{ // Do access check
|
||||
ClassDeclaration *cd;
|
||||
ClassDeclaration *cd;
|
||||
|
||||
cd = (ClassDeclaration *)(((TypeClass *)e->type)->sym);
|
||||
cd = (ClassDeclaration *)(((TypeClass *)e->type)->sym);
|
||||
#if 1
|
||||
if (e->op == TOKsuper)
|
||||
{ ClassDeclaration *cd2;
|
||||
if (e->op == TOKsuper)
|
||||
{ ClassDeclaration *cd2;
|
||||
|
||||
cd2 = sc->func->toParent()->isClassDeclaration();
|
||||
if (cd2)
|
||||
cd = cd2;
|
||||
}
|
||||
cd2 = sc->func->toParent()->isClassDeclaration();
|
||||
if (cd2)
|
||||
cd = cd2;
|
||||
}
|
||||
#endif
|
||||
cd->accessCheck(loc, sc, d);
|
||||
cd->accessCheck(loc, sc, d);
|
||||
}
|
||||
else if (e->type->ty == Tstruct)
|
||||
{ // Do access check
|
||||
StructDeclaration *cd;
|
||||
StructDeclaration *cd;
|
||||
|
||||
cd = (StructDeclaration *)(((TypeStruct *)e->type)->sym);
|
||||
cd->accessCheck(loc, sc, d);
|
||||
cd = (StructDeclaration *)(((TypeStruct *)e->type)->sym);
|
||||
cd->accessCheck(loc, sc, d);
|
||||
}
|
||||
}
|
||||
|
||||
130
dmd/aggregate.h
130
dmd/aggregate.h
@@ -56,36 +56,36 @@ struct AggregateDeclaration : ScopeDsymbol
|
||||
Type *type;
|
||||
StorageClass storage_class;
|
||||
enum PROT protection;
|
||||
Type *handle; // 'this' type
|
||||
unsigned structsize; // size of struct
|
||||
unsigned alignsize; // size of struct for alignment purposes
|
||||
unsigned structalign; // struct member alignment in effect
|
||||
int hasUnions; // set if aggregate has overlapping fields
|
||||
Array fields; // VarDeclaration fields
|
||||
unsigned sizeok; // set when structsize contains valid data
|
||||
// 0: no size
|
||||
// 1: size is correct
|
||||
// 2: cannot determine size; fwd referenced
|
||||
int isdeprecated; // !=0 if deprecated
|
||||
Type *handle; // 'this' type
|
||||
unsigned structsize; // size of struct
|
||||
unsigned alignsize; // size of struct for alignment purposes
|
||||
unsigned structalign; // struct member alignment in effect
|
||||
int hasUnions; // set if aggregate has overlapping fields
|
||||
Array fields; // VarDeclaration fields
|
||||
unsigned sizeok; // set when structsize contains valid data
|
||||
// 0: no size
|
||||
// 1: size is correct
|
||||
// 2: cannot determine size; fwd referenced
|
||||
int isdeprecated; // !=0 if deprecated
|
||||
|
||||
#if DMDV2
|
||||
int isnested; // !=0 if is nested
|
||||
VarDeclaration *vthis; // 'this' parameter if this aggregate is nested
|
||||
int isnested; // !=0 if is nested
|
||||
VarDeclaration *vthis; // 'this' parameter if this aggregate is nested
|
||||
#endif
|
||||
// Special member functions
|
||||
InvariantDeclaration *inv; // invariant
|
||||
NewDeclaration *aggNew; // allocator
|
||||
DeleteDeclaration *aggDelete; // deallocator
|
||||
InvariantDeclaration *inv; // invariant
|
||||
NewDeclaration *aggNew; // allocator
|
||||
DeleteDeclaration *aggDelete; // deallocator
|
||||
|
||||
#if DMDV2
|
||||
//CtorDeclaration *ctor;
|
||||
Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration
|
||||
CtorDeclaration *defaultCtor; // default constructor
|
||||
Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
|
||||
Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration
|
||||
CtorDeclaration *defaultCtor; // default constructor
|
||||
Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
|
||||
#endif
|
||||
|
||||
FuncDeclarations dtors; // Array of destructors
|
||||
FuncDeclaration *dtor; // aggregate destructor
|
||||
FuncDeclarations dtors; // Array of destructors
|
||||
FuncDeclaration *dtor; // aggregate destructor
|
||||
|
||||
#ifdef IN_GCC
|
||||
Array methods; // flat list of all methods for debug information
|
||||
@@ -99,7 +99,7 @@ struct AggregateDeclaration : ScopeDsymbol
|
||||
static void alignmember(unsigned salign, unsigned size, unsigned *poffset);
|
||||
Type *getType();
|
||||
void addField(Scope *sc, VarDeclaration *v);
|
||||
int isDeprecated(); // is aggregate deprecated?
|
||||
int isDeprecated(); // is aggregate deprecated?
|
||||
FuncDeclaration *buildDtor(Scope *sc);
|
||||
int isNested();
|
||||
|
||||
@@ -108,16 +108,16 @@ struct AggregateDeclaration : ScopeDsymbol
|
||||
void toDocBuffer(OutBuffer *buf);
|
||||
|
||||
// For access checking
|
||||
virtual PROT getAccess(Dsymbol *smember); // determine access to smember
|
||||
virtual PROT getAccess(Dsymbol *smember); // determine access to smember
|
||||
int isFriendOf(AggregateDeclaration *cd);
|
||||
int hasPrivateAccess(Dsymbol *smember); // does smember have private access to members of this class?
|
||||
int hasPrivateAccess(Dsymbol *smember); // does smember have private access to members of this class?
|
||||
void accessCheck(Loc loc, Scope *sc, Dsymbol *smember);
|
||||
|
||||
enum PROT prot();
|
||||
|
||||
#if IN_DMD
|
||||
// Back end
|
||||
Symbol *stag; // tag symbol for debug data
|
||||
Symbol *stag; // tag symbol for debug data
|
||||
Symbol *sinit;
|
||||
Symbol *toInitializer();
|
||||
#endif
|
||||
@@ -133,7 +133,7 @@ struct AggregateDeclaration : ScopeDsymbol
|
||||
struct AnonymousAggregateDeclaration : AggregateDeclaration
|
||||
{
|
||||
AnonymousAggregateDeclaration()
|
||||
: AggregateDeclaration(0, NULL)
|
||||
: AggregateDeclaration(0, NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -142,13 +142,13 @@ struct AnonymousAggregateDeclaration : AggregateDeclaration
|
||||
|
||||
struct StructDeclaration : AggregateDeclaration
|
||||
{
|
||||
int zeroInit; // !=0 if initialize with 0 fill
|
||||
int zeroInit; // !=0 if initialize with 0 fill
|
||||
#if DMDV2
|
||||
int hasIdentityAssign; // !=0 if has identity opAssign
|
||||
FuncDeclaration *cpctor; // generated copy-constructor, if any
|
||||
int hasIdentityAssign; // !=0 if has identity opAssign
|
||||
FuncDeclaration *cpctor; // generated copy-constructor, if any
|
||||
|
||||
FuncDeclarations postblits; // Array of postblit functions
|
||||
FuncDeclaration *postblit; // aggregate postblit
|
||||
FuncDeclarations postblits; // Array of postblit functions
|
||||
FuncDeclaration *postblit; // aggregate postblit
|
||||
#endif
|
||||
|
||||
StructDeclaration(Loc loc, Identifier *id);
|
||||
@@ -169,12 +169,12 @@ struct StructDeclaration : AggregateDeclaration
|
||||
#endif
|
||||
void toDocBuffer(OutBuffer *buf);
|
||||
|
||||
PROT getAccess(Dsymbol *smember); // determine access to smember
|
||||
PROT getAccess(Dsymbol *smember); // determine access to smember
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toDt(dt_t **pdt);
|
||||
void toDebug(); // to symbolic debug info
|
||||
void toDebug(); // to symbolic debug info
|
||||
#endif
|
||||
|
||||
StructDeclaration *isStructDeclaration() { return this; }
|
||||
@@ -197,17 +197,17 @@ struct UnionDeclaration : StructDeclaration
|
||||
// BaseClass instance.
|
||||
struct BaseClass
|
||||
{
|
||||
Type *type; // (before semantic processing)
|
||||
enum PROT protection; // protection for the base interface
|
||||
Type *type; // (before semantic processing)
|
||||
enum PROT protection; // protection for the base interface
|
||||
|
||||
ClassDeclaration *base;
|
||||
int offset; // 'this' pointer offset
|
||||
Array vtbl; // for interfaces: Array of FuncDeclaration's
|
||||
// making up the vtbl[]
|
||||
int offset; // 'this' pointer offset
|
||||
Array vtbl; // for interfaces: Array of FuncDeclaration's
|
||||
// making up the vtbl[]
|
||||
|
||||
int baseInterfaces_dim;
|
||||
BaseClass *baseInterfaces; // if BaseClass is an interface, these
|
||||
// are a copy of the InterfaceDeclaration::interfaces
|
||||
BaseClass *baseInterfaces; // if BaseClass is an interface, these
|
||||
// are a copy of the InterfaceDeclaration::interfaces
|
||||
|
||||
BaseClass();
|
||||
BaseClass(Type *type, enum PROT protection);
|
||||
@@ -217,9 +217,9 @@ struct BaseClass
|
||||
};
|
||||
|
||||
#if DMDV2
|
||||
#define CLASSINFO_SIZE (0x3C+16+4) // value of ClassInfo.size
|
||||
#define CLASSINFO_SIZE (0x3C+16+4) // value of ClassInfo.size
|
||||
#else
|
||||
#define CLASSINFO_SIZE (0x3C+12+4) // value of ClassInfo.size
|
||||
#define CLASSINFO_SIZE (0x3C+12+4) // value of ClassInfo.size
|
||||
#endif
|
||||
|
||||
struct ClassDeclaration : AggregateDeclaration
|
||||
@@ -227,36 +227,36 @@ struct ClassDeclaration : AggregateDeclaration
|
||||
static ClassDeclaration *object;
|
||||
static ClassDeclaration *classinfo;
|
||||
|
||||
ClassDeclaration *baseClass; // NULL only if this is Object
|
||||
ClassDeclaration *baseClass; // NULL only if this is Object
|
||||
#if DMDV1
|
||||
CtorDeclaration *ctor;
|
||||
CtorDeclaration *defaultCtor; // default constructor
|
||||
CtorDeclaration *defaultCtor; // default constructor
|
||||
#endif
|
||||
FuncDeclaration *staticCtor;
|
||||
FuncDeclaration *staticDtor;
|
||||
Array vtbl; // Array of FuncDeclaration's making up the vtbl[]
|
||||
Array vtblFinal; // More FuncDeclaration's that aren't in vtbl[]
|
||||
Array vtbl; // Array of FuncDeclaration's making up the vtbl[]
|
||||
Array vtblFinal; // More FuncDeclaration's that aren't in vtbl[]
|
||||
|
||||
BaseClasses baseclasses; // Array of BaseClass's; first is super,
|
||||
// rest are Interface's
|
||||
BaseClasses baseclasses; // Array of BaseClass's; first is super,
|
||||
// rest are Interface's
|
||||
|
||||
int interfaces_dim;
|
||||
BaseClass **interfaces; // interfaces[interfaces_dim] for this class
|
||||
// (does not include baseClass)
|
||||
BaseClass **interfaces; // interfaces[interfaces_dim] for this class
|
||||
// (does not include baseClass)
|
||||
|
||||
BaseClasses *vtblInterfaces; // array of base interfaces that have
|
||||
// their own vtbl[]
|
||||
BaseClasses *vtblInterfaces; // array of base interfaces that have
|
||||
// their own vtbl[]
|
||||
|
||||
ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration
|
||||
int com; // !=0 if this is a COM class (meaning
|
||||
// it derives from IUnknown)
|
||||
int isscope; // !=0 if this is a scope class
|
||||
int isabstract; // !=0 if abstract class
|
||||
ClassInfoDeclaration *vclassinfo; // the ClassInfo object for this ClassDeclaration
|
||||
int com; // !=0 if this is a COM class (meaning
|
||||
// it derives from IUnknown)
|
||||
int isscope; // !=0 if this is a scope class
|
||||
int isabstract; // !=0 if abstract class
|
||||
#if DMDV1
|
||||
int isnested; // !=0 if is nested
|
||||
VarDeclaration *vthis; // 'this' parameter if this class is nested
|
||||
int isnested; // !=0 if is nested
|
||||
VarDeclaration *vthis; // 'this' parameter if this class is nested
|
||||
#endif
|
||||
int inuse; // to prevent recursive attempts
|
||||
int inuse; // to prevent recursive attempts
|
||||
|
||||
ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses);
|
||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||
@@ -287,13 +287,13 @@ struct ClassDeclaration : AggregateDeclaration
|
||||
char *mangle();
|
||||
void toDocBuffer(OutBuffer *buf);
|
||||
|
||||
PROT getAccess(Dsymbol *smember); // determine access to smember
|
||||
PROT getAccess(Dsymbol *smember); // determine access to smember
|
||||
|
||||
void addLocalClass(ClassDeclarations *);
|
||||
|
||||
#if IN_DMD
|
||||
// Back end
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toDebug();
|
||||
unsigned baseVtblOffset(BaseClass *bc);
|
||||
Symbol *toSymbol();
|
||||
@@ -314,7 +314,7 @@ struct ClassDeclaration : AggregateDeclaration
|
||||
struct InterfaceDeclaration : ClassDeclaration
|
||||
{
|
||||
#if DMDV2
|
||||
int cpp; // !=0 if this is a C++ interface
|
||||
int cpp; // !=0 if this is a C++ interface
|
||||
#endif
|
||||
InterfaceDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses);
|
||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||
@@ -329,7 +329,7 @@ struct InterfaceDeclaration : ClassDeclaration
|
||||
virtual int isCOMinterface();
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
Symbol *toSymbol();
|
||||
#endif
|
||||
|
||||
|
||||
144
dmd/arrayop.c
144
dmd/arrayop.c
@@ -94,10 +94,10 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arrayExpSliceAddass_t",
|
||||
// "_arrayExpSliceAddass_u",
|
||||
// "_arrayExpSliceAddass_w",
|
||||
//
|
||||
//
|
||||
// "_arrayExpSliceDivass_d", // T[]/=T
|
||||
// "_arrayExpSliceDivass_f", // T[]/=T
|
||||
//
|
||||
//
|
||||
// "_arrayExpSliceMinSliceAssign_a",
|
||||
// "_arrayExpSliceMinSliceAssign_d", // T[]=T-T[]
|
||||
// "_arrayExpSliceMinSliceAssign_f", // T[]=T-T[]
|
||||
@@ -109,7 +109,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arrayExpSliceMinSliceAssign_t",
|
||||
// "_arrayExpSliceMinSliceAssign_u",
|
||||
// "_arrayExpSliceMinSliceAssign_w",
|
||||
//
|
||||
//
|
||||
// "_arrayExpSliceMinass_a",
|
||||
// "_arrayExpSliceMinass_d", // T[]-=T
|
||||
// "_arrayExpSliceMinass_f", // T[]-=T
|
||||
@@ -121,7 +121,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arrayExpSliceMinass_t",
|
||||
// "_arrayExpSliceMinass_u",
|
||||
// "_arrayExpSliceMinass_w",
|
||||
//
|
||||
//
|
||||
// "_arrayExpSliceMulass_d", // T[]*=T
|
||||
// "_arrayExpSliceMulass_f", // T[]*=T
|
||||
// "_arrayExpSliceMulass_i",
|
||||
@@ -130,7 +130,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arrayExpSliceMulass_t",
|
||||
// "_arrayExpSliceMulass_u",
|
||||
// "_arrayExpSliceMulass_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceExpAddSliceAssign_a",
|
||||
// "_arraySliceExpAddSliceAssign_d", // T[]=T[]+T
|
||||
// "_arraySliceExpAddSliceAssign_f", // T[]=T[]+T
|
||||
@@ -142,10 +142,10 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceExpAddSliceAssign_t",
|
||||
// "_arraySliceExpAddSliceAssign_u",
|
||||
// "_arraySliceExpAddSliceAssign_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceExpDivSliceAssign_d", // T[]=T[]/T
|
||||
// "_arraySliceExpDivSliceAssign_f", // T[]=T[]/T
|
||||
//
|
||||
//
|
||||
// "_arraySliceExpMinSliceAssign_a",
|
||||
// "_arraySliceExpMinSliceAssign_d", // T[]=T[]-T
|
||||
// "_arraySliceExpMinSliceAssign_f", // T[]=T[]-T
|
||||
@@ -157,11 +157,11 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceExpMinSliceAssign_t",
|
||||
// "_arraySliceExpMinSliceAssign_u",
|
||||
// "_arraySliceExpMinSliceAssign_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceExpMulSliceAddass_d", // T[] += T[]*T
|
||||
// "_arraySliceExpMulSliceAddass_f",
|
||||
// "_arraySliceExpMulSliceAddass_r",
|
||||
//
|
||||
//
|
||||
// "_arraySliceExpMulSliceAssign_d", // T[]=T[]*T
|
||||
// "_arraySliceExpMulSliceAssign_f", // T[]=T[]*T
|
||||
// "_arraySliceExpMulSliceAssign_i",
|
||||
@@ -170,11 +170,11 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceExpMulSliceAssign_t",
|
||||
// "_arraySliceExpMulSliceAssign_u",
|
||||
// "_arraySliceExpMulSliceAssign_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceExpMulSliceMinass_d", // T[] -= T[]*T
|
||||
// "_arraySliceExpMulSliceMinass_f",
|
||||
// "_arraySliceExpMulSliceMinass_r",
|
||||
//
|
||||
//
|
||||
// "_arraySliceSliceAddSliceAssign_a",
|
||||
// "_arraySliceSliceAddSliceAssign_d", // T[]=T[]+T[]
|
||||
// "_arraySliceSliceAddSliceAssign_f", // T[]=T[]+T[]
|
||||
@@ -187,7 +187,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceSliceAddSliceAssign_t",
|
||||
// "_arraySliceSliceAddSliceAssign_u",
|
||||
// "_arraySliceSliceAddSliceAssign_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceSliceAddass_a",
|
||||
// "_arraySliceSliceAddass_d", // T[]+=T[]
|
||||
// "_arraySliceSliceAddass_f", // T[]+=T[]
|
||||
@@ -199,7 +199,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceSliceAddass_t",
|
||||
// "_arraySliceSliceAddass_u",
|
||||
// "_arraySliceSliceAddass_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceSliceMinSliceAssign_a",
|
||||
// "_arraySliceSliceMinSliceAssign_d", // T[]=T[]-T[]
|
||||
// "_arraySliceSliceMinSliceAssign_f", // T[]=T[]-T[]
|
||||
@@ -212,7 +212,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceSliceMinSliceAssign_t",
|
||||
// "_arraySliceSliceMinSliceAssign_u",
|
||||
// "_arraySliceSliceMinSliceAssign_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceSliceMinass_a",
|
||||
// "_arraySliceSliceMinass_d", // T[]-=T[]
|
||||
// "_arraySliceSliceMinass_f", // T[]-=T[]
|
||||
@@ -224,7 +224,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceSliceMinass_t",
|
||||
// "_arraySliceSliceMinass_u",
|
||||
// "_arraySliceSliceMinass_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceSliceMulSliceAssign_d", // T[]=T[]*T[]
|
||||
// "_arraySliceSliceMulSliceAssign_f", // T[]=T[]*T[]
|
||||
// "_arraySliceSliceMulSliceAssign_i",
|
||||
@@ -233,7 +233,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceSliceMulSliceAssign_t",
|
||||
// "_arraySliceSliceMulSliceAssign_u",
|
||||
// "_arraySliceSliceMulSliceAssign_w",
|
||||
//
|
||||
//
|
||||
// "_arraySliceSliceMulass_d", // T[]*=T[]
|
||||
// "_arraySliceSliceMulass_f", // T[]*=T[]
|
||||
// "_arraySliceSliceMulass_i",
|
||||
@@ -243,7 +243,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
// "_arraySliceSliceMulass_u",
|
||||
// "_arraySliceSliceMulass_w",
|
||||
// };
|
||||
//
|
||||
//
|
||||
// int i = binary(name, libArrayopFuncs, sizeof(libArrayopFuncs) / sizeof(char *));
|
||||
// if (i == -1)
|
||||
// {
|
||||
@@ -305,8 +305,8 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
sc->stc = 0;
|
||||
sc->linkage = LINKd;
|
||||
fd->semantic(sc);
|
||||
fd->semantic2(sc);
|
||||
fd->semantic3(sc);
|
||||
fd->semantic2(sc);
|
||||
fd->semantic3(sc);
|
||||
sc->pop();
|
||||
// }
|
||||
// else
|
||||
@@ -342,10 +342,10 @@ void CastExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments)
|
||||
Type *tb = type->toBasetype();
|
||||
if (tb->ty == Tarray || tb->ty == Tsarray)
|
||||
{
|
||||
e1->buildArrayIdent(buf, arguments);
|
||||
e1->buildArrayIdent(buf, arguments);
|
||||
}
|
||||
else
|
||||
Expression::buildArrayIdent(buf, arguments);
|
||||
Expression::buildArrayIdent(buf, arguments);
|
||||
}
|
||||
|
||||
void SliceExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments)
|
||||
@@ -365,13 +365,13 @@ void AssignExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments)
|
||||
|
||||
#define X(Str) \
|
||||
void Str##AssignExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments) \
|
||||
{ \
|
||||
/* Evaluate assign expressions right to left \
|
||||
*/ \
|
||||
e2->buildArrayIdent(buf, arguments); \
|
||||
e1->buildArrayIdent(buf, arguments); \
|
||||
buf->writestring(#Str); \
|
||||
buf->writestring("ass"); \
|
||||
{ \
|
||||
/* Evaluate assign expressions right to left \
|
||||
*/ \
|
||||
e2->buildArrayIdent(buf, arguments); \
|
||||
e1->buildArrayIdent(buf, arguments); \
|
||||
buf->writestring(#Str); \
|
||||
buf->writestring("ass"); \
|
||||
}
|
||||
|
||||
X(Add)
|
||||
@@ -398,13 +398,13 @@ void ComExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments)
|
||||
}
|
||||
|
||||
#define X(Str) \
|
||||
void Str##Exp::buildArrayIdent(OutBuffer *buf, Expressions *arguments) \
|
||||
{ \
|
||||
/* Evaluate assign expressions left to right \
|
||||
*/ \
|
||||
e1->buildArrayIdent(buf, arguments); \
|
||||
e2->buildArrayIdent(buf, arguments); \
|
||||
buf->writestring(#Str); \
|
||||
void Str##Exp::buildArrayIdent(OutBuffer *buf, Expressions *arguments) \
|
||||
{ \
|
||||
/* Evaluate assign expressions left to right \
|
||||
*/ \
|
||||
e1->buildArrayIdent(buf, arguments); \
|
||||
e2->buildArrayIdent(buf, arguments); \
|
||||
buf->writestring(#Str); \
|
||||
}
|
||||
|
||||
X(Add)
|
||||
@@ -437,10 +437,10 @@ Expression *CastExp::buildArrayLoop(Parameters *fparams)
|
||||
Type *tb = type->toBasetype();
|
||||
if (tb->ty == Tarray || tb->ty == Tsarray)
|
||||
{
|
||||
return e1->buildArrayLoop(fparams);
|
||||
return e1->buildArrayLoop(fparams);
|
||||
}
|
||||
else
|
||||
return Expression::buildArrayLoop(fparams);
|
||||
return Expression::buildArrayLoop(fparams);
|
||||
}
|
||||
|
||||
Expression *SliceExp::buildArrayLoop(Parameters *fparams)
|
||||
@@ -477,16 +477,16 @@ Expression *AssignExp::buildArrayLoop(Parameters *fparams)
|
||||
}
|
||||
|
||||
#define X(Str) \
|
||||
Expression *Str##AssignExp::buildArrayLoop(Parameters *fparams) \
|
||||
{ \
|
||||
/* Evaluate assign expressions right to left \
|
||||
*/ \
|
||||
Expression *ex2 = e2->buildArrayLoop(fparams); \
|
||||
Expression *ex1 = e1->buildArrayLoop(fparams); \
|
||||
Parameter *param = (Parameter *)fparams->data[0]; \
|
||||
param->storageClass = 0; \
|
||||
Expression *e = new Str##AssignExp(0, ex1, ex2); \
|
||||
return e; \
|
||||
Expression *Str##AssignExp::buildArrayLoop(Parameters *fparams) \
|
||||
{ \
|
||||
/* Evaluate assign expressions right to left \
|
||||
*/ \
|
||||
Expression *ex2 = e2->buildArrayLoop(fparams); \
|
||||
Expression *ex1 = e1->buildArrayLoop(fparams); \
|
||||
Parameter *param = (Parameter *)fparams->data[0]; \
|
||||
param->storageClass = 0; \
|
||||
Expression *e = new Str##AssignExp(0, ex1, ex2); \
|
||||
return e; \
|
||||
}
|
||||
|
||||
X(Add)
|
||||
@@ -515,14 +515,14 @@ Expression *ComExp::buildArrayLoop(Parameters *fparams)
|
||||
}
|
||||
|
||||
#define X(Str) \
|
||||
Expression *Str##Exp::buildArrayLoop(Parameters *fparams) \
|
||||
{ \
|
||||
/* Evaluate assign expressions left to right \
|
||||
*/ \
|
||||
Expression *ex1 = e1->buildArrayLoop(fparams); \
|
||||
Expression *ex2 = e2->buildArrayLoop(fparams); \
|
||||
Expression *e = new Str##Exp(0, ex1, ex2); \
|
||||
return e; \
|
||||
Expression *Str##Exp::buildArrayLoop(Parameters *fparams) \
|
||||
{ \
|
||||
/* Evaluate assign expressions left to right \
|
||||
*/ \
|
||||
Expression *ex1 = e1->buildArrayLoop(fparams); \
|
||||
Expression *ex2 = e2->buildArrayLoop(fparams); \
|
||||
Expression *e = new Str##Exp(0, ex1, ex2); \
|
||||
return e; \
|
||||
}
|
||||
|
||||
X(Add)
|
||||
@@ -545,26 +545,26 @@ int Expression::isArrayOperand()
|
||||
{
|
||||
//printf("Expression::isArrayOperand() %s\n", toChars());
|
||||
if (op == TOKslice)
|
||||
return 1;
|
||||
return 1;
|
||||
if (type->toBasetype()->ty == Tarray)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case TOKadd:
|
||||
case TOKmin:
|
||||
case TOKmul:
|
||||
case TOKdiv:
|
||||
case TOKmod:
|
||||
case TOKxor:
|
||||
case TOKand:
|
||||
case TOKor:
|
||||
case TOKneg:
|
||||
case TOKtilde:
|
||||
return 1;
|
||||
switch (op)
|
||||
{
|
||||
case TOKadd:
|
||||
case TOKmin:
|
||||
case TOKmul:
|
||||
case TOKdiv:
|
||||
case TOKmod:
|
||||
case TOKxor:
|
||||
case TOKand:
|
||||
case TOKor:
|
||||
case TOKneg:
|
||||
case TOKtilde:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
1106
dmd/attrib.c
1106
dmd/attrib.c
File diff suppressed because it is too large
Load Diff
20
dmd/attrib.h
20
dmd/attrib.h
@@ -31,17 +31,17 @@ struct HdrGenState;
|
||||
|
||||
struct AttribDeclaration : Dsymbol
|
||||
{
|
||||
Array *decl; // array of Dsymbol's
|
||||
Array *decl; // array of Dsymbol's
|
||||
|
||||
AttribDeclaration(Array *decl);
|
||||
virtual Array *include(Scope *sc, ScopeDsymbol *s);
|
||||
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
||||
void setScopeNewSc(Scope *sc,
|
||||
StorageClass newstc, enum LINK linkage, enum PROT protection, int explictProtection,
|
||||
unsigned structalign);
|
||||
StorageClass newstc, enum LINK linkage, enum PROT protection, int explictProtection,
|
||||
unsigned structalign);
|
||||
void semanticNewSc(Scope *sc,
|
||||
StorageClass newstc, enum LINK linkage, enum PROT protection, int explictProtection,
|
||||
unsigned structalign);
|
||||
StorageClass newstc, enum LINK linkage, enum PROT protection, int explictProtection,
|
||||
unsigned structalign);
|
||||
void semantic(Scope *sc);
|
||||
void semantic2(Scope *sc);
|
||||
void semantic3(Scope *sc);
|
||||
@@ -58,7 +58,7 @@ struct AttribDeclaration : Dsymbol
|
||||
AttribDeclaration *isAttribDeclaration() { return this; }
|
||||
|
||||
#if IN_DMD
|
||||
virtual void toObjFile(int multiobj); // compile to .obj file
|
||||
virtual void toObjFile(int multiobj); // compile to .obj file
|
||||
int cvMember(unsigned char *p);
|
||||
#endif
|
||||
|
||||
@@ -121,7 +121,7 @@ struct AlignDeclaration : AttribDeclaration
|
||||
struct AnonDeclaration : AttribDeclaration
|
||||
{
|
||||
int isunion;
|
||||
int sem; // 1 if successful semantic()
|
||||
int sem; // 1 if successful semantic()
|
||||
|
||||
AnonDeclaration(Loc loc, int isunion, Array *decl);
|
||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||
@@ -132,7 +132,7 @@ struct AnonDeclaration : AttribDeclaration
|
||||
|
||||
struct PragmaDeclaration : AttribDeclaration
|
||||
{
|
||||
Expressions *args; // array of Expression's
|
||||
Expressions *args; // array of Expression's
|
||||
|
||||
PragmaDeclaration(Loc loc, Identifier *ident, Expressions *args, Array *decl);
|
||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||
@@ -143,7 +143,7 @@ struct PragmaDeclaration : AttribDeclaration
|
||||
const char *kind();
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
#endif
|
||||
|
||||
#if IN_LLVM
|
||||
@@ -154,7 +154,7 @@ struct PragmaDeclaration : AttribDeclaration
|
||||
struct ConditionalDeclaration : AttribDeclaration
|
||||
{
|
||||
Condition *condition;
|
||||
Array *elsedecl; // array of Dsymbol's for else block
|
||||
Array *elsedecl; // array of Dsymbol's for else block
|
||||
|
||||
ConditionalDeclaration(Condition *condition, Array *decl, Array *elsedecl);
|
||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||
|
||||
1758
dmd/cast.c
1758
dmd/cast.c
File diff suppressed because it is too large
Load Diff
1434
dmd/class.c
1434
dmd/class.c
File diff suppressed because it is too large
Load Diff
194
dmd/clone.c
194
dmd/clone.c
@@ -35,44 +35,44 @@ Expression *StructDeclaration::cloneMembers()
|
||||
|
||||
for (size_t i = 0; i < fields.dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||
VarDeclaration *v = s->isVarDeclaration();
|
||||
assert(v && v->storage_class & STCfield);
|
||||
Type *tv = v->type->toBasetype();
|
||||
size_t dim = 1;
|
||||
while (tv->ty == Tsarray)
|
||||
{ TypeSArray *ta = (TypeSArray *)tv;
|
||||
dim *= ((TypeSArray *)tv)->dim->toInteger();
|
||||
tv = tv->nextOf()->toBasetype();
|
||||
}
|
||||
if (tv->ty == Tstruct)
|
||||
{ TypeStruct *ts = (TypeStruct *)tv;
|
||||
StructDeclaration *sd = ts->sym;
|
||||
if (sd->opclone)
|
||||
{ Expression *ex;
|
||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||
VarDeclaration *v = s->isVarDeclaration();
|
||||
assert(v && v->storage_class & STCfield);
|
||||
Type *tv = v->type->toBasetype();
|
||||
size_t dim = 1;
|
||||
while (tv->ty == Tsarray)
|
||||
{ TypeSArray *ta = (TypeSArray *)tv;
|
||||
dim *= ((TypeSArray *)tv)->dim->toInteger();
|
||||
tv = tv->nextOf()->toBasetype();
|
||||
}
|
||||
if (tv->ty == Tstruct)
|
||||
{ TypeStruct *ts = (TypeStruct *)tv;
|
||||
StructDeclaration *sd = ts->sym;
|
||||
if (sd->opclone)
|
||||
{ Expression *ex;
|
||||
|
||||
// this.v
|
||||
ex = new ThisExp(0);
|
||||
ex = new DotVarExp(0, ex, v, 0);
|
||||
// this.v
|
||||
ex = new ThisExp(0);
|
||||
ex = new DotVarExp(0, ex, v, 0);
|
||||
|
||||
if (dim == 1)
|
||||
{ // this.v.opClone()
|
||||
ex = new DotVarExp(0, ex, sd->opclone, 0);
|
||||
ex = new CallExp(0, ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// _callOpClones(&this.v, opclone, dim)
|
||||
Expressions *args = new Expressions();
|
||||
args->push(new AddrExp(0, ex));
|
||||
args->push(new SymOffExp(0, sd->opclone, 0));
|
||||
args->push(new IntegerExp(dim));
|
||||
FuncDeclaration *ec = FuncDeclaration::genCfunc(Type::tvoid, "_callOpClones");
|
||||
ex = new CallExp(0, new VarExp(0, ec), args);
|
||||
}
|
||||
e = Expression::combine(e, ex);
|
||||
}
|
||||
}
|
||||
if (dim == 1)
|
||||
{ // this.v.opClone()
|
||||
ex = new DotVarExp(0, ex, sd->opclone, 0);
|
||||
ex = new CallExp(0, ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// _callOpClones(&this.v, opclone, dim)
|
||||
Expressions *args = new Expressions();
|
||||
args->push(new AddrExp(0, ex));
|
||||
args->push(new SymOffExp(0, sd->opclone, 0));
|
||||
args->push(new IntegerExp(dim));
|
||||
FuncDeclaration *ec = FuncDeclaration::genCfunc(Type::tvoid, "_callOpClones");
|
||||
ex = new CallExp(0, new VarExp(0, ec), args);
|
||||
}
|
||||
e = Expression::combine(e, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -92,83 +92,83 @@ FuncDeclaration *AggregateDeclaration::buildDtor(Scope *sc)
|
||||
#if DMDV2
|
||||
for (size_t i = 0; i < fields.dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||
VarDeclaration *v = s->isVarDeclaration();
|
||||
assert(v && v->storage_class & STCfield);
|
||||
Type *tv = v->type->toBasetype();
|
||||
size_t dim = 1;
|
||||
while (tv->ty == Tsarray)
|
||||
{ TypeSArray *ta = (TypeSArray *)tv;
|
||||
dim *= ((TypeSArray *)tv)->dim->toInteger();
|
||||
tv = tv->nextOf()->toBasetype();
|
||||
}
|
||||
if (tv->ty == Tstruct)
|
||||
{ TypeStruct *ts = (TypeStruct *)tv;
|
||||
StructDeclaration *sd = ts->sym;
|
||||
if (sd->dtor)
|
||||
{ Expression *ex;
|
||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||
VarDeclaration *v = s->isVarDeclaration();
|
||||
assert(v && v->storage_class & STCfield);
|
||||
Type *tv = v->type->toBasetype();
|
||||
size_t dim = 1;
|
||||
while (tv->ty == Tsarray)
|
||||
{ TypeSArray *ta = (TypeSArray *)tv;
|
||||
dim *= ((TypeSArray *)tv)->dim->toInteger();
|
||||
tv = tv->nextOf()->toBasetype();
|
||||
}
|
||||
if (tv->ty == Tstruct)
|
||||
{ TypeStruct *ts = (TypeStruct *)tv;
|
||||
StructDeclaration *sd = ts->sym;
|
||||
if (sd->dtor)
|
||||
{ Expression *ex;
|
||||
|
||||
// this.v
|
||||
ex = new ThisExp(0);
|
||||
ex = new DotVarExp(0, ex, v, 0);
|
||||
// this.v
|
||||
ex = new ThisExp(0);
|
||||
ex = new DotVarExp(0, ex, v, 0);
|
||||
|
||||
if (dim == 1)
|
||||
{ // this.v.dtor()
|
||||
ex = new DotVarExp(0, ex, sd->dtor, 0);
|
||||
ex = new CallExp(0, ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Typeinfo.destroy(cast(void*)&this.v);
|
||||
Expression *ea = new AddrExp(0, ex);
|
||||
ea = new CastExp(0, ea, Type::tvoid->pointerTo());
|
||||
Expressions *args = new Expressions();
|
||||
args->push(ea);
|
||||
if (dim == 1)
|
||||
{ // this.v.dtor()
|
||||
ex = new DotVarExp(0, ex, sd->dtor, 0);
|
||||
ex = new CallExp(0, ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Typeinfo.destroy(cast(void*)&this.v);
|
||||
Expression *ea = new AddrExp(0, ex);
|
||||
ea = new CastExp(0, ea, Type::tvoid->pointerTo());
|
||||
Expressions *args = new Expressions();
|
||||
args->push(ea);
|
||||
|
||||
Expression *et = v->type->getTypeInfo(sc);
|
||||
et = new DotIdExp(0, et, Id::destroy);
|
||||
Expression *et = v->type->getTypeInfo(sc);
|
||||
et = new DotIdExp(0, et, Id::destroy);
|
||||
|
||||
ex = new CallExp(0, et, args);
|
||||
}
|
||||
e = Expression::combine(ex, e); // combine in reverse order
|
||||
}
|
||||
}
|
||||
ex = new CallExp(0, et, args);
|
||||
}
|
||||
e = Expression::combine(ex, e); // combine in reverse order
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Build our own "destructor" which executes e
|
||||
*/
|
||||
if (e)
|
||||
{ //printf("Building __fieldDtor()\n");
|
||||
DtorDeclaration *dd = new DtorDeclaration(0, 0, Lexer::idPool("__fieldDtor"));
|
||||
dd->fbody = new ExpStatement(0, e);
|
||||
dtors.shift(dd);
|
||||
members->push(dd);
|
||||
dd->semantic(sc);
|
||||
{ //printf("Building __fieldDtor()\n");
|
||||
DtorDeclaration *dd = new DtorDeclaration(0, 0, Lexer::idPool("__fieldDtor"));
|
||||
dd->fbody = new ExpStatement(0, e);
|
||||
dtors.shift(dd);
|
||||
members->push(dd);
|
||||
dd->semantic(sc);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (dtors.dim)
|
||||
{
|
||||
case 0:
|
||||
return NULL;
|
||||
case 0:
|
||||
return NULL;
|
||||
|
||||
case 1:
|
||||
return (FuncDeclaration *)dtors.data[0];
|
||||
case 1:
|
||||
return (FuncDeclaration *)dtors.data[0];
|
||||
|
||||
default:
|
||||
e = NULL;
|
||||
for (size_t i = 0; i < dtors.dim; i++)
|
||||
{ FuncDeclaration *fd = (FuncDeclaration *)dtors.data[i];
|
||||
Expression *ex = new ThisExp(0);
|
||||
ex = new DotVarExp(0, ex, fd);
|
||||
ex = new CallExp(0, ex);
|
||||
e = Expression::combine(ex, e);
|
||||
}
|
||||
DtorDeclaration *dd = new DtorDeclaration(0, 0, Lexer::idPool("__aggrDtor"));
|
||||
dd->fbody = new ExpStatement(0, e);
|
||||
members->push(dd);
|
||||
dd->semantic(sc);
|
||||
return dd;
|
||||
default:
|
||||
e = NULL;
|
||||
for (size_t i = 0; i < dtors.dim; i++)
|
||||
{ FuncDeclaration *fd = (FuncDeclaration *)dtors.data[i];
|
||||
Expression *ex = new ThisExp(0);
|
||||
ex = new DotVarExp(0, ex, fd);
|
||||
ex = new CallExp(0, ex);
|
||||
e = Expression::combine(ex, e);
|
||||
}
|
||||
DtorDeclaration *dd = new DtorDeclaration(0, 0, Lexer::idPool("__aggrDtor"));
|
||||
dd->fbody = new ExpStatement(0, e);
|
||||
members->push(dd);
|
||||
dd->semantic(sc);
|
||||
return dd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
struct complex_t
|
||||
{
|
||||
long double re;
|
||||
long double im;
|
||||
long double im;
|
||||
|
||||
complex_t() { this->re = 0; this->im = 0; }
|
||||
complex_t(long double re) { this->re = re; this->im = 0; }
|
||||
@@ -27,27 +27,27 @@ struct complex_t
|
||||
complex_t operator - (complex_t y) { complex_t r; r.re = re - y.re; r.im = im - y.im; return r; }
|
||||
complex_t operator - () { complex_t r; r.re = -re; r.im = -im; return r; }
|
||||
complex_t operator * (complex_t y) { return complex_t(re * y.re - im * y.im, im * y.re + re * y.im); }
|
||||
|
||||
|
||||
complex_t operator / (complex_t y)
|
||||
{
|
||||
long double abs_y_re = y.re < 0 ? -y.re : y.re;
|
||||
long double abs_y_im = y.im < 0 ? -y.im : y.im;
|
||||
long double r, den;
|
||||
long double abs_y_re = y.re < 0 ? -y.re : y.re;
|
||||
long double abs_y_im = y.im < 0 ? -y.im : y.im;
|
||||
long double r, den;
|
||||
|
||||
if (abs_y_re < abs_y_im)
|
||||
{
|
||||
r = y.re / y.im;
|
||||
den = y.im + r * y.re;
|
||||
return complex_t((re * r + im) / den,
|
||||
(im * r - re) / den);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = y.im / y.re;
|
||||
den = y.re + r * y.im;
|
||||
return complex_t((re + r * im) / den,
|
||||
(im - r * re) / den);
|
||||
}
|
||||
if (abs_y_re < abs_y_im)
|
||||
{
|
||||
r = y.re / y.im;
|
||||
den = y.im + r * y.re;
|
||||
return complex_t((re * r + im) / den,
|
||||
(im * r - re) / den);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = y.im / y.re;
|
||||
den = y.re + r * y.im;
|
||||
return complex_t((re + r * im) / den,
|
||||
(im - r * re) / den);
|
||||
}
|
||||
}
|
||||
|
||||
operator bool () { return re || im; }
|
||||
|
||||
336
dmd/cond.c
336
dmd/cond.c
@@ -29,13 +29,13 @@ int findCondition(Array *ids, Identifier *ident)
|
||||
{
|
||||
if (ids)
|
||||
{
|
||||
for (int i = 0; i < ids->dim; i++)
|
||||
{
|
||||
const char *id = (const char *)ids->data[i];
|
||||
for (int i = 0; i < ids->dim; i++)
|
||||
{
|
||||
const char *id = (const char *)ids->data[i];
|
||||
|
||||
if (strcmp(id, ident->toChars()) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
if (strcmp(id, ident->toChars()) == 0)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -52,7 +52,7 @@ Condition::Condition(Loc loc)
|
||||
/* ============================================================ */
|
||||
|
||||
DVCondition::DVCondition(Module *mod, unsigned level, Identifier *ident)
|
||||
: Condition(0)
|
||||
: Condition(0)
|
||||
{
|
||||
this->mod = mod;
|
||||
this->level = level;
|
||||
@@ -61,7 +61,7 @@ DVCondition::DVCondition(Module *mod, unsigned level, Identifier *ident)
|
||||
|
||||
Condition *DVCondition::syntaxCopy()
|
||||
{
|
||||
return this; // don't need to copy
|
||||
return this; // don't need to copy
|
||||
}
|
||||
|
||||
/* ============================================================ */
|
||||
@@ -74,7 +74,7 @@ void DebugCondition::setGlobalLevel(unsigned level)
|
||||
void DebugCondition::addGlobalIdent(const char *ident)
|
||||
{
|
||||
if (!global.params.debugids)
|
||||
global.params.debugids = new Array();
|
||||
global.params.debugids = new Array();
|
||||
global.params.debugids->push((void *)ident);
|
||||
}
|
||||
|
||||
@@ -89,21 +89,21 @@ int DebugCondition::include(Scope *sc, ScopeDsymbol *s)
|
||||
//printf("DebugCondition::include() level = %d, debuglevel = %d\n", level, global.params.debuglevel);
|
||||
if (inc == 0)
|
||||
{
|
||||
inc = 2;
|
||||
if (ident)
|
||||
{
|
||||
if (findCondition(mod->debugids, ident))
|
||||
inc = 1;
|
||||
else if (findCondition(global.params.debugids, ident))
|
||||
inc = 1;
|
||||
else
|
||||
{ if (!mod->debugidsNot)
|
||||
mod->debugidsNot = new Array();
|
||||
mod->debugidsNot->push(ident->toChars());
|
||||
}
|
||||
}
|
||||
else if (level <= global.params.debuglevel || level <= mod->debuglevel)
|
||||
inc = 1;
|
||||
inc = 2;
|
||||
if (ident)
|
||||
{
|
||||
if (findCondition(mod->debugids, ident))
|
||||
inc = 1;
|
||||
else if (findCondition(global.params.debugids, ident))
|
||||
inc = 1;
|
||||
else
|
||||
{ if (!mod->debugidsNot)
|
||||
mod->debugidsNot = new Array();
|
||||
mod->debugidsNot->push(ident->toChars());
|
||||
}
|
||||
}
|
||||
else if (level <= global.params.debuglevel || level <= mod->debuglevel)
|
||||
inc = 1;
|
||||
}
|
||||
return (inc == 1);
|
||||
}
|
||||
@@ -111,9 +111,9 @@ int DebugCondition::include(Scope *sc, ScopeDsymbol *s)
|
||||
void DebugCondition::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
if (ident)
|
||||
buf->printf("debug (%s)", ident->toChars());
|
||||
buf->printf("debug (%s)", ident->toChars());
|
||||
else
|
||||
buf->printf("debug (%u)", level);
|
||||
buf->printf("debug (%u)", level);
|
||||
}
|
||||
|
||||
/* ============================================================ */
|
||||
@@ -127,20 +127,20 @@ void VersionCondition::checkPredefined(Loc loc, const char *ident)
|
||||
{
|
||||
static const char* reserved[] =
|
||||
{
|
||||
"DigitalMars", "X86", "X86_64",
|
||||
"Windows", "Win32", "Win64",
|
||||
"linux",
|
||||
"DigitalMars", "X86", "X86_64",
|
||||
"Windows", "Win32", "Win64",
|
||||
"linux",
|
||||
#if DMDV2
|
||||
/* Although Posix is predefined by D1, disallowing its
|
||||
* redefinition breaks makefiles and older builds.
|
||||
*/
|
||||
"Posix",
|
||||
/* Although Posix is predefined by D1, disallowing its
|
||||
* redefinition breaks makefiles and older builds.
|
||||
*/
|
||||
"Posix",
|
||||
#endif
|
||||
"OSX", "FreeBSD",
|
||||
"Solaris",
|
||||
"LittleEndian", "BigEndian",
|
||||
"all",
|
||||
"none",
|
||||
"OSX", "FreeBSD",
|
||||
"Solaris",
|
||||
"LittleEndian", "BigEndian",
|
||||
"all",
|
||||
"none",
|
||||
|
||||
#if IN_LLVM
|
||||
"LLVM", "LDC", "LLVM64",
|
||||
@@ -151,12 +151,12 @@ void VersionCondition::checkPredefined(Loc loc, const char *ident)
|
||||
|
||||
for (unsigned i = 0; i < sizeof(reserved) / sizeof(reserved[0]); i++)
|
||||
{
|
||||
if (strcmp(ident, reserved[i]) == 0)
|
||||
goto Lerror;
|
||||
if (strcmp(ident, reserved[i]) == 0)
|
||||
goto Lerror;
|
||||
}
|
||||
|
||||
if (ident[0] == 'D' && ident[1] == '_')
|
||||
goto Lerror;
|
||||
goto Lerror;
|
||||
|
||||
return;
|
||||
|
||||
@@ -173,7 +173,7 @@ void VersionCondition::addGlobalIdent(const char *ident)
|
||||
void VersionCondition::addPredefinedGlobalIdent(const char *ident)
|
||||
{
|
||||
if (!global.params.versionids)
|
||||
global.params.versionids = new Array();
|
||||
global.params.versionids = new Array();
|
||||
global.params.versionids->push((void *)ident);
|
||||
}
|
||||
|
||||
@@ -189,22 +189,22 @@ int VersionCondition::include(Scope *sc, ScopeDsymbol *s)
|
||||
//if (ident) printf("\tident = '%s'\n", ident->toChars());
|
||||
if (inc == 0)
|
||||
{
|
||||
inc = 2;
|
||||
if (ident)
|
||||
{
|
||||
if (findCondition(mod->versionids, ident))
|
||||
inc = 1;
|
||||
else if (findCondition(global.params.versionids, ident))
|
||||
inc = 1;
|
||||
else
|
||||
{
|
||||
if (!mod->versionidsNot)
|
||||
mod->versionidsNot = new Array();
|
||||
mod->versionidsNot->push(ident->toChars());
|
||||
}
|
||||
}
|
||||
else if (level <= global.params.versionlevel || level <= mod->versionlevel)
|
||||
inc = 1;
|
||||
inc = 2;
|
||||
if (ident)
|
||||
{
|
||||
if (findCondition(mod->versionids, ident))
|
||||
inc = 1;
|
||||
else if (findCondition(global.params.versionids, ident))
|
||||
inc = 1;
|
||||
else
|
||||
{
|
||||
if (!mod->versionidsNot)
|
||||
mod->versionidsNot = new Array();
|
||||
mod->versionidsNot->push(ident->toChars());
|
||||
}
|
||||
}
|
||||
else if (level <= global.params.versionlevel || level <= mod->versionlevel)
|
||||
inc = 1;
|
||||
}
|
||||
return (inc == 1);
|
||||
}
|
||||
@@ -212,9 +212,9 @@ int VersionCondition::include(Scope *sc, ScopeDsymbol *s)
|
||||
void VersionCondition::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
if (ident)
|
||||
buf->printf("version (%s)", ident->toChars());
|
||||
buf->printf("version (%s)", ident->toChars());
|
||||
else
|
||||
buf->printf("version (%u)", level);
|
||||
buf->printf("version (%u)", level);
|
||||
}
|
||||
|
||||
|
||||
@@ -237,33 +237,33 @@ int StaticIfCondition::include(Scope *sc, ScopeDsymbol *s)
|
||||
printf("StaticIfCondition::include(sc = %p, s = %p)\n", sc, s);
|
||||
if (s)
|
||||
{
|
||||
printf("\ts = '%s', kind = %s\n", s->toChars(), s->kind());
|
||||
printf("\ts = '%s', kind = %s\n", s->toChars(), s->kind());
|
||||
}
|
||||
#endif
|
||||
if (inc == 0)
|
||||
{
|
||||
if (!sc)
|
||||
{
|
||||
error(loc, "static if conditional cannot be at global scope");
|
||||
inc = 2;
|
||||
return 0;
|
||||
}
|
||||
if (!sc)
|
||||
{
|
||||
error(loc, "static if conditional cannot be at global scope");
|
||||
inc = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
sc = sc->push(sc->scopesym);
|
||||
sc->sd = s; // s gets any addMember()
|
||||
sc->flags |= SCOPEstaticif;
|
||||
Expression *e = exp->semantic(sc);
|
||||
sc->pop();
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
if (e->isBool(TRUE))
|
||||
inc = 1;
|
||||
else if (e->isBool(FALSE))
|
||||
inc = 2;
|
||||
else
|
||||
{
|
||||
e->error("expression %s is not constant or does not evaluate to a bool", e->toChars());
|
||||
inc = 2;
|
||||
}
|
||||
sc = sc->push(sc->scopesym);
|
||||
sc->sd = s; // s gets any addMember()
|
||||
sc->flags |= SCOPEstaticif;
|
||||
Expression *e = exp->semantic(sc);
|
||||
sc->pop();
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
if (e->isBool(TRUE))
|
||||
inc = 1;
|
||||
else if (e->isBool(FALSE))
|
||||
inc = 2;
|
||||
else
|
||||
{
|
||||
e->error("expression %s is not constant or does not evaluate to a bool", e->toChars());
|
||||
inc = 2;
|
||||
}
|
||||
}
|
||||
return (inc == 1);
|
||||
}
|
||||
@@ -290,10 +290,10 @@ IftypeCondition::IftypeCondition(Loc loc, Type *targ, Identifier *id, enum TOK t
|
||||
Condition *IftypeCondition::syntaxCopy()
|
||||
{
|
||||
return new IftypeCondition(loc,
|
||||
targ->syntaxCopy(),
|
||||
id,
|
||||
tok,
|
||||
tspec ? tspec->syntaxCopy() : NULL);
|
||||
targ->syntaxCopy(),
|
||||
id,
|
||||
tok,
|
||||
tspec ? tspec->syntaxCopy() : NULL);
|
||||
}
|
||||
|
||||
int IftypeCondition::include(Scope *sc, ScopeDsymbol *sd)
|
||||
@@ -301,87 +301,87 @@ int IftypeCondition::include(Scope *sc, ScopeDsymbol *sd)
|
||||
//printf("IftypeCondition::include()\n");
|
||||
if (inc == 0)
|
||||
{
|
||||
if (!sc)
|
||||
{
|
||||
error(loc, "iftype conditional cannot be at global scope");
|
||||
inc = 2;
|
||||
return 0;
|
||||
}
|
||||
unsigned errors = global.errors;
|
||||
global.gag++; // suppress printing of error messages
|
||||
targ = targ->semantic(loc, sc);
|
||||
global.gag--;
|
||||
if (errors != global.errors) // if any errors happened
|
||||
{ inc = 2; // then condition is false
|
||||
global.errors = errors;
|
||||
}
|
||||
else if (id && tspec)
|
||||
{
|
||||
/* Evaluate to TRUE if targ matches tspec.
|
||||
* If TRUE, declare id as an alias for the specialized type.
|
||||
*/
|
||||
if (!sc)
|
||||
{
|
||||
error(loc, "iftype conditional cannot be at global scope");
|
||||
inc = 2;
|
||||
return 0;
|
||||
}
|
||||
unsigned errors = global.errors;
|
||||
global.gag++; // suppress printing of error messages
|
||||
targ = targ->semantic(loc, sc);
|
||||
global.gag--;
|
||||
if (errors != global.errors) // if any errors happened
|
||||
{ inc = 2; // then condition is false
|
||||
global.errors = errors;
|
||||
}
|
||||
else if (id && tspec)
|
||||
{
|
||||
/* Evaluate to TRUE if targ matches tspec.
|
||||
* If TRUE, declare id as an alias for the specialized type.
|
||||
*/
|
||||
|
||||
MATCH m;
|
||||
TemplateTypeParameter tp(loc, id, NULL, NULL);
|
||||
MATCH m;
|
||||
TemplateTypeParameter tp(loc, id, NULL, NULL);
|
||||
|
||||
TemplateParameters parameters;
|
||||
parameters.setDim(1);
|
||||
parameters.data[0] = (void *)&tp;
|
||||
TemplateParameters parameters;
|
||||
parameters.setDim(1);
|
||||
parameters.data[0] = (void *)&tp;
|
||||
|
||||
Objects dedtypes;
|
||||
dedtypes.setDim(1);
|
||||
Objects dedtypes;
|
||||
dedtypes.setDim(1);
|
||||
|
||||
m = targ->deduceType(NULL, tspec, ¶meters, &dedtypes);
|
||||
if (m == MATCHnomatch ||
|
||||
(m != MATCHexact && tok == TOKequal))
|
||||
inc = 2;
|
||||
else
|
||||
{
|
||||
inc = 1;
|
||||
Type *tded = (Type *)dedtypes.data[0];
|
||||
if (!tded)
|
||||
tded = targ;
|
||||
Dsymbol *s = new AliasDeclaration(loc, id, tded);
|
||||
s->semantic(sc);
|
||||
sc->insert(s);
|
||||
if (sd)
|
||||
s->addMember(sc, sd, 1);
|
||||
}
|
||||
}
|
||||
else if (id)
|
||||
{
|
||||
/* Declare id as an alias for type targ. Evaluate to TRUE
|
||||
*/
|
||||
Dsymbol *s = new AliasDeclaration(loc, id, targ);
|
||||
s->semantic(sc);
|
||||
sc->insert(s);
|
||||
if (sd)
|
||||
s->addMember(sc, sd, 1);
|
||||
inc = 1;
|
||||
}
|
||||
else if (tspec)
|
||||
{
|
||||
/* Evaluate to TRUE if targ matches tspec
|
||||
*/
|
||||
tspec = tspec->semantic(loc, sc);
|
||||
//printf("targ = %s\n", targ->toChars());
|
||||
//printf("tspec = %s\n", tspec->toChars());
|
||||
if (tok == TOKcolon)
|
||||
{ if (targ->implicitConvTo(tspec))
|
||||
inc = 1;
|
||||
else
|
||||
inc = 2;
|
||||
}
|
||||
else /* == */
|
||||
{ if (targ->equals(tspec))
|
||||
inc = 1;
|
||||
else
|
||||
inc = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
inc = 1;
|
||||
//printf("inc = %d\n", inc);
|
||||
m = targ->deduceType(NULL, tspec, ¶meters, &dedtypes);
|
||||
if (m == MATCHnomatch ||
|
||||
(m != MATCHexact && tok == TOKequal))
|
||||
inc = 2;
|
||||
else
|
||||
{
|
||||
inc = 1;
|
||||
Type *tded = (Type *)dedtypes.data[0];
|
||||
if (!tded)
|
||||
tded = targ;
|
||||
Dsymbol *s = new AliasDeclaration(loc, id, tded);
|
||||
s->semantic(sc);
|
||||
sc->insert(s);
|
||||
if (sd)
|
||||
s->addMember(sc, sd, 1);
|
||||
}
|
||||
}
|
||||
else if (id)
|
||||
{
|
||||
/* Declare id as an alias for type targ. Evaluate to TRUE
|
||||
*/
|
||||
Dsymbol *s = new AliasDeclaration(loc, id, targ);
|
||||
s->semantic(sc);
|
||||
sc->insert(s);
|
||||
if (sd)
|
||||
s->addMember(sc, sd, 1);
|
||||
inc = 1;
|
||||
}
|
||||
else if (tspec)
|
||||
{
|
||||
/* Evaluate to TRUE if targ matches tspec
|
||||
*/
|
||||
tspec = tspec->semantic(loc, sc);
|
||||
//printf("targ = %s\n", targ->toChars());
|
||||
//printf("tspec = %s\n", tspec->toChars());
|
||||
if (tok == TOKcolon)
|
||||
{ if (targ->implicitConvTo(tspec))
|
||||
inc = 1;
|
||||
else
|
||||
inc = 2;
|
||||
}
|
||||
else /* == */
|
||||
{ if (targ->equals(tspec))
|
||||
inc = 1;
|
||||
else
|
||||
inc = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
inc = 1;
|
||||
//printf("inc = %d\n", inc);
|
||||
}
|
||||
return (inc == 1);
|
||||
}
|
||||
@@ -392,11 +392,11 @@ void IftypeCondition::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
targ->toCBuffer(buf, id, hgs);
|
||||
if (tspec)
|
||||
{
|
||||
if (tok == TOKcolon)
|
||||
buf->writestring(" : ");
|
||||
else
|
||||
buf->writestring(" == ");
|
||||
tspec->toCBuffer(buf, NULL, hgs);
|
||||
if (tok == TOKcolon)
|
||||
buf->writestring(" : ");
|
||||
else
|
||||
buf->writestring(" == ");
|
||||
tspec->toCBuffer(buf, NULL, hgs);
|
||||
}
|
||||
buf->writeByte(')');
|
||||
}
|
||||
|
||||
12
dmd/cond.h
12
dmd/cond.h
@@ -30,9 +30,9 @@ int findCondition(Array *ids, Identifier *ident);
|
||||
struct Condition
|
||||
{
|
||||
Loc loc;
|
||||
int inc; // 0: not computed yet
|
||||
// 1: include
|
||||
// 2: do not include
|
||||
int inc; // 0: not computed yet
|
||||
// 1: include
|
||||
// 2: do not include
|
||||
|
||||
Condition(Loc loc);
|
||||
|
||||
@@ -92,9 +92,9 @@ struct IftypeCondition : Condition
|
||||
/* iftype (targ id tok tspec)
|
||||
*/
|
||||
Type *targ;
|
||||
Identifier *id; // can be NULL
|
||||
enum TOK tok; // ':' or '=='
|
||||
Type *tspec; // can be NULL
|
||||
Identifier *id; // can be NULL
|
||||
enum TOK tok; // ':' or '=='
|
||||
Type *tspec; // can be NULL
|
||||
|
||||
IftypeCondition(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec);
|
||||
Condition *syntaxCopy();
|
||||
|
||||
1820
dmd/constfold.c
1820
dmd/constfold.c
File diff suppressed because it is too large
Load Diff
1310
dmd/declaration.c
1310
dmd/declaration.c
File diff suppressed because it is too large
Load Diff
@@ -49,73 +49,73 @@ enum MATCH;
|
||||
enum STC
|
||||
{
|
||||
STCundefined = 0,
|
||||
STCstatic = 1,
|
||||
STCextern = 2,
|
||||
STCconst = 4,
|
||||
STCfinal = 8,
|
||||
STCstatic = 1,
|
||||
STCextern = 2,
|
||||
STCconst = 4,
|
||||
STCfinal = 8,
|
||||
STCabstract = 0x10,
|
||||
STCparameter = 0x20,
|
||||
STCfield = 0x40,
|
||||
STCoverride = 0x80,
|
||||
STCfield = 0x40,
|
||||
STCoverride = 0x80,
|
||||
STCauto = 0x100,
|
||||
STCsynchronized = 0x200,
|
||||
STCdeprecated = 0x400,
|
||||
STCin = 0x800, // in parameter
|
||||
STCout = 0x1000, // out parameter
|
||||
STClazy = 0x2000, // lazy parameter
|
||||
STCforeach = 0x4000, // variable for foreach loop
|
||||
STCcomdat = 0x8000, // should go into COMDAT record
|
||||
STCvariadic = 0x10000, // variadic function argument
|
||||
STCctorinit = 0x20000, // can only be set inside constructor
|
||||
STCtemplateparameter = 0x40000, // template parameter
|
||||
STCscope = 0x80000, // template parameter
|
||||
STCin = 0x800, // in parameter
|
||||
STCout = 0x1000, // out parameter
|
||||
STClazy = 0x2000, // lazy parameter
|
||||
STCforeach = 0x4000, // variable for foreach loop
|
||||
STCcomdat = 0x8000, // should go into COMDAT record
|
||||
STCvariadic = 0x10000, // variadic function argument
|
||||
STCctorinit = 0x20000, // can only be set inside constructor
|
||||
STCtemplateparameter = 0x40000, // template parameter
|
||||
STCscope = 0x80000, // template parameter
|
||||
STCimmutable = 0x100000,
|
||||
STCref = 0x200000,
|
||||
STCinit = 0x400000, // has explicit initializer
|
||||
STCmanifest = 0x800000, // manifest constant
|
||||
STCnodtor = 0x1000000, // don't run destructor
|
||||
STCnothrow = 0x2000000, // never throws exceptions
|
||||
STCpure = 0x4000000, // pure function
|
||||
STCtls = 0x8000000, // thread local
|
||||
STCalias = 0x10000000, // alias parameter
|
||||
STCshared = 0x20000000, // accessible from multiple threads
|
||||
STCgshared = 0x40000000, // accessible from multiple threads
|
||||
// but not typed as "shared"
|
||||
STCwild = 0x80000000, // for "wild" type constructor
|
||||
STCref = 0x200000,
|
||||
STCinit = 0x400000, // has explicit initializer
|
||||
STCmanifest = 0x800000, // manifest constant
|
||||
STCnodtor = 0x1000000, // don't run destructor
|
||||
STCnothrow = 0x2000000, // never throws exceptions
|
||||
STCpure = 0x4000000, // pure function
|
||||
STCtls = 0x8000000, // thread local
|
||||
STCalias = 0x10000000, // alias parameter
|
||||
STCshared = 0x20000000, // accessible from multiple threads
|
||||
STCgshared = 0x40000000, // accessible from multiple threads
|
||||
// but not typed as "shared"
|
||||
STCwild = 0x80000000, // for "wild" type constructor
|
||||
STC_TYPECTOR = (STCconst | STCimmutable | STCshared | STCwild),
|
||||
};
|
||||
|
||||
#define STCproperty 0x100000000LL
|
||||
#define STCsafe 0x200000000LL
|
||||
#define STCtrusted 0x400000000LL
|
||||
#define STCsystem 0x800000000LL
|
||||
#define STCctfe 0x1000000000LL // can be used in CTFE, even if it is static
|
||||
#define STCproperty 0x100000000LL
|
||||
#define STCsafe 0x200000000LL
|
||||
#define STCtrusted 0x400000000LL
|
||||
#define STCsystem 0x800000000LL
|
||||
#define STCctfe 0x1000000000LL // can be used in CTFE, even if it is static
|
||||
|
||||
struct Match
|
||||
{
|
||||
int count; // number of matches found
|
||||
MATCH last; // match level of lastf
|
||||
FuncDeclaration *lastf; // last matching function we found
|
||||
FuncDeclaration *nextf; // current matching function
|
||||
FuncDeclaration *anyf; // pick a func, any func, to use for error recovery
|
||||
int count; // number of matches found
|
||||
MATCH last; // match level of lastf
|
||||
FuncDeclaration *lastf; // last matching function we found
|
||||
FuncDeclaration *nextf; // current matching function
|
||||
FuncDeclaration *anyf; // pick a func, any func, to use for error recovery
|
||||
};
|
||||
|
||||
void overloadResolveX(Match *m, FuncDeclaration *f,
|
||||
Expression *ethis, Expressions *arguments, Module *from);
|
||||
Expression *ethis, Expressions *arguments, Module *from);
|
||||
int overloadApply(Module* from, FuncDeclaration *fstart,
|
||||
int (*fp)(void *, FuncDeclaration *),
|
||||
void *param);
|
||||
int (*fp)(void *, FuncDeclaration *),
|
||||
void *param);
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
struct Declaration : Dsymbol
|
||||
{
|
||||
Type *type;
|
||||
Type *originalType; // before semantic analysis
|
||||
Type *originalType; // before semantic analysis
|
||||
StorageClass storage_class;
|
||||
enum PROT protection;
|
||||
enum LINK linkage;
|
||||
int inuse; // used to detect cycles
|
||||
int inuse; // used to detect cycles
|
||||
|
||||
Declaration(Identifier *id);
|
||||
void semantic(Scope *sc);
|
||||
@@ -146,7 +146,7 @@ struct Declaration : Dsymbol
|
||||
int isParameter() { return storage_class & STCparameter; }
|
||||
int isDeprecated() { return storage_class & STCdeprecated; }
|
||||
int isOverride() { return storage_class & STCoverride; }
|
||||
|
||||
|
||||
virtual int isSameAsInitializer() { return isConst(); };
|
||||
|
||||
int isIn() { return storage_class & STCin; }
|
||||
@@ -168,9 +168,9 @@ struct Declaration : Dsymbol
|
||||
struct TupleDeclaration : Declaration
|
||||
{
|
||||
Objects *objects;
|
||||
int isexp; // 1: expression tuple
|
||||
int isexp; // 1: expression tuple
|
||||
|
||||
TypeTuple *tupletype; // !=NULL if this is a type tuple
|
||||
TypeTuple *tupletype; // !=NULL if this is a type tuple
|
||||
|
||||
TupleDeclaration(Loc loc, Identifier *ident, Objects *objects);
|
||||
Dsymbol *syntaxCopy(Dsymbol *);
|
||||
@@ -192,10 +192,10 @@ struct TypedefDeclaration : Declaration
|
||||
{
|
||||
Type *basetype;
|
||||
Initializer *init;
|
||||
int sem; // 0: semantic() has not been run
|
||||
// 1: semantic() is in progress
|
||||
// 2: semantic() has been run
|
||||
// 3: semantic2() has been run
|
||||
int sem; // 0: semantic() has not been run
|
||||
// 1: semantic() is in progress
|
||||
// 2: semantic() has been run
|
||||
// 3: semantic2() has been run
|
||||
|
||||
TypedefDeclaration(Loc loc, Identifier *ident, Type *basetype, Initializer *init);
|
||||
Dsymbol *syntaxCopy(Dsymbol *);
|
||||
@@ -213,7 +213,7 @@ struct TypedefDeclaration : Declaration
|
||||
void toDocBuffer(OutBuffer *buf);
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toDebug();
|
||||
int cvMember(unsigned char *p);
|
||||
#endif
|
||||
@@ -236,9 +236,9 @@ struct TypedefDeclaration : Declaration
|
||||
struct AliasDeclaration : Declaration
|
||||
{
|
||||
Dsymbol *aliassym;
|
||||
Dsymbol *overnext; // next in overload list
|
||||
Dsymbol *overnext; // next in overload list
|
||||
int inSemantic;
|
||||
PROT importprot; // if generated by import, store its protection
|
||||
PROT importprot; // if generated by import, store its protection
|
||||
|
||||
AliasDeclaration(Loc loc, Identifier *ident, Type *type);
|
||||
AliasDeclaration(Loc loc, Identifier *ident, Dsymbol *s);
|
||||
@@ -265,24 +265,24 @@ struct VarDeclaration : Declaration
|
||||
{
|
||||
Initializer *init;
|
||||
unsigned offset;
|
||||
int noscope; // no scope semantics
|
||||
int noscope; // no scope semantics
|
||||
#if DMDV2
|
||||
FuncDeclarations nestedrefs; // referenced by these lexically nested functions
|
||||
bool isargptr; // if parameter that _argptr points to
|
||||
bool isargptr; // if parameter that _argptr points to
|
||||
#else
|
||||
int nestedref; // referenced by a lexically nested function
|
||||
int nestedref; // referenced by a lexically nested function
|
||||
#endif
|
||||
int ctorinit; // it has been initialized in a ctor
|
||||
int onstack; // 1: it has been allocated on the stack
|
||||
// 2: on stack, run destructor anyway
|
||||
int canassign; // it can be assigned to
|
||||
Dsymbol *aliassym; // if redone as alias to another symbol
|
||||
Expression *value; // when interpreting, this is the value
|
||||
// (NULL if value not determinable)
|
||||
int ctorinit; // it has been initialized in a ctor
|
||||
int onstack; // 1: it has been allocated on the stack
|
||||
// 2: on stack, run destructor anyway
|
||||
int canassign; // it can be assigned to
|
||||
Dsymbol *aliassym; // if redone as alias to another symbol
|
||||
Expression *value; // when interpreting, this is the value
|
||||
// (NULL if value not determinable)
|
||||
#if DMDV2
|
||||
VarDeclaration *rundtor; // if !NULL, rundtor is tested at runtime to see
|
||||
// if the destructor should be run. Used to prevent
|
||||
// dtor calls on postblitted vars
|
||||
VarDeclaration *rundtor; // if !NULL, rundtor is tested at runtime to see
|
||||
// if the destructor should be run. Used to prevent
|
||||
// dtor calls on postblitted vars
|
||||
#endif
|
||||
|
||||
VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init);
|
||||
@@ -311,11 +311,11 @@ struct VarDeclaration : Declaration
|
||||
void checkCtorConstInit();
|
||||
void checkNestedReference(Scope *sc, Loc loc);
|
||||
Dsymbol *toAlias();
|
||||
|
||||
|
||||
virtual int isSameAsInitializer();
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
Symbol *toSymbol();
|
||||
int cvMember(unsigned char *p);
|
||||
#endif
|
||||
@@ -409,7 +409,7 @@ struct TypeInfoDeclaration : VarDeclaration
|
||||
void toJsonBuffer(OutBuffer *buf);
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
Symbol *toSymbol();
|
||||
virtual void toDt(dt_t **pdt);
|
||||
#endif
|
||||
@@ -625,9 +625,9 @@ struct ThisDeclaration : VarDeclaration
|
||||
|
||||
enum ILS
|
||||
{
|
||||
ILSuninitialized, // not computed yet
|
||||
ILSno, // cannot inline
|
||||
ILSyes, // can inline
|
||||
ILSuninitialized, // not computed yet
|
||||
ILSno, // cannot inline
|
||||
ILSyes, // can inline
|
||||
};
|
||||
|
||||
/**************************************************************/
|
||||
@@ -635,13 +635,13 @@ enum ILS
|
||||
|
||||
enum BUILTIN
|
||||
{
|
||||
BUILTINunknown = -1, // not known if this is a builtin
|
||||
BUILTINnot, // this is not a builtin
|
||||
BUILTINsin, // std.math.sin
|
||||
BUILTINcos, // std.math.cos
|
||||
BUILTINtan, // std.math.tan
|
||||
BUILTINsqrt, // std.math.sqrt
|
||||
BUILTINfabs, // std.math.fabs
|
||||
BUILTINunknown = -1, // not known if this is a builtin
|
||||
BUILTINnot, // this is not a builtin
|
||||
BUILTINsin, // std.math.sin
|
||||
BUILTINcos, // std.math.cos
|
||||
BUILTINtan, // std.math.tan
|
||||
BUILTINsqrt, // std.math.sqrt
|
||||
BUILTINfabs, // std.math.fabs
|
||||
};
|
||||
|
||||
Expression *eval_builtin(enum BUILTIN builtin, Expressions *arguments);
|
||||
@@ -652,74 +652,74 @@ enum BUILTIN { };
|
||||
|
||||
struct FuncDeclaration : Declaration
|
||||
{
|
||||
Array *fthrows; // Array of Type's of exceptions (not used)
|
||||
Array *fthrows; // Array of Type's of exceptions (not used)
|
||||
Statement *frequire;
|
||||
Statement *fensure;
|
||||
Statement *fbody;
|
||||
|
||||
FuncDeclarations foverrides; // functions this function overrides
|
||||
FuncDeclaration *fdrequire; // function that does the in contract
|
||||
FuncDeclaration *fdensure; // function that does the out contract
|
||||
FuncDeclarations foverrides; // functions this function overrides
|
||||
FuncDeclaration *fdrequire; // function that does the in contract
|
||||
FuncDeclaration *fdensure; // function that does the out contract
|
||||
|
||||
Identifier *outId; // identifier for out statement
|
||||
VarDeclaration *vresult; // variable corresponding to outId
|
||||
LabelDsymbol *returnLabel; // where the return goes
|
||||
Identifier *outId; // identifier for out statement
|
||||
VarDeclaration *vresult; // variable corresponding to outId
|
||||
LabelDsymbol *returnLabel; // where the return goes
|
||||
|
||||
DsymbolTable *localsymtab; // used to prevent symbols in different
|
||||
// scopes from having the same name
|
||||
VarDeclaration *vthis; // 'this' parameter (member and nested)
|
||||
VarDeclaration *v_arguments; // '_arguments' parameter
|
||||
DsymbolTable *localsymtab; // used to prevent symbols in different
|
||||
// scopes from having the same name
|
||||
VarDeclaration *vthis; // 'this' parameter (member and nested)
|
||||
VarDeclaration *v_arguments; // '_arguments' parameter
|
||||
#if IN_GCC
|
||||
VarDeclaration *v_argptr; // '_argptr' variable
|
||||
VarDeclaration *v_argptr; // '_argptr' variable
|
||||
#endif
|
||||
Dsymbols *parameters; // Array of VarDeclaration's for parameters
|
||||
DsymbolTable *labtab; // statement label symbol table
|
||||
Declaration *overnext; // next in overload list
|
||||
Loc endloc; // location of closing curly bracket
|
||||
int vtblIndex; // for member functions, index into vtbl[]
|
||||
int naked; // !=0 if naked
|
||||
int inlineAsm; // !=0 if has inline assembler
|
||||
Dsymbols *parameters; // Array of VarDeclaration's for parameters
|
||||
DsymbolTable *labtab; // statement label symbol table
|
||||
Declaration *overnext; // next in overload list
|
||||
Loc endloc; // location of closing curly bracket
|
||||
int vtblIndex; // for member functions, index into vtbl[]
|
||||
int naked; // !=0 if naked
|
||||
int inlineAsm; // !=0 if has inline assembler
|
||||
ILS inlineStatus;
|
||||
int inlineNest; // !=0 if nested inline
|
||||
int cantInterpret; // !=0 if cannot interpret function
|
||||
int semanticRun; // 1 semantic() run
|
||||
// 2 semantic2() run
|
||||
// 3 semantic3() started
|
||||
// 4 semantic3() done
|
||||
// 5 toObjFile() run
|
||||
// this function's frame ptr
|
||||
ForeachStatement *fes; // if foreach body, this is the foreach
|
||||
int introducing; // !=0 if 'introducing' function
|
||||
Type *tintro; // if !=NULL, then this is the type
|
||||
// of the 'introducing' function
|
||||
// this one is overriding
|
||||
int inferRetType; // !=0 if return type is to be inferred
|
||||
int inlineNest; // !=0 if nested inline
|
||||
int cantInterpret; // !=0 if cannot interpret function
|
||||
int semanticRun; // 1 semantic() run
|
||||
// 2 semantic2() run
|
||||
// 3 semantic3() started
|
||||
// 4 semantic3() done
|
||||
// 5 toObjFile() run
|
||||
// this function's frame ptr
|
||||
ForeachStatement *fes; // if foreach body, this is the foreach
|
||||
int introducing; // !=0 if 'introducing' function
|
||||
Type *tintro; // if !=NULL, then this is the type
|
||||
// of the 'introducing' function
|
||||
// this one is overriding
|
||||
int inferRetType; // !=0 if return type is to be inferred
|
||||
|
||||
// Things that should really go into Scope
|
||||
int hasReturnExp; // 1 if there's a return exp; statement
|
||||
// 2 if there's a throw statement
|
||||
// 4 if there's an assert(0)
|
||||
// 8 if there's inline asm
|
||||
int hasReturnExp; // 1 if there's a return exp; statement
|
||||
// 2 if there's a throw statement
|
||||
// 4 if there's an assert(0)
|
||||
// 8 if there's inline asm
|
||||
|
||||
// Support for NRVO (named return value optimization)
|
||||
int nrvo_can; // !=0 means we can do it
|
||||
VarDeclaration *nrvo_var; // variable to replace with shidden
|
||||
int nrvo_can; // !=0 means we can do it
|
||||
VarDeclaration *nrvo_var; // variable to replace with shidden
|
||||
#if IN_DMD
|
||||
Symbol *shidden; // hidden pointer passed to function
|
||||
Symbol *shidden; // hidden pointer passed to function
|
||||
#endif
|
||||
|
||||
#if DMDV2
|
||||
enum BUILTIN builtin; // set if this is a known, builtin
|
||||
// function we can evaluate at compile
|
||||
// time
|
||||
enum BUILTIN builtin; // set if this is a known, builtin
|
||||
// function we can evaluate at compile
|
||||
// time
|
||||
|
||||
int tookAddressOf; // set if someone took the address of
|
||||
// this function
|
||||
Dsymbols closureVars; // local variables in this function
|
||||
// which are referenced by nested
|
||||
// functions
|
||||
int tookAddressOf; // set if someone took the address of
|
||||
// this function
|
||||
Dsymbols closureVars; // local variables in this function
|
||||
// which are referenced by nested
|
||||
// functions
|
||||
#else
|
||||
int nestedFrameRef; // !=0 if nested variables referenced
|
||||
int nestedFrameRef; // !=0 if nested variables referenced
|
||||
#endif
|
||||
|
||||
FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageClass storage_class, Type *type);
|
||||
@@ -741,7 +741,7 @@ struct FuncDeclaration : Declaration
|
||||
LabelDsymbol *searchLabel(Identifier *ident);
|
||||
AggregateDeclaration *isThis();
|
||||
AggregateDeclaration *isMember2();
|
||||
int getLevel(Loc loc, FuncDeclaration *fd); // lexical nesting level difference
|
||||
int getLevel(Loc loc, FuncDeclaration *fd); // lexical nesting level difference
|
||||
void appendExp(Expression *e);
|
||||
void appendState(Statement *s);
|
||||
char *mangle();
|
||||
@@ -780,8 +780,8 @@ struct FuncDeclaration : Declaration
|
||||
|
||||
#if IN_DMD
|
||||
Symbol *toSymbol();
|
||||
Symbol *toThunkSymbol(int offset); // thunk version
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
Symbol *toThunkSymbol(int offset); // thunk version
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
int cvMember(unsigned char *p);
|
||||
void buildClosure(IRState *irs);
|
||||
#endif
|
||||
@@ -822,17 +822,17 @@ struct FuncDeclaration : Declaration
|
||||
|
||||
#if DMDV2
|
||||
FuncDeclaration *resolveFuncCall(Scope *sc, Loc loc, Dsymbol *s,
|
||||
Objects *tiargs,
|
||||
Expression *ethis,
|
||||
Expressions *arguments,
|
||||
int flags);
|
||||
Objects *tiargs,
|
||||
Expression *ethis,
|
||||
Expressions *arguments,
|
||||
int flags);
|
||||
#endif
|
||||
|
||||
struct FuncAliasDeclaration : FuncDeclaration
|
||||
{
|
||||
FuncDeclaration *funcalias;
|
||||
PROT importprot; // if generated by import, store its protection
|
||||
|
||||
PROT importprot; // if generated by import, store its protection
|
||||
|
||||
FuncAliasDeclaration(FuncDeclaration *funcalias);
|
||||
|
||||
FuncAliasDeclaration *isFuncAliasDeclaration() { return this; }
|
||||
@@ -844,10 +844,10 @@ struct FuncAliasDeclaration : FuncDeclaration
|
||||
|
||||
struct FuncLiteralDeclaration : FuncDeclaration
|
||||
{
|
||||
enum TOK tok; // TOKfunction or TOKdelegate
|
||||
enum TOK tok; // TOKfunction or TOKdelegate
|
||||
|
||||
FuncLiteralDeclaration(Loc loc, Loc endloc, Type *type, enum TOK tok,
|
||||
ForeachStatement *fes);
|
||||
ForeachStatement *fes);
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
Dsymbol *syntaxCopy(Dsymbol *);
|
||||
int isNested();
|
||||
@@ -931,7 +931,7 @@ struct StaticCtorDeclaration : FuncDeclaration
|
||||
};
|
||||
|
||||
struct StaticDtorDeclaration : FuncDeclaration
|
||||
{ VarDeclaration *vgate; // 'gate' variable
|
||||
{ VarDeclaration *vgate; // 'gate' variable
|
||||
|
||||
StaticDtorDeclaration(Loc loc, Loc endloc);
|
||||
Dsymbol *syntaxCopy(Dsymbol *);
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
/********************************************
|
||||
* Convert from expression to delegate that returns the expression,
|
||||
* i.e. convert:
|
||||
* expr
|
||||
* expr
|
||||
* to:
|
||||
* t delegate() { return expr; }
|
||||
* t delegate() { return expr; }
|
||||
*/
|
||||
|
||||
Expression *Expression::toDelegate(Scope *sc, Type *t)
|
||||
@@ -33,11 +33,11 @@ Expression *Expression::toDelegate(Scope *sc, Type *t)
|
||||
//printf("Expression::toDelegate(t = %s) %s\n", t->toChars(), toChars());
|
||||
TypeFunction *tf = new TypeFunction(NULL, t, 0, LINKd);
|
||||
FuncLiteralDeclaration *fld =
|
||||
new FuncLiteralDeclaration(loc, loc, tf, TOKdelegate, NULL);
|
||||
new FuncLiteralDeclaration(loc, loc, tf, TOKdelegate, NULL);
|
||||
Expression *e;
|
||||
#if 1
|
||||
sc = sc->push();
|
||||
sc->parent = fld; // set current function to be the delegate
|
||||
sc->parent = fld; // set current function to be the delegate
|
||||
e = this;
|
||||
e->scanForNestedRef(sc);
|
||||
sc = sc->pop();
|
||||
@@ -60,14 +60,14 @@ void arrayExpressionScanForNestedRef(Scope *sc, Expressions *a)
|
||||
//printf("arrayExpressionScanForNestedRef(%p)\n", a);
|
||||
if (a)
|
||||
{
|
||||
for (int i = 0; i < a->dim; i++)
|
||||
{ Expression *e = (Expression *)a->data[i];
|
||||
for (int i = 0; i < a->dim; i++)
|
||||
{ Expression *e = (Expression *)a->data[i];
|
||||
|
||||
if (e)
|
||||
{
|
||||
e->scanForNestedRef(sc);
|
||||
}
|
||||
}
|
||||
if (e)
|
||||
{
|
||||
e->scanForNestedRef(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ void SymOffExp::scanForNestedRef(Scope *sc)
|
||||
//printf("SymOffExp::scanForNestedRef(%s)\n", toChars());
|
||||
VarDeclaration *v = var->isVarDeclaration();
|
||||
if (v)
|
||||
v->checkNestedReference(sc, 0);
|
||||
v->checkNestedReference(sc, 0);
|
||||
}
|
||||
|
||||
void VarExp::scanForNestedRef(Scope *sc)
|
||||
@@ -89,7 +89,7 @@ void VarExp::scanForNestedRef(Scope *sc)
|
||||
//printf("VarExp::scanForNestedRef(%s)\n", toChars());
|
||||
VarDeclaration *v = var->isVarDeclaration();
|
||||
if (v)
|
||||
v->checkNestedReference(sc, 0);
|
||||
v->checkNestedReference(sc, 0);
|
||||
}
|
||||
|
||||
void ThisExp::scanForNestedRef(Scope *sc)
|
||||
@@ -120,7 +120,7 @@ void NewExp::scanForNestedRef(Scope *sc)
|
||||
//printf("NewExp::scanForNestedRef(Scope *sc): %s\n", toChars());
|
||||
|
||||
if (thisexp)
|
||||
thisexp->scanForNestedRef(sc);
|
||||
thisexp->scanForNestedRef(sc);
|
||||
arrayExpressionScanForNestedRef(sc, newargs);
|
||||
arrayExpressionScanForNestedRef(sc, arguments);
|
||||
}
|
||||
@@ -149,8 +149,8 @@ void IndexExp::scanForNestedRef(Scope *sc)
|
||||
e1->scanForNestedRef(sc);
|
||||
|
||||
if (lengthVar)
|
||||
{ //printf("lengthVar\n");
|
||||
lengthVar->parent = sc->parent;
|
||||
{ //printf("lengthVar\n");
|
||||
lengthVar->parent = sc->parent;
|
||||
}
|
||||
e2->scanForNestedRef(sc);
|
||||
}
|
||||
@@ -161,13 +161,13 @@ void SliceExp::scanForNestedRef(Scope *sc)
|
||||
e1->scanForNestedRef(sc);
|
||||
|
||||
if (lengthVar)
|
||||
{ //printf("lengthVar\n");
|
||||
lengthVar->parent = sc->parent;
|
||||
{ //printf("lengthVar\n");
|
||||
lengthVar->parent = sc->parent;
|
||||
}
|
||||
if (lwr)
|
||||
lwr->scanForNestedRef(sc);
|
||||
lwr->scanForNestedRef(sc);
|
||||
if (upr)
|
||||
upr->scanForNestedRef(sc);
|
||||
upr->scanForNestedRef(sc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
764
dmd/dsymbol.c
764
dmd/dsymbol.c
File diff suppressed because it is too large
Load Diff
@@ -102,7 +102,7 @@ namespace llvm
|
||||
enum PROT
|
||||
{
|
||||
PROTundefined,
|
||||
PROTnone, // no access
|
||||
PROTnone, // no access
|
||||
PROTprivate,
|
||||
PROTpackage,
|
||||
PROTprotected,
|
||||
@@ -114,13 +114,13 @@ enum PROT
|
||||
*/
|
||||
enum PASS
|
||||
{
|
||||
PASSinit, // initial state
|
||||
PASSsemantic, // semantic() started
|
||||
PASSsemanticdone, // semantic() done
|
||||
PASSsemantic2, // semantic2() run
|
||||
PASSsemantic3, // semantic3() started
|
||||
PASSsemantic3done, // semantic3() done
|
||||
PASSobj, // toObjFile() run
|
||||
PASSinit, // initial state
|
||||
PASSsemantic, // semantic() started
|
||||
PASSsemanticdone, // semantic() done
|
||||
PASSsemantic2, // semantic2() run
|
||||
PASSsemantic3, // semantic3() started
|
||||
PASSsemantic3done, // semantic3() done
|
||||
PASSobj, // toObjFile() run
|
||||
};
|
||||
|
||||
struct Dsymbol : Object
|
||||
@@ -129,12 +129,12 @@ struct Dsymbol : Object
|
||||
Identifier *c_ident;
|
||||
Dsymbol *parent;
|
||||
#if IN_DMD
|
||||
Symbol *csym; // symbol for code generator
|
||||
Symbol *isym; // import version of csym
|
||||
Symbol *csym; // symbol for code generator
|
||||
Symbol *isym; // import version of csym
|
||||
#endif
|
||||
unsigned char *comment; // documentation comment for this Dsymbol
|
||||
Loc loc; // where defined
|
||||
Scope *scope; // !=NULL means context to use for semantic()
|
||||
unsigned char *comment; // documentation comment for this Dsymbol
|
||||
Loc loc; // where defined
|
||||
Scope *scope; // !=NULL means context to use for semantic()
|
||||
|
||||
Dsymbol();
|
||||
Dsymbol(Identifier *);
|
||||
@@ -152,13 +152,13 @@ struct Dsymbol : Object
|
||||
Dsymbol *toParent2();
|
||||
TemplateInstance *inTemplateInstance();
|
||||
|
||||
int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol()
|
||||
int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol()
|
||||
|
||||
static Array *arraySyntaxCopy(Array *a);
|
||||
|
||||
virtual const char *toPrettyChars();
|
||||
virtual const char *kind();
|
||||
virtual Dsymbol *toAlias(); // resolve real symbol
|
||||
virtual Dsymbol *toAlias(); // resolve real symbol
|
||||
virtual int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
||||
virtual void setScope(Scope *sc);
|
||||
virtual void importAll(Scope *sc);
|
||||
@@ -180,21 +180,21 @@ struct Dsymbol : Object
|
||||
virtual unsigned size(Loc loc);
|
||||
virtual int isforwardRef();
|
||||
virtual void defineRef(Dsymbol *s);
|
||||
virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member
|
||||
virtual ClassDeclaration *isClassMember(); // are we a member of a class?
|
||||
virtual int isExport(); // is Dsymbol exported?
|
||||
virtual int isImportedSymbol(); // is Dsymbol imported?
|
||||
virtual int isDeprecated(); // is Dsymbol deprecated?
|
||||
virtual AggregateDeclaration *isThis(); // is a 'this' required to access the member
|
||||
virtual ClassDeclaration *isClassMember(); // are we a member of a class?
|
||||
virtual int isExport(); // is Dsymbol exported?
|
||||
virtual int isImportedSymbol(); // is Dsymbol imported?
|
||||
virtual int isDeprecated(); // is Dsymbol deprecated?
|
||||
#if DMDV2
|
||||
virtual int isOverloadable();
|
||||
#endif
|
||||
virtual LabelDsymbol *isLabel(); // is this a LabelDsymbol?
|
||||
virtual AggregateDeclaration *isMember(); // is this symbol a member of an AggregateDeclaration?
|
||||
virtual Type *getType(); // is this a type?
|
||||
virtual LabelDsymbol *isLabel(); // is this a LabelDsymbol?
|
||||
virtual AggregateDeclaration *isMember(); // is this symbol a member of an AggregateDeclaration?
|
||||
virtual Type *getType(); // is this a type?
|
||||
virtual char *mangle();
|
||||
virtual int needThis(); // need a 'this' pointer?
|
||||
virtual int needThis(); // need a 'this' pointer?
|
||||
virtual enum PROT prot();
|
||||
virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees
|
||||
virtual Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees
|
||||
virtual int oneMember(Dsymbol **ps);
|
||||
static int oneMembers(Array *members, Dsymbol **ps);
|
||||
virtual int hasPointers();
|
||||
@@ -208,14 +208,14 @@ struct Dsymbol : Object
|
||||
#if IN_DMD
|
||||
// Backend
|
||||
|
||||
virtual Symbol *toSymbol(); // to backend symbol
|
||||
virtual void toObjFile(int multiobj); // compile to .obj file
|
||||
virtual int cvMember(unsigned char *p); // emit cv debug info for member
|
||||
virtual Symbol *toSymbol(); // to backend symbol
|
||||
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
|
||||
static Symbol *toImport(Symbol *s); // to backend import symbol
|
||||
Symbol *toImport(); // to backend import symbol
|
||||
static Symbol *toImport(Symbol *s); // to backend import symbol
|
||||
|
||||
Symbol *toSymbolX(const char *prefix, int sclass, TYPE *t, const char *suffix); // helper
|
||||
Symbol *toSymbolX(const char *prefix, int sclass, TYPE *t, const char *suffix); // helper
|
||||
#endif
|
||||
|
||||
// Eliminate need for dynamic_cast
|
||||
@@ -281,11 +281,11 @@ struct Dsymbol : Object
|
||||
|
||||
struct ScopeDsymbol : Dsymbol
|
||||
{
|
||||
Array *members; // all Dsymbol's in this scope
|
||||
DsymbolTable *symtab; // members[] sorted into table
|
||||
Array *members; // all Dsymbol's in this scope
|
||||
DsymbolTable *symtab; // members[] sorted into table
|
||||
|
||||
Array *imports; // imported ScopeDsymbol's
|
||||
unsigned char *prots; // array of PROT, one for each import
|
||||
Array *imports; // imported ScopeDsymbol's
|
||||
unsigned char *prots; // array of PROT, one for each import
|
||||
|
||||
ScopeDsymbol();
|
||||
ScopeDsymbol(Identifier *id);
|
||||
@@ -324,9 +324,9 @@ struct WithScopeSymbol : ScopeDsymbol
|
||||
|
||||
struct ArrayScopeSymbol : ScopeDsymbol
|
||||
{
|
||||
Expression *exp; // IndexExp or SliceExp
|
||||
TypeTuple *type; // for tuple[length]
|
||||
TupleDeclaration *td; // for tuples of objects
|
||||
Expression *exp; // IndexExp or SliceExp
|
||||
TypeTuple *type; // for tuple[length]
|
||||
TupleDeclaration *td; // for tuples of objects
|
||||
Scope *sc;
|
||||
|
||||
ArrayScopeSymbol(Expression *e);
|
||||
@@ -342,7 +342,7 @@ struct ArrayScopeSymbol : ScopeDsymbol
|
||||
#if DMDV2
|
||||
struct OverloadSet : Dsymbol
|
||||
{
|
||||
Dsymbols a; // array of Dsymbols
|
||||
Dsymbols a; // array of Dsymbols
|
||||
|
||||
OverloadSet();
|
||||
void push(Dsymbol *s);
|
||||
@@ -368,7 +368,7 @@ struct DsymbolTable : Object
|
||||
|
||||
// Look for Dsymbol in table. If there, return it. If not, insert s and return that.
|
||||
Dsymbol *update(Dsymbol *s);
|
||||
Dsymbol *insert(Identifier *ident, Dsymbol *s); // when ident and s are not the same
|
||||
Dsymbol *insert(Identifier *ident, Dsymbol *s); // when ident and s are not the same
|
||||
};
|
||||
|
||||
#endif /* DMD_DSYMBOL_H */
|
||||
|
||||
34
dmd/dump.c
34
dmd/dump.c
@@ -23,7 +23,7 @@ static void indent(int indent)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < indent; i++)
|
||||
printf(" ");
|
||||
printf(" ");
|
||||
}
|
||||
|
||||
static char *type_print(Type *type)
|
||||
@@ -34,12 +34,12 @@ static char *type_print(Type *type)
|
||||
void dumpExpressions(int i, Expressions *exps)
|
||||
{
|
||||
for (size_t j = 0; j < exps->dim; j++)
|
||||
{ Expression *e = (Expression *)exps->data[j];
|
||||
indent(i);
|
||||
printf("(\n");
|
||||
e->dump(i + 2);
|
||||
indent(i);
|
||||
printf(")\n");
|
||||
{ Expression *e = (Expression *)exps->data[j];
|
||||
indent(i);
|
||||
printf("(\n");
|
||||
e->dump(i + 2);
|
||||
indent(i);
|
||||
printf(")\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ void UnaExp::dump(int i)
|
||||
indent(i);
|
||||
printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1);
|
||||
if (e1)
|
||||
e1->dump(i + 2);
|
||||
e1->dump(i + 2);
|
||||
}
|
||||
|
||||
void CallExp::dump(int i)
|
||||
@@ -92,11 +92,11 @@ void SliceExp::dump(int i)
|
||||
indent(i);
|
||||
printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1);
|
||||
if (e1)
|
||||
e1->dump(i + 2);
|
||||
e1->dump(i + 2);
|
||||
if (lwr)
|
||||
lwr->dump(i + 2);
|
||||
lwr->dump(i + 2);
|
||||
if (upr)
|
||||
upr->dump(i + 2);
|
||||
upr->dump(i + 2);
|
||||
}
|
||||
|
||||
void DotIdExp::dump(int i)
|
||||
@@ -104,7 +104,7 @@ void DotIdExp::dump(int i)
|
||||
indent(i);
|
||||
printf("%p %s type=%s ident=%s e1=%p\n", this, Token::toChars(op), type_print(type), ident->toChars(), e1);
|
||||
if (e1)
|
||||
e1->dump(i + 2);
|
||||
e1->dump(i + 2);
|
||||
}
|
||||
|
||||
void DotVarExp::dump(int i)
|
||||
@@ -112,7 +112,7 @@ void DotVarExp::dump(int i)
|
||||
indent(i);
|
||||
printf("%p %s type=%s var='%s' e1=%p\n", this, Token::toChars(op), type_print(type), var->toChars(), e1);
|
||||
if (e1)
|
||||
e1->dump(i + 2);
|
||||
e1->dump(i + 2);
|
||||
}
|
||||
|
||||
void DotTemplateInstanceExp::dump(int i)
|
||||
@@ -120,7 +120,7 @@ void DotTemplateInstanceExp::dump(int i)
|
||||
indent(i);
|
||||
printf("%p %s type=%s ti='%s' e1=%p\n", this, Token::toChars(op), type_print(type), ti->toChars(), e1);
|
||||
if (e1)
|
||||
e1->dump(i + 2);
|
||||
e1->dump(i + 2);
|
||||
}
|
||||
|
||||
void DelegateExp::dump(int i)
|
||||
@@ -128,7 +128,7 @@ void DelegateExp::dump(int i)
|
||||
indent(i);
|
||||
printf("%p %s func=%s type=%s e1=%p\n", this, Token::toChars(op), func->toChars(), type_print(type), e1);
|
||||
if (e1)
|
||||
e1->dump(i + 2);
|
||||
e1->dump(i + 2);
|
||||
}
|
||||
|
||||
void BinExp::dump(int i)
|
||||
@@ -136,9 +136,9 @@ void BinExp::dump(int i)
|
||||
indent(i);
|
||||
printf("%p %s type=%s e1=%p e2=%p\n", this, Token::toChars(op), type_print(type), e1, e2);
|
||||
if (e1)
|
||||
e1->dump(i + 2);
|
||||
e1->dump(i + 2);
|
||||
if (e2)
|
||||
e2->dump(i + 2);
|
||||
e2->dump(i + 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
2456
dmd/entity.c
2456
dmd/entity.c
File diff suppressed because it is too large
Load Diff
298
dmd/enum.c
298
dmd/enum.c
@@ -38,15 +38,15 @@ Dsymbol *EnumDeclaration::syntaxCopy(Dsymbol *s)
|
||||
{
|
||||
Type *t = NULL;
|
||||
if (memtype)
|
||||
t = memtype->syntaxCopy();
|
||||
t = memtype->syntaxCopy();
|
||||
|
||||
EnumDeclaration *ed;
|
||||
if (s)
|
||||
{ ed = (EnumDeclaration *)s;
|
||||
ed->memtype = t;
|
||||
{ ed = (EnumDeclaration *)s;
|
||||
ed->memtype = t;
|
||||
}
|
||||
else
|
||||
ed = new EnumDeclaration(loc, ident, t);
|
||||
ed = new EnumDeclaration(loc, ident, t);
|
||||
ScopeDsymbol::syntaxCopy(ed);
|
||||
return ed;
|
||||
}
|
||||
@@ -59,14 +59,14 @@ void EnumDeclaration::semantic(Scope *sc)
|
||||
|
||||
//printf("EnumDeclaration::semantic(sd = %p, '%s')\n", sc->scopesym, sc->scopesym->toChars());
|
||||
if (!memtype)
|
||||
memtype = Type::tint32;
|
||||
memtype = Type::tint32;
|
||||
|
||||
if (symtab) // if already done
|
||||
{ if (isdone || !scope)
|
||||
return; // semantic() already completed
|
||||
if (symtab) // if already done
|
||||
{ if (isdone || !scope)
|
||||
return; // semantic() already completed
|
||||
}
|
||||
else
|
||||
symtab = new DsymbolTable();
|
||||
symtab = new DsymbolTable();
|
||||
|
||||
Scope *scx = NULL;
|
||||
if (scope)
|
||||
@@ -78,7 +78,7 @@ void EnumDeclaration::semantic(Scope *sc)
|
||||
unsigned dprogress_save = Module::dprogress;
|
||||
|
||||
if (sc->stc & STCdeprecated)
|
||||
isdeprecated = 1;
|
||||
isdeprecated = 1;
|
||||
|
||||
parent = sc->scopesym;
|
||||
memtype = memtype->semantic(loc, sc);
|
||||
@@ -86,17 +86,17 @@ void EnumDeclaration::semantic(Scope *sc)
|
||||
/* Check to see if memtype is forward referenced
|
||||
*/
|
||||
if (memtype->ty == Tenum)
|
||||
{ EnumDeclaration *sym = (EnumDeclaration *)memtype->toDsymbol(sc);
|
||||
if (!sym->memtype)
|
||||
{
|
||||
error("base enum %s is forward referenced", sym->toChars());
|
||||
memtype = Type::tint32;
|
||||
}
|
||||
{ EnumDeclaration *sym = (EnumDeclaration *)memtype->toDsymbol(sc);
|
||||
if (!sym->memtype)
|
||||
{
|
||||
error("base enum %s is forward referenced", sym->toChars());
|
||||
memtype = Type::tint32;
|
||||
}
|
||||
}
|
||||
|
||||
if (!memtype->isintegral())
|
||||
{ error("base type must be of integral type, not %s", memtype->toChars());
|
||||
memtype = Type::tint32;
|
||||
{ error("base type must be of integral type, not %s", memtype->toChars());
|
||||
memtype = Type::tint32;
|
||||
}
|
||||
|
||||
isdone = 1;
|
||||
@@ -107,135 +107,135 @@ void EnumDeclaration::semantic(Scope *sc)
|
||||
sce = sc->push(this);
|
||||
sce->parent = this;
|
||||
number = 0;
|
||||
if (!members) // enum ident;
|
||||
return;
|
||||
if (!members) // enum ident;
|
||||
return;
|
||||
if (members->dim == 0)
|
||||
error("enum %s must have at least one member", toChars());
|
||||
error("enum %s must have at least one member", toChars());
|
||||
int first = 1;
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
||||
Expression *e;
|
||||
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
||||
Expression *e;
|
||||
|
||||
if (!em)
|
||||
/* The e->semantic(sce) can insert other symbols, such as
|
||||
* template instances and function literals.
|
||||
*/
|
||||
continue;
|
||||
if (!em)
|
||||
/* The e->semantic(sce) can insert other symbols, such as
|
||||
* template instances and function literals.
|
||||
*/
|
||||
continue;
|
||||
|
||||
//printf("Enum member '%s'\n",em->toChars());
|
||||
e = em->value;
|
||||
if (e)
|
||||
{
|
||||
assert(e->dyncast() == DYNCAST_EXPRESSION);
|
||||
e = e->semantic(sce);
|
||||
e = e->optimize(WANTvalue);
|
||||
// Need to copy it because we're going to change the type
|
||||
e = e->copy();
|
||||
e = e->implicitCastTo(sc, memtype);
|
||||
e = e->optimize(WANTvalue);
|
||||
number = e->toInteger();
|
||||
e->type = t;
|
||||
}
|
||||
else
|
||||
{ // Default is the previous number plus 1
|
||||
//printf("Enum member '%s'\n",em->toChars());
|
||||
e = em->value;
|
||||
if (e)
|
||||
{
|
||||
assert(e->dyncast() == DYNCAST_EXPRESSION);
|
||||
e = e->semantic(sce);
|
||||
e = e->optimize(WANTvalue);
|
||||
// Need to copy it because we're going to change the type
|
||||
e = e->copy();
|
||||
e = e->implicitCastTo(sc, memtype);
|
||||
e = e->optimize(WANTvalue);
|
||||
number = e->toInteger();
|
||||
e->type = t;
|
||||
}
|
||||
else
|
||||
{ // Default is the previous number plus 1
|
||||
|
||||
// Check for overflow
|
||||
if (!first)
|
||||
{
|
||||
switch (t->toBasetype()->ty)
|
||||
{
|
||||
case Tbool:
|
||||
if (number == 2) goto Loverflow;
|
||||
break;
|
||||
// Check for overflow
|
||||
if (!first)
|
||||
{
|
||||
switch (t->toBasetype()->ty)
|
||||
{
|
||||
case Tbool:
|
||||
if (number == 2) goto Loverflow;
|
||||
break;
|
||||
|
||||
case Tint8:
|
||||
if (number == 128) goto Loverflow;
|
||||
break;
|
||||
case Tint8:
|
||||
if (number == 128) goto Loverflow;
|
||||
break;
|
||||
|
||||
case Tchar:
|
||||
case Tuns8:
|
||||
if (number == 256) goto Loverflow;
|
||||
break;
|
||||
case Tchar:
|
||||
case Tuns8:
|
||||
if (number == 256) goto Loverflow;
|
||||
break;
|
||||
|
||||
case Tint16:
|
||||
if (number == 0x8000) goto Loverflow;
|
||||
break;
|
||||
case Tint16:
|
||||
if (number == 0x8000) goto Loverflow;
|
||||
break;
|
||||
|
||||
case Twchar:
|
||||
case Tuns16:
|
||||
if (number == 0x10000) goto Loverflow;
|
||||
break;
|
||||
case Twchar:
|
||||
case Tuns16:
|
||||
if (number == 0x10000) goto Loverflow;
|
||||
break;
|
||||
|
||||
case Tint32:
|
||||
if (number == 0x80000000) goto Loverflow;
|
||||
break;
|
||||
case Tint32:
|
||||
if (number == 0x80000000) goto Loverflow;
|
||||
break;
|
||||
|
||||
case Tdchar:
|
||||
case Tuns32:
|
||||
if (number == 0x100000000LL) goto Loverflow;
|
||||
break;
|
||||
case Tdchar:
|
||||
case Tuns32:
|
||||
if (number == 0x100000000LL) goto Loverflow;
|
||||
break;
|
||||
|
||||
case Tint64:
|
||||
if (number == 0x8000000000000000LL) goto Loverflow;
|
||||
break;
|
||||
case Tint64:
|
||||
if (number == 0x8000000000000000LL) goto Loverflow;
|
||||
break;
|
||||
|
||||
case Tuns64:
|
||||
if (number == 0) goto Loverflow;
|
||||
break;
|
||||
case Tuns64:
|
||||
if (number == 0) goto Loverflow;
|
||||
break;
|
||||
|
||||
Loverflow:
|
||||
error("overflow of enum value");
|
||||
break;
|
||||
Loverflow:
|
||||
error("overflow of enum value");
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
e = new IntegerExp(em->loc, number, t);
|
||||
}
|
||||
em->value = e;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
e = new IntegerExp(em->loc, number, t);
|
||||
}
|
||||
em->value = e;
|
||||
|
||||
// Add to symbol table only after evaluating 'value'
|
||||
if (isAnonymous())
|
||||
{
|
||||
//sce->enclosing->insert(em);
|
||||
for (Scope *scx = sce->enclosing; scx; scx = scx->enclosing)
|
||||
{
|
||||
if (scx->scopesym)
|
||||
{
|
||||
if (!scx->scopesym->symtab)
|
||||
scx->scopesym->symtab = new DsymbolTable();
|
||||
em->addMember(sce, scx->scopesym, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
em->addMember(sc, this, 1);
|
||||
// Add to symbol table only after evaluating 'value'
|
||||
if (isAnonymous())
|
||||
{
|
||||
//sce->enclosing->insert(em);
|
||||
for (Scope *scx = sce->enclosing; scx; scx = scx->enclosing)
|
||||
{
|
||||
if (scx->scopesym)
|
||||
{
|
||||
if (!scx->scopesym->symtab)
|
||||
scx->scopesym->symtab = new DsymbolTable();
|
||||
em->addMember(sce, scx->scopesym, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
em->addMember(sc, this, 1);
|
||||
|
||||
if (first)
|
||||
{ first = 0;
|
||||
defaultval = number;
|
||||
minval = number;
|
||||
maxval = number;
|
||||
}
|
||||
else if (memtype->isunsigned())
|
||||
{
|
||||
if (number < minval)
|
||||
minval = number;
|
||||
if (number > maxval)
|
||||
maxval = number;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sinteger_t)number < (sinteger_t)minval)
|
||||
minval = number;
|
||||
if ((sinteger_t)number > (sinteger_t)maxval)
|
||||
maxval = number;
|
||||
}
|
||||
if (first)
|
||||
{ first = 0;
|
||||
defaultval = number;
|
||||
minval = number;
|
||||
maxval = number;
|
||||
}
|
||||
else if (memtype->isunsigned())
|
||||
{
|
||||
if (number < minval)
|
||||
minval = number;
|
||||
if (number > maxval)
|
||||
maxval = number;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((sinteger_t)number < (sinteger_t)minval)
|
||||
minval = number;
|
||||
if ((sinteger_t)number > (sinteger_t)maxval)
|
||||
maxval = number;
|
||||
}
|
||||
|
||||
number++;
|
||||
number++;
|
||||
}
|
||||
//printf("defaultval = %lld\n", defaultval);
|
||||
|
||||
@@ -246,7 +246,7 @@ void EnumDeclaration::semantic(Scope *sc)
|
||||
int EnumDeclaration::oneMember(Dsymbol **ps)
|
||||
{
|
||||
if (isAnonymous())
|
||||
return Dsymbol::oneMembers(members, ps);
|
||||
return Dsymbol::oneMembers(members, ps);
|
||||
return Dsymbol::oneMember(ps);
|
||||
}
|
||||
|
||||
@@ -255,32 +255,32 @@ void EnumDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
|
||||
buf->writestring("enum ");
|
||||
if (ident)
|
||||
{ buf->writestring(ident->toChars());
|
||||
buf->writeByte(' ');
|
||||
{ buf->writestring(ident->toChars());
|
||||
buf->writeByte(' ');
|
||||
}
|
||||
if (memtype)
|
||||
{
|
||||
buf->writestring(": ");
|
||||
memtype->toCBuffer(buf, NULL, hgs);
|
||||
buf->writestring(": ");
|
||||
memtype->toCBuffer(buf, NULL, hgs);
|
||||
}
|
||||
if (!members)
|
||||
{
|
||||
buf->writeByte(';');
|
||||
buf->writenl();
|
||||
return;
|
||||
buf->writeByte(';');
|
||||
buf->writenl();
|
||||
return;
|
||||
}
|
||||
buf->writenl();
|
||||
buf->writeByte('{');
|
||||
buf->writenl();
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
||||
if (!em)
|
||||
continue;
|
||||
//buf->writestring(" ");
|
||||
em->toCBuffer(buf, hgs);
|
||||
buf->writeByte(',');
|
||||
buf->writenl();
|
||||
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
||||
if (!em)
|
||||
continue;
|
||||
//buf->writestring(" ");
|
||||
em->toCBuffer(buf, hgs);
|
||||
buf->writeByte(',');
|
||||
buf->writenl();
|
||||
}
|
||||
buf->writeByte('}');
|
||||
buf->writenl();
|
||||
@@ -314,16 +314,16 @@ Dsymbol *EnumMember::syntaxCopy(Dsymbol *s)
|
||||
{
|
||||
Expression *e = NULL;
|
||||
if (value)
|
||||
e = value->syntaxCopy();
|
||||
e = value->syntaxCopy();
|
||||
|
||||
EnumMember *em;
|
||||
if (s)
|
||||
{ em = (EnumMember *)s;
|
||||
em->loc = loc;
|
||||
em->value = e;
|
||||
{ em = (EnumMember *)s;
|
||||
em->loc = loc;
|
||||
em->value = e;
|
||||
}
|
||||
else
|
||||
em = new EnumMember(loc, ident, e);
|
||||
em = new EnumMember(loc, ident, e);
|
||||
return em;
|
||||
}
|
||||
|
||||
@@ -332,8 +332,8 @@ void EnumMember::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
buf->writestring(ident->toChars());
|
||||
if (value)
|
||||
{
|
||||
buf->writestring(" = ");
|
||||
value->toCBuffer(buf, hgs);
|
||||
buf->writestring(" = ");
|
||||
value->toCBuffer(buf, hgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
dmd/enum.h
16
dmd/enum.h
@@ -29,21 +29,21 @@ struct HdrGenState;
|
||||
struct EnumDeclaration : ScopeDsymbol
|
||||
{ /* enum ident : memtype { ... }
|
||||
*/
|
||||
Type *type; // the TypeEnum
|
||||
Type *memtype; // type of the members
|
||||
Type *type; // the TypeEnum
|
||||
Type *memtype; // type of the members
|
||||
|
||||
#if DMDV1
|
||||
dinteger_t maxval;
|
||||
dinteger_t minval;
|
||||
dinteger_t defaultval; // default initializer
|
||||
dinteger_t defaultval; // default initializer
|
||||
#else
|
||||
Expression *maxval;
|
||||
Expression *minval;
|
||||
Expression *defaultval; // default initializer
|
||||
Expression *defaultval; // default initializer
|
||||
#endif
|
||||
int isdeprecated;
|
||||
int isdone; // 0: not done
|
||||
// 1: semantic() successfully completed
|
||||
int isdone; // 0: not done
|
||||
// 1: semantic() successfully completed
|
||||
|
||||
EnumDeclaration(Loc loc, Identifier *id, Type *memtype);
|
||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||
@@ -55,7 +55,7 @@ struct EnumDeclaration : ScopeDsymbol
|
||||
#if DMDV2
|
||||
Dsymbol *search(Loc, Identifier *ident, int flags);
|
||||
#endif
|
||||
int isDeprecated(); // is Dsymbol deprecated?
|
||||
int isDeprecated(); // is Dsymbol deprecated?
|
||||
|
||||
void emitComment(Scope *sc);
|
||||
void toJsonBuffer(OutBuffer *buf);
|
||||
@@ -64,7 +64,7 @@ struct EnumDeclaration : ScopeDsymbol
|
||||
EnumDeclaration *isEnumDeclaration() { return this; }
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toDebug();
|
||||
int cvMember(unsigned char *p);
|
||||
|
||||
|
||||
8486
dmd/expression.c
8486
dmd/expression.c
File diff suppressed because it is too large
Load Diff
128
dmd/expression.h
128
dmd/expression.h
@@ -53,7 +53,7 @@ struct IRState;
|
||||
|
||||
struct dt_t;
|
||||
struct elem;
|
||||
struct Symbol; // back end symbol
|
||||
struct Symbol; // back end symbol
|
||||
#endif
|
||||
|
||||
#ifdef IN_GCC
|
||||
@@ -89,17 +89,17 @@ struct IntRange
|
||||
|
||||
struct Expression : Object
|
||||
{
|
||||
Loc loc; // file location
|
||||
enum TOK op; // handy to minimize use of dynamic_cast
|
||||
Type *type; // !=NULL means that semantic() has been run
|
||||
int size; // # of bytes in Expression so we can copy() it
|
||||
Loc loc; // file location
|
||||
enum TOK op; // handy to minimize use of dynamic_cast
|
||||
Type *type; // !=NULL means that semantic() has been run
|
||||
int size; // # of bytes in Expression so we can copy() it
|
||||
|
||||
Expression(Loc loc, enum TOK op, int size);
|
||||
Expression *copy();
|
||||
virtual Expression *syntaxCopy();
|
||||
virtual Expression *semantic(Scope *sc);
|
||||
|
||||
int dyncast() { return DYNCAST_EXPRESSION; } // kludge for template.isExpression()
|
||||
int dyncast() { return DYNCAST_EXPRESSION; } // kludge for template.isExpression()
|
||||
|
||||
void print();
|
||||
char *toChars();
|
||||
@@ -140,8 +140,8 @@ struct Expression : Object
|
||||
virtual void scanForNestedRef(Scope *sc);
|
||||
|
||||
virtual Expression *optimize(int result);
|
||||
#define WANTflags 1
|
||||
#define WANTvalue 2
|
||||
#define WANTflags 1
|
||||
#define WANTvalue 2
|
||||
#define WANTinterpret 4
|
||||
|
||||
virtual Expression *interpret(InterState *istate);
|
||||
@@ -350,7 +350,7 @@ struct SuperExp : ThisExp
|
||||
|
||||
struct NullExp : Expression
|
||||
{
|
||||
unsigned char committed; // !=0 if type is committed
|
||||
unsigned char committed; // !=0 if type is committed
|
||||
|
||||
NullExp(Loc loc, Type *t = NULL);
|
||||
Expression *semantic(Scope *sc);
|
||||
@@ -372,11 +372,11 @@ struct NullExp : Expression
|
||||
|
||||
struct StringExp : Expression
|
||||
{
|
||||
void *string; // char, wchar, or dchar data
|
||||
size_t len; // number of chars, wchars, or dchars
|
||||
unsigned char sz; // 1: char, 2: wchar, 4: dchar
|
||||
unsigned char committed; // !=0 if type is committed
|
||||
unsigned char postfix; // 'c', 'w', 'd'
|
||||
void *string; // char, wchar, or dchar data
|
||||
size_t len; // number of chars, wchars, or dchars
|
||||
unsigned char sz; // 1: char, 2: wchar, 4: dchar
|
||||
unsigned char committed; // !=0 if type is committed
|
||||
unsigned char postfix; // 'c', 'w', 'd'
|
||||
|
||||
StringExp(Loc loc, char *s);
|
||||
StringExp(Loc loc, void *s, size_t len);
|
||||
@@ -500,15 +500,15 @@ struct AssocArrayLiteralExp : Expression
|
||||
|
||||
struct StructLiteralExp : Expression
|
||||
{
|
||||
StructDeclaration *sd; // which aggregate this is for
|
||||
Expressions *elements; // parallels sd->fields[] with
|
||||
// NULL entries for fields to skip
|
||||
StructDeclaration *sd; // which aggregate this is for
|
||||
Expressions *elements; // parallels sd->fields[] with
|
||||
// NULL entries for fields to skip
|
||||
|
||||
#if IN_DMD
|
||||
Symbol *sym; // back end symbol to initialize with literal
|
||||
Symbol *sym; // back end symbol to initialize with literal
|
||||
#endif
|
||||
size_t soffset; // offset from start of s
|
||||
int fillHoles; // fill alignment 'holes' with zero
|
||||
size_t soffset; // offset from start of s
|
||||
int fillHoles; // fill alignment 'holes' with zero
|
||||
|
||||
StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements);
|
||||
|
||||
@@ -591,17 +591,17 @@ struct NewExp : Expression
|
||||
{
|
||||
/* thisexp.new(newargs) newtype(arguments)
|
||||
*/
|
||||
Expression *thisexp; // if !NULL, 'this' for class being allocated
|
||||
Expressions *newargs; // Array of Expression's to call new operator
|
||||
Expression *thisexp; // if !NULL, 'this' for class being allocated
|
||||
Expressions *newargs; // Array of Expression's to call new operator
|
||||
Type *newtype;
|
||||
Expressions *arguments; // Array of Expression's
|
||||
Expressions *arguments; // Array of Expression's
|
||||
|
||||
CtorDeclaration *member; // constructor function
|
||||
NewDeclaration *allocator; // allocator function
|
||||
int onstack; // allocate on stack
|
||||
CtorDeclaration *member; // constructor function
|
||||
NewDeclaration *allocator; // allocator function
|
||||
int onstack; // allocate on stack
|
||||
|
||||
NewExp(Loc loc, Expression *thisexp, Expressions *newargs,
|
||||
Type *newtype, Expressions *arguments);
|
||||
Type *newtype, Expressions *arguments);
|
||||
Expression *syntaxCopy();
|
||||
Expression *semantic(Scope *sc);
|
||||
Expression *optimize(int result);
|
||||
@@ -625,13 +625,13 @@ struct NewAnonClassExp : Expression
|
||||
{
|
||||
/* thisexp.new(newargs) class baseclasses { } (arguments)
|
||||
*/
|
||||
Expression *thisexp; // if !NULL, 'this' for class being allocated
|
||||
Expressions *newargs; // Array of Expression's to call new operator
|
||||
ClassDeclaration *cd; // class being instantiated
|
||||
Expressions *arguments; // Array of Expression's to call class constructor
|
||||
Expression *thisexp; // if !NULL, 'this' for class being allocated
|
||||
Expressions *newargs; // Array of Expression's to call new operator
|
||||
ClassDeclaration *cd; // class being instantiated
|
||||
Expressions *arguments; // Array of Expression's to call class constructor
|
||||
|
||||
NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs,
|
||||
ClassDeclaration *cd, Expressions *arguments);
|
||||
ClassDeclaration *cd, Expressions *arguments);
|
||||
Expression *syntaxCopy();
|
||||
Expression *semantic(Scope *sc);
|
||||
int checkSideEffect(int flag);
|
||||
@@ -644,7 +644,7 @@ struct SymOffExp : Expression
|
||||
{
|
||||
Declaration *var;
|
||||
unsigned offset;
|
||||
Module* m; // starting point for overload resolution
|
||||
Module* m; // starting point for overload resolution
|
||||
|
||||
SymOffExp(Loc loc, Declaration *var, unsigned offset);
|
||||
Expression *semantic(Scope *sc);
|
||||
@@ -815,10 +815,10 @@ struct IsExp : Expression
|
||||
* is(targ id == tok2)
|
||||
*/
|
||||
Type *targ;
|
||||
Identifier *id; // can be NULL
|
||||
enum TOK tok; // ':' or '=='
|
||||
Type *tspec; // can be NULL
|
||||
enum TOK tok2; // 'struct', 'union', 'typedef', etc.
|
||||
Identifier *id; // can be NULL
|
||||
enum TOK tok; // ':' or '=='
|
||||
Type *tspec; // can be NULL
|
||||
enum TOK tok2; // 'struct', 'union', 'typedef', etc.
|
||||
|
||||
IsExp(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec, enum TOK tok2);
|
||||
Expression *syntaxCopy();
|
||||
@@ -845,7 +845,7 @@ struct UnaExp : Expression
|
||||
Expression *doInline(InlineDoState *ids);
|
||||
Expression *inlineScan(InlineScanState *iss);
|
||||
|
||||
Expression *op_overload(Scope *sc); // doesn't need to be virtual
|
||||
Expression *op_overload(Scope *sc); // doesn't need to be virtual
|
||||
};
|
||||
|
||||
struct BinExp : Expression
|
||||
@@ -986,7 +986,7 @@ struct DotTemplateInstanceExp : UnaExp
|
||||
struct DelegateExp : UnaExp
|
||||
{
|
||||
FuncDeclaration *func;
|
||||
Module* m; // starting point for overload resolution
|
||||
Module* m; // starting point for overload resolution
|
||||
|
||||
DelegateExp(Loc loc, Expression *e, FuncDeclaration *func);
|
||||
Expression *semantic(Scope *sc);
|
||||
@@ -1008,7 +1008,7 @@ struct DelegateExp : UnaExp
|
||||
|
||||
struct DotTypeExp : UnaExp
|
||||
{
|
||||
Dsymbol *sym; // symbol that represents a type
|
||||
Dsymbol *sym; // symbol that represents a type
|
||||
|
||||
DotTypeExp(Loc loc, Expression *e, Dsymbol *sym);
|
||||
Expression *semantic(Scope *sc);
|
||||
@@ -1024,7 +1024,7 @@ struct DotTypeExp : UnaExp
|
||||
|
||||
struct CallExp : UnaExp
|
||||
{
|
||||
Expressions *arguments; // function arguments
|
||||
Expressions *arguments; // function arguments
|
||||
|
||||
CallExp(Loc loc, Expression *e, Expressions *exps);
|
||||
CallExp(Loc loc, Expression *e);
|
||||
@@ -1056,7 +1056,7 @@ struct CallExp : UnaExp
|
||||
|
||||
struct AddrExp : UnaExp
|
||||
{
|
||||
Module* m; // starting point for overload resolution
|
||||
Module* m; // starting point for overload resolution
|
||||
|
||||
AddrExp(Loc loc, Expression *e);
|
||||
Expression *semantic(Scope *sc);
|
||||
@@ -1196,7 +1196,7 @@ struct DeleteExp : UnaExp
|
||||
struct CastExp : UnaExp
|
||||
{
|
||||
// Possible to cast to one type while painting to another type
|
||||
Type *to; // type to cast to
|
||||
Type *to; // type to cast to
|
||||
|
||||
CastExp(Loc loc, Expression *e, Type *t);
|
||||
Expression *syntaxCopy();
|
||||
@@ -1224,8 +1224,8 @@ struct CastExp : UnaExp
|
||||
|
||||
struct SliceExp : UnaExp
|
||||
{
|
||||
Expression *upr; // NULL if implicit 0
|
||||
Expression *lwr; // NULL if implicit [length - 1]
|
||||
Expression *upr; // NULL if implicit 0
|
||||
Expression *lwr; // NULL if implicit [length - 1]
|
||||
VarDeclaration *lengthVar;
|
||||
|
||||
SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr);
|
||||
@@ -1276,7 +1276,7 @@ struct ArrayLengthExp : UnaExp
|
||||
|
||||
struct ArrayExp : UnaExp
|
||||
{
|
||||
Expressions *arguments; // Array of Expression's
|
||||
Expressions *arguments; // Array of Expression's
|
||||
|
||||
ArrayExp(Loc loc, Expression *e1, Expressions *arguments);
|
||||
Expression *syntaxCopy();
|
||||
@@ -1365,7 +1365,7 @@ struct PostExp : BinExp
|
||||
};
|
||||
|
||||
struct AssignExp : BinExp
|
||||
{ int ismemset; // !=0 if setting the contents of an array
|
||||
{ int ismemset; // !=0 if setting the contents of an array
|
||||
|
||||
AssignExp(Loc loc, Expression *e1, Expression *e2);
|
||||
Expression *semantic(Scope *sc);
|
||||
@@ -1393,18 +1393,18 @@ struct AssignExp : BinExp
|
||||
#define ASSIGNEXP_TOELEM
|
||||
#endif
|
||||
|
||||
#define ASSIGNEXP(op) \
|
||||
struct op##AssignExp : BinExp \
|
||||
{ \
|
||||
op##AssignExp(Loc loc, Expression *e1, Expression *e2); \
|
||||
Expression *semantic(Scope *sc); \
|
||||
Expression *interpret(InterState *istate); \
|
||||
#define ASSIGNEXP(op) \
|
||||
struct op##AssignExp : BinExp \
|
||||
{ \
|
||||
op##AssignExp(Loc loc, Expression *e1, Expression *e2); \
|
||||
Expression *semantic(Scope *sc); \
|
||||
Expression *interpret(InterState *istate); \
|
||||
X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \
|
||||
X(Expression *buildArrayLoop(Parameters *fparams);) \
|
||||
\
|
||||
Identifier *opId(); /* For operator overloading */ \
|
||||
\
|
||||
ASSIGNEXP_TOELEM \
|
||||
X(Expression *buildArrayLoop(Parameters *fparams);) \
|
||||
\
|
||||
Identifier *opId(); /* For operator overloading */ \
|
||||
\
|
||||
ASSIGNEXP_TOELEM \
|
||||
};
|
||||
|
||||
#define X(a) a
|
||||
@@ -1871,7 +1871,7 @@ struct CondExp : BinExp
|
||||
|
||||
struct DefaultInitExp : Expression
|
||||
{
|
||||
enum TOK subop; // which of the derived classes this is
|
||||
enum TOK subop; // which of the derived classes this is
|
||||
|
||||
DefaultInitExp(Loc loc, enum TOK subop, int size);
|
||||
virtual Expression *resolve(Loc loc, Scope *sc) = 0;
|
||||
@@ -1918,11 +1918,11 @@ struct GEPExp : UnaExp
|
||||
|
||||
/* Special values used by the interpreter
|
||||
*/
|
||||
#define EXP_CANT_INTERPRET ((Expression *)1)
|
||||
#define EXP_CONTINUE_INTERPRET ((Expression *)2)
|
||||
#define EXP_BREAK_INTERPRET ((Expression *)3)
|
||||
#define EXP_GOTO_INTERPRET ((Expression *)4)
|
||||
#define EXP_VOID_INTERPRET ((Expression *)5)
|
||||
#define EXP_CANT_INTERPRET ((Expression *)1)
|
||||
#define EXP_CONTINUE_INTERPRET ((Expression *)2)
|
||||
#define EXP_BREAK_INTERPRET ((Expression *)3)
|
||||
#define EXP_GOTO_INTERPRET ((Expression *)4)
|
||||
#define EXP_VOID_INTERPRET ((Expression *)5)
|
||||
|
||||
Expression *expType(Type *type, Expression *e);
|
||||
|
||||
|
||||
2994
dmd/func.c
2994
dmd/func.c
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@
|
||||
#ifdef _DH
|
||||
|
||||
#define PRETTY_PRINT
|
||||
#define TEST_EMIT_ALL 0 // For Testing
|
||||
#define TEST_EMIT_ALL 0 // For Testing
|
||||
|
||||
#define LOG 0
|
||||
|
||||
@@ -69,7 +69,7 @@ void Module::genhdrfile()
|
||||
|
||||
char *pt = FileName::path(hdrfile->toChars());
|
||||
if (*pt)
|
||||
FileName::ensurePathExists(pt);
|
||||
FileName::ensurePathExists(pt);
|
||||
mem.free(pt);
|
||||
hdrfile->writev();
|
||||
}
|
||||
@@ -80,7 +80,7 @@ void Module::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
if (md)
|
||||
{
|
||||
buf->writestring("module ");
|
||||
buf->writestring(md->toChars());
|
||||
buf->writestring(md->toChars());
|
||||
buf->writebyte(';');
|
||||
buf->writenl();
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
struct HdrGenState
|
||||
{
|
||||
int hdrgen; // 1 if generating header file
|
||||
int ddoc; // 1 if generating Ddoc file
|
||||
int console; // 1 if writing to console
|
||||
int hdrgen; // 1 if generating header file
|
||||
int ddoc; // 1 if generating Ddoc file
|
||||
int console; // 1 if writing to console
|
||||
int tpltMember;
|
||||
int inCallExp;
|
||||
int inPtrExp;
|
||||
|
||||
834
dmd/html.c
834
dmd/html.c
File diff suppressed because it is too large
Load Diff
12
dmd/html.h
12
dmd/html.h
@@ -17,12 +17,12 @@ struct Html
|
||||
{
|
||||
const char *sourcename;
|
||||
|
||||
unsigned char *base; // pointer to start of buffer
|
||||
unsigned char *end; // past end of buffer
|
||||
unsigned char *p; // current character
|
||||
unsigned linnum; // current line number
|
||||
OutBuffer *dbuf; // code source buffer
|
||||
int inCode; // !=0 if in code
|
||||
unsigned char *base; // pointer to start of buffer
|
||||
unsigned char *end; // past end of buffer
|
||||
unsigned char *p; // current character
|
||||
unsigned linnum; // current line number
|
||||
OutBuffer *dbuf; // code source buffer
|
||||
int inCode; // !=0 if in code
|
||||
|
||||
|
||||
Html(const char *sourcename, unsigned char *base, unsigned length);
|
||||
|
||||
@@ -58,14 +58,14 @@ const char *Identifier::toHChars2()
|
||||
else if (this == Id::result) p = "result";
|
||||
else if (this == Id::returnLabel) p = "return";
|
||||
else
|
||||
{ p = toChars();
|
||||
if (*p == '_')
|
||||
{
|
||||
if (memcmp(p, "_staticCtor", 11) == 0)
|
||||
p = "static this";
|
||||
else if (memcmp(p, "_staticDtor", 11) == 0)
|
||||
p = "static ~this";
|
||||
}
|
||||
{ p = toChars();
|
||||
if (*p == '_')
|
||||
{
|
||||
if (memcmp(p, "_staticCtor", 11) == 0)
|
||||
p = "static this";
|
||||
else if (memcmp(p, "_staticDtor", 11) == 0)
|
||||
p = "static ~this";
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
|
||||
116
dmd/idgen.c
116
dmd/idgen.c
@@ -11,8 +11,8 @@
|
||||
// Program to generate string files in d data structures.
|
||||
// Saves much tedious typing, and eliminates typo problems.
|
||||
// Generates:
|
||||
// id.h
|
||||
// id.c
|
||||
// id.h
|
||||
// id.c
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
struct Msgtable
|
||||
{
|
||||
const char *ident; // name to use in DMD source
|
||||
const char *name; // name in D executable
|
||||
const char *ident; // name to use in DMD source
|
||||
const char *name; // name in D executable
|
||||
};
|
||||
|
||||
Msgtable msgtable[] =
|
||||
@@ -139,7 +139,7 @@ Msgtable msgtable[] =
|
||||
{ "__LOCAL_SIZE" },
|
||||
|
||||
// For operator overloads
|
||||
{ "uadd", "opPos" },
|
||||
{ "uadd", "opPos" },
|
||||
{ "neg", "opNeg" },
|
||||
{ "com", "opCom" },
|
||||
{ "add", "opAdd" },
|
||||
@@ -183,14 +183,14 @@ Msgtable msgtable[] =
|
||||
{ "catass", "opCatAssign" },
|
||||
{ "postinc", "opPostInc" },
|
||||
{ "postdec", "opPostDec" },
|
||||
{ "index", "opIndex" },
|
||||
{ "index", "opIndex" },
|
||||
{ "indexass", "opIndexAssign" },
|
||||
{ "slice", "opSlice" },
|
||||
{ "slice", "opSlice" },
|
||||
{ "sliceass", "opSliceAssign" },
|
||||
{ "call", "opCall" },
|
||||
{ "cast", "opCast" },
|
||||
{ "match", "opMatch" },
|
||||
{ "next", "opNext" },
|
||||
{ "call", "opCall" },
|
||||
{ "cast", "opCast" },
|
||||
{ "match", "opMatch" },
|
||||
{ "next", "opNext" },
|
||||
{ "opIn" },
|
||||
{ "opIn_r" },
|
||||
|
||||
@@ -251,71 +251,71 @@ int main()
|
||||
unsigned i;
|
||||
|
||||
{
|
||||
fp = fopen("id.h","w");
|
||||
if (!fp)
|
||||
{ printf("can't open id.h\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fp = fopen("id.h","w");
|
||||
if (!fp)
|
||||
{ printf("can't open id.h\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf(fp, "// File generated by idgen.c\n");
|
||||
fprintf(fp, "// File generated by idgen.c\n");
|
||||
#if __DMC__
|
||||
fprintf(fp, "#pragma once\n");
|
||||
fprintf(fp, "#pragma once\n");
|
||||
#endif
|
||||
fprintf(fp, "#ifndef DMD_ID_H\n");
|
||||
fprintf(fp, "#define DMD_ID_H 1\n");
|
||||
fprintf(fp, "struct Identifier;\n");
|
||||
fprintf(fp, "struct Id\n");
|
||||
fprintf(fp, "{\n");
|
||||
fprintf(fp, "#ifndef DMD_ID_H\n");
|
||||
fprintf(fp, "#define DMD_ID_H 1\n");
|
||||
fprintf(fp, "struct Identifier;\n");
|
||||
fprintf(fp, "struct Id\n");
|
||||
fprintf(fp, "{\n");
|
||||
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ const char *id = msgtable[i].ident;
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ const char *id = msgtable[i].ident;
|
||||
|
||||
fprintf(fp," static Identifier *%s;\n", id);
|
||||
}
|
||||
fprintf(fp," static Identifier *%s;\n", id);
|
||||
}
|
||||
|
||||
fprintf(fp, " static void initialize();\n");
|
||||
fprintf(fp, "};\n");
|
||||
fprintf(fp, "#endif\n");
|
||||
fprintf(fp, " static void initialize();\n");
|
||||
fprintf(fp, "};\n");
|
||||
fprintf(fp, "#endif\n");
|
||||
|
||||
fclose(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
{
|
||||
fp = fopen("id.c","w");
|
||||
if (!fp)
|
||||
{ printf("can't open id.c\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fp = fopen("id.c","w");
|
||||
if (!fp)
|
||||
{ printf("can't open id.c\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf(fp, "// File generated by idgen.c\n");
|
||||
fprintf(fp, "#include \"id.h\"\n");
|
||||
fprintf(fp, "#include \"identifier.h\"\n");
|
||||
fprintf(fp, "#include \"lexer.h\"\n");
|
||||
fprintf(fp, "// File generated by idgen.c\n");
|
||||
fprintf(fp, "#include \"id.h\"\n");
|
||||
fprintf(fp, "#include \"identifier.h\"\n");
|
||||
fprintf(fp, "#include \"lexer.h\"\n");
|
||||
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ const char *id = msgtable[i].ident;
|
||||
const char *p = msgtable[i].name;
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ const char *id = msgtable[i].ident;
|
||||
const char *p = msgtable[i].name;
|
||||
|
||||
if (!p)
|
||||
p = id;
|
||||
fprintf(fp,"Identifier *Id::%s;\n", id);
|
||||
}
|
||||
if (!p)
|
||||
p = id;
|
||||
fprintf(fp,"Identifier *Id::%s;\n", id);
|
||||
}
|
||||
|
||||
fprintf(fp, "void Id::initialize()\n");
|
||||
fprintf(fp, "{\n");
|
||||
fprintf(fp, "void Id::initialize()\n");
|
||||
fprintf(fp, "{\n");
|
||||
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ const char *id = msgtable[i].ident;
|
||||
const char *p = msgtable[i].name;
|
||||
for (i = 0; i < sizeof(msgtable) / sizeof(msgtable[0]); i++)
|
||||
{ const char *id = msgtable[i].ident;
|
||||
const char *p = msgtable[i].name;
|
||||
|
||||
if (!p)
|
||||
p = id;
|
||||
fprintf(fp," %s = Lexer::idPool(\"%s\");\n", id, p);
|
||||
}
|
||||
if (!p)
|
||||
p = id;
|
||||
fprintf(fp," %s = Lexer::idPool(\"%s\");\n", id, p);
|
||||
}
|
||||
|
||||
fprintf(fp, "}\n");
|
||||
fprintf(fp, "}\n");
|
||||
|
||||
fclose(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
100
dmd/impcnvgen.c
100
dmd/impcnvgen.c
@@ -21,16 +21,16 @@ int integral_promotion(int t)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case Tchar:
|
||||
case Twchar:
|
||||
case Tbit:
|
||||
case Tbool:
|
||||
case Tint8:
|
||||
case Tuns8:
|
||||
case Tint16:
|
||||
case Tuns16: return Tint32;
|
||||
case Tdchar: return Tuns32;
|
||||
default: return t;
|
||||
case Tchar:
|
||||
case Twchar:
|
||||
case Tbit:
|
||||
case Tbool:
|
||||
case Tint8:
|
||||
case Tuns8:
|
||||
case Tint16:
|
||||
case Tuns16: return Tint32;
|
||||
case Tdchar: return Tuns32;
|
||||
default: return t;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,17 +39,17 @@ void init()
|
||||
|
||||
// Set conversion tables
|
||||
for (i = 0; i < TMAX; i++)
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{ impcnvResult[i][j] = Terror;
|
||||
impcnvType1[i][j] = Terror;
|
||||
impcnvType2[i][j] = Terror;
|
||||
impcnvWarn[i][j] = 0;
|
||||
}
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{ impcnvResult[i][j] = Terror;
|
||||
impcnvType1[i][j] = Terror;
|
||||
impcnvType2[i][j] = Terror;
|
||||
impcnvWarn[i][j] = 0;
|
||||
}
|
||||
|
||||
#define X(t1,t2, nt1,nt2, rt) \
|
||||
impcnvResult[t1][t2] = rt; \
|
||||
impcnvType1[t1][t2] = nt1; \
|
||||
impcnvType2[t1][t2] = nt2;
|
||||
#define X(t1,t2, nt1,nt2, rt) \
|
||||
impcnvResult[t1][t2] = rt; \
|
||||
impcnvType1[t1][t2] = nt1; \
|
||||
impcnvType2[t1][t2] = nt2;
|
||||
|
||||
/* ======================= */
|
||||
|
||||
@@ -318,7 +318,7 @@ void init()
|
||||
|
||||
#undef X
|
||||
|
||||
#define Y(t1,t2) impcnvWarn[t1][t2] = 1;
|
||||
#define Y(t1,t2) impcnvWarn[t1][t2] = 1;
|
||||
Y(Tint8, Tbit)
|
||||
Y(Tuns8, Tbit)
|
||||
Y(Tint16, Tbit)
|
||||
@@ -385,15 +385,15 @@ void init()
|
||||
Y(Tuns64, Tint64)
|
||||
|
||||
for (i = 0; i < TMAX; i++)
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
if (impcnvResult[i][j] == Terror)
|
||||
{
|
||||
impcnvResult[i][j] = impcnvResult[j][i];
|
||||
impcnvType1[i][j] = impcnvType2[j][i];
|
||||
impcnvType2[i][j] = impcnvType1[j][i];
|
||||
}
|
||||
}
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
if (impcnvResult[i][j] == Terror)
|
||||
{
|
||||
impcnvResult[i][j] = impcnvResult[j][i];
|
||||
impcnvType1[i][j] = impcnvType2[j][i];
|
||||
impcnvType2[i][j] = impcnvType1[j][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -411,44 +411,44 @@ int main()
|
||||
fprintf(fp,"unsigned char Type::impcnvResult[TMAX][TMAX] =\n{\n");
|
||||
for (i = 0; i < TMAX; i++)
|
||||
{
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
fprintf(fp, "%d,",impcnvResult[i][j]);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
fprintf(fp, "%d,",impcnvResult[i][j]);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
fprintf(fp,"};\n");
|
||||
|
||||
fprintf(fp,"unsigned char Type::impcnvType1[TMAX][TMAX] =\n{\n");
|
||||
for (i = 0; i < TMAX; i++)
|
||||
{
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
fprintf(fp, "%d,",impcnvType1[i][j]);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
fprintf(fp, "%d,",impcnvType1[i][j]);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
fprintf(fp,"};\n");
|
||||
|
||||
fprintf(fp,"unsigned char Type::impcnvType2[TMAX][TMAX] =\n{\n");
|
||||
for (i = 0; i < TMAX; i++)
|
||||
{
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
fprintf(fp, "%d,",impcnvType2[i][j]);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
fprintf(fp, "%d,",impcnvType2[i][j]);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
fprintf(fp,"};\n");
|
||||
|
||||
fprintf(fp,"unsigned char Type::impcnvWarn[TMAX][TMAX] =\n{\n");
|
||||
for (i = 0; i < TMAX; i++)
|
||||
{
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
fprintf(fp, "%d,",impcnvWarn[i][j]);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
for (j = 0; j < TMAX; j++)
|
||||
{
|
||||
fprintf(fp, "%d,",impcnvWarn[i][j]);
|
||||
}
|
||||
fprintf(fp, "\n");
|
||||
}
|
||||
fprintf(fp,"};\n");
|
||||
|
||||
|
||||
312
dmd/import.c
312
dmd/import.c
@@ -26,7 +26,7 @@
|
||||
/********************************* Import ****************************/
|
||||
|
||||
Import::Import(Loc loc, Array *packages, Identifier *id, Identifier *aliasId,
|
||||
int isstatic)
|
||||
int isstatic)
|
||||
: Dsymbol(id)
|
||||
{
|
||||
assert(id);
|
||||
@@ -40,19 +40,19 @@ Import::Import(Loc loc, Array *packages, Identifier *id, Identifier *aliasId,
|
||||
mod = NULL;
|
||||
|
||||
if (aliasId)
|
||||
this->ident = aliasId;
|
||||
this->ident = aliasId;
|
||||
// Kludge to change Import identifier to first package
|
||||
else if (packages && packages->dim)
|
||||
this->ident = (Identifier *)packages->data[0];
|
||||
this->ident = (Identifier *)packages->data[0];
|
||||
}
|
||||
|
||||
void Import::addAlias(Identifier *name, Identifier *alias)
|
||||
{
|
||||
if (isstatic)
|
||||
error("cannot have an import bind list");
|
||||
error("cannot have an import bind list");
|
||||
|
||||
if (!aliasId)
|
||||
this->ident = NULL; // make it an anonymous import
|
||||
this->ident = NULL; // make it an anonymous import
|
||||
|
||||
names.push(name);
|
||||
aliases.push(alias);
|
||||
@@ -78,7 +78,7 @@ Dsymbol *Import::syntaxCopy(Dsymbol *s)
|
||||
|
||||
for (size_t i = 0; i < names.dim; i++)
|
||||
{
|
||||
si->addAlias((Identifier *)names.data[i], (Identifier *)aliases.data[i]);
|
||||
si->addAlias((Identifier *)names.data[i], (Identifier *)aliases.data[i]);
|
||||
}
|
||||
|
||||
return si;
|
||||
@@ -95,26 +95,26 @@ void Import::load(Scope *sc)
|
||||
if (s)
|
||||
{
|
||||
#if TARGET_NET
|
||||
mod = (Module *)s;
|
||||
mod = (Module *)s;
|
||||
#else
|
||||
if (s->isModule())
|
||||
mod = (Module *)s;
|
||||
else
|
||||
error("package and module have the same name");
|
||||
if (s->isModule())
|
||||
mod = (Module *)s;
|
||||
else
|
||||
error("package and module have the same name");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!mod)
|
||||
{
|
||||
// Load module
|
||||
mod = Module::load(loc, packages, id);
|
||||
dst->insert(id, mod); // id may be different from mod->ident,
|
||||
// if so then insert alias
|
||||
if (!mod->importedFrom)
|
||||
mod->importedFrom = sc ? sc->module->importedFrom : Module::rootModule;
|
||||
// Load module
|
||||
mod = Module::load(loc, packages, id);
|
||||
dst->insert(id, mod); // id may be different from mod->ident,
|
||||
// if so then insert alias
|
||||
if (!mod->importedFrom)
|
||||
mod->importedFrom = sc ? sc->module->importedFrom : Module::rootModule;
|
||||
}
|
||||
if (!pkg)
|
||||
pkg = mod;
|
||||
pkg = mod;
|
||||
|
||||
//printf("-Import::load('%s'), pkg = %p\n", toChars(), pkg);
|
||||
}
|
||||
@@ -123,19 +123,19 @@ void escapePath(OutBuffer *buf, const char *fname)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
switch (*fname)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case '(':
|
||||
case ')':
|
||||
case '\\':
|
||||
buf->writebyte('\\');
|
||||
default:
|
||||
buf->writebyte(*fname);
|
||||
break;
|
||||
}
|
||||
fname++;
|
||||
switch (*fname)
|
||||
{
|
||||
case 0:
|
||||
return;
|
||||
case '(':
|
||||
case ')':
|
||||
case '\\':
|
||||
buf->writebyte('\\');
|
||||
default:
|
||||
buf->writebyte(*fname);
|
||||
break;
|
||||
}
|
||||
fname++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,124 +164,124 @@ void Import::semantic(Scope *sc)
|
||||
|
||||
// Load if not already done so
|
||||
if (!mod)
|
||||
{ load(sc);
|
||||
mod->importAll(0);
|
||||
{ load(sc);
|
||||
mod->importAll(0);
|
||||
}
|
||||
|
||||
if (mod)
|
||||
{
|
||||
#if 0
|
||||
if (mod->loc.linnum != 0)
|
||||
{ /* If the line number is not 0, then this is not
|
||||
* a 'root' module, i.e. it was not specified on the command line.
|
||||
*/
|
||||
mod->importedFrom = sc->module->importedFrom;
|
||||
assert(mod->importedFrom);
|
||||
}
|
||||
if (mod->loc.linnum != 0)
|
||||
{ /* If the line number is not 0, then this is not
|
||||
* a 'root' module, i.e. it was not specified on the command line.
|
||||
*/
|
||||
mod->importedFrom = sc->module->importedFrom;
|
||||
assert(mod->importedFrom);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Modules need a list of each imported module
|
||||
//printf("%s imports %s\n", sc->module->toChars(), mod->toChars());
|
||||
sc->module->aimports.push(mod);
|
||||
// Modules need a list of each imported module
|
||||
//printf("%s imports %s\n", sc->module->toChars(), mod->toChars());
|
||||
sc->module->aimports.push(mod);
|
||||
|
||||
/* Default to private importing
|
||||
*/
|
||||
protection = sc->protection;
|
||||
if (!sc->explicitProtection)
|
||||
protection = PROTprivate;
|
||||
/* Default to private importing
|
||||
*/
|
||||
protection = sc->protection;
|
||||
if (!sc->explicitProtection)
|
||||
protection = PROTprivate;
|
||||
|
||||
if (!isstatic && !aliasId && !names.dim)
|
||||
{
|
||||
sc->scopesym->importScope(mod, protection);
|
||||
}
|
||||
if (!isstatic && !aliasId && !names.dim)
|
||||
{
|
||||
sc->scopesym->importScope(mod, protection);
|
||||
}
|
||||
|
||||
mod->semantic();
|
||||
mod->semantic();
|
||||
|
||||
if (mod->needmoduleinfo)
|
||||
sc->module->needmoduleinfo = 1;
|
||||
if (mod->needmoduleinfo)
|
||||
sc->module->needmoduleinfo = 1;
|
||||
|
||||
sc = sc->push(mod);
|
||||
for (size_t i = 0; i < aliasdecls.dim; i++)
|
||||
{ AliasDeclaration *ad = (AliasDeclaration *)aliasdecls.data[i];
|
||||
sc = sc->push(mod);
|
||||
for (size_t i = 0; i < aliasdecls.dim; i++)
|
||||
{ AliasDeclaration *ad = (AliasDeclaration *)aliasdecls.data[i];
|
||||
|
||||
//printf("\tImport alias semantic('%s')\n", s->toChars());
|
||||
if (!mod->search(loc, (Identifier *)names.data[i], 0))
|
||||
error("%s not found", ((Identifier *)names.data[i])->toChars());
|
||||
//printf("\tImport alias semantic('%s')\n", s->toChars());
|
||||
if (!mod->search(loc, (Identifier *)names.data[i], 0))
|
||||
error("%s not found", ((Identifier *)names.data[i])->toChars());
|
||||
|
||||
ad->importprot = protection;
|
||||
ad->semantic(sc);
|
||||
}
|
||||
sc = sc->pop();
|
||||
ad->importprot = protection;
|
||||
ad->semantic(sc);
|
||||
}
|
||||
sc = sc->pop();
|
||||
}
|
||||
//printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
|
||||
|
||||
if (global.params.moduleDeps != NULL)
|
||||
{
|
||||
/* The grammar of the file is:
|
||||
* ImportDeclaration
|
||||
* ::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
|
||||
* ModuleAliasIdentifier ] "\n"
|
||||
*
|
||||
* BasicImportDeclaration
|
||||
* ::= ModuleFullyQualifiedName " (" FilePath ") : " Protection
|
||||
* " [ " static" ] : " ModuleFullyQualifiedName " (" FilePath ")"
|
||||
*
|
||||
* FilePath
|
||||
* - any string with '(', ')' and '\' escaped with the '\' character
|
||||
*/
|
||||
/* The grammar of the file is:
|
||||
* ImportDeclaration
|
||||
* ::= BasicImportDeclaration [ " : " ImportBindList ] [ " -> "
|
||||
* ModuleAliasIdentifier ] "\n"
|
||||
*
|
||||
* BasicImportDeclaration
|
||||
* ::= ModuleFullyQualifiedName " (" FilePath ") : " Protection
|
||||
* " [ " static" ] : " ModuleFullyQualifiedName " (" FilePath ")"
|
||||
*
|
||||
* FilePath
|
||||
* - any string with '(', ')' and '\' escaped with the '\' character
|
||||
*/
|
||||
|
||||
OutBuffer *ob = global.params.moduleDeps;
|
||||
OutBuffer *ob = global.params.moduleDeps;
|
||||
|
||||
ob->writestring(sc->module->toPrettyChars());
|
||||
ob->writestring(" (");
|
||||
escapePath(ob, sc->module->srcfile->toChars());
|
||||
ob->writestring(") : ");
|
||||
ob->writestring(sc->module->toPrettyChars());
|
||||
ob->writestring(" (");
|
||||
escapePath(ob, sc->module->srcfile->toChars());
|
||||
ob->writestring(") : ");
|
||||
|
||||
ProtDeclaration::protectionToCBuffer(ob, sc->protection);
|
||||
if (isstatic)
|
||||
StorageClassDeclaration::stcToCBuffer(ob, STCstatic);
|
||||
ob->writestring(": ");
|
||||
ProtDeclaration::protectionToCBuffer(ob, sc->protection);
|
||||
if (isstatic)
|
||||
StorageClassDeclaration::stcToCBuffer(ob, STCstatic);
|
||||
ob->writestring(": ");
|
||||
|
||||
if (packages)
|
||||
{
|
||||
for (size_t i = 0; i < packages->dim; i++)
|
||||
{
|
||||
Identifier *pid = (Identifier *)packages->data[i];
|
||||
ob->printf("%s.", pid->toChars());
|
||||
}
|
||||
}
|
||||
if (packages)
|
||||
{
|
||||
for (size_t i = 0; i < packages->dim; i++)
|
||||
{
|
||||
Identifier *pid = (Identifier *)packages->data[i];
|
||||
ob->printf("%s.", pid->toChars());
|
||||
}
|
||||
}
|
||||
|
||||
ob->writestring(id->toChars());
|
||||
ob->writestring(" (");
|
||||
if (mod)
|
||||
escapePath(ob, mod->srcfile->toChars());
|
||||
else
|
||||
ob->writestring("???");
|
||||
ob->writebyte(')');
|
||||
ob->writestring(id->toChars());
|
||||
ob->writestring(" (");
|
||||
if (mod)
|
||||
escapePath(ob, mod->srcfile->toChars());
|
||||
else
|
||||
ob->writestring("???");
|
||||
ob->writebyte(')');
|
||||
|
||||
for (size_t i = 0; i < names.dim; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
ob->writebyte(':');
|
||||
else
|
||||
ob->writebyte(',');
|
||||
for (size_t i = 0; i < names.dim; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
ob->writebyte(':');
|
||||
else
|
||||
ob->writebyte(',');
|
||||
|
||||
Identifier *name = (Identifier *)names.data[i];
|
||||
Identifier *alias = (Identifier *)aliases.data[i];
|
||||
Identifier *name = (Identifier *)names.data[i];
|
||||
Identifier *alias = (Identifier *)aliases.data[i];
|
||||
|
||||
if (!alias)
|
||||
{
|
||||
ob->printf("%s", name->toChars());
|
||||
alias = name;
|
||||
}
|
||||
else
|
||||
ob->printf("%s=%s", alias->toChars(), name->toChars());
|
||||
}
|
||||
if (!alias)
|
||||
{
|
||||
ob->printf("%s", name->toChars());
|
||||
alias = name;
|
||||
}
|
||||
else
|
||||
ob->printf("%s=%s", alias->toChars(), name->toChars());
|
||||
}
|
||||
|
||||
if (aliasId)
|
||||
ob->printf(" -> %s", aliasId->toChars());
|
||||
if (aliasId)
|
||||
ob->printf(" -> %s", aliasId->toChars());
|
||||
|
||||
ob->writenl();
|
||||
ob->writenl();
|
||||
}
|
||||
|
||||
//printf("-Import::semantic('%s'), pkg = %p\n", toChars(), pkg);
|
||||
@@ -292,13 +292,13 @@ void Import::semantic2(Scope *sc)
|
||||
//printf("Import::semantic2('%s')\n", toChars());
|
||||
mod->semantic2();
|
||||
if (mod->needmoduleinfo)
|
||||
sc->module->needmoduleinfo = 1;
|
||||
sc->module->needmoduleinfo = 1;
|
||||
}
|
||||
|
||||
Dsymbol *Import::toAlias()
|
||||
{
|
||||
if (aliasId)
|
||||
return mod;
|
||||
return mod;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -311,27 +311,27 @@ int Import::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
||||
int result = 0;
|
||||
|
||||
if (names.dim == 0)
|
||||
return Dsymbol::addMember(sc, sd, memnum);
|
||||
return Dsymbol::addMember(sc, sd, memnum);
|
||||
|
||||
if (aliasId)
|
||||
result = Dsymbol::addMember(sc, sd, memnum);
|
||||
result = Dsymbol::addMember(sc, sd, memnum);
|
||||
|
||||
/* Instead of adding the import to sd's symbol table,
|
||||
* add each of the alias=name pairs
|
||||
*/
|
||||
for (size_t i = 0; i < names.dim; i++)
|
||||
{
|
||||
Identifier *name = (Identifier *)names.data[i];
|
||||
Identifier *alias = (Identifier *)aliases.data[i];
|
||||
Identifier *name = (Identifier *)names.data[i];
|
||||
Identifier *alias = (Identifier *)aliases.data[i];
|
||||
|
||||
if (!alias)
|
||||
alias = name;
|
||||
if (!alias)
|
||||
alias = name;
|
||||
|
||||
TypeIdentifier *tname = new TypeIdentifier(loc, name);
|
||||
AliasDeclaration *ad = new AliasDeclaration(loc, alias, tname);
|
||||
result |= ad->addMember(sc, sd, memnum);
|
||||
TypeIdentifier *tname = new TypeIdentifier(loc, name);
|
||||
AliasDeclaration *ad = new AliasDeclaration(loc, alias, tname);
|
||||
result |= ad->addMember(sc, sd, memnum);
|
||||
|
||||
aliasdecls.push(ad);
|
||||
aliasdecls.push(ad);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -342,8 +342,8 @@ Dsymbol *Import::search(Loc loc, Identifier *ident, int flags)
|
||||
//printf("%s.Import::search(ident = '%s', flags = x%x)\n", toChars(), ident->toChars(), flags);
|
||||
|
||||
if (!pkg)
|
||||
{ load(NULL);
|
||||
mod->semantic();
|
||||
{ load(NULL);
|
||||
mod->semantic();
|
||||
}
|
||||
|
||||
// Forward it to the package/module
|
||||
@@ -359,42 +359,42 @@ int Import::overloadInsert(Dsymbol *s)
|
||||
void Import::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
if (hgs->hdrgen && id == Id::object)
|
||||
return; // object is imported by default
|
||||
return; // object is imported by default
|
||||
|
||||
if (isstatic)
|
||||
buf->writestring("static ");
|
||||
buf->writestring("static ");
|
||||
buf->writestring("import ");
|
||||
if (aliasId)
|
||||
{
|
||||
buf->printf("%s = ", aliasId->toChars());
|
||||
buf->printf("%s = ", aliasId->toChars());
|
||||
}
|
||||
if (packages && packages->dim)
|
||||
{
|
||||
for (size_t i = 0; i < packages->dim; i++)
|
||||
{ Identifier *pid = (Identifier *)packages->data[i];
|
||||
for (size_t i = 0; i < packages->dim; i++)
|
||||
{ Identifier *pid = (Identifier *)packages->data[i];
|
||||
|
||||
buf->printf("%s.", pid->toChars());
|
||||
}
|
||||
buf->printf("%s.", pid->toChars());
|
||||
}
|
||||
}
|
||||
buf->printf("%s", id->toChars());
|
||||
if (names.dim > 0) {
|
||||
buf->writebyte(':');
|
||||
for (size_t i = 0; i < names.dim; i++)
|
||||
{
|
||||
if (i > 0) {
|
||||
buf->writebyte(',');
|
||||
}
|
||||
buf->writebyte(':');
|
||||
for (size_t i = 0; i < names.dim; i++)
|
||||
{
|
||||
if (i > 0) {
|
||||
buf->writebyte(',');
|
||||
}
|
||||
|
||||
Identifier *name = (Identifier *)names.data[i];
|
||||
Identifier *alias = (Identifier *)aliases.data[i];
|
||||
Identifier *name = (Identifier *)names.data[i];
|
||||
Identifier *alias = (Identifier *)aliases.data[i];
|
||||
|
||||
if (!alias) {
|
||||
buf->printf("%s", name->toChars());
|
||||
alias = name;
|
||||
} else {
|
||||
buf->printf("%s=%s", alias->toChars(), name->toChars());
|
||||
}
|
||||
}
|
||||
if (!alias) {
|
||||
buf->printf("%s", name->toChars());
|
||||
alias = name;
|
||||
} else {
|
||||
buf->printf("%s=%s", alias->toChars(), name->toChars());
|
||||
}
|
||||
}
|
||||
}
|
||||
buf->writebyte(';');
|
||||
buf->writenl();
|
||||
|
||||
14
dmd/import.h
14
dmd/import.h
@@ -30,28 +30,28 @@ struct HdrGenState;
|
||||
|
||||
struct Import : Dsymbol
|
||||
{
|
||||
Array *packages; // array of Identifier's representing packages
|
||||
Identifier *id; // module Identifier
|
||||
Array *packages; // array of Identifier's representing packages
|
||||
Identifier *id; // module Identifier
|
||||
Identifier *aliasId;
|
||||
int isstatic; // !=0 if static import
|
||||
int isstatic; // !=0 if static import
|
||||
enum PROT protection;
|
||||
|
||||
// Pairs of alias=name to bind into current namespace
|
||||
Array names;
|
||||
Array aliases;
|
||||
|
||||
Array aliasdecls; // AliasDeclarations for names/aliases
|
||||
Array aliasdecls; // AliasDeclarations for names/aliases
|
||||
|
||||
Module *mod;
|
||||
Package *pkg; // leftmost package/module
|
||||
Package *pkg; // leftmost package/module
|
||||
|
||||
Import(Loc loc, Array *packages, Identifier *id, Identifier *aliasId,
|
||||
int isstatic);
|
||||
int isstatic);
|
||||
void addAlias(Identifier *name, Identifier *alias);
|
||||
|
||||
const char *kind();
|
||||
enum PROT prot();
|
||||
Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees
|
||||
Dsymbol *syntaxCopy(Dsymbol *s); // copy only syntax trees
|
||||
void load(Scope *sc);
|
||||
void importAll(Scope *sc);
|
||||
void semantic(Scope *sc);
|
||||
|
||||
442
dmd/init.c
442
dmd/init.c
@@ -50,14 +50,14 @@ Initializers *Initializer::arraySyntaxCopy(Initializers *ai)
|
||||
|
||||
if (ai)
|
||||
{
|
||||
a = new Initializers();
|
||||
a->setDim(ai->dim);
|
||||
for (int i = 0; i < a->dim; i++)
|
||||
{ Initializer *e = (Initializer *)ai->data[i];
|
||||
a = new Initializers();
|
||||
a->setDim(ai->dim);
|
||||
for (int i = 0; i < a->dim; i++)
|
||||
{ Initializer *e = (Initializer *)ai->data[i];
|
||||
|
||||
e = e->syntaxCopy();
|
||||
a->data[i] = e;
|
||||
}
|
||||
e = e->syntaxCopy();
|
||||
a->data[i] = e;
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
@@ -124,12 +124,12 @@ Initializer *StructInitializer::syntaxCopy()
|
||||
ai->field.setDim(field.dim);
|
||||
ai->value.setDim(value.dim);
|
||||
for (int i = 0; i < field.dim; i++)
|
||||
{
|
||||
ai->field.data[i] = field.data[i];
|
||||
{
|
||||
ai->field.data[i] = field.data[i];
|
||||
|
||||
Initializer *init = (Initializer *)value.data[i];
|
||||
init = init->syntaxCopy();
|
||||
ai->value.data[i] = init;
|
||||
Initializer *init = (Initializer *)value.data[i];
|
||||
init = init->syntaxCopy();
|
||||
ai->value.data[i] = init;
|
||||
}
|
||||
return ai;
|
||||
}
|
||||
@@ -150,88 +150,88 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t)
|
||||
vars.setDim(field.dim);
|
||||
t = t->toBasetype();
|
||||
if (t->ty == Tstruct)
|
||||
{ unsigned i;
|
||||
unsigned fieldi = 0;
|
||||
{ unsigned i;
|
||||
unsigned fieldi = 0;
|
||||
|
||||
ts = (TypeStruct *)t;
|
||||
ad = ts->sym;
|
||||
for (i = 0; i < field.dim; i++)
|
||||
{
|
||||
Identifier *id = (Identifier *)field.data[i];
|
||||
Initializer *val = (Initializer *)value.data[i];
|
||||
Dsymbol *s;
|
||||
VarDeclaration *v;
|
||||
ts = (TypeStruct *)t;
|
||||
ad = ts->sym;
|
||||
for (i = 0; i < field.dim; i++)
|
||||
{
|
||||
Identifier *id = (Identifier *)field.data[i];
|
||||
Initializer *val = (Initializer *)value.data[i];
|
||||
Dsymbol *s;
|
||||
VarDeclaration *v;
|
||||
|
||||
if (id == NULL)
|
||||
{
|
||||
if (fieldi >= ad->fields.dim)
|
||||
{ error(loc, "too many initializers for %s", ad->toChars());
|
||||
field.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = (Dsymbol *)ad->fields.data[fieldi];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//s = ad->symtab->lookup(id);
|
||||
s = ad->search(loc, id, 0);
|
||||
if (!s)
|
||||
{
|
||||
error(loc, "'%s' is not a member of '%s'", id->toChars(), t->toChars());
|
||||
continue;
|
||||
}
|
||||
if (id == NULL)
|
||||
{
|
||||
if (fieldi >= ad->fields.dim)
|
||||
{ error(loc, "too many initializers for %s", ad->toChars());
|
||||
field.remove(i);
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = (Dsymbol *)ad->fields.data[fieldi];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//s = ad->symtab->lookup(id);
|
||||
s = ad->search(loc, id, 0);
|
||||
if (!s)
|
||||
{
|
||||
error(loc, "'%s' is not a member of '%s'", id->toChars(), t->toChars());
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find out which field index it is
|
||||
for (fieldi = 0; 1; fieldi++)
|
||||
{
|
||||
if (fieldi >= ad->fields.dim)
|
||||
{
|
||||
s->error("is not a per-instance initializable field");
|
||||
break;
|
||||
}
|
||||
if (s == (Dsymbol *)ad->fields.data[fieldi])
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s && (v = s->isVarDeclaration()) != NULL)
|
||||
{
|
||||
val = val->semantic(sc, v->type);
|
||||
value.data[i] = (void *)val;
|
||||
vars.data[i] = (void *)v;
|
||||
}
|
||||
else
|
||||
{ error(loc, "%s is not a field of %s", id ? id->toChars() : s->toChars(), ad->toChars());
|
||||
errors = 1;
|
||||
}
|
||||
fieldi++;
|
||||
}
|
||||
// Find out which field index it is
|
||||
for (fieldi = 0; 1; fieldi++)
|
||||
{
|
||||
if (fieldi >= ad->fields.dim)
|
||||
{
|
||||
s->error("is not a per-instance initializable field");
|
||||
break;
|
||||
}
|
||||
if (s == (Dsymbol *)ad->fields.data[fieldi])
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s && (v = s->isVarDeclaration()) != NULL)
|
||||
{
|
||||
val = val->semantic(sc, v->type);
|
||||
value.data[i] = (void *)val;
|
||||
vars.data[i] = (void *)v;
|
||||
}
|
||||
else
|
||||
{ error(loc, "%s is not a field of %s", id ? id->toChars() : s->toChars(), ad->toChars());
|
||||
errors = 1;
|
||||
}
|
||||
fieldi++;
|
||||
}
|
||||
}
|
||||
else if (t->ty == Tdelegate && value.dim == 0)
|
||||
{ /* Rewrite as empty delegate literal { }
|
||||
*/
|
||||
Parameters *arguments = new Parameters;
|
||||
Type *tf = new TypeFunction(arguments, NULL, 0, LINKd);
|
||||
FuncLiteralDeclaration *fd = new FuncLiteralDeclaration(loc, 0, tf, TOKdelegate, NULL);
|
||||
fd->fbody = new CompoundStatement(loc, new Statements());
|
||||
fd->endloc = loc;
|
||||
Expression *e = new FuncExp(loc, fd);
|
||||
ExpInitializer *ie = new ExpInitializer(loc, e);
|
||||
return ie->semantic(sc, t);
|
||||
{ /* Rewrite as empty delegate literal { }
|
||||
*/
|
||||
Parameters *arguments = new Parameters;
|
||||
Type *tf = new TypeFunction(arguments, NULL, 0, LINKd);
|
||||
FuncLiteralDeclaration *fd = new FuncLiteralDeclaration(loc, 0, tf, TOKdelegate, NULL);
|
||||
fd->fbody = new CompoundStatement(loc, new Statements());
|
||||
fd->endloc = loc;
|
||||
Expression *e = new FuncExp(loc, fd);
|
||||
ExpInitializer *ie = new ExpInitializer(loc, e);
|
||||
return ie->semantic(sc, t);
|
||||
}
|
||||
else
|
||||
{
|
||||
error(loc, "a struct is not a valid initializer for a %s", t->toChars());
|
||||
errors = 1;
|
||||
error(loc, "a struct is not a valid initializer for a %s", t->toChars());
|
||||
errors = 1;
|
||||
}
|
||||
if (errors)
|
||||
{
|
||||
field.setDim(0);
|
||||
value.setDim(0);
|
||||
vars.setDim(0);
|
||||
field.setDim(0);
|
||||
value.setDim(0);
|
||||
vars.setDim(0);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -246,25 +246,25 @@ Expression *StructInitializer::toExpression()
|
||||
{ Expression *e;
|
||||
|
||||
//printf("StructInitializer::toExpression() %s\n", toChars());
|
||||
if (!ad) // if fwd referenced
|
||||
if (!ad) // if fwd referenced
|
||||
{
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
StructDeclaration *sd = ad->isStructDeclaration();
|
||||
if (!sd)
|
||||
return NULL;
|
||||
return NULL;
|
||||
Expressions *elements = new Expressions();
|
||||
for (size_t i = 0; i < value.dim; i++)
|
||||
{
|
||||
if (field.data[i])
|
||||
goto Lno;
|
||||
Initializer *iz = (Initializer *)value.data[i];
|
||||
if (!iz)
|
||||
goto Lno;
|
||||
Expression *ex = iz->toExpression();
|
||||
if (!ex)
|
||||
goto Lno;
|
||||
elements->push(ex);
|
||||
if (field.data[i])
|
||||
goto Lno;
|
||||
Initializer *iz = (Initializer *)value.data[i];
|
||||
if (!iz)
|
||||
goto Lno;
|
||||
Expression *ex = iz->toExpression();
|
||||
if (!ex)
|
||||
goto Lno;
|
||||
elements->push(ex);
|
||||
}
|
||||
e = new StructLiteralExp(loc, sd, elements);
|
||||
e->type = sd->type;
|
||||
@@ -284,7 +284,7 @@ void StructInitializer::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
for (int i = 0; i < field.dim; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
buf->writebyte(',');
|
||||
buf->writebyte(',');
|
||||
Identifier *id = (Identifier *)field.data[i];
|
||||
if (id)
|
||||
{
|
||||
@@ -318,14 +318,14 @@ Initializer *ArrayInitializer::syntaxCopy()
|
||||
ai->index.setDim(index.dim);
|
||||
ai->value.setDim(value.dim);
|
||||
for (int i = 0; i < ai->value.dim; i++)
|
||||
{ Expression *e = (Expression *)index.data[i];
|
||||
if (e)
|
||||
e = e->syntaxCopy();
|
||||
ai->index.data[i] = e;
|
||||
{ Expression *e = (Expression *)index.data[i];
|
||||
if (e)
|
||||
e = e->syntaxCopy();
|
||||
ai->index.data[i] = e;
|
||||
|
||||
Initializer *init = (Initializer *)value.data[i];
|
||||
init = init->syntaxCopy();
|
||||
ai->value.data[i] = init;
|
||||
Initializer *init = (Initializer *)value.data[i];
|
||||
init = init->syntaxCopy();
|
||||
ai->value.data[i] = init;
|
||||
}
|
||||
return ai;
|
||||
}
|
||||
@@ -343,48 +343,48 @@ Initializer *ArrayInitializer::semantic(Scope *sc, Type *t)
|
||||
unsigned length;
|
||||
|
||||
//printf("ArrayInitializer::semantic(%s)\n", t->toChars());
|
||||
if (sem) // if semantic() already run
|
||||
return this;
|
||||
if (sem) // if semantic() already run
|
||||
return this;
|
||||
sem = 1;
|
||||
type = t;
|
||||
t = t->toBasetype();
|
||||
switch (t->ty)
|
||||
{
|
||||
case Tpointer:
|
||||
case Tsarray:
|
||||
case Tarray:
|
||||
break;
|
||||
case Tpointer:
|
||||
case Tsarray:
|
||||
case Tarray:
|
||||
break;
|
||||
|
||||
default:
|
||||
error(loc, "cannot use array to initialize %s", type->toChars());
|
||||
return this;
|
||||
default:
|
||||
error(loc, "cannot use array to initialize %s", type->toChars());
|
||||
return this;
|
||||
}
|
||||
|
||||
length = 0;
|
||||
for (i = 0; i < index.dim; i++)
|
||||
{ Expression *idx;
|
||||
Initializer *val;
|
||||
{ Expression *idx;
|
||||
Initializer *val;
|
||||
|
||||
idx = (Expression *)index.data[i];
|
||||
if (idx)
|
||||
{ idx = idx->semantic(sc);
|
||||
idx = idx->optimize(WANTvalue | WANTinterpret);
|
||||
index.data[i] = (void *)idx;
|
||||
length = idx->toInteger();
|
||||
}
|
||||
idx = (Expression *)index.data[i];
|
||||
if (idx)
|
||||
{ idx = idx->semantic(sc);
|
||||
idx = idx->optimize(WANTvalue | WANTinterpret);
|
||||
index.data[i] = (void *)idx;
|
||||
length = idx->toInteger();
|
||||
}
|
||||
|
||||
val = (Initializer *)value.data[i];
|
||||
val = val->semantic(sc, t->next);
|
||||
value.data[i] = (void *)val;
|
||||
length++;
|
||||
if (length == 0)
|
||||
error(loc, "array dimension overflow");
|
||||
if (length > dim)
|
||||
dim = length;
|
||||
val = (Initializer *)value.data[i];
|
||||
val = val->semantic(sc, t->next);
|
||||
value.data[i] = (void *)val;
|
||||
length++;
|
||||
if (length == 0)
|
||||
error(loc, "array dimension overflow");
|
||||
if (length > dim)
|
||||
dim = length;
|
||||
}
|
||||
unsigned long amax = 0x80000000;
|
||||
if ((unsigned long) dim * t->next->size() >= amax)
|
||||
error(loc, "array dimension %u exceeds max of %ju", dim, amax / t->next->size());
|
||||
error(loc, "array dimension %u exceeds max of %ju", dim, amax / t->next->size());
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -403,53 +403,53 @@ Expression *ArrayInitializer::toExpression()
|
||||
Type *t = NULL;
|
||||
if (type)
|
||||
{
|
||||
if (type == Type::terror)
|
||||
return new ErrorExp();
|
||||
if (type == Type::terror)
|
||||
return new ErrorExp();
|
||||
|
||||
t = type->toBasetype();
|
||||
switch (t->ty)
|
||||
{
|
||||
case Tsarray:
|
||||
edim = ((TypeSArray *)t)->dim->toInteger();
|
||||
break;
|
||||
t = type->toBasetype();
|
||||
switch (t->ty)
|
||||
{
|
||||
case Tsarray:
|
||||
edim = ((TypeSArray *)t)->dim->toInteger();
|
||||
break;
|
||||
|
||||
case Tpointer:
|
||||
case Tarray:
|
||||
edim = dim;
|
||||
break;
|
||||
case Tpointer:
|
||||
case Tarray:
|
||||
edim = dim;
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
edim = value.dim;
|
||||
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
|
||||
{
|
||||
if (index.data[i])
|
||||
j = ((Expression *)index.data[i])->toInteger();
|
||||
if (j >= edim)
|
||||
edim = j + 1;
|
||||
}
|
||||
edim = value.dim;
|
||||
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
|
||||
{
|
||||
if (index.data[i])
|
||||
j = ((Expression *)index.data[i])->toInteger();
|
||||
if (j >= edim)
|
||||
edim = j + 1;
|
||||
}
|
||||
}
|
||||
|
||||
elements = new Expressions();
|
||||
elements->setDim(edim);
|
||||
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
|
||||
{
|
||||
if (index.data[i])
|
||||
j = ((Expression *)index.data[i])->toInteger();
|
||||
assert(j < edim);
|
||||
Initializer *iz = (Initializer *)value.data[i];
|
||||
if (!iz)
|
||||
goto Lno;
|
||||
Expression *ex = iz->toExpression();
|
||||
if (!ex)
|
||||
{
|
||||
goto Lno;
|
||||
}
|
||||
elements->data[j] = ex;
|
||||
if (index.data[i])
|
||||
j = ((Expression *)index.data[i])->toInteger();
|
||||
assert(j < edim);
|
||||
Initializer *iz = (Initializer *)value.data[i];
|
||||
if (!iz)
|
||||
goto Lno;
|
||||
Expression *ex = iz->toExpression();
|
||||
if (!ex)
|
||||
{
|
||||
goto Lno;
|
||||
}
|
||||
elements->data[j] = ex;
|
||||
}
|
||||
|
||||
/* Fill in any missing elements with the default initializer
|
||||
@@ -458,14 +458,14 @@ Expression *ArrayInitializer::toExpression()
|
||||
Expression *init = NULL;
|
||||
for (size_t i = 0; i < edim; i++)
|
||||
{
|
||||
if (!elements->data[i])
|
||||
{
|
||||
if (!type)
|
||||
goto Lno;
|
||||
if (!init)
|
||||
init = t->next->defaultInit();
|
||||
elements->data[i] = init;
|
||||
}
|
||||
if (!elements->data[i])
|
||||
{
|
||||
if (!type)
|
||||
goto Lno;
|
||||
if (!init)
|
||||
init = t->next->defaultInit();
|
||||
elements->data[i] = init;
|
||||
}
|
||||
}
|
||||
|
||||
Expression *e = new ArrayLiteralExp(loc, elements);
|
||||
@@ -497,18 +497,18 @@ Initializer *ArrayInitializer::toAssocArrayInitializer()
|
||||
|
||||
for (size_t i = 0; i < value.dim; i++)
|
||||
{
|
||||
e = (Expression *)index.data[i];
|
||||
if (!e)
|
||||
goto Lno;
|
||||
keys->data[i] = (void *)e;
|
||||
e = (Expression *)index.data[i];
|
||||
if (!e)
|
||||
goto Lno;
|
||||
keys->data[i] = (void *)e;
|
||||
|
||||
Initializer *iz = (Initializer *)value.data[i];
|
||||
if (!iz)
|
||||
goto Lno;
|
||||
e = iz->toExpression();
|
||||
if (!e)
|
||||
goto Lno;
|
||||
values->data[i] = (void *)e;
|
||||
Initializer *iz = (Initializer *)value.data[i];
|
||||
if (!iz)
|
||||
goto Lno;
|
||||
e = iz->toExpression();
|
||||
if (!e)
|
||||
goto Lno;
|
||||
values->data[i] = (void *)e;
|
||||
}
|
||||
e = new AssocArrayLiteralExp(loc, keys, values);
|
||||
return new ExpInitializer(loc, e);
|
||||
@@ -525,18 +525,18 @@ Type *ArrayInitializer::inferType(Scope *sc)
|
||||
{
|
||||
for (size_t i = 0; i < value.dim; i++)
|
||||
{
|
||||
if (index.data[i])
|
||||
goto Laa;
|
||||
if (index.data[i])
|
||||
goto Laa;
|
||||
}
|
||||
if (value.dim)
|
||||
{
|
||||
Initializer *iz = (Initializer *)value.data[0];
|
||||
if (iz)
|
||||
{ Type *t = iz->inferType(sc);
|
||||
t = new TypeSArray(t, new IntegerExp(value.dim));
|
||||
t = t->semantic(loc, sc);
|
||||
return t;
|
||||
}
|
||||
Initializer *iz = (Initializer *)value.data[0];
|
||||
if (iz)
|
||||
{ Type *t = iz->inferType(sc);
|
||||
t = new TypeSArray(t, new IntegerExp(value.dim));
|
||||
t = t->semantic(loc, sc);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
Laa:
|
||||
@@ -546,13 +546,13 @@ Laa:
|
||||
Expression *indexinit = (Expression *)index.data[0];
|
||||
if (iz && indexinit)
|
||||
{ Type *t = iz->inferType(sc);
|
||||
indexinit = indexinit->semantic(sc);
|
||||
Type *indext = indexinit->type;
|
||||
t = new TypeAArray(t, indext);
|
||||
type = t->semantic(loc, sc);
|
||||
indexinit = indexinit->semantic(sc);
|
||||
Type *indext = indexinit->type;
|
||||
t = new TypeAArray(t, indext);
|
||||
type = t->semantic(loc, sc);
|
||||
}
|
||||
else
|
||||
error(loc, "cannot infer type from this array initializer");
|
||||
error(loc, "cannot infer type from this array initializer");
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ void ArrayInitializer::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
for (int i = 0; i < index.dim; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
buf->writebyte(',');
|
||||
buf->writebyte(',');
|
||||
Expression *ex = (Expression *)index.data[i];
|
||||
if (ex)
|
||||
{
|
||||
@@ -599,30 +599,30 @@ Initializer *ExpInitializer::semantic(Scope *sc, Type *t)
|
||||
|
||||
/* Look for case of initializing a static array with a too-short
|
||||
* string literal, such as:
|
||||
* char[5] foo = "abc";
|
||||
* char[5] foo = "abc";
|
||||
* Allow this by doing an explicit cast, which will lengthen the string
|
||||
* literal.
|
||||
*/
|
||||
if (exp->op == TOKstring && tb->ty == Tsarray && exp->type->ty == Tsarray)
|
||||
{ StringExp *se = (StringExp *)exp;
|
||||
{ StringExp *se = (StringExp *)exp;
|
||||
|
||||
if (!se->committed && se->type->ty == Tsarray &&
|
||||
((TypeSArray *)se->type)->dim->toInteger() <
|
||||
((TypeSArray *)t)->dim->toInteger())
|
||||
{
|
||||
exp = se->castTo(sc, t);
|
||||
goto L1;
|
||||
}
|
||||
if (!se->committed && se->type->ty == Tsarray &&
|
||||
((TypeSArray *)se->type)->dim->toInteger() <
|
||||
((TypeSArray *)t)->dim->toInteger())
|
||||
{
|
||||
exp = se->castTo(sc, t);
|
||||
goto L1;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for the case of statically initializing an array
|
||||
// with a single member.
|
||||
if (tb->ty == Tsarray &&
|
||||
!tb->next->equals(exp->type->toBasetype()->next) &&
|
||||
exp->implicitConvTo(tb->next)
|
||||
!tb->next->equals(exp->type->toBasetype()->next) &&
|
||||
exp->implicitConvTo(tb->next)
|
||||
)
|
||||
{
|
||||
t = tb->next;
|
||||
t = tb->next;
|
||||
}
|
||||
|
||||
exp = exp->implicitCastTo(sc, t);
|
||||
@@ -641,28 +641,28 @@ Type *ExpInitializer::inferType(Scope *sc)
|
||||
// Give error for overloaded function addresses
|
||||
if (exp->op == TOKsymoff)
|
||||
{ SymOffExp *se = (SymOffExp *)exp;
|
||||
if (
|
||||
if (
|
||||
#if DMDV2
|
||||
se->hasOverloads &&
|
||||
se->hasOverloads &&
|
||||
#else
|
||||
se->var->isFuncDeclaration() &&
|
||||
se->var->isFuncDeclaration() &&
|
||||
#endif
|
||||
!se->var->isFuncDeclaration()->isUnique())
|
||||
exp->error("cannot infer type from overloaded function symbol %s", exp->toChars());
|
||||
!se->var->isFuncDeclaration()->isUnique())
|
||||
exp->error("cannot infer type from overloaded function symbol %s", exp->toChars());
|
||||
}
|
||||
|
||||
// Give error for overloaded function addresses
|
||||
if (exp->op == TOKdelegate)
|
||||
{ DelegateExp *se = (DelegateExp *)exp;
|
||||
if (
|
||||
se->func->isFuncDeclaration() &&
|
||||
!se->func->isFuncDeclaration()->isUnique())
|
||||
exp->error("cannot infer type from overloaded function symbol %s", exp->toChars());
|
||||
if (
|
||||
se->func->isFuncDeclaration() &&
|
||||
!se->func->isFuncDeclaration()->isUnique())
|
||||
exp->error("cannot infer type from overloaded function symbol %s", exp->toChars());
|
||||
}
|
||||
|
||||
Type *t = exp->type;
|
||||
if (!t)
|
||||
t = Initializer::inferType(sc);
|
||||
t = Initializer::inferType(sc);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
22
dmd/init.h
22
dmd/init.h
@@ -56,7 +56,7 @@ struct Initializer : Object
|
||||
|
||||
struct VoidInitializer : Initializer
|
||||
{
|
||||
Type *type; // type that this will initialize to
|
||||
Type *type; // type that this will initialize to
|
||||
|
||||
VoidInitializer(Loc loc);
|
||||
Initializer *syntaxCopy();
|
||||
@@ -73,11 +73,11 @@ struct VoidInitializer : Initializer
|
||||
|
||||
struct StructInitializer : Initializer
|
||||
{
|
||||
Identifiers field; // of Identifier *'s
|
||||
Initializers value; // parallel array of Initializer *'s
|
||||
Identifiers field; // of Identifier *'s
|
||||
Initializers value; // parallel array of Initializer *'s
|
||||
|
||||
Array vars; // parallel array of VarDeclaration *'s
|
||||
AggregateDeclaration *ad; // which aggregate this is for
|
||||
Array vars; // parallel array of VarDeclaration *'s
|
||||
AggregateDeclaration *ad; // which aggregate this is for
|
||||
|
||||
StructInitializer(Loc loc);
|
||||
Initializer *syntaxCopy();
|
||||
@@ -95,11 +95,11 @@ struct StructInitializer : Initializer
|
||||
|
||||
struct ArrayInitializer : Initializer
|
||||
{
|
||||
Expressions index; // indices
|
||||
Initializers value; // of Initializer *'s
|
||||
unsigned dim; // length of array being initialized
|
||||
Type *type; // type that array will be used to initialize
|
||||
int sem; // !=0 if semantic() is run
|
||||
Expressions index; // indices
|
||||
Initializers value; // of Initializer *'s
|
||||
unsigned dim; // length of array being initialized
|
||||
Type *type; // type that array will be used to initialize
|
||||
int sem; // !=0 if semantic() is run
|
||||
|
||||
ArrayInitializer(Loc loc);
|
||||
Initializer *syntaxCopy();
|
||||
@@ -112,7 +112,7 @@ struct ArrayInitializer : Initializer
|
||||
|
||||
#if IN_DMD
|
||||
dt_t *toDt();
|
||||
dt_t *toDtBit(); // for bit arrays
|
||||
dt_t *toDtBit(); // for bit arrays
|
||||
#endif
|
||||
|
||||
ArrayInitializer *isArrayInitializer() { return this; }
|
||||
|
||||
924
dmd/inline.c
924
dmd/inline.c
File diff suppressed because it is too large
Load Diff
1872
dmd/interpret.c
1872
dmd/interpret.c
File diff suppressed because it is too large
Load Diff
246
dmd/json.c
246
dmd/json.c
@@ -51,11 +51,11 @@ void json_generate(Array *modules)
|
||||
|
||||
buf.writestring("[\n");
|
||||
for (int i = 0; i < modules->dim; i++)
|
||||
{ Module *m = (Module *)modules->data[i];
|
||||
if (global.params.verbose)
|
||||
printf("json gen %s\n", m->toChars());
|
||||
m->toJsonBuffer(&buf);
|
||||
buf.writestring(",\n");
|
||||
{ Module *m = (Module *)modules->data[i];
|
||||
if (global.params.verbose)
|
||||
printf("json gen %s\n", m->toChars());
|
||||
m->toJsonBuffer(&buf);
|
||||
buf.writestring(",\n");
|
||||
}
|
||||
JsonRemoveComma(&buf);
|
||||
buf.writestring("]\n");
|
||||
@@ -71,9 +71,9 @@ void json_generate(Array *modules)
|
||||
arg = fn->toChars();
|
||||
}
|
||||
else if (arg[0] == '-' && arg[1] == 0)
|
||||
{ // Write to stdout
|
||||
fwrite(buf.data, 1, buf.offset, stdout);
|
||||
return;
|
||||
{ // Write to stdout
|
||||
fwrite(buf.data, 1, buf.offset, stdout);
|
||||
return;
|
||||
}
|
||||
// if (!FileName::absolute(arg))
|
||||
// arg = FileName::combine(dir, arg);
|
||||
@@ -84,7 +84,7 @@ void json_generate(Array *modules)
|
||||
jsonfile->ref = 1;
|
||||
char *pt = FileName::path(jsonfile->toChars());
|
||||
if (*pt)
|
||||
FileName::ensurePathExists(pt);
|
||||
FileName::ensurePathExists(pt);
|
||||
mem.free(pt);
|
||||
jsonfile->writev();
|
||||
}
|
||||
@@ -98,49 +98,49 @@ void JsonString(OutBuffer *buf, const char *s)
|
||||
buf->writeByte('\"');
|
||||
for (; *s; s++)
|
||||
{
|
||||
unsigned char c = (unsigned char) *s;
|
||||
switch (c)
|
||||
{
|
||||
case '\n':
|
||||
buf->writestring("\\n");
|
||||
break;
|
||||
unsigned char c = (unsigned char) *s;
|
||||
switch (c)
|
||||
{
|
||||
case '\n':
|
||||
buf->writestring("\\n");
|
||||
break;
|
||||
|
||||
case '\r':
|
||||
buf->writestring("\\r");
|
||||
break;
|
||||
case '\r':
|
||||
buf->writestring("\\r");
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
buf->writestring("\\t");
|
||||
break;
|
||||
case '\t':
|
||||
buf->writestring("\\t");
|
||||
break;
|
||||
|
||||
case '\"':
|
||||
buf->writestring("\\\"");
|
||||
break;
|
||||
case '\"':
|
||||
buf->writestring("\\\"");
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
buf->writestring("\\\\");
|
||||
break;
|
||||
case '\\':
|
||||
buf->writestring("\\\\");
|
||||
break;
|
||||
|
||||
case '/':
|
||||
buf->writestring("\\/");
|
||||
break;
|
||||
case '/':
|
||||
buf->writestring("\\/");
|
||||
break;
|
||||
|
||||
case '\b':
|
||||
buf->writestring("\\b");
|
||||
break;
|
||||
case '\b':
|
||||
buf->writestring("\\b");
|
||||
break;
|
||||
|
||||
case '\f':
|
||||
buf->writestring("\\f");
|
||||
break;
|
||||
case '\f':
|
||||
buf->writestring("\\f");
|
||||
break;
|
||||
|
||||
default:
|
||||
if (c < 0x20)
|
||||
buf->printf("\\u%04x", c);
|
||||
else
|
||||
// Note that UTF-8 chars pass through here just fine
|
||||
buf->writeByte(c);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (c < 0x20)
|
||||
buf->printf("\\u%04x", c);
|
||||
else
|
||||
// Note that UTF-8 chars pass through here just fine
|
||||
buf->writeByte(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
buf->writeByte('\"');
|
||||
}
|
||||
@@ -164,9 +164,9 @@ void JsonProperty(OutBuffer *buf, const char *name, int value)
|
||||
void JsonRemoveComma(OutBuffer *buf)
|
||||
{
|
||||
if (buf->offset >= 2 &&
|
||||
buf->data[buf->offset - 2] == ',' &&
|
||||
buf->data[buf->offset - 1] == '\n')
|
||||
buf->offset -= 2;
|
||||
buf->data[buf->offset - 2] == ',' &&
|
||||
buf->data[buf->offset - 1] == '\n')
|
||||
buf->offset -= 2;
|
||||
}
|
||||
|
||||
void Dsymbol::toJsonBuffer(OutBuffer *buf)
|
||||
@@ -178,26 +178,26 @@ void Module::toJsonBuffer(OutBuffer *buf)
|
||||
buf->writestring("{\n");
|
||||
|
||||
if (md)
|
||||
JsonProperty(buf, Pname, md->toChars());
|
||||
JsonProperty(buf, Pname, md->toChars());
|
||||
|
||||
JsonProperty(buf, Pkind, kind());
|
||||
|
||||
JsonProperty(buf, Pfile, srcfile->toChars());
|
||||
|
||||
if (comment)
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
|
||||
JsonString(buf, Pmembers);
|
||||
buf->writestring(" : [\n");
|
||||
|
||||
size_t offset = buf->offset;
|
||||
for (int i = 0; i < members->dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
s->toJsonBuffer(buf);
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
s->toJsonBuffer(buf);
|
||||
}
|
||||
|
||||
JsonRemoveComma(buf);
|
||||
@@ -214,11 +214,11 @@ void AttribDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||
|
||||
if (d)
|
||||
{
|
||||
for (unsigned i = 0; i < d->dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)d->data[i];
|
||||
//printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars());
|
||||
s->toJsonBuffer(buf);
|
||||
}
|
||||
for (unsigned i = 0; i < d->dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)d->data[i];
|
||||
//printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars());
|
||||
s->toJsonBuffer(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ void ConditionalDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||
//printf("ConditionalDeclaration::toJsonBuffer()\n");
|
||||
if (condition->inc)
|
||||
{
|
||||
AttribDeclaration::toJsonBuffer(buf);
|
||||
AttribDeclaration::toJsonBuffer(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,18 +252,18 @@ void Declaration::toJsonBuffer(OutBuffer *buf)
|
||||
JsonProperty(buf, Pname, toChars());
|
||||
JsonProperty(buf, Pkind, kind());
|
||||
if (type)
|
||||
JsonProperty(buf, Ptype, type->toChars());
|
||||
JsonProperty(buf, Ptype, type->toChars());
|
||||
|
||||
if (comment)
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
|
||||
if (loc.linnum)
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
|
||||
TypedefDeclaration *td = isTypedefDeclaration();
|
||||
if (td)
|
||||
{
|
||||
JsonProperty(buf, "base", td->basetype->toChars());
|
||||
JsonProperty(buf, "base", td->basetype->toChars());
|
||||
}
|
||||
|
||||
JsonRemoveComma(buf);
|
||||
@@ -278,45 +278,45 @@ void AggregateDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||
JsonProperty(buf, Pname, toChars());
|
||||
JsonProperty(buf, Pkind, kind());
|
||||
if (comment)
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
if (loc.linnum)
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
|
||||
ClassDeclaration *cd = isClassDeclaration();
|
||||
if (cd)
|
||||
{
|
||||
if (cd->baseClass)
|
||||
{
|
||||
JsonProperty(buf, "base", cd->baseClass->toChars());
|
||||
}
|
||||
if (cd->interfaces_dim)
|
||||
{
|
||||
JsonString(buf, "interfaces");
|
||||
buf->writestring(" : [\n");
|
||||
size_t offset = buf->offset;
|
||||
for (int i = 0; i < cd->interfaces_dim; i++)
|
||||
{ BaseClass *b = cd->interfaces[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
JsonString(buf, b->base->toChars());
|
||||
}
|
||||
JsonRemoveComma(buf);
|
||||
buf->writestring("],\n");
|
||||
}
|
||||
if (cd->baseClass)
|
||||
{
|
||||
JsonProperty(buf, "base", cd->baseClass->toChars());
|
||||
}
|
||||
if (cd->interfaces_dim)
|
||||
{
|
||||
JsonString(buf, "interfaces");
|
||||
buf->writestring(" : [\n");
|
||||
size_t offset = buf->offset;
|
||||
for (int i = 0; i < cd->interfaces_dim; i++)
|
||||
{ BaseClass *b = cd->interfaces[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
JsonString(buf, b->base->toChars());
|
||||
}
|
||||
JsonRemoveComma(buf);
|
||||
buf->writestring("],\n");
|
||||
}
|
||||
}
|
||||
|
||||
JsonString(buf, Pmembers);
|
||||
buf->writestring(" : [\n");
|
||||
size_t offset = buf->offset;
|
||||
for (int i = 0; i < members->dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
s->toJsonBuffer(buf);
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
s->toJsonBuffer(buf);
|
||||
}
|
||||
JsonRemoveComma(buf);
|
||||
buf->writestring("]\n");
|
||||
@@ -333,21 +333,21 @@ void TemplateDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||
JsonProperty(buf, Pname, toChars());
|
||||
JsonProperty(buf, Pkind, kind());
|
||||
if (comment)
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
|
||||
if (loc.linnum)
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
|
||||
JsonString(buf, Pmembers);
|
||||
buf->writestring(" : [\n");
|
||||
size_t offset = buf->offset;
|
||||
for (int i = 0; i < members->dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
s->toJsonBuffer(buf);
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
s->toJsonBuffer(buf);
|
||||
}
|
||||
JsonRemoveComma(buf);
|
||||
buf->writestring("]\n");
|
||||
@@ -360,17 +360,17 @@ void EnumDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||
//printf("EnumDeclaration::toJsonBuffer()\n");
|
||||
if (isAnonymous())
|
||||
{
|
||||
if (members)
|
||||
{
|
||||
for (int i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
s->toJsonBuffer(buf);
|
||||
buf->writestring(",\n");
|
||||
}
|
||||
JsonRemoveComma(buf);
|
||||
}
|
||||
return;
|
||||
if (members)
|
||||
{
|
||||
for (int i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
s->toJsonBuffer(buf);
|
||||
buf->writestring(",\n");
|
||||
}
|
||||
JsonRemoveComma(buf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
buf->writestring("{\n");
|
||||
@@ -378,24 +378,24 @@ void EnumDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||
JsonProperty(buf, Pname, toChars());
|
||||
JsonProperty(buf, Pkind, kind());
|
||||
if (comment)
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
|
||||
if (loc.linnum)
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
|
||||
if (memtype)
|
||||
JsonProperty(buf, "base", memtype->toChars());
|
||||
JsonProperty(buf, "base", memtype->toChars());
|
||||
|
||||
JsonString(buf, Pmembers);
|
||||
buf->writestring(" : [\n");
|
||||
size_t offset = buf->offset;
|
||||
for (int i = 0; i < members->dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
s->toJsonBuffer(buf);
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
if (offset != buf->offset)
|
||||
{ buf->writestring(",\n");
|
||||
offset = buf->offset;
|
||||
}
|
||||
s->toJsonBuffer(buf);
|
||||
}
|
||||
JsonRemoveComma(buf);
|
||||
buf->writestring("]\n");
|
||||
@@ -412,10 +412,10 @@ void EnumMember::toJsonBuffer(OutBuffer *buf)
|
||||
JsonProperty(buf, Pkind, kind());
|
||||
|
||||
if (comment)
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||
|
||||
if (loc.linnum)
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
JsonProperty(buf, Pline, loc.linnum);
|
||||
|
||||
JsonRemoveComma(buf);
|
||||
buf->writestring("}\n");
|
||||
|
||||
4230
dmd/lexer.c
4230
dmd/lexer.c
File diff suppressed because it is too large
Load Diff
350
dmd/lexer.h
350
dmd/lexer.h
@@ -23,143 +23,143 @@ struct Identifier;
|
||||
struct Module;
|
||||
|
||||
/* Tokens:
|
||||
( )
|
||||
[ ]
|
||||
{ }
|
||||
< > <= >= == != === !==
|
||||
<< >> <<= >>= >>> >>>=
|
||||
+ - += -=
|
||||
* / % *= /= %=
|
||||
& | ^ &= |= ^=
|
||||
= ! ~
|
||||
++ --
|
||||
. -> : ,
|
||||
? && ||
|
||||
( )
|
||||
[ ]
|
||||
{ }
|
||||
< > <= >= == != === !==
|
||||
<< >> <<= >>= >>> >>>=
|
||||
+ - += -=
|
||||
* / % *= /= %=
|
||||
& | ^ &= |= ^=
|
||||
= ! ~
|
||||
++ --
|
||||
. -> : ,
|
||||
? && ||
|
||||
*/
|
||||
|
||||
enum TOK
|
||||
{
|
||||
TOKreserved,
|
||||
TOKreserved,
|
||||
|
||||
// Other
|
||||
TOKlparen, TOKrparen,
|
||||
TOKlbracket, TOKrbracket,
|
||||
TOKlcurly, TOKrcurly,
|
||||
TOKcolon, TOKneg,
|
||||
TOKsemicolon, TOKdotdotdot,
|
||||
TOKeof, TOKcast,
|
||||
TOKnull, TOKassert,
|
||||
TOKtrue, TOKfalse,
|
||||
TOKarray, TOKcall,
|
||||
TOKaddress,
|
||||
TOKtype, TOKthrow,
|
||||
TOKnew, TOKdelete,
|
||||
TOKstar, TOKsymoff,
|
||||
TOKvar, TOKdotvar,
|
||||
TOKdotti, TOKdotexp,
|
||||
TOKdottype, TOKslice,
|
||||
TOKarraylength, TOKversion,
|
||||
TOKmodule, TOKdollar,
|
||||
TOKtemplate, TOKdottd,
|
||||
TOKdeclaration, TOKtypeof,
|
||||
TOKpragma, TOKdsymbol,
|
||||
TOKtypeid, TOKuadd,
|
||||
TOKremove,
|
||||
TOKnewanonclass, TOKcomment,
|
||||
TOKarrayliteral, TOKassocarrayliteral,
|
||||
TOKstructliteral,
|
||||
// Other
|
||||
TOKlparen, TOKrparen,
|
||||
TOKlbracket, TOKrbracket,
|
||||
TOKlcurly, TOKrcurly,
|
||||
TOKcolon, TOKneg,
|
||||
TOKsemicolon, TOKdotdotdot,
|
||||
TOKeof, TOKcast,
|
||||
TOKnull, TOKassert,
|
||||
TOKtrue, TOKfalse,
|
||||
TOKarray, TOKcall,
|
||||
TOKaddress,
|
||||
TOKtype, TOKthrow,
|
||||
TOKnew, TOKdelete,
|
||||
TOKstar, TOKsymoff,
|
||||
TOKvar, TOKdotvar,
|
||||
TOKdotti, TOKdotexp,
|
||||
TOKdottype, TOKslice,
|
||||
TOKarraylength, TOKversion,
|
||||
TOKmodule, TOKdollar,
|
||||
TOKtemplate, TOKdottd,
|
||||
TOKdeclaration, TOKtypeof,
|
||||
TOKpragma, TOKdsymbol,
|
||||
TOKtypeid, TOKuadd,
|
||||
TOKremove,
|
||||
TOKnewanonclass, TOKcomment,
|
||||
TOKarrayliteral, TOKassocarrayliteral,
|
||||
TOKstructliteral,
|
||||
|
||||
// Operators
|
||||
TOKlt, TOKgt,
|
||||
TOKle, TOKge,
|
||||
TOKequal, TOKnotequal,
|
||||
TOKidentity, TOKnotidentity,
|
||||
TOKindex, TOKis,
|
||||
TOKtobool,
|
||||
// Operators
|
||||
TOKlt, TOKgt,
|
||||
TOKle, TOKge,
|
||||
TOKequal, TOKnotequal,
|
||||
TOKidentity, TOKnotidentity,
|
||||
TOKindex, TOKis,
|
||||
TOKtobool,
|
||||
|
||||
// 60
|
||||
// NCEG floating point compares
|
||||
// !<>= <> <>= !> !>= !< !<= !<>
|
||||
TOKunord,TOKlg,TOKleg,TOKule,TOKul,TOKuge,TOKug,TOKue,
|
||||
// NCEG floating point compares
|
||||
// !<>= <> <>= !> !>= !< !<= !<>
|
||||
TOKunord,TOKlg,TOKleg,TOKule,TOKul,TOKuge,TOKug,TOKue,
|
||||
|
||||
TOKshl, TOKshr,
|
||||
TOKshlass, TOKshrass,
|
||||
TOKushr, TOKushrass,
|
||||
TOKcat, TOKcatass, // ~ ~=
|
||||
TOKadd, TOKmin, TOKaddass, TOKminass,
|
||||
TOKmul, TOKdiv, TOKmod,
|
||||
TOKmulass, TOKdivass, TOKmodass,
|
||||
TOKand, TOKor, TOKxor,
|
||||
TOKandass, TOKorass, TOKxorass,
|
||||
TOKassign, TOKnot, TOKtilde,
|
||||
TOKplusplus, TOKminusminus, TOKconstruct, TOKblit,
|
||||
TOKdot, TOKarrow, TOKcomma,
|
||||
TOKquestion, TOKandand, TOKoror,
|
||||
TOKshl, TOKshr,
|
||||
TOKshlass, TOKshrass,
|
||||
TOKushr, TOKushrass,
|
||||
TOKcat, TOKcatass, // ~ ~=
|
||||
TOKadd, TOKmin, TOKaddass, TOKminass,
|
||||
TOKmul, TOKdiv, TOKmod,
|
||||
TOKmulass, TOKdivass, TOKmodass,
|
||||
TOKand, TOKor, TOKxor,
|
||||
TOKandass, TOKorass, TOKxorass,
|
||||
TOKassign, TOKnot, TOKtilde,
|
||||
TOKplusplus, TOKminusminus, TOKconstruct, TOKblit,
|
||||
TOKdot, TOKarrow, TOKcomma,
|
||||
TOKquestion, TOKandand, TOKoror,
|
||||
|
||||
// 104
|
||||
// Numeric literals
|
||||
TOKint32v, TOKuns32v,
|
||||
TOKint64v, TOKuns64v,
|
||||
TOKfloat32v, TOKfloat64v, TOKfloat80v,
|
||||
TOKimaginary32v, TOKimaginary64v, TOKimaginary80v,
|
||||
// Numeric literals
|
||||
TOKint32v, TOKuns32v,
|
||||
TOKint64v, TOKuns64v,
|
||||
TOKfloat32v, TOKfloat64v, TOKfloat80v,
|
||||
TOKimaginary32v, TOKimaginary64v, TOKimaginary80v,
|
||||
|
||||
// Char constants
|
||||
TOKcharv, TOKwcharv, TOKdcharv,
|
||||
// Char constants
|
||||
TOKcharv, TOKwcharv, TOKdcharv,
|
||||
|
||||
// Leaf operators
|
||||
TOKidentifier, TOKstring,
|
||||
TOKthis, TOKsuper,
|
||||
TOKhalt, TOKtuple,
|
||||
TOKerror,
|
||||
// Leaf operators
|
||||
TOKidentifier, TOKstring,
|
||||
TOKthis, TOKsuper,
|
||||
TOKhalt, TOKtuple,
|
||||
TOKerror,
|
||||
|
||||
// Basic types
|
||||
TOKvoid,
|
||||
TOKint8, TOKuns8,
|
||||
TOKint16, TOKuns16,
|
||||
TOKint32, TOKuns32,
|
||||
TOKint64, TOKuns64,
|
||||
TOKfloat32, TOKfloat64, TOKfloat80,
|
||||
TOKimaginary32, TOKimaginary64, TOKimaginary80,
|
||||
TOKcomplex32, TOKcomplex64, TOKcomplex80,
|
||||
TOKchar, TOKwchar, TOKdchar, TOKbit, TOKbool,
|
||||
TOKcent, TOKucent,
|
||||
// Basic types
|
||||
TOKvoid,
|
||||
TOKint8, TOKuns8,
|
||||
TOKint16, TOKuns16,
|
||||
TOKint32, TOKuns32,
|
||||
TOKint64, TOKuns64,
|
||||
TOKfloat32, TOKfloat64, TOKfloat80,
|
||||
TOKimaginary32, TOKimaginary64, TOKimaginary80,
|
||||
TOKcomplex32, TOKcomplex64, TOKcomplex80,
|
||||
TOKchar, TOKwchar, TOKdchar, TOKbit, TOKbool,
|
||||
TOKcent, TOKucent,
|
||||
|
||||
// 150
|
||||
// Aggregates
|
||||
TOKstruct, TOKclass, TOKinterface, TOKunion, TOKenum, TOKimport,
|
||||
TOKtypedef, TOKalias, TOKoverride, TOKdelegate, TOKfunction,
|
||||
TOKmixin,
|
||||
// Aggregates
|
||||
TOKstruct, TOKclass, TOKinterface, TOKunion, TOKenum, TOKimport,
|
||||
TOKtypedef, TOKalias, TOKoverride, TOKdelegate, TOKfunction,
|
||||
TOKmixin,
|
||||
|
||||
TOKalign, TOKextern, TOKprivate, TOKprotected, TOKpublic, TOKexport,
|
||||
TOKstatic, /*TOKvirtual,*/ TOKfinal, TOKconst, TOKabstract, TOKvolatile,
|
||||
TOKdebug, TOKdeprecated, TOKin, TOKout, TOKinout, TOKlazy,
|
||||
TOKauto, TOKpackage, TOKmanifest,
|
||||
TOKalign, TOKextern, TOKprivate, TOKprotected, TOKpublic, TOKexport,
|
||||
TOKstatic, /*TOKvirtual,*/ TOKfinal, TOKconst, TOKabstract, TOKvolatile,
|
||||
TOKdebug, TOKdeprecated, TOKin, TOKout, TOKinout, TOKlazy,
|
||||
TOKauto, TOKpackage, TOKmanifest,
|
||||
|
||||
// Statements
|
||||
TOKif, TOKelse, TOKwhile, TOKfor, TOKdo, TOKswitch,
|
||||
TOKcase, TOKdefault, TOKbreak, TOKcontinue, TOKwith,
|
||||
TOKsynchronized, TOKreturn, TOKgoto, TOKtry, TOKcatch, TOKfinally,
|
||||
TOKasm, TOKforeach, TOKforeach_reverse,
|
||||
TOKscope,
|
||||
TOKon_scope_exit, TOKon_scope_failure, TOKon_scope_success,
|
||||
// Statements
|
||||
TOKif, TOKelse, TOKwhile, TOKfor, TOKdo, TOKswitch,
|
||||
TOKcase, TOKdefault, TOKbreak, TOKcontinue, TOKwith,
|
||||
TOKsynchronized, TOKreturn, TOKgoto, TOKtry, TOKcatch, TOKfinally,
|
||||
TOKasm, TOKforeach, TOKforeach_reverse,
|
||||
TOKscope,
|
||||
TOKon_scope_exit, TOKon_scope_failure, TOKon_scope_success,
|
||||
|
||||
// Contracts
|
||||
TOKbody, TOKinvariant,
|
||||
// Contracts
|
||||
TOKbody, TOKinvariant,
|
||||
|
||||
// Testing
|
||||
TOKunittest,
|
||||
// Testing
|
||||
TOKunittest,
|
||||
|
||||
// Added after 1.0
|
||||
TOKref,
|
||||
TOKmacro,
|
||||
// Added after 1.0
|
||||
TOKref,
|
||||
TOKmacro,
|
||||
#if DMDV2
|
||||
TOKtraits,
|
||||
TOKoverloadset,
|
||||
TOKpure,
|
||||
TOKnothrow,
|
||||
TOKtls,
|
||||
TOKline,
|
||||
TOKfile,
|
||||
TOKtraits,
|
||||
TOKoverloadset,
|
||||
TOKpure,
|
||||
TOKnothrow,
|
||||
TOKtls,
|
||||
TOKline,
|
||||
TOKfile,
|
||||
TOKshared,
|
||||
#endif
|
||||
|
||||
@@ -168,74 +168,74 @@ enum TOK
|
||||
TOKgep,
|
||||
#endif
|
||||
|
||||
TOKMAX
|
||||
TOKMAX
|
||||
};
|
||||
|
||||
#define BASIC_TYPES \
|
||||
TOKwchar: case TOKdchar: \
|
||||
case TOKbit: case TOKbool: case TOKchar: \
|
||||
case TOKint8: case TOKuns8: \
|
||||
case TOKint16: case TOKuns16: \
|
||||
case TOKint32: case TOKuns32: \
|
||||
case TOKint64: case TOKuns64: \
|
||||
case TOKfloat32: case TOKfloat64: case TOKfloat80: \
|
||||
case TOKimaginary32: case TOKimaginary64: case TOKimaginary80: \
|
||||
case TOKcomplex32: case TOKcomplex64: case TOKcomplex80: \
|
||||
case TOKvoid
|
||||
#define BASIC_TYPES \
|
||||
TOKwchar: case TOKdchar: \
|
||||
case TOKbit: case TOKbool: case TOKchar: \
|
||||
case TOKint8: case TOKuns8: \
|
||||
case TOKint16: case TOKuns16: \
|
||||
case TOKint32: case TOKuns32: \
|
||||
case TOKint64: case TOKuns64: \
|
||||
case TOKfloat32: case TOKfloat64: case TOKfloat80: \
|
||||
case TOKimaginary32: case TOKimaginary64: case TOKimaginary80: \
|
||||
case TOKcomplex32: case TOKcomplex64: case TOKcomplex80: \
|
||||
case TOKvoid
|
||||
|
||||
#define BASIC_TYPES_X(t) \
|
||||
TOKvoid: t = Type::tvoid; goto LabelX; \
|
||||
case TOKint8: t = Type::tint8; goto LabelX; \
|
||||
case TOKuns8: t = Type::tuns8; goto LabelX; \
|
||||
case TOKint16: t = Type::tint16; goto LabelX; \
|
||||
case TOKuns16: t = Type::tuns16; goto LabelX; \
|
||||
case TOKint32: t = Type::tint32; goto LabelX; \
|
||||
case TOKuns32: t = Type::tuns32; goto LabelX; \
|
||||
case TOKint64: t = Type::tint64; goto LabelX; \
|
||||
case TOKuns64: t = Type::tuns64; goto LabelX; \
|
||||
case TOKfloat32: t = Type::tfloat32; goto LabelX; \
|
||||
case TOKfloat64: t = Type::tfloat64; goto LabelX; \
|
||||
case TOKfloat80: t = Type::tfloat80; goto LabelX; \
|
||||
case TOKimaginary32: t = Type::timaginary32; goto LabelX; \
|
||||
case TOKimaginary64: t = Type::timaginary64; goto LabelX; \
|
||||
case TOKimaginary80: t = Type::timaginary80; goto LabelX; \
|
||||
case TOKcomplex32: t = Type::tcomplex32; goto LabelX; \
|
||||
case TOKcomplex64: t = Type::tcomplex64; goto LabelX; \
|
||||
case TOKcomplex80: t = Type::tcomplex80; goto LabelX; \
|
||||
case TOKbit: t = Type::tbit; goto LabelX; \
|
||||
case TOKbool: t = Type::tbool; goto LabelX; \
|
||||
case TOKchar: t = Type::tchar; goto LabelX; \
|
||||
case TOKwchar: t = Type::twchar; goto LabelX; \
|
||||
case TOKdchar: t = Type::tdchar; goto LabelX; \
|
||||
LabelX
|
||||
#define BASIC_TYPES_X(t) \
|
||||
TOKvoid: t = Type::tvoid; goto LabelX; \
|
||||
case TOKint8: t = Type::tint8; goto LabelX; \
|
||||
case TOKuns8: t = Type::tuns8; goto LabelX; \
|
||||
case TOKint16: t = Type::tint16; goto LabelX; \
|
||||
case TOKuns16: t = Type::tuns16; goto LabelX; \
|
||||
case TOKint32: t = Type::tint32; goto LabelX; \
|
||||
case TOKuns32: t = Type::tuns32; goto LabelX; \
|
||||
case TOKint64: t = Type::tint64; goto LabelX; \
|
||||
case TOKuns64: t = Type::tuns64; goto LabelX; \
|
||||
case TOKfloat32: t = Type::tfloat32; goto LabelX; \
|
||||
case TOKfloat64: t = Type::tfloat64; goto LabelX; \
|
||||
case TOKfloat80: t = Type::tfloat80; goto LabelX; \
|
||||
case TOKimaginary32: t = Type::timaginary32; goto LabelX; \
|
||||
case TOKimaginary64: t = Type::timaginary64; goto LabelX; \
|
||||
case TOKimaginary80: t = Type::timaginary80; goto LabelX; \
|
||||
case TOKcomplex32: t = Type::tcomplex32; goto LabelX; \
|
||||
case TOKcomplex64: t = Type::tcomplex64; goto LabelX; \
|
||||
case TOKcomplex80: t = Type::tcomplex80; goto LabelX; \
|
||||
case TOKbit: t = Type::tbit; goto LabelX; \
|
||||
case TOKbool: t = Type::tbool; goto LabelX; \
|
||||
case TOKchar: t = Type::tchar; goto LabelX; \
|
||||
case TOKwchar: t = Type::twchar; goto LabelX; \
|
||||
case TOKdchar: t = Type::tdchar; goto LabelX; \
|
||||
LabelX
|
||||
|
||||
struct Token
|
||||
{
|
||||
Token *next;
|
||||
unsigned char *ptr; // pointer to first character of this token within buffer
|
||||
unsigned char *ptr; // pointer to first character of this token within buffer
|
||||
enum TOK value;
|
||||
unsigned char *blockComment; // doc comment string prior to this token
|
||||
unsigned char *lineComment; // doc comment for previous token
|
||||
unsigned char *lineComment; // doc comment for previous token
|
||||
union
|
||||
{
|
||||
// Integers
|
||||
d_int64 int64value;
|
||||
d_uns64 uns64value;
|
||||
// Integers
|
||||
d_int64 int64value;
|
||||
d_uns64 uns64value;
|
||||
|
||||
// Floats
|
||||
// Floats
|
||||
#ifdef IN_GCC
|
||||
// real_t float80value; // can't use this in a union!
|
||||
// real_t float80value; // can't use this in a union!
|
||||
#else
|
||||
d_float80 float80value;
|
||||
d_float80 float80value;
|
||||
#endif
|
||||
|
||||
struct
|
||||
{ unsigned char *ustring; // UTF8 string
|
||||
unsigned len;
|
||||
unsigned char postfix; // 'c', 'w', 'd'
|
||||
};
|
||||
struct
|
||||
{ unsigned char *ustring; // UTF8 string
|
||||
unsigned len;
|
||||
unsigned char postfix; // 'c', 'w', 'd'
|
||||
};
|
||||
|
||||
Identifier *ident;
|
||||
Identifier *ident;
|
||||
};
|
||||
#ifdef IN_GCC
|
||||
real_t float80value; // can't use this in a union!
|
||||
@@ -256,20 +256,20 @@ struct Lexer
|
||||
static OutBuffer stringbuffer;
|
||||
static Token *freelist;
|
||||
|
||||
Loc loc; // for error messages
|
||||
Loc loc; // for error messages
|
||||
|
||||
unsigned char *base; // pointer to start of buffer
|
||||
unsigned char *end; // past end of buffer
|
||||
unsigned char *p; // current character
|
||||
unsigned char *base; // pointer to start of buffer
|
||||
unsigned char *end; // past end of buffer
|
||||
unsigned char *p; // current character
|
||||
Token token;
|
||||
Module *mod;
|
||||
int doDocComment; // collect doc comment information
|
||||
int anyToken; // !=0 means seen at least one token
|
||||
int commentToken; // !=0 means comments are TOKcomment's
|
||||
int doDocComment; // collect doc comment information
|
||||
int anyToken; // !=0 means seen at least one token
|
||||
int commentToken; // !=0 means comments are TOKcomment's
|
||||
|
||||
Lexer(Module *mod,
|
||||
unsigned char *base, unsigned begoffset, unsigned endoffset,
|
||||
int doDocComment, int commentToken);
|
||||
unsigned char *base, unsigned begoffset, unsigned endoffset,
|
||||
int doDocComment, int commentToken);
|
||||
|
||||
static void initKeywords();
|
||||
static Identifier *idPool(const char *s);
|
||||
|
||||
518
dmd/macro.c
518
dmd/macro.c
@@ -56,12 +56,12 @@ Macro *Macro::search(unsigned char *name, size_t namelen)
|
||||
//printf("Macro::search(%.*s)\n", namelen, name);
|
||||
for (table = this; table; table = table->next)
|
||||
{
|
||||
if (table->namelen == namelen &&
|
||||
memcmp(table->name, name, namelen) == 0)
|
||||
{
|
||||
//printf("\tfound %d\n", table->textlen);
|
||||
break;
|
||||
}
|
||||
if (table->namelen == namelen &&
|
||||
memcmp(table->name, name, namelen) == 0)
|
||||
{
|
||||
//printf("\tfound %d\n", table->textlen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return table;
|
||||
}
|
||||
@@ -75,13 +75,13 @@ Macro *Macro::define(Macro **ptable, unsigned char *name, size_t namelen, unsign
|
||||
//assert(ptable);
|
||||
for (table = *ptable; table; table = table->next)
|
||||
{
|
||||
if (table->namelen == namelen &&
|
||||
memcmp(table->name, name, namelen) == 0)
|
||||
{
|
||||
table->text = text;
|
||||
table->textlen = textlen;
|
||||
return table;
|
||||
}
|
||||
if (table->namelen == namelen &&
|
||||
memcmp(table->name, name, namelen) == 0)
|
||||
{
|
||||
table->text = text;
|
||||
table->textlen = textlen;
|
||||
return table;
|
||||
}
|
||||
}
|
||||
table = new Macro(name, namelen, text, textlen);
|
||||
table->next = *ptable;
|
||||
@@ -92,9 +92,9 @@ Macro *Macro::define(Macro **ptable, unsigned char *name, size_t namelen, unsign
|
||||
/**********************************************************
|
||||
* Given buffer p[0..end], extract argument marg[0..marglen].
|
||||
* Params:
|
||||
* n 0: get entire argument
|
||||
* 1..9: get nth argument
|
||||
* -1: get 2nd through end
|
||||
* n 0: get entire argument
|
||||
* 1..9: get nth argument
|
||||
* -1: get 2nd through end
|
||||
*/
|
||||
|
||||
unsigned extractArgN(unsigned char *p, unsigned end, unsigned char **pmarg, unsigned *pmarglen, int n)
|
||||
@@ -120,111 +120,111 @@ unsigned extractArgN(unsigned char *p, unsigned end, unsigned char **pmarg, unsi
|
||||
#if 1
|
||||
// Skip first space, if any, to find the start of the macro argument
|
||||
if (v < end && isspace(p[v]))
|
||||
v++;
|
||||
v++;
|
||||
#else
|
||||
// Skip past spaces to find the start of the macro argument
|
||||
for (; v < end && isspace(p[v]); v++)
|
||||
;
|
||||
;
|
||||
#endif
|
||||
*pmarg = p + v;
|
||||
|
||||
for (; v < end; v++)
|
||||
{ unsigned char c = p[v];
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case ',':
|
||||
if (!inexp && !instring && !incomment && parens == 1)
|
||||
{
|
||||
argn++;
|
||||
if (argn == 1 && n == -1)
|
||||
{ v++;
|
||||
goto Largstart;
|
||||
}
|
||||
if (argn == n)
|
||||
break;
|
||||
if (argn + 1 == n)
|
||||
{ v++;
|
||||
goto Largstart;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
switch (c)
|
||||
{
|
||||
case ',':
|
||||
if (!inexp && !instring && !incomment && parens == 1)
|
||||
{
|
||||
argn++;
|
||||
if (argn == 1 && n == -1)
|
||||
{ v++;
|
||||
goto Largstart;
|
||||
}
|
||||
if (argn == n)
|
||||
break;
|
||||
if (argn + 1 == n)
|
||||
{ v++;
|
||||
goto Largstart;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
case '(':
|
||||
if (!inexp && !instring && !incomment)
|
||||
parens++;
|
||||
continue;
|
||||
case '(':
|
||||
if (!inexp && !instring && !incomment)
|
||||
parens++;
|
||||
continue;
|
||||
|
||||
case ')':
|
||||
if (!inexp && !instring && !incomment && --parens == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
case ')':
|
||||
if (!inexp && !instring && !incomment && --parens == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
|
||||
case '"':
|
||||
case '\'':
|
||||
if (!inexp && !incomment && intag)
|
||||
{
|
||||
if (c == instring)
|
||||
instring = 0;
|
||||
else if (!instring)
|
||||
instring = c;
|
||||
}
|
||||
continue;
|
||||
case '"':
|
||||
case '\'':
|
||||
if (!inexp && !incomment && intag)
|
||||
{
|
||||
if (c == instring)
|
||||
instring = 0;
|
||||
else if (!instring)
|
||||
instring = c;
|
||||
}
|
||||
continue;
|
||||
|
||||
case '<':
|
||||
if (!inexp && !instring && !incomment)
|
||||
{
|
||||
if (v + 6 < end &&
|
||||
p[v + 1] == '!' &&
|
||||
p[v + 2] == '-' &&
|
||||
p[v + 3] == '-')
|
||||
{
|
||||
incomment = 1;
|
||||
v += 3;
|
||||
}
|
||||
else if (v + 2 < end &&
|
||||
isalpha(p[v + 1]))
|
||||
intag = 1;
|
||||
}
|
||||
continue;
|
||||
case '<':
|
||||
if (!inexp && !instring && !incomment)
|
||||
{
|
||||
if (v + 6 < end &&
|
||||
p[v + 1] == '!' &&
|
||||
p[v + 2] == '-' &&
|
||||
p[v + 3] == '-')
|
||||
{
|
||||
incomment = 1;
|
||||
v += 3;
|
||||
}
|
||||
else if (v + 2 < end &&
|
||||
isalpha(p[v + 1]))
|
||||
intag = 1;
|
||||
}
|
||||
continue;
|
||||
|
||||
case '>':
|
||||
if (!inexp)
|
||||
intag = 0;
|
||||
continue;
|
||||
case '>':
|
||||
if (!inexp)
|
||||
intag = 0;
|
||||
continue;
|
||||
|
||||
case '-':
|
||||
if (!inexp &&
|
||||
!instring &&
|
||||
incomment &&
|
||||
v + 2 < end &&
|
||||
p[v + 1] == '-' &&
|
||||
p[v + 2] == '>')
|
||||
{
|
||||
incomment = 0;
|
||||
v += 2;
|
||||
}
|
||||
continue;
|
||||
case '-':
|
||||
if (!inexp &&
|
||||
!instring &&
|
||||
incomment &&
|
||||
v + 2 < end &&
|
||||
p[v + 1] == '-' &&
|
||||
p[v + 2] == '>')
|
||||
{
|
||||
incomment = 0;
|
||||
v += 2;
|
||||
}
|
||||
continue;
|
||||
|
||||
case 0xFF:
|
||||
if (v + 1 < end)
|
||||
{
|
||||
if (p[v + 1] == '{')
|
||||
inexp++;
|
||||
else if (p[v + 1] == '}')
|
||||
inexp--;
|
||||
}
|
||||
continue;
|
||||
case 0xFF:
|
||||
if (v + 1 < end)
|
||||
{
|
||||
if (p[v + 1] == '{')
|
||||
inexp++;
|
||||
else if (p[v + 1] == '}')
|
||||
inexp--;
|
||||
}
|
||||
continue;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (argn == 0 && n == -1)
|
||||
*pmarg = p + v;
|
||||
*pmarg = p + v;
|
||||
*pmarglen = p + v - *pmarg;
|
||||
//printf("extractArg%d('%.*s') = '%.*s'\n", n, end, p, *pmarglen, *pmarg);
|
||||
return v;
|
||||
@@ -237,7 +237,7 @@ unsigned extractArgN(unsigned char *p, unsigned end, unsigned char **pmarg, unsi
|
||||
*/
|
||||
|
||||
void Macro::expand(OutBuffer *buf, unsigned start, unsigned *pend,
|
||||
unsigned char *arg, unsigned arglen)
|
||||
unsigned char *arg, unsigned arglen)
|
||||
{
|
||||
#if 0
|
||||
printf("Macro::expand(buf[%d..%d], arg = '%.*s')\n", start, *pend, arglen, arg);
|
||||
@@ -245,8 +245,8 @@ void Macro::expand(OutBuffer *buf, unsigned start, unsigned *pend,
|
||||
#endif
|
||||
|
||||
static int nest;
|
||||
if (nest > 100) // limit recursive expansion
|
||||
return;
|
||||
if (nest > 100) // limit recursive expansion
|
||||
return;
|
||||
nest++;
|
||||
|
||||
unsigned end = *pend;
|
||||
@@ -258,190 +258,190 @@ void Macro::expand(OutBuffer *buf, unsigned start, unsigned *pend,
|
||||
arg = memdup(arg, arglen);
|
||||
for (unsigned u = start; u + 1 < end; )
|
||||
{
|
||||
unsigned char *p = buf->data; // buf->data is not loop invariant
|
||||
unsigned char *p = buf->data; // buf->data is not loop invariant
|
||||
|
||||
/* Look for $0, but not $$0, and replace it with arg.
|
||||
*/
|
||||
if (p[u] == '$' && (isdigit(p[u + 1]) || p[u + 1] == '+'))
|
||||
{
|
||||
if (u > start && p[u - 1] == '$')
|
||||
{ // Don't expand $$0, but replace it with $0
|
||||
buf->remove(u - 1, 1);
|
||||
end--;
|
||||
u += 1; // now u is one past the closing '1'
|
||||
continue;
|
||||
}
|
||||
/* Look for $0, but not $$0, and replace it with arg.
|
||||
*/
|
||||
if (p[u] == '$' && (isdigit(p[u + 1]) || p[u + 1] == '+'))
|
||||
{
|
||||
if (u > start && p[u - 1] == '$')
|
||||
{ // Don't expand $$0, but replace it with $0
|
||||
buf->remove(u - 1, 1);
|
||||
end--;
|
||||
u += 1; // now u is one past the closing '1'
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned char c = p[u + 1];
|
||||
int n = (c == '+') ? -1 : c - '0';
|
||||
unsigned char c = p[u + 1];
|
||||
int n = (c == '+') ? -1 : c - '0';
|
||||
|
||||
unsigned char *marg;
|
||||
unsigned marglen;
|
||||
extractArgN(arg, arglen, &marg, &marglen, n);
|
||||
if (marglen == 0)
|
||||
{ // Just remove macro invocation
|
||||
//printf("Replacing '$%c' with '%.*s'\n", p[u + 1], marglen, marg);
|
||||
buf->remove(u, 2);
|
||||
end -= 2;
|
||||
}
|
||||
else if (c == '+')
|
||||
{
|
||||
// Replace '$+' with 'arg'
|
||||
//printf("Replacing '$%c' with '%.*s'\n", p[u + 1], marglen, marg);
|
||||
buf->remove(u, 2);
|
||||
buf->insert(u, marg, marglen);
|
||||
end += marglen - 2;
|
||||
unsigned char *marg;
|
||||
unsigned marglen;
|
||||
extractArgN(arg, arglen, &marg, &marglen, n);
|
||||
if (marglen == 0)
|
||||
{ // Just remove macro invocation
|
||||
//printf("Replacing '$%c' with '%.*s'\n", p[u + 1], marglen, marg);
|
||||
buf->remove(u, 2);
|
||||
end -= 2;
|
||||
}
|
||||
else if (c == '+')
|
||||
{
|
||||
// Replace '$+' with 'arg'
|
||||
//printf("Replacing '$%c' with '%.*s'\n", p[u + 1], marglen, marg);
|
||||
buf->remove(u, 2);
|
||||
buf->insert(u, marg, marglen);
|
||||
end += marglen - 2;
|
||||
|
||||
// Scan replaced text for further expansion
|
||||
unsigned mend = u + marglen;
|
||||
expand(buf, u, &mend, NULL, 0);
|
||||
end += mend - (u + marglen);
|
||||
u = mend;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replace '$1' with '\xFF{arg\xFF}'
|
||||
//printf("Replacing '$%c' with '\xFF{%.*s\xFF}'\n", p[u + 1], marglen, marg);
|
||||
buf->data[u] = 0xFF;
|
||||
buf->data[u + 1] = '{';
|
||||
buf->insert(u + 2, marg, marglen);
|
||||
buf->insert(u + 2 + marglen, "\xFF}", 2);
|
||||
end += -2 + 2 + marglen + 2;
|
||||
// Scan replaced text for further expansion
|
||||
unsigned mend = u + marglen;
|
||||
expand(buf, u, &mend, NULL, 0);
|
||||
end += mend - (u + marglen);
|
||||
u = mend;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replace '$1' with '\xFF{arg\xFF}'
|
||||
//printf("Replacing '$%c' with '\xFF{%.*s\xFF}'\n", p[u + 1], marglen, marg);
|
||||
buf->data[u] = 0xFF;
|
||||
buf->data[u + 1] = '{';
|
||||
buf->insert(u + 2, marg, marglen);
|
||||
buf->insert(u + 2 + marglen, "\xFF}", 2);
|
||||
end += -2 + 2 + marglen + 2;
|
||||
|
||||
// Scan replaced text for further expansion
|
||||
unsigned mend = u + 2 + marglen;
|
||||
expand(buf, u + 2, &mend, NULL, 0);
|
||||
end += mend - (u + 2 + marglen);
|
||||
u = mend;
|
||||
}
|
||||
//printf("u = %d, end = %d\n", u, end);
|
||||
//printf("#%.*s#\n", end, &buf->data[0]);
|
||||
continue;
|
||||
}
|
||||
// Scan replaced text for further expansion
|
||||
unsigned mend = u + 2 + marglen;
|
||||
expand(buf, u + 2, &mend, NULL, 0);
|
||||
end += mend - (u + 2 + marglen);
|
||||
u = mend;
|
||||
}
|
||||
//printf("u = %d, end = %d\n", u, end);
|
||||
//printf("#%.*s#\n", end, &buf->data[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
u++;
|
||||
u++;
|
||||
}
|
||||
|
||||
/* Second pass - replace other macros
|
||||
*/
|
||||
for (unsigned u = start; u + 4 < end; )
|
||||
{
|
||||
unsigned char *p = buf->data; // buf->data is not loop invariant
|
||||
unsigned char *p = buf->data; // buf->data is not loop invariant
|
||||
|
||||
/* A valid start of macro expansion is $(c, where c is
|
||||
* an id start character, and not $$(c.
|
||||
*/
|
||||
if (p[u] == '$' && p[u + 1] == '(' && isidstart(p[u + 2]))
|
||||
{
|
||||
//printf("\tfound macro start '%c'\n", p[u + 2]);
|
||||
unsigned char *name = p + u + 2;
|
||||
unsigned namelen = 0;
|
||||
/* A valid start of macro expansion is $(c, where c is
|
||||
* an id start character, and not $$(c.
|
||||
*/
|
||||
if (p[u] == '$' && p[u + 1] == '(' && isidstart(p[u + 2]))
|
||||
{
|
||||
//printf("\tfound macro start '%c'\n", p[u + 2]);
|
||||
unsigned char *name = p + u + 2;
|
||||
unsigned namelen = 0;
|
||||
|
||||
unsigned char *marg;
|
||||
unsigned marglen;
|
||||
unsigned char *marg;
|
||||
unsigned marglen;
|
||||
|
||||
unsigned v;
|
||||
/* Scan forward to find end of macro name and
|
||||
* beginning of macro argument (marg).
|
||||
*/
|
||||
for (v = u + 2; v < end; v++)
|
||||
{ unsigned char c = p[v];
|
||||
unsigned v;
|
||||
/* Scan forward to find end of macro name and
|
||||
* beginning of macro argument (marg).
|
||||
*/
|
||||
for (v = u + 2; v < end; v++)
|
||||
{ unsigned char c = p[v];
|
||||
|
||||
if (!isidchar(c))
|
||||
{ // We've gone past the end of the macro name.
|
||||
namelen = v - (u + 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isidchar(c))
|
||||
{ // We've gone past the end of the macro name.
|
||||
namelen = v - (u + 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
v += extractArgN(p + v, end - v, &marg, &marglen, 0);
|
||||
assert(v <= end);
|
||||
v += extractArgN(p + v, end - v, &marg, &marglen, 0);
|
||||
assert(v <= end);
|
||||
|
||||
if (v < end)
|
||||
{ // v is on the closing ')'
|
||||
if (u > start && p[u - 1] == '$')
|
||||
{ // Don't expand $$(NAME), but replace it with $(NAME)
|
||||
buf->remove(u - 1, 1);
|
||||
end--;
|
||||
u = v; // now u is one past the closing ')'
|
||||
continue;
|
||||
}
|
||||
if (v < end)
|
||||
{ // v is on the closing ')'
|
||||
if (u > start && p[u - 1] == '$')
|
||||
{ // Don't expand $$(NAME), but replace it with $(NAME)
|
||||
buf->remove(u - 1, 1);
|
||||
end--;
|
||||
u = v; // now u is one past the closing ')'
|
||||
continue;
|
||||
}
|
||||
|
||||
Macro *m = search(name, namelen);
|
||||
if (m)
|
||||
{
|
||||
Macro *m = search(name, namelen);
|
||||
if (m)
|
||||
{
|
||||
#if 0
|
||||
if (m->textlen && m->text[0] == ' ')
|
||||
{ m->text++;
|
||||
m->textlen--;
|
||||
}
|
||||
if (m->textlen && m->text[0] == ' ')
|
||||
{ m->text++;
|
||||
m->textlen--;
|
||||
}
|
||||
#endif
|
||||
if (m->inuse && marglen == 0)
|
||||
{ // Remove macro invocation
|
||||
buf->remove(u, v + 1 - u);
|
||||
end -= v + 1 - u;
|
||||
}
|
||||
else if (m->inuse && arglen == marglen && memcmp(arg, marg, arglen) == 0)
|
||||
{ // Recursive expansion; just leave in place
|
||||
if (m->inuse && marglen == 0)
|
||||
{ // Remove macro invocation
|
||||
buf->remove(u, v + 1 - u);
|
||||
end -= v + 1 - u;
|
||||
}
|
||||
else if (m->inuse && arglen == marglen && memcmp(arg, marg, arglen) == 0)
|
||||
{ // Recursive expansion; just leave in place
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("\tmacro '%.*s'(%.*s) = '%.*s'\n", m->namelen, m->name, marglen, marg, m->textlen, m->text);
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("\tmacro '%.*s'(%.*s) = '%.*s'\n", m->namelen, m->name, marglen, marg, m->textlen, m->text);
|
||||
#if 1
|
||||
marg = memdup(marg, marglen);
|
||||
// Insert replacement text
|
||||
buf->spread(v + 1, 2 + m->textlen + 2);
|
||||
buf->data[v + 1] = 0xFF;
|
||||
buf->data[v + 2] = '{';
|
||||
memcpy(buf->data + v + 3, m->text, m->textlen);
|
||||
buf->data[v + 3 + m->textlen] = 0xFF;
|
||||
buf->data[v + 3 + m->textlen + 1] = '}';
|
||||
marg = memdup(marg, marglen);
|
||||
// Insert replacement text
|
||||
buf->spread(v + 1, 2 + m->textlen + 2);
|
||||
buf->data[v + 1] = 0xFF;
|
||||
buf->data[v + 2] = '{';
|
||||
memcpy(buf->data + v + 3, m->text, m->textlen);
|
||||
buf->data[v + 3 + m->textlen] = 0xFF;
|
||||
buf->data[v + 3 + m->textlen + 1] = '}';
|
||||
|
||||
end += 2 + m->textlen + 2;
|
||||
end += 2 + m->textlen + 2;
|
||||
|
||||
// Scan replaced text for further expansion
|
||||
m->inuse++;
|
||||
unsigned mend = v + 1 + 2+m->textlen+2;
|
||||
expand(buf, v + 1, &mend, marg, marglen);
|
||||
end += mend - (v + 1 + 2+m->textlen+2);
|
||||
m->inuse--;
|
||||
// Scan replaced text for further expansion
|
||||
m->inuse++;
|
||||
unsigned mend = v + 1 + 2+m->textlen+2;
|
||||
expand(buf, v + 1, &mend, marg, marglen);
|
||||
end += mend - (v + 1 + 2+m->textlen+2);
|
||||
m->inuse--;
|
||||
|
||||
buf->remove(u, v + 1 - u);
|
||||
end -= v + 1 - u;
|
||||
u += mend - (v + 1);
|
||||
buf->remove(u, v + 1 - u);
|
||||
end -= v + 1 - u;
|
||||
u += mend - (v + 1);
|
||||
#else
|
||||
// Insert replacement text
|
||||
buf->insert(v + 1, m->text, m->textlen);
|
||||
end += m->textlen;
|
||||
// Insert replacement text
|
||||
buf->insert(v + 1, m->text, m->textlen);
|
||||
end += m->textlen;
|
||||
|
||||
// Scan replaced text for further expansion
|
||||
m->inuse++;
|
||||
unsigned mend = v + 1 + m->textlen;
|
||||
expand(buf, v + 1, &mend, marg, marglen);
|
||||
end += mend - (v + 1 + m->textlen);
|
||||
m->inuse--;
|
||||
// Scan replaced text for further expansion
|
||||
m->inuse++;
|
||||
unsigned mend = v + 1 + m->textlen;
|
||||
expand(buf, v + 1, &mend, marg, marglen);
|
||||
end += mend - (v + 1 + m->textlen);
|
||||
m->inuse--;
|
||||
|
||||
buf->remove(u, v + 1 - u);
|
||||
end -= v + 1 - u;
|
||||
u += mend - (v + 1);
|
||||
buf->remove(u, v + 1 - u);
|
||||
end -= v + 1 - u;
|
||||
u += mend - (v + 1);
|
||||
#endif
|
||||
mem.free(marg);
|
||||
//printf("u = %d, end = %d\n", u, end);
|
||||
//printf("#%.*s#\n", end - u, &buf->data[u]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replace $(NAME) with nothing
|
||||
buf->remove(u, v + 1 - u);
|
||||
end -= (v + 1 - u);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
u++;
|
||||
mem.free(marg);
|
||||
//printf("u = %d, end = %d\n", u, end);
|
||||
//printf("#%.*s#\n", end - u, &buf->data[u]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replace $(NAME) with nothing
|
||||
buf->remove(u, v + 1 - u);
|
||||
end -= (v + 1 - u);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
u++;
|
||||
}
|
||||
mem.free(arg);
|
||||
*pend = end;
|
||||
|
||||
14
dmd/macro.h
14
dmd/macro.h
@@ -21,15 +21,15 @@
|
||||
|
||||
class Macro
|
||||
{
|
||||
Macro *next; // next in list
|
||||
Macro *next; // next in list
|
||||
|
||||
unsigned char *name; // macro name
|
||||
size_t namelen; // length of macro name
|
||||
unsigned char *name; // macro name
|
||||
size_t namelen; // length of macro name
|
||||
|
||||
unsigned char *text; // macro replacement text
|
||||
size_t textlen; // length of replacement text
|
||||
unsigned char *text; // macro replacement text
|
||||
size_t textlen; // length of replacement text
|
||||
|
||||
int inuse; // macro is in use (don't expand)
|
||||
int inuse; // macro is in use (don't expand)
|
||||
|
||||
Macro(unsigned char *name, size_t namelen, unsigned char *text, size_t textlen);
|
||||
Macro *search(unsigned char *name, size_t namelen);
|
||||
@@ -38,7 +38,7 @@ class Macro
|
||||
static Macro *define(Macro **ptable, unsigned char *name, size_t namelen, unsigned char *text, size_t textlen);
|
||||
|
||||
void expand(OutBuffer *buf, unsigned start, unsigned *pend,
|
||||
unsigned char *arg, unsigned arglen);
|
||||
unsigned char *arg, unsigned arglen);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
206
dmd/mangle.c
206
dmd/mangle.c
@@ -38,29 +38,29 @@ char *mangle(Declaration *sthis)
|
||||
s = sthis;
|
||||
do
|
||||
{
|
||||
//printf("mangle: s = %p, '%s', parent = %p\n", s, s->toChars(), s->parent);
|
||||
if (s->ident)
|
||||
{
|
||||
FuncDeclaration *fd = s->isFuncDeclaration();
|
||||
if (s != sthis && fd)
|
||||
{
|
||||
id = mangle(fd);
|
||||
buf.prependstring(id);
|
||||
goto L1;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = s->ident->toChars();
|
||||
int len = strlen(id);
|
||||
char tmp[sizeof(len) * 3 + 1];
|
||||
buf.prependstring(id);
|
||||
sprintf(tmp, "%d", len);
|
||||
buf.prependstring(tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
buf.prependstring("0");
|
||||
s = s->parent;
|
||||
//printf("mangle: s = %p, '%s', parent = %p\n", s, s->toChars(), s->parent);
|
||||
if (s->ident)
|
||||
{
|
||||
FuncDeclaration *fd = s->isFuncDeclaration();
|
||||
if (s != sthis && fd)
|
||||
{
|
||||
id = mangle(fd);
|
||||
buf.prependstring(id);
|
||||
goto L1;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = s->ident->toChars();
|
||||
int len = strlen(id);
|
||||
char tmp[sizeof(len) * 3 + 1];
|
||||
buf.prependstring(id);
|
||||
sprintf(tmp, "%d", len);
|
||||
buf.prependstring(tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
buf.prependstring("0");
|
||||
s = s->parent;
|
||||
} while (s);
|
||||
|
||||
// buf.prependstring("_D");
|
||||
@@ -69,16 +69,16 @@ L1:
|
||||
//printf("sthis->type = %s\n", sthis->type->toChars());
|
||||
FuncDeclaration *fd = sthis->isFuncDeclaration();
|
||||
if (fd && (fd->needThis() || fd->isNested()))
|
||||
buf.writeByte(Type::needThisPrefix());
|
||||
buf.writeByte(Type::needThisPrefix());
|
||||
if (sthis->type->deco)
|
||||
buf.writestring(sthis->type->deco);
|
||||
buf.writestring(sthis->type->deco);
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (!fd->inferRetType)
|
||||
printf("%s\n", fd->toChars());
|
||||
if (!fd->inferRetType)
|
||||
printf("%s\n", fd->toChars());
|
||||
#endif
|
||||
assert(fd && fd->inferRetType);
|
||||
assert(fd && fd->inferRetType);
|
||||
}
|
||||
|
||||
id = buf.toChars();
|
||||
@@ -90,81 +90,81 @@ char *Declaration::mangle()
|
||||
#if __DMC__
|
||||
__out(result)
|
||||
{
|
||||
int len = strlen(result);
|
||||
int len = strlen(result);
|
||||
|
||||
assert(len > 0);
|
||||
//printf("mangle: '%s' => '%s'\n", toChars(), result);
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
assert(result[i] == '_' ||
|
||||
result[i] == '@' ||
|
||||
isalnum(result[i]) || result[i] & 0x80);
|
||||
}
|
||||
assert(len > 0);
|
||||
//printf("mangle: '%s' => '%s'\n", toChars(), result);
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
assert(result[i] == '_' ||
|
||||
result[i] == '@' ||
|
||||
isalnum(result[i]) || result[i] & 0x80);
|
||||
}
|
||||
}
|
||||
__body
|
||||
#endif
|
||||
{
|
||||
//printf("Declaration::mangle(this = %p, '%s', parent = '%s', linkage = %d)\n", this, toChars(), parent ? parent->toChars() : "null", linkage);
|
||||
if (!parent || parent->isModule()) // if at global scope
|
||||
{
|
||||
// If it's not a D declaration, no mangling
|
||||
switch (linkage)
|
||||
{
|
||||
case LINKd:
|
||||
break;
|
||||
//printf("Declaration::mangle(this = %p, '%s', parent = '%s', linkage = %d)\n", this, toChars(), parent ? parent->toChars() : "null", linkage);
|
||||
if (!parent || parent->isModule()) // if at global scope
|
||||
{
|
||||
// If it's not a D declaration, no mangling
|
||||
switch (linkage)
|
||||
{
|
||||
case LINKd:
|
||||
break;
|
||||
|
||||
#if IN_LLVM
|
||||
case LINKintrinsic:
|
||||
#endif
|
||||
case LINKc:
|
||||
case LINKwindows:
|
||||
case LINKpascal:
|
||||
return ident->toChars();
|
||||
case LINKc:
|
||||
case LINKwindows:
|
||||
case LINKpascal:
|
||||
return ident->toChars();
|
||||
|
||||
case LINKcpp:
|
||||
case LINKcpp:
|
||||
#if DMDV2 && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_SOLARIS)
|
||||
return cpp_mangle(this);
|
||||
return cpp_mangle(this);
|
||||
#else
|
||||
// Windows C++ mangling is done by C++ back end
|
||||
return ident->toChars();
|
||||
// Windows C++ mangling is done by C++ back end
|
||||
return ident->toChars();
|
||||
#endif
|
||||
|
||||
case LINKdefault:
|
||||
error("forward declaration");
|
||||
return ident->toChars();
|
||||
case LINKdefault:
|
||||
error("forward declaration");
|
||||
return ident->toChars();
|
||||
|
||||
default:
|
||||
fprintf(stdmsg, "'%s', linkage = %d\n", toChars(), linkage);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
char *p = ::mangle(this);
|
||||
OutBuffer buf;
|
||||
buf.writestring("_D");
|
||||
buf.writestring(p);
|
||||
p = buf.toChars();
|
||||
buf.data = NULL;
|
||||
//printf("Declaration::mangle(this = %p, '%s', parent = '%s', linkage = %d) = %s\n", this, toChars(), parent ? parent->toChars() : "null", linkage, p);
|
||||
return p;
|
||||
default:
|
||||
fprintf(stdmsg, "'%s', linkage = %d\n", toChars(), linkage);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
char *p = ::mangle(this);
|
||||
OutBuffer buf;
|
||||
buf.writestring("_D");
|
||||
buf.writestring(p);
|
||||
p = buf.toChars();
|
||||
buf.data = NULL;
|
||||
//printf("Declaration::mangle(this = %p, '%s', parent = '%s', linkage = %d) = %s\n", this, toChars(), parent ? parent->toChars() : "null", linkage, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
char *FuncDeclaration::mangle()
|
||||
#if __DMC__
|
||||
__out(result)
|
||||
{
|
||||
assert(strlen(result) > 0);
|
||||
assert(strlen(result) > 0);
|
||||
}
|
||||
__body
|
||||
#endif
|
||||
{
|
||||
if (isMain())
|
||||
return (char *)"_Dmain";
|
||||
if (isMain())
|
||||
return (char *)"_Dmain";
|
||||
|
||||
if (isWinMain() || isDllMain())
|
||||
return ident->toChars();
|
||||
if (isWinMain() || isDllMain())
|
||||
return ident->toChars();
|
||||
|
||||
assert(this);
|
||||
return Declaration::mangle();
|
||||
assert(this);
|
||||
return Declaration::mangle();
|
||||
}
|
||||
|
||||
char *StructDeclaration::mangle()
|
||||
@@ -191,21 +191,21 @@ char *ClassDeclaration::mangle()
|
||||
* names for them.
|
||||
*/
|
||||
if (ident == Id::Exception)
|
||||
{ if (parent->ident == Id::object)
|
||||
parent = NULL;
|
||||
{ if (parent->ident == Id::object)
|
||||
parent = NULL;
|
||||
}
|
||||
else if (ident == Id::TypeInfo ||
|
||||
// ident == Id::Exception ||
|
||||
ident == Id::TypeInfo_Struct ||
|
||||
ident == Id::TypeInfo_Class ||
|
||||
ident == Id::TypeInfo_Typedef ||
|
||||
ident == Id::TypeInfo_Tuple ||
|
||||
this == object ||
|
||||
this == classinfo ||
|
||||
this == Module::moduleinfo ||
|
||||
memcmp(ident->toChars(), "TypeInfo_", 9) == 0
|
||||
// ident == Id::Exception ||
|
||||
ident == Id::TypeInfo_Struct ||
|
||||
ident == Id::TypeInfo_Class ||
|
||||
ident == Id::TypeInfo_Typedef ||
|
||||
ident == Id::TypeInfo_Tuple ||
|
||||
this == object ||
|
||||
this == classinfo ||
|
||||
this == Module::moduleinfo ||
|
||||
memcmp(ident->toChars(), "TypeInfo_", 9) == 0
|
||||
)
|
||||
parent = NULL;
|
||||
parent = NULL;
|
||||
|
||||
char *id = Dsymbol::mangle();
|
||||
parent = parentsave;
|
||||
@@ -221,18 +221,18 @@ char *TemplateInstance::mangle()
|
||||
#if 0
|
||||
printf("TemplateInstance::mangle() %s", toChars());
|
||||
if (parent)
|
||||
printf(" parent = %s %s", parent->kind(), parent->toChars());
|
||||
printf(" parent = %s %s", parent->kind(), parent->toChars());
|
||||
printf("\n");
|
||||
#endif
|
||||
id = ident ? ident->toChars() : toChars();
|
||||
if (!tempdecl)
|
||||
error("is not defined");
|
||||
error("is not defined");
|
||||
else if (tempdecl->parent)
|
||||
{
|
||||
char *p = tempdecl->parent->mangle();
|
||||
if (p[0] == '_' && p[1] == 'D')
|
||||
p += 2;
|
||||
buf.writestring(p);
|
||||
char *p = tempdecl->parent->mangle();
|
||||
if (p[0] == '_' && p[1] == 'D')
|
||||
p += 2;
|
||||
buf.writestring(p);
|
||||
}
|
||||
buf.printf("%zu%s", strlen(id), id);
|
||||
id = buf.toChars();
|
||||
@@ -256,10 +256,10 @@ char *TemplateMixin::mangle()
|
||||
id = ident ? ident->toChars() : toChars();
|
||||
if (parent)
|
||||
{
|
||||
char *p = parent->mangle();
|
||||
if (p[0] == '_' && p[1] == 'D')
|
||||
p += 2;
|
||||
buf.writestring(p);
|
||||
char *p = parent->mangle();
|
||||
if (p[0] == '_' && p[1] == 'D')
|
||||
p += 2;
|
||||
buf.writestring(p);
|
||||
}
|
||||
buf.printf("%zu%s", strlen(id), id);
|
||||
id = buf.toChars();
|
||||
@@ -276,16 +276,16 @@ char *Dsymbol::mangle()
|
||||
#if 0
|
||||
printf("Dsymbol::mangle() '%s'", toChars());
|
||||
if (parent)
|
||||
printf(" parent = %s %s", parent->kind(), parent->toChars());
|
||||
printf(" parent = %s %s", parent->kind(), parent->toChars());
|
||||
printf("\n");
|
||||
#endif
|
||||
id = ident ? ident->toChars() : toChars();
|
||||
if (parent)
|
||||
{
|
||||
char *p = parent->mangle();
|
||||
if (p[0] == '_' && p[1] == 'D')
|
||||
p += 2;
|
||||
buf.writestring(p);
|
||||
char *p = parent->mangle();
|
||||
if (p[0] == '_' && p[1] == 'D')
|
||||
p += 2;
|
||||
buf.writestring(p);
|
||||
}
|
||||
buf.printf("%zu%s", strlen(id), id);
|
||||
id = buf.toChars();
|
||||
|
||||
174
dmd/mars.c
174
dmd/mars.c
@@ -82,11 +82,11 @@ char *Loc::toChars() const
|
||||
|
||||
if (filename)
|
||||
{
|
||||
buf.printf("%s", filename);
|
||||
buf.printf("%s", filename);
|
||||
}
|
||||
|
||||
if (linnum)
|
||||
buf.printf("(%d)", linnum);
|
||||
buf.printf("(%d)", linnum);
|
||||
buf.writeByte(0);
|
||||
return (char *)buf.extractData();
|
||||
}
|
||||
@@ -126,16 +126,16 @@ void verror(Loc loc, const char *format, va_list ap)
|
||||
{
|
||||
if (!global.gag)
|
||||
{
|
||||
char *p = loc.toChars();
|
||||
char *p = loc.toChars();
|
||||
|
||||
if (*p)
|
||||
fprintf(stdmsg, "%s: ", p);
|
||||
mem.free(p);
|
||||
if (*p)
|
||||
fprintf(stdmsg, "%s: ", p);
|
||||
mem.free(p);
|
||||
|
||||
fprintf(stdmsg, "Error: ");
|
||||
vfprintf(stdmsg, format, ap);
|
||||
fprintf(stdmsg, "\n");
|
||||
fflush(stdmsg);
|
||||
fprintf(stdmsg, "Error: ");
|
||||
vfprintf(stdmsg, format, ap);
|
||||
fprintf(stdmsg, "\n");
|
||||
fflush(stdmsg);
|
||||
}
|
||||
global.errors++;
|
||||
}
|
||||
@@ -144,26 +144,26 @@ void vwarning(Loc loc, const char *format, va_list ap)
|
||||
{
|
||||
if (global.params.warnings && !global.gag)
|
||||
{
|
||||
char *p = loc.toChars();
|
||||
char *p = loc.toChars();
|
||||
|
||||
if (*p)
|
||||
fprintf(stdmsg, "%s: ", p);
|
||||
mem.free(p);
|
||||
if (*p)
|
||||
fprintf(stdmsg, "%s: ", p);
|
||||
mem.free(p);
|
||||
|
||||
fprintf(stdmsg, "Warning: ");
|
||||
fprintf(stdmsg, "Warning: ");
|
||||
#if _MSC_VER
|
||||
// MS doesn't recognize %zu format
|
||||
OutBuffer tmp;
|
||||
tmp.vprintf(format, ap);
|
||||
fprintf(stdmsg, "%s", tmp.toChars());
|
||||
// MS doesn't recognize %zu format
|
||||
OutBuffer tmp;
|
||||
tmp.vprintf(format, ap);
|
||||
fprintf(stdmsg, "%s", tmp.toChars());
|
||||
#else
|
||||
vfprintf(stdmsg, format, ap);
|
||||
vfprintf(stdmsg, format, ap);
|
||||
#endif
|
||||
fprintf(stdmsg, "\n");
|
||||
fflush(stdmsg);
|
||||
fprintf(stdmsg, "\n");
|
||||
fflush(stdmsg);
|
||||
//halt();
|
||||
if (global.params.warnings == 1)
|
||||
global.warnings++; // warnings don't count if gagged
|
||||
if (global.params.warnings == 1)
|
||||
global.warnings++; // warnings don't count if gagged
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,9 +208,9 @@ void getenv_setargv(const char *envvar, int *pargc, char** *pargv)
|
||||
|
||||
char *env = getenv(envvar);
|
||||
if (!env)
|
||||
return;
|
||||
return;
|
||||
|
||||
env = mem.strdup(env); // create our own writable copy
|
||||
env = mem.strdup(env); // create our own writable copy
|
||||
|
||||
int argc = *pargc;
|
||||
Array *argv = new Array();
|
||||
@@ -235,76 +235,76 @@ void getenv_setargv(const char *envvar, int *pargc, char** *pargv)
|
||||
argv->push((char*)"");
|
||||
argc++;
|
||||
|
||||
int j = 1; // leave argv[0] alone
|
||||
int j = 1; // leave argv[0] alone
|
||||
while (1)
|
||||
{
|
||||
int wildcard = 1; // do wildcard expansion
|
||||
switch (*env)
|
||||
{
|
||||
case ' ':
|
||||
case '\t':
|
||||
env++;
|
||||
break;
|
||||
int wildcard = 1; // do wildcard expansion
|
||||
switch (*env)
|
||||
{
|
||||
case ' ':
|
||||
case '\t':
|
||||
env++;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
goto Ldone;
|
||||
case 0:
|
||||
goto Ldone;
|
||||
|
||||
case '"':
|
||||
wildcard = 0;
|
||||
default:
|
||||
argv->push(env); // append
|
||||
//argv->insert(j, env); // insert at position j
|
||||
j++;
|
||||
argc++;
|
||||
p = env;
|
||||
slash = 0;
|
||||
instring = 0;
|
||||
c = 0;
|
||||
case '"':
|
||||
wildcard = 0;
|
||||
default:
|
||||
argv->push(env); // append
|
||||
//argv->insert(j, env); // insert at position j
|
||||
j++;
|
||||
argc++;
|
||||
p = env;
|
||||
slash = 0;
|
||||
instring = 0;
|
||||
c = 0;
|
||||
|
||||
while (1)
|
||||
{
|
||||
c = *env++;
|
||||
switch (c)
|
||||
{
|
||||
case '"':
|
||||
p -= (slash >> 1);
|
||||
if (slash & 1)
|
||||
{ p--;
|
||||
goto Laddc;
|
||||
}
|
||||
instring ^= 1;
|
||||
slash = 0;
|
||||
continue;
|
||||
while (1)
|
||||
{
|
||||
c = *env++;
|
||||
switch (c)
|
||||
{
|
||||
case '"':
|
||||
p -= (slash >> 1);
|
||||
if (slash & 1)
|
||||
{ p--;
|
||||
goto Laddc;
|
||||
}
|
||||
instring ^= 1;
|
||||
slash = 0;
|
||||
continue;
|
||||
|
||||
case ' ':
|
||||
case '\t':
|
||||
if (instring)
|
||||
goto Laddc;
|
||||
*p = 0;
|
||||
//if (wildcard)
|
||||
//wildcardexpand(); // not implemented
|
||||
break;
|
||||
case ' ':
|
||||
case '\t':
|
||||
if (instring)
|
||||
goto Laddc;
|
||||
*p = 0;
|
||||
//if (wildcard)
|
||||
//wildcardexpand(); // not implemented
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
slash++;
|
||||
*p++ = c;
|
||||
continue;
|
||||
case '\\':
|
||||
slash++;
|
||||
*p++ = c;
|
||||
continue;
|
||||
|
||||
case 0:
|
||||
*p = 0;
|
||||
//if (wildcard)
|
||||
//wildcardexpand(); // not implemented
|
||||
goto Ldone;
|
||||
case 0:
|
||||
*p = 0;
|
||||
//if (wildcard)
|
||||
//wildcardexpand(); // not implemented
|
||||
goto Ldone;
|
||||
|
||||
default:
|
||||
Laddc:
|
||||
slash = 0;
|
||||
*p++ = c;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
Laddc:
|
||||
slash = 0;
|
||||
*p++ = c;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ldone:
|
||||
|
||||
192
dmd/mars.h
192
dmd/mars.h
@@ -26,37 +26,37 @@ dmd are:
|
||||
Macros defined by the compiler, not the code:
|
||||
|
||||
Compiler:
|
||||
__DMC__ Digital Mars compiler
|
||||
_MSC_VER Microsoft compiler
|
||||
__GNUC__ Gnu compiler
|
||||
__DMC__ Digital Mars compiler
|
||||
_MSC_VER Microsoft compiler
|
||||
__GNUC__ Gnu compiler
|
||||
|
||||
Host operating system:
|
||||
_WIN32 Microsoft NT, Windows 95, Windows 98, Win32s,
|
||||
Windows 2000, Win XP, Vista
|
||||
_WIN64 Windows for AMD64
|
||||
linux Linux
|
||||
__APPLE__ Mac OSX
|
||||
__FreeBSD__ FreeBSD
|
||||
__sun&&__SVR4 Solaris, OpenSolaris (yes, both macros are necessary)
|
||||
_WIN32 Microsoft NT, Windows 95, Windows 98, Win32s,
|
||||
Windows 2000, Win XP, Vista
|
||||
_WIN64 Windows for AMD64
|
||||
linux Linux
|
||||
__APPLE__ Mac OSX
|
||||
__FreeBSD__ FreeBSD
|
||||
__sun&&__SVR4 Solaris, OpenSolaris (yes, both macros are necessary)
|
||||
|
||||
For the target systems, there are the target operating system and
|
||||
the target object file format:
|
||||
|
||||
Target operating system:
|
||||
TARGET_WINDOS Covers 32 bit windows and 64 bit windows
|
||||
TARGET_LINUX Covers 32 and 64 bit linux
|
||||
TARGET_OSX Covers 32 and 64 bit Mac OSX
|
||||
TARGET_FREEBSD Covers 32 and 64 bit FreeBSD
|
||||
TARGET_SOLARIS Covers 32 and 64 bit Solaris
|
||||
TARGET_NET Covers .Net
|
||||
TARGET_WINDOS Covers 32 bit windows and 64 bit windows
|
||||
TARGET_LINUX Covers 32 and 64 bit linux
|
||||
TARGET_OSX Covers 32 and 64 bit Mac OSX
|
||||
TARGET_FREEBSD Covers 32 and 64 bit FreeBSD
|
||||
TARGET_SOLARIS Covers 32 and 64 bit Solaris
|
||||
TARGET_NET Covers .Net
|
||||
|
||||
It is expected that the compiler for each platform will be able
|
||||
to generate 32 and 64 bit code from the same compiler binary.
|
||||
|
||||
Target object module format:
|
||||
OMFOBJ Intel Object Module Format, used on Windows
|
||||
ELFOBJ Elf Object Module Format, used on linux, FreeBSD and Solaris
|
||||
MACHOBJ Mach-O Object Module Format, used on Mac OSX
|
||||
OMFOBJ Intel Object Module Format, used on Windows
|
||||
ELFOBJ Elf Object Module Format, used on linux, FreeBSD and Solaris
|
||||
MACHOBJ Mach-O Object Module Format, used on Mac OSX
|
||||
|
||||
There are currently no macros for byte endianness order.
|
||||
*/
|
||||
@@ -89,11 +89,11 @@ the target object file format:
|
||||
/* Changes for the GDC compiler by David Friedman */
|
||||
#endif
|
||||
|
||||
#define DMDV2 0 // Version 2.0 features
|
||||
#define BREAKABI 1 // 0 if not ready to break the ABI just yet
|
||||
#define STRUCTTHISREF DMDV2 // if 'this' for struct is a reference, not a pointer
|
||||
#define SNAN_DEFAULT_INIT DMDV2 // if floats are default initialized to signalling NaN
|
||||
#define SARRAYVALUE DMDV2 // static arrays are value types
|
||||
#define DMDV2 0 // Version 2.0 features
|
||||
#define BREAKABI 1 // 0 if not ready to break the ABI just yet
|
||||
#define STRUCTTHISREF DMDV2 // if 'this' for struct is a reference, not a pointer
|
||||
#define SNAN_DEFAULT_INIT DMDV2 // if floats are default initialized to signalling NaN
|
||||
#define SARRAYVALUE DMDV2 // static arrays are value types
|
||||
#define MODULEINFO_IS_STRUCT DMDV2 // if ModuleInfo is a struct rather than a class
|
||||
|
||||
// Set if C++ mangling is done by the front end
|
||||
@@ -105,7 +105,7 @@ the target object file format:
|
||||
*/
|
||||
|
||||
#if _WIN32
|
||||
#define TARGET_WINDOS 1 // Windows dmd generates Windows targets
|
||||
#define TARGET_WINDOS 1 // Windows dmd generates Windows targets
|
||||
#define OMFOBJ 1
|
||||
#endif
|
||||
|
||||
@@ -161,15 +161,15 @@ struct Param
|
||||
bool obj; // write object file
|
||||
bool link; // perform link
|
||||
bool verbose; // verbose compile
|
||||
ubyte symdebug; // insert debug symbolic information
|
||||
ubyte symdebug; // insert debug symbolic information
|
||||
#if !IN_LLVM
|
||||
// LDC uses a different mechanism
|
||||
bool optimize; // run optimizer
|
||||
char optimizeLevel; // optimization level
|
||||
#endif
|
||||
char vtls; // identify thread local variables
|
||||
ARCH cpu; // target CPU
|
||||
OS os; // target OS
|
||||
char vtls; // identify thread local variables
|
||||
ARCH cpu; // target CPU
|
||||
OS os; // target OS
|
||||
bool is64bit; // generate 64 bit code
|
||||
bool isLE; // generate little endian code
|
||||
bool useDeprecated; // allow use of deprecated features
|
||||
@@ -182,42 +182,42 @@ struct Param
|
||||
bool useUnitTests; // generate unittest code
|
||||
bool useInline; // inline expand functions
|
||||
bool warnings; // enable warnings
|
||||
ubyte Dversion; // D version number
|
||||
// 1: warnings as errors
|
||||
// 2: informational warnings (no errors)
|
||||
char safe; // enforce safe memory model
|
||||
ubyte Dversion; // D version number
|
||||
// 1: warnings as errors
|
||||
// 2: informational warnings (no errors)
|
||||
char safe; // enforce safe memory model
|
||||
|
||||
char *argv0; // program name
|
||||
Array *imppath; // array of char*'s of where to look for import modules
|
||||
Array *fileImppath; // array of char*'s of where to look for file import modules
|
||||
char *objdir; // .obj file output directory
|
||||
char *objname; // .obj file output name
|
||||
char *argv0; // program name
|
||||
Array *imppath; // array of char*'s of where to look for import modules
|
||||
Array *fileImppath; // array of char*'s of where to look for file import modules
|
||||
char *objdir; // .obj file output directory
|
||||
char *objname; // .obj file output name
|
||||
|
||||
bool doDocComments; // process embedded documentation comments
|
||||
char *docdir; // write documentation file to docdir directory
|
||||
char *docname; // write documentation file to docname
|
||||
Array *ddocfiles; // macro include files for Ddoc
|
||||
char *docdir; // write documentation file to docdir directory
|
||||
char *docname; // write documentation file to docname
|
||||
Array *ddocfiles; // macro include files for Ddoc
|
||||
|
||||
bool doHdrGeneration; // process embedded documentation comments
|
||||
char *hdrdir; // write 'header' file to docdir directory
|
||||
char *hdrname; // write 'header' file to docname
|
||||
char *hdrdir; // write 'header' file to docdir directory
|
||||
char *hdrname; // write 'header' file to docname
|
||||
|
||||
char doXGeneration; // write JSON file
|
||||
char *xfilename; // write JSON file to xfilename
|
||||
char doXGeneration; // write JSON file
|
||||
char *xfilename; // write JSON file to xfilename
|
||||
|
||||
unsigned debuglevel; // debug level
|
||||
Array *debugids; // debug identifiers
|
||||
unsigned debuglevel; // debug level
|
||||
Array *debugids; // debug identifiers
|
||||
|
||||
unsigned versionlevel; // version level
|
||||
Array *versionids; // version identifiers
|
||||
unsigned versionlevel; // version level
|
||||
Array *versionids; // version identifiers
|
||||
|
||||
bool dump_source;
|
||||
|
||||
Array *defaultlibnames; // default libraries for non-debug builds
|
||||
Array *debuglibnames; // default libraries for debug builds
|
||||
Array *defaultlibnames; // default libraries for non-debug builds
|
||||
Array *debuglibnames; // default libraries for debug builds
|
||||
|
||||
char *moduleDepsFile; // filename for deps output
|
||||
OutBuffer *moduleDeps; // contents to be written to deps file
|
||||
char *moduleDepsFile; // filename for deps output
|
||||
OutBuffer *moduleDeps; // contents to be written to deps file
|
||||
|
||||
// Hidden debug switches
|
||||
bool debuga;
|
||||
@@ -270,24 +270,24 @@ struct Global
|
||||
char *bc_ext;
|
||||
char *s_ext;
|
||||
const char *lib_ext;
|
||||
const char *doc_ext; // for Ddoc generated files
|
||||
const char *ddoc_ext; // for Ddoc macro include files
|
||||
const char *hdr_ext; // for D 'header' import files
|
||||
const char *json_ext; // for JSON files
|
||||
const char *map_ext; // for .map files
|
||||
const char *doc_ext; // for Ddoc generated files
|
||||
const char *ddoc_ext; // for Ddoc macro include files
|
||||
const char *hdr_ext; // for D 'header' import files
|
||||
const char *json_ext; // for JSON files
|
||||
const char *map_ext; // for .map files
|
||||
const char *copyright;
|
||||
const char *written;
|
||||
Array *path; // Array of char*'s which form the import lookup path
|
||||
Array *filePath; // Array of char*'s which form the file import lookup path
|
||||
Array *path; // Array of char*'s which form the import lookup path
|
||||
Array *filePath; // Array of char*'s which form the file import lookup path
|
||||
int structalign;
|
||||
const char *version;
|
||||
char *ldc_version;
|
||||
char *llvm_version;
|
||||
|
||||
Param params;
|
||||
unsigned errors; // number of errors reported so far
|
||||
unsigned warnings; // number of warnings reported so far
|
||||
unsigned gag; // !=0 means gag reporting of errors & warnings
|
||||
unsigned errors; // number of errors reported so far
|
||||
unsigned warnings; // number of warnings reported so far
|
||||
unsigned gag; // !=0 means gag reporting of errors & warnings
|
||||
|
||||
Global();
|
||||
};
|
||||
@@ -297,7 +297,7 @@ extern Global global;
|
||||
/* Set if Windows Structured Exception Handling C extensions are supported.
|
||||
* Apparently, VC has dropped support for these?
|
||||
*/
|
||||
#define WINDOWS_SEH (_WIN32 && __DMC__)
|
||||
#define WINDOWS_SEH (_WIN32 && __DMC__)
|
||||
|
||||
|
||||
#ifdef __DMC__
|
||||
@@ -313,29 +313,29 @@ extern Global global;
|
||||
|
||||
// Be careful not to care about sign when using dinteger_t
|
||||
//typedef uint64_t integer_t;
|
||||
typedef uint64_t dinteger_t; // use this instead of integer_t to
|
||||
// avoid conflicts with system #include's
|
||||
typedef uint64_t dinteger_t; // use this instead of integer_t to
|
||||
// avoid conflicts with system #include's
|
||||
|
||||
// Signed and unsigned variants
|
||||
typedef int64_t sinteger_t;
|
||||
typedef uint64_t uinteger_t;
|
||||
|
||||
typedef int8_t d_int8;
|
||||
typedef uint8_t d_uns8;
|
||||
typedef int16_t d_int16;
|
||||
typedef uint16_t d_uns16;
|
||||
typedef int32_t d_int32;
|
||||
typedef uint32_t d_uns32;
|
||||
typedef int64_t d_int64;
|
||||
typedef uint64_t d_uns64;
|
||||
typedef int8_t d_int8;
|
||||
typedef uint8_t d_uns8;
|
||||
typedef int16_t d_int16;
|
||||
typedef uint16_t d_uns16;
|
||||
typedef int32_t d_int32;
|
||||
typedef uint32_t d_uns32;
|
||||
typedef int64_t d_int64;
|
||||
typedef uint64_t d_uns64;
|
||||
|
||||
typedef float d_float32;
|
||||
typedef double d_float64;
|
||||
typedef long double d_float80;
|
||||
typedef float d_float32;
|
||||
typedef double d_float64;
|
||||
typedef long double d_float80;
|
||||
|
||||
typedef d_uns8 d_char;
|
||||
typedef d_uns16 d_wchar;
|
||||
typedef d_uns32 d_dchar;
|
||||
typedef d_uns8 d_char;
|
||||
typedef d_uns16 d_wchar;
|
||||
typedef d_uns32 d_dchar;
|
||||
|
||||
#ifdef IN_GCC
|
||||
#include "d-gcc-real.h"
|
||||
@@ -357,7 +357,7 @@ typedef long double real_t;
|
||||
|
||||
struct Module;
|
||||
|
||||
//typedef unsigned Loc; // file location
|
||||
//typedef unsigned Loc; // file location
|
||||
struct Loc
|
||||
{
|
||||
const char *filename;
|
||||
@@ -365,14 +365,14 @@ struct Loc
|
||||
|
||||
Loc()
|
||||
{
|
||||
linnum = 0;
|
||||
filename = NULL;
|
||||
linnum = 0;
|
||||
filename = NULL;
|
||||
}
|
||||
|
||||
Loc(int x)
|
||||
{
|
||||
linnum = x;
|
||||
filename = NULL;
|
||||
linnum = x;
|
||||
filename = NULL;
|
||||
}
|
||||
|
||||
Loc(Module *mod, unsigned linnum);
|
||||
@@ -382,15 +382,15 @@ struct Loc
|
||||
};
|
||||
|
||||
#ifndef GCC_SAFE_DMD
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry
|
||||
// in interface vtbl[]'s
|
||||
#define INTERFACE_VIRTUAL 0 // 1 means if an interface appears
|
||||
// in the inheritance graph multiple
|
||||
// times, only one is used
|
||||
#define INTERFACE_OFFSET 0 // if 1, put classinfo as first entry
|
||||
// in interface vtbl[]'s
|
||||
#define INTERFACE_VIRTUAL 0 // 1 means if an interface appears
|
||||
// in the inheritance graph multiple
|
||||
// times, only one is used
|
||||
|
||||
enum LINK
|
||||
{
|
||||
@@ -418,12 +418,12 @@ enum DYNCAST
|
||||
|
||||
enum MATCH
|
||||
{
|
||||
MATCHnomatch, // no match
|
||||
MATCHconvert, // match with conversions
|
||||
MATCHnomatch, // no match
|
||||
MATCHconvert, // match with conversions
|
||||
#if DMDV2
|
||||
MATCHconst, // match with conversion to const
|
||||
MATCHconst, // match with conversion to const
|
||||
#endif
|
||||
MATCHexact // exact match
|
||||
MATCHexact // exact match
|
||||
};
|
||||
|
||||
typedef uint64_t StorageClass;
|
||||
|
||||
66
dmd/mem.c
66
dmd/mem.c
@@ -1,6 +1,6 @@
|
||||
|
||||
/* Copyright (c) 2000 Digital Mars */
|
||||
/* All Rights Reserved */
|
||||
/* Copyright (c) 2000 Digital Mars */
|
||||
/* All Rights Reserved */
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
@@ -35,10 +35,10 @@ char *Mem::strdup(const char *s)
|
||||
|
||||
if (s)
|
||||
{
|
||||
p = GC_strdup(s);
|
||||
if (p)
|
||||
return p;
|
||||
error();
|
||||
p = GC_strdup(s);
|
||||
if (p)
|
||||
return p;
|
||||
error();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -47,12 +47,12 @@ void *Mem::malloc(size_t size)
|
||||
{ void *p;
|
||||
|
||||
if (!size)
|
||||
p = NULL;
|
||||
p = NULL;
|
||||
else
|
||||
{
|
||||
p = GC_malloc(size);
|
||||
if (!p)
|
||||
error();
|
||||
p = GC_malloc(size);
|
||||
if (!p)
|
||||
error();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -61,12 +61,12 @@ void *Mem::calloc(size_t size, size_t n)
|
||||
{ void *p;
|
||||
|
||||
if (!size || !n)
|
||||
p = NULL;
|
||||
p = NULL;
|
||||
else
|
||||
{
|
||||
p = GC_malloc(size * n);
|
||||
if (!p)
|
||||
error();
|
||||
p = GC_malloc(size * n);
|
||||
if (!p)
|
||||
error();
|
||||
memset(p, 0, size * n);
|
||||
}
|
||||
return p;
|
||||
@@ -75,22 +75,22 @@ void *Mem::calloc(size_t size, size_t n)
|
||||
void *Mem::realloc(void *p, size_t size)
|
||||
{
|
||||
if (!size)
|
||||
{ if (p)
|
||||
{ GC_free(p);
|
||||
p = NULL;
|
||||
}
|
||||
{ if (p)
|
||||
{ GC_free(p);
|
||||
p = NULL;
|
||||
}
|
||||
}
|
||||
else if (!p)
|
||||
{
|
||||
p = GC_malloc(size);
|
||||
if (!p)
|
||||
error();
|
||||
p = GC_malloc(size);
|
||||
if (!p)
|
||||
error();
|
||||
}
|
||||
else
|
||||
{
|
||||
p = GC_realloc(p, size);
|
||||
if (!p)
|
||||
error();
|
||||
p = GC_realloc(p, size);
|
||||
if (!p)
|
||||
error();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -98,21 +98,21 @@ void *Mem::realloc(void *p, size_t size)
|
||||
void Mem::free(void *p)
|
||||
{
|
||||
if (p)
|
||||
GC_free(p);
|
||||
GC_free(p);
|
||||
}
|
||||
|
||||
void *Mem::mallocdup(void *o, size_t size)
|
||||
{ void *p;
|
||||
|
||||
if (!size)
|
||||
p = NULL;
|
||||
p = NULL;
|
||||
else
|
||||
{
|
||||
p = GC_malloc(size);
|
||||
if (!p)
|
||||
error();
|
||||
else
|
||||
memcpy(p,o,size);
|
||||
p = GC_malloc(size);
|
||||
if (!p)
|
||||
error();
|
||||
else
|
||||
memcpy(p,o,size);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ void Mem::fullcollect()
|
||||
|
||||
void Mem::mark(void *pointer)
|
||||
{
|
||||
(void) pointer; // necessary for VC /W4
|
||||
(void) pointer; // necessary for VC /W4
|
||||
}
|
||||
|
||||
/* =================================================== */
|
||||
@@ -143,7 +143,7 @@ void * operator new(size_t m_size)
|
||||
}
|
||||
void *p = GC_malloc(m_size);
|
||||
if (p)
|
||||
return p;
|
||||
return p;
|
||||
printf("Error: out of memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
return p;
|
||||
|
||||
14
dmd/mem.h
14
dmd/mem.h
@@ -4,15 +4,15 @@
|
||||
#ifndef ROOT_MEM_H
|
||||
#define ROOT_MEM_H
|
||||
|
||||
#include <stddef.h> // for size_t
|
||||
#include <stddef.h> // for size_t
|
||||
|
||||
typedef void (*FINALIZERPROC)(void* pObj, void* pClientData);
|
||||
|
||||
struct GC; // thread specific allocator
|
||||
struct GC; // thread specific allocator
|
||||
|
||||
struct Mem
|
||||
{
|
||||
GC *gc; // pointer to our thread specific allocator
|
||||
GC *gc; // pointer to our thread specific allocator
|
||||
Mem() { gc = NULL; }
|
||||
|
||||
void init();
|
||||
@@ -35,15 +35,15 @@ struct Mem
|
||||
void free_uncollectable(void *p);
|
||||
void *mallocdup(void *o, size_t size);
|
||||
void error();
|
||||
void check(void *p); // validate pointer
|
||||
void fullcollect(); // do full garbage collection
|
||||
void fullcollectNoStack(); // do full garbage collection, no scan stack
|
||||
void check(void *p); // validate pointer
|
||||
void fullcollect(); // do full garbage collection
|
||||
void fullcollectNoStack(); // do full garbage collection, no scan stack
|
||||
void mark(void *pointer);
|
||||
void addroots(char* pStart, char* pEnd);
|
||||
void removeroots(char* pStart);
|
||||
void setFinalizer(void* pObj, FINALIZERPROC pFn, void* pClientData);
|
||||
void setStackBottom(void *bottom);
|
||||
GC *getThreadGC(); // get apartment allocator for this thread
|
||||
GC *getThreadGC(); // get apartment allocator for this thread
|
||||
};
|
||||
|
||||
extern Mem mem;
|
||||
|
||||
884
dmd/module.c
884
dmd/module.c
File diff suppressed because it is too large
Load Diff
108
dmd/module.h
108
dmd/module.h
@@ -59,70 +59,70 @@ struct Package : ScopeDsymbol
|
||||
struct Module : Package
|
||||
{
|
||||
static Module *rootModule;
|
||||
static DsymbolTable *modules; // symbol table of all modules
|
||||
static Array amodules; // array of all modules
|
||||
static Array deferred; // deferred Dsymbol's needing semantic() run on them
|
||||
static unsigned dprogress; // progress resolving the deferred list
|
||||
static DsymbolTable *modules; // symbol table of all modules
|
||||
static Array amodules; // array of all modules
|
||||
static Array deferred; // deferred Dsymbol's needing semantic() run on them
|
||||
static unsigned dprogress; // progress resolving the deferred list
|
||||
static void init();
|
||||
|
||||
static ClassDeclaration *moduleinfo;
|
||||
|
||||
|
||||
const char *arg; // original argument name
|
||||
const char *arg; // original argument name
|
||||
ModuleDeclaration *md; // if !NULL, the contents of the ModuleDeclaration declaration
|
||||
File *srcfile; // input source file
|
||||
File *srcfile; // input source file
|
||||
|
||||
File *objfile; // output object file
|
||||
File *docfile; // output doc file
|
||||
File *hdrfile; // output hdr file
|
||||
|
||||
unsigned errors; // if any errors in file
|
||||
unsigned numlines; // number of lines in source file
|
||||
int isHtml; // if it is an HTML file
|
||||
int isDocFile; // if it is a documentation input file, not D source
|
||||
|
||||
unsigned errors; // if any errors in file
|
||||
unsigned numlines; // number of lines in source file
|
||||
int isHtml; // if it is an HTML file
|
||||
int isDocFile; // if it is a documentation input file, not D source
|
||||
int needmoduleinfo;
|
||||
#ifdef IN_GCC
|
||||
int strictlyneedmoduleinfo;
|
||||
#endif
|
||||
|
||||
int selfimports; // 0: don't know, 1: does not, 2: does
|
||||
int selfImports(); // returns !=0 if module imports itself
|
||||
int selfimports; // 0: don't know, 1: does not, 2: does
|
||||
int selfImports(); // returns !=0 if module imports itself
|
||||
|
||||
int insearch;
|
||||
Identifier *searchCacheIdent;
|
||||
Dsymbol *searchCacheSymbol; // cached value of search
|
||||
int searchCacheFlags; // cached flags
|
||||
Dsymbol *searchCacheSymbol; // cached value of search
|
||||
int searchCacheFlags; // cached flags
|
||||
|
||||
int semanticstarted; // has semantic() been started?
|
||||
int semanticRun; // has semantic() been done?
|
||||
int root; // != 0 if this is a 'root' module,
|
||||
// i.e. a module that will be taken all the
|
||||
// way to an object file
|
||||
Module *importedFrom; // module from command line we're imported from,
|
||||
// i.e. a module that will be taken all the
|
||||
// way to an object file
|
||||
int semanticstarted; // has semantic() been started?
|
||||
int semanticRun; // has semantic() been done?
|
||||
int root; // != 0 if this is a 'root' module,
|
||||
// i.e. a module that will be taken all the
|
||||
// way to an object file
|
||||
Module *importedFrom; // module from command line we're imported from,
|
||||
// i.e. a module that will be taken all the
|
||||
// way to an object file
|
||||
|
||||
Array *decldefs; // top level declarations for this Module
|
||||
Array *decldefs; // top level declarations for this Module
|
||||
|
||||
Array aimports; // all imported modules
|
||||
Array aimports; // all imported modules
|
||||
|
||||
ModuleInfoDeclaration *vmoduleinfo;
|
||||
|
||||
unsigned debuglevel; // debug level
|
||||
Array *debugids; // debug identifiers
|
||||
Array *debugidsNot; // forward referenced debug identifiers
|
||||
unsigned debuglevel; // debug level
|
||||
Array *debugids; // debug identifiers
|
||||
Array *debugidsNot; // forward referenced debug identifiers
|
||||
|
||||
unsigned versionlevel; // version level
|
||||
Array *versionids; // version identifiers
|
||||
Array *versionidsNot; // forward referenced version identifiers
|
||||
unsigned versionlevel; // version level
|
||||
Array *versionids; // version identifiers
|
||||
Array *versionidsNot; // forward referenced version identifiers
|
||||
|
||||
Macro *macrotable; // document comment macros
|
||||
struct Escape *escapetable; // document comment escapes
|
||||
Macro *macrotable; // document comment macros
|
||||
struct Escape *escapetable; // document comment escapes
|
||||
|
||||
int doDocComment; // enable generating doc comments for this module
|
||||
int doHdrGen; // enable generating header file for this module
|
||||
|
||||
bool safe; // TRUE if module is marked as 'safe'
|
||||
bool safe; // TRUE if module is marked as 'safe'
|
||||
|
||||
Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen);
|
||||
~Module();
|
||||
@@ -132,17 +132,17 @@ struct Module : Package
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
void toJsonBuffer(OutBuffer *buf);
|
||||
const char *kind();
|
||||
void read(Loc loc); // read file
|
||||
void read(Loc loc); // read file
|
||||
#if IN_GCC
|
||||
void parse(bool dump_source = false); // syntactic parse
|
||||
void parse(bool dump_source = false); // syntactic parse
|
||||
#else
|
||||
void parse(); // syntactic parse
|
||||
void parse(); // syntactic parse
|
||||
#endif
|
||||
void importAll(Scope *sc);
|
||||
void semantic(Scope* unused_sc = NULL); // semantic analysis
|
||||
void semantic2(Scope* unused_sc = NULL); // pass 2 semantic analysis
|
||||
void semantic3(Scope* unused_sc = NULL); // pass 3 semantic analysis
|
||||
void inlineScan(); // scan for functions to inline
|
||||
void semantic(Scope* unused_sc = NULL); // semantic analysis
|
||||
void semantic2(Scope* unused_sc = NULL); // pass 2 semantic analysis
|
||||
void semantic3(Scope* unused_sc = NULL); // pass 3 semantic analysis
|
||||
void inlineScan(); // scan for functions to inline
|
||||
#ifdef _DH
|
||||
void genhdrfile(); // generate D import file
|
||||
#endif
|
||||
@@ -159,22 +159,22 @@ struct Module : Package
|
||||
|
||||
// Back end
|
||||
#if IN_DMD
|
||||
int doppelganger; // sub-module
|
||||
Symbol *cov; // private uint[] __coverage;
|
||||
unsigned *covb; // bit array of valid code line numbers
|
||||
int doppelganger; // sub-module
|
||||
Symbol *cov; // private uint[] __coverage;
|
||||
unsigned *covb; // bit array of valid code line numbers
|
||||
|
||||
Symbol *sictor; // module order independent constructor
|
||||
Symbol *sctor; // module constructor
|
||||
Symbol *sdtor; // module destructor
|
||||
Symbol *stest; // module unit test
|
||||
Symbol *sictor; // module order independent constructor
|
||||
Symbol *sctor; // module constructor
|
||||
Symbol *sdtor; // module destructor
|
||||
Symbol *stest; // module unit test
|
||||
|
||||
Symbol *sfilename; // symbol for filename
|
||||
Symbol *sfilename; // symbol for filename
|
||||
|
||||
Symbol *massert; // module assert function
|
||||
Symbol *toModuleAssert(); // get module assert function
|
||||
Symbol *massert; // module assert function
|
||||
Symbol *toModuleAssert(); // get module assert function
|
||||
|
||||
Symbol *marray; // module array bounds function
|
||||
Symbol *toModuleArray(); // get module array bounds function
|
||||
Symbol *marray; // module array bounds function
|
||||
Symbol *toModuleArray(); // get module array bounds function
|
||||
|
||||
|
||||
static Symbol *gencritsec();
|
||||
@@ -203,7 +203,7 @@ struct Module : Package
|
||||
struct ModuleDeclaration
|
||||
{
|
||||
Identifier *id;
|
||||
Array *packages; // array of Identifier's representing packages
|
||||
Array *packages; // array of Identifier's representing packages
|
||||
bool safe;
|
||||
|
||||
ModuleDeclaration(Array *packages, Identifier *id);
|
||||
|
||||
4592
dmd/mtype.c
4592
dmd/mtype.c
File diff suppressed because it is too large
Load Diff
114
dmd/mtype.h
114
dmd/mtype.h
@@ -59,9 +59,9 @@ struct Symbol;
|
||||
|
||||
enum TY
|
||||
{
|
||||
Tarray, // dynamic array
|
||||
Tsarray, // static array
|
||||
Taarray, // associative array
|
||||
Tarray, // dynamic array
|
||||
Tsarray, // static array
|
||||
Taarray, // associative array
|
||||
Tpointer,
|
||||
Treference,
|
||||
Tfunction,
|
||||
@@ -118,60 +118,60 @@ extern int Tptrdiff_t;
|
||||
struct Type : Object
|
||||
{
|
||||
TY ty;
|
||||
unsigned char mod; // modifiers MODxxxx
|
||||
/* pick this order of numbers so switch statements work better
|
||||
*/
|
||||
#define MODconst 1 // type is const
|
||||
#define MODimmutable 4 // type is invariant
|
||||
#define MODshared 2 // type is shared
|
||||
unsigned char mod; // modifiers MODxxxx
|
||||
/* pick this order of numbers so switch statements work better
|
||||
*/
|
||||
#define MODconst 1 // type is const
|
||||
#define MODimmutable 4 // type is invariant
|
||||
#define MODshared 2 // type is shared
|
||||
char *deco;
|
||||
Type *pto; // merged pointer to this type
|
||||
Type *rto; // reference to this type
|
||||
Type *arrayof; // array of this type
|
||||
TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type
|
||||
Type *pto; // merged pointer to this type
|
||||
Type *rto; // reference to this type
|
||||
Type *arrayof; // array of this type
|
||||
TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type
|
||||
|
||||
#if IN_DMD
|
||||
type *ctype; // for back end
|
||||
type *ctype; // for back end
|
||||
#endif
|
||||
|
||||
#define tvoid basic[Tvoid]
|
||||
#define tint8 basic[Tint8]
|
||||
#define tuns8 basic[Tuns8]
|
||||
#define tint16 basic[Tint16]
|
||||
#define tuns16 basic[Tuns16]
|
||||
#define tint32 basic[Tint32]
|
||||
#define tuns32 basic[Tuns32]
|
||||
#define tint64 basic[Tint64]
|
||||
#define tuns64 basic[Tuns64]
|
||||
#define tfloat32 basic[Tfloat32]
|
||||
#define tfloat64 basic[Tfloat64]
|
||||
#define tfloat80 basic[Tfloat80]
|
||||
#define tvoid basic[Tvoid]
|
||||
#define tint8 basic[Tint8]
|
||||
#define tuns8 basic[Tuns8]
|
||||
#define tint16 basic[Tint16]
|
||||
#define tuns16 basic[Tuns16]
|
||||
#define tint32 basic[Tint32]
|
||||
#define tuns32 basic[Tuns32]
|
||||
#define tint64 basic[Tint64]
|
||||
#define tuns64 basic[Tuns64]
|
||||
#define tfloat32 basic[Tfloat32]
|
||||
#define tfloat64 basic[Tfloat64]
|
||||
#define tfloat80 basic[Tfloat80]
|
||||
|
||||
#define timaginary32 basic[Timaginary32]
|
||||
#define timaginary64 basic[Timaginary64]
|
||||
#define timaginary80 basic[Timaginary80]
|
||||
|
||||
#define tcomplex32 basic[Tcomplex32]
|
||||
#define tcomplex64 basic[Tcomplex64]
|
||||
#define tcomplex80 basic[Tcomplex80]
|
||||
#define tcomplex32 basic[Tcomplex32]
|
||||
#define tcomplex64 basic[Tcomplex64]
|
||||
#define tcomplex80 basic[Tcomplex80]
|
||||
|
||||
#define tbit basic[Tbit]
|
||||
#define tbool basic[Tbool]
|
||||
#define tchar basic[Tchar]
|
||||
#define twchar basic[Twchar]
|
||||
#define tdchar basic[Tdchar]
|
||||
#define tbit basic[Tbit]
|
||||
#define tbool basic[Tbool]
|
||||
#define tchar basic[Tchar]
|
||||
#define twchar basic[Twchar]
|
||||
#define tdchar basic[Tdchar]
|
||||
|
||||
// Some special types
|
||||
#define tshiftcnt tint32 // right side of shift expression
|
||||
// #define tboolean tint32 // result of boolean expression
|
||||
#define tboolean tbool // result of boolean expression
|
||||
#define tindex tint32 // array/ptr index
|
||||
static Type *tvoidptr; // void*
|
||||
#define terror basic[Terror] // for error recovery
|
||||
#define tshiftcnt tint32 // right side of shift expression
|
||||
// #define tboolean tint32 // result of boolean expression
|
||||
#define tboolean tbool // result of boolean expression
|
||||
#define tindex tint32 // array/ptr index
|
||||
static Type *tvoidptr; // void*
|
||||
#define terror basic[Terror] // for error recovery
|
||||
|
||||
#define tsize_t basic[Tsize_t] // matches size_t alias
|
||||
#define tptrdiff_t basic[Tptrdiff_t] // matches ptrdiff_t alias
|
||||
#define thash_t tsize_t // matches hash_t alias
|
||||
#define tsize_t basic[Tsize_t] // matches size_t alias
|
||||
#define tptrdiff_t basic[Tptrdiff_t] // matches ptrdiff_t alias
|
||||
#define thash_t tsize_t // matches hash_t alias
|
||||
|
||||
static ClassDeclaration *typeinfo;
|
||||
static ClassDeclaration *typeinfoclass;
|
||||
@@ -228,7 +228,7 @@ struct Type : Object
|
||||
void toCBuffer3(OutBuffer *buf, HdrGenState *hgs, int mod);
|
||||
virtual int isbit();
|
||||
virtual int isintegral();
|
||||
virtual int isfloating(); // real, imaginary, or complex
|
||||
virtual int isfloating(); // real, imaginary, or complex
|
||||
virtual int isreal();
|
||||
virtual int isimaginary();
|
||||
virtual int iscomplex();
|
||||
@@ -236,7 +236,7 @@ struct Type : Object
|
||||
virtual int isunsigned();
|
||||
virtual int isscope();
|
||||
virtual int isString();
|
||||
virtual int checkBoolean(); // if can be converted to boolean value
|
||||
virtual int checkBoolean(); // if can be converted to boolean value
|
||||
void checkDeprecated(Loc loc, Scope *sc);
|
||||
Type *pointerTo();
|
||||
Type *referenceTo();
|
||||
@@ -251,7 +251,7 @@ struct Type : Object
|
||||
virtual unsigned memalign(unsigned salign);
|
||||
virtual Expression *defaultInit(Loc loc = 0);
|
||||
virtual Expression *defaultInitLiteral(Loc loc = 0);
|
||||
virtual int isZeroInit(Loc loc = 0); // if initializer is 0
|
||||
virtual int isZeroInit(Loc loc = 0); // if initializer is 0
|
||||
#if IN_DMD
|
||||
virtual dt_t **toDt(dt_t **pdt);
|
||||
#endif
|
||||
@@ -387,8 +387,8 @@ struct TypeDArray : TypeArray
|
||||
|
||||
struct TypeAArray : TypeArray
|
||||
{
|
||||
Type *index; // key type for type checking
|
||||
Type *key; // actual key type
|
||||
Type *index; // key type for type checking
|
||||
Type *key; // actual key type
|
||||
|
||||
TypeAArray(Type *t, Type *index);
|
||||
Type *syntaxCopy();
|
||||
@@ -447,16 +447,16 @@ struct TypeReference : Type
|
||||
|
||||
enum RET
|
||||
{
|
||||
RETregs = 1, // returned in registers
|
||||
RETstack = 2, // returned on stack
|
||||
RETregs = 1, // returned in registers
|
||||
RETstack = 2, // returned on stack
|
||||
};
|
||||
|
||||
struct TypeFunction : Type
|
||||
{
|
||||
Parameters *parameters; // function parameters
|
||||
int varargs; // 1: T t, ...) style for variable number of arguments
|
||||
// 2: T t ...) style for variable number of arguments
|
||||
enum LINK linkage; // calling convention
|
||||
Parameters *parameters; // function parameters
|
||||
int varargs; // 1: T t, ...) style for variable number of arguments
|
||||
// 2: T t ...) style for variable number of arguments
|
||||
enum LINK linkage; // calling convention
|
||||
|
||||
int inuse;
|
||||
|
||||
@@ -510,7 +510,7 @@ struct TypeDelegate : Type
|
||||
struct TypeQualified : Type
|
||||
{
|
||||
Loc loc;
|
||||
Array idents; // array of Identifier's representing ident.ident.ident etc.
|
||||
Array idents; // array of Identifier's representing ident.ident.ident etc.
|
||||
|
||||
TypeQualified(TY ty, Loc loc);
|
||||
void syntaxCopyHelper(TypeQualified *t);
|
||||
@@ -518,7 +518,7 @@ struct TypeQualified : Type
|
||||
void toCBuffer2Helper(OutBuffer *buf, HdrGenState *hgs);
|
||||
d_uns64 size(Loc loc);
|
||||
void resolveHelper(Loc loc, Scope *sc, Dsymbol *s, Dsymbol *scopesym,
|
||||
Expression **pe, Type **pt, Dsymbol **ps);
|
||||
Expression **pe, Type **pt, Dsymbol **ps);
|
||||
};
|
||||
|
||||
struct TypeIdentifier : TypeQualified
|
||||
@@ -721,7 +721,7 @@ struct TypeClass : Type
|
||||
|
||||
struct TypeTuple : Type
|
||||
{
|
||||
Parameters *arguments; // types making up the tuple
|
||||
Parameters *arguments; // types making up the tuple
|
||||
|
||||
TypeTuple(Parameters *arguments);
|
||||
TypeTuple(Expressions *exps);
|
||||
|
||||
752
dmd/opover.c
752
dmd/opover.c
@@ -45,7 +45,7 @@ static void templateResolve(Match *m, TemplateDeclaration *td, Scope *sc, Loc lo
|
||||
|
||||
int Expression::isCommutative()
|
||||
{
|
||||
return FALSE; // default is no reverse
|
||||
return FALSE; // default is no reverse
|
||||
}
|
||||
|
||||
/***********************************
|
||||
@@ -82,8 +82,8 @@ Identifier *InExp::opId() { return Id::opIn; }
|
||||
Identifier *InExp::opId_r() { return Id::opIn_r; }
|
||||
|
||||
Identifier *PostExp::opId() { return (op == TOKplusplus)
|
||||
? Id::postinc
|
||||
: Id::postdec; }
|
||||
? Id::postinc
|
||||
: Id::postdec; }
|
||||
|
||||
int AddExp::isCommutative() { return TRUE; }
|
||||
Identifier *AddExp::opId() { return Id::add; }
|
||||
@@ -146,7 +146,7 @@ Identifier *EqualExp::opId() { return Id::eq; }
|
||||
int CmpExp::isCommutative() { return TRUE; }
|
||||
Identifier *CmpExp::opId() { return Id::cmp; }
|
||||
|
||||
Identifier *ArrayExp::opId() { return Id::index; }
|
||||
Identifier *ArrayExp::opId() { return Id::index; }
|
||||
|
||||
|
||||
/************************************
|
||||
@@ -165,48 +165,48 @@ Expression *UnaExp::op_overload(Scope *sc)
|
||||
|
||||
if (t1->ty == Tclass)
|
||||
{
|
||||
ad = ((TypeClass *)t1)->sym;
|
||||
goto L1;
|
||||
ad = ((TypeClass *)t1)->sym;
|
||||
goto L1;
|
||||
}
|
||||
else if (t1->ty == Tstruct)
|
||||
{
|
||||
ad = ((TypeStruct *)t1)->sym;
|
||||
ad = ((TypeStruct *)t1)->sym;
|
||||
|
||||
L1:
|
||||
fd = search_function(ad, opId());
|
||||
if (fd)
|
||||
{
|
||||
if (op == TOKarray)
|
||||
{
|
||||
/* Rewrite op e1[arguments] as:
|
||||
* e1.fd(arguments)
|
||||
*/
|
||||
Expression *e = new DotIdExp(loc, e1, fd->ident);
|
||||
ArrayExp *ae = (ArrayExp *)this;
|
||||
e = new CallExp(loc, e, ae->arguments);
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rewrite +e1 as e1.add()
|
||||
return build_overload(loc, sc, e1, NULL, fd->ident);
|
||||
}
|
||||
}
|
||||
fd = search_function(ad, opId());
|
||||
if (fd)
|
||||
{
|
||||
if (op == TOKarray)
|
||||
{
|
||||
/* Rewrite op e1[arguments] as:
|
||||
* e1.fd(arguments)
|
||||
*/
|
||||
Expression *e = new DotIdExp(loc, e1, fd->ident);
|
||||
ArrayExp *ae = (ArrayExp *)this;
|
||||
e = new CallExp(loc, e, ae->arguments);
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rewrite +e1 as e1.add()
|
||||
return build_overload(loc, sc, e1, NULL, fd->ident);
|
||||
}
|
||||
}
|
||||
|
||||
#if DMDV2
|
||||
// Didn't find it. Forward to aliasthis
|
||||
if (ad->aliasthis)
|
||||
{
|
||||
/* Rewrite op(e1) as:
|
||||
* op(e1.aliasthis)
|
||||
*/
|
||||
Expression *e1 = new DotIdExp(loc, this->e1, ad->aliasthis->ident);
|
||||
Expression *e = copy();
|
||||
((UnaExp *)e)->e1 = e1;
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
}
|
||||
// Didn't find it. Forward to aliasthis
|
||||
if (ad->aliasthis)
|
||||
{
|
||||
/* Rewrite op(e1) as:
|
||||
* op(e1.aliasthis)
|
||||
*/
|
||||
Expression *e1 = new DotIdExp(loc, this->e1, ad->aliasthis->ident);
|
||||
Expression *e = copy();
|
||||
((UnaExp *)e)->e1 = e1;
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return NULL;
|
||||
@@ -230,19 +230,19 @@ Expression *BinExp::op_overload(Scope *sc)
|
||||
|
||||
AggregateDeclaration *ad1;
|
||||
if (t1->ty == Tclass)
|
||||
ad1 = ((TypeClass *)t1)->sym;
|
||||
ad1 = ((TypeClass *)t1)->sym;
|
||||
else if (t1->ty == Tstruct)
|
||||
ad1 = ((TypeStruct *)t1)->sym;
|
||||
ad1 = ((TypeStruct *)t1)->sym;
|
||||
else
|
||||
ad1 = NULL;
|
||||
ad1 = NULL;
|
||||
|
||||
AggregateDeclaration *ad2;
|
||||
if (t2->ty == Tclass)
|
||||
ad2 = ((TypeClass *)t2)->sym;
|
||||
ad2 = ((TypeClass *)t2)->sym;
|
||||
else if (t2->ty == Tstruct)
|
||||
ad2 = ((TypeStruct *)t2)->sym;
|
||||
ad2 = ((TypeStruct *)t2)->sym;
|
||||
else
|
||||
ad2 = NULL;
|
||||
ad2 = NULL;
|
||||
|
||||
Dsymbol *s = NULL;
|
||||
Dsymbol *s_r = NULL;
|
||||
@@ -250,221 +250,221 @@ Expression *BinExp::op_overload(Scope *sc)
|
||||
TemplateDeclaration *td = NULL;
|
||||
if (ad1 && id)
|
||||
{
|
||||
s = search_function(ad1, id);
|
||||
s = search_function(ad1, id);
|
||||
}
|
||||
if (ad2 && id_r)
|
||||
{
|
||||
s_r = search_function(ad2, id_r);
|
||||
s_r = search_function(ad2, id_r);
|
||||
}
|
||||
|
||||
if (s || s_r)
|
||||
{
|
||||
/* Try:
|
||||
* a.opfunc(b)
|
||||
* b.opfunc_r(a)
|
||||
* and see which is better.
|
||||
*/
|
||||
Expression *e;
|
||||
FuncDeclaration *lastf;
|
||||
/* Try:
|
||||
* a.opfunc(b)
|
||||
* b.opfunc_r(a)
|
||||
* and see which is better.
|
||||
*/
|
||||
Expression *e;
|
||||
FuncDeclaration *lastf;
|
||||
|
||||
args1.setDim(1);
|
||||
args1.data[0] = (void*) e1;
|
||||
args2.setDim(1);
|
||||
args2.data[0] = (void*) e2;
|
||||
argsset = 1;
|
||||
args1.setDim(1);
|
||||
args1.data[0] = (void*) e1;
|
||||
args2.setDim(1);
|
||||
args2.data[0] = (void*) e2;
|
||||
argsset = 1;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.last = MATCHnomatch;
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.last = MATCHnomatch;
|
||||
|
||||
if (s)
|
||||
{
|
||||
fd = s->isFuncDeclaration();
|
||||
if (fd)
|
||||
{
|
||||
overloadResolveX(&m, fd, NULL, &args2, sc->module);
|
||||
}
|
||||
else
|
||||
{ td = s->isTemplateDeclaration();
|
||||
templateResolve(&m, td, sc, loc, NULL, NULL, &args2);
|
||||
}
|
||||
}
|
||||
|
||||
lastf = m.lastf;
|
||||
if (s)
|
||||
{
|
||||
fd = s->isFuncDeclaration();
|
||||
if (fd)
|
||||
{
|
||||
overloadResolveX(&m, fd, NULL, &args2, sc->module);
|
||||
}
|
||||
else
|
||||
{ td = s->isTemplateDeclaration();
|
||||
templateResolve(&m, td, sc, loc, NULL, NULL, &args2);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_r)
|
||||
{
|
||||
fd = s_r->isFuncDeclaration();
|
||||
if (fd)
|
||||
{
|
||||
overloadResolveX(&m, fd, NULL, &args1, sc->module);
|
||||
}
|
||||
else
|
||||
{ td = s_r->isTemplateDeclaration();
|
||||
templateResolve(&m, td, sc, loc, NULL, NULL, &args1);
|
||||
}
|
||||
}
|
||||
lastf = m.lastf;
|
||||
|
||||
if (m.count > 1)
|
||||
{
|
||||
// Error, ambiguous
|
||||
error("overloads %s and %s both match argument list for %s",
|
||||
m.lastf->type->toChars(),
|
||||
m.nextf->type->toChars(),
|
||||
m.lastf->toChars());
|
||||
}
|
||||
else if (m.last == MATCHnomatch)
|
||||
{
|
||||
m.lastf = m.anyf;
|
||||
}
|
||||
if (s_r)
|
||||
{
|
||||
fd = s_r->isFuncDeclaration();
|
||||
if (fd)
|
||||
{
|
||||
overloadResolveX(&m, fd, NULL, &args1, sc->module);
|
||||
}
|
||||
else
|
||||
{ td = s_r->isTemplateDeclaration();
|
||||
templateResolve(&m, td, sc, loc, NULL, NULL, &args1);
|
||||
}
|
||||
}
|
||||
|
||||
if (op == TOKplusplus || op == TOKminusminus)
|
||||
// Kludge because operator overloading regards e++ and e--
|
||||
// as unary, but it's implemented as a binary.
|
||||
// Rewrite (e1 ++ e2) as e1.postinc()
|
||||
// Rewrite (e1 -- e2) as e1.postdec()
|
||||
e = build_overload(loc, sc, e1, NULL, id);
|
||||
else if (lastf && m.lastf == lastf || m.last == MATCHnomatch)
|
||||
// Rewrite (e1 op e2) as e1.opfunc(e2)
|
||||
e = build_overload(loc, sc, e1, e2, id);
|
||||
else
|
||||
// Rewrite (e1 op e2) as e2.opfunc_r(e1)
|
||||
e = build_overload(loc, sc, e2, e1, id_r);
|
||||
return e;
|
||||
if (m.count > 1)
|
||||
{
|
||||
// Error, ambiguous
|
||||
error("overloads %s and %s both match argument list for %s",
|
||||
m.lastf->type->toChars(),
|
||||
m.nextf->type->toChars(),
|
||||
m.lastf->toChars());
|
||||
}
|
||||
else if (m.last == MATCHnomatch)
|
||||
{
|
||||
m.lastf = m.anyf;
|
||||
}
|
||||
|
||||
if (op == TOKplusplus || op == TOKminusminus)
|
||||
// Kludge because operator overloading regards e++ and e--
|
||||
// as unary, but it's implemented as a binary.
|
||||
// Rewrite (e1 ++ e2) as e1.postinc()
|
||||
// Rewrite (e1 -- e2) as e1.postdec()
|
||||
e = build_overload(loc, sc, e1, NULL, id);
|
||||
else if (lastf && m.lastf == lastf || m.last == MATCHnomatch)
|
||||
// Rewrite (e1 op e2) as e1.opfunc(e2)
|
||||
e = build_overload(loc, sc, e1, e2, id);
|
||||
else
|
||||
// Rewrite (e1 op e2) as e2.opfunc_r(e1)
|
||||
e = build_overload(loc, sc, e2, e1, id_r);
|
||||
return e;
|
||||
}
|
||||
|
||||
if (isCommutative())
|
||||
{
|
||||
s = NULL;
|
||||
s_r = NULL;
|
||||
if (ad1 && id_r)
|
||||
{
|
||||
s_r = search_function(ad1, id_r);
|
||||
}
|
||||
if (ad2 && id)
|
||||
{
|
||||
s = search_function(ad2, id);
|
||||
}
|
||||
s = NULL;
|
||||
s_r = NULL;
|
||||
if (ad1 && id_r)
|
||||
{
|
||||
s_r = search_function(ad1, id_r);
|
||||
}
|
||||
if (ad2 && id)
|
||||
{
|
||||
s = search_function(ad2, id);
|
||||
}
|
||||
|
||||
if (s || s_r)
|
||||
{
|
||||
/* Try:
|
||||
* a.opfunc_r(b)
|
||||
* b.opfunc(a)
|
||||
* and see which is better.
|
||||
*/
|
||||
FuncDeclaration *lastf;
|
||||
if (s || s_r)
|
||||
{
|
||||
/* Try:
|
||||
* a.opfunc_r(b)
|
||||
* b.opfunc(a)
|
||||
* and see which is better.
|
||||
*/
|
||||
FuncDeclaration *lastf;
|
||||
|
||||
if (!argsset)
|
||||
{ args1.setDim(1);
|
||||
args1.data[0] = (void*) e1;
|
||||
args2.setDim(1);
|
||||
args2.data[0] = (void*) e2;
|
||||
}
|
||||
if (!argsset)
|
||||
{ args1.setDim(1);
|
||||
args1.data[0] = (void*) e1;
|
||||
args2.setDim(1);
|
||||
args2.data[0] = (void*) e2;
|
||||
}
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.last = MATCHnomatch;
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.last = MATCHnomatch;
|
||||
|
||||
if (s_r)
|
||||
{
|
||||
fd = s_r->isFuncDeclaration();
|
||||
if (fd)
|
||||
{
|
||||
overloadResolveX(&m, fd, NULL, &args2, sc->module);
|
||||
}
|
||||
else
|
||||
{ td = s_r->isTemplateDeclaration();
|
||||
templateResolve(&m, td, sc, loc, NULL, NULL, &args2);
|
||||
}
|
||||
}
|
||||
lastf = m.lastf;
|
||||
if (s_r)
|
||||
{
|
||||
fd = s_r->isFuncDeclaration();
|
||||
if (fd)
|
||||
{
|
||||
overloadResolveX(&m, fd, NULL, &args2, sc->module);
|
||||
}
|
||||
else
|
||||
{ td = s_r->isTemplateDeclaration();
|
||||
templateResolve(&m, td, sc, loc, NULL, NULL, &args2);
|
||||
}
|
||||
}
|
||||
lastf = m.lastf;
|
||||
|
||||
if (s)
|
||||
{
|
||||
fd = s->isFuncDeclaration();
|
||||
if (fd)
|
||||
{
|
||||
overloadResolveX(&m, fd, NULL, &args1, sc->module);
|
||||
}
|
||||
else
|
||||
{ td = s->isTemplateDeclaration();
|
||||
templateResolve(&m, td, sc, loc, NULL, NULL, &args1);
|
||||
}
|
||||
}
|
||||
if (s)
|
||||
{
|
||||
fd = s->isFuncDeclaration();
|
||||
if (fd)
|
||||
{
|
||||
overloadResolveX(&m, fd, NULL, &args1, sc->module);
|
||||
}
|
||||
else
|
||||
{ td = s->isTemplateDeclaration();
|
||||
templateResolve(&m, td, sc, loc, NULL, NULL, &args1);
|
||||
}
|
||||
}
|
||||
|
||||
if (m.count > 1)
|
||||
{
|
||||
// Error, ambiguous
|
||||
error("overloads %s and %s both match argument list for %s",
|
||||
m.lastf->type->toChars(),
|
||||
m.nextf->type->toChars(),
|
||||
m.lastf->toChars());
|
||||
}
|
||||
else if (m.last == MATCHnomatch)
|
||||
{
|
||||
m.lastf = m.anyf;
|
||||
}
|
||||
if (m.count > 1)
|
||||
{
|
||||
// Error, ambiguous
|
||||
error("overloads %s and %s both match argument list for %s",
|
||||
m.lastf->type->toChars(),
|
||||
m.nextf->type->toChars(),
|
||||
m.lastf->toChars());
|
||||
}
|
||||
else if (m.last == MATCHnomatch)
|
||||
{
|
||||
m.lastf = m.anyf;
|
||||
}
|
||||
|
||||
Expression *e;
|
||||
if (lastf && m.lastf == lastf ||
|
||||
id_r && m.last == MATCHnomatch)
|
||||
// Rewrite (e1 op e2) as e1.opfunc_r(e2)
|
||||
e = build_overload(loc, sc, e1, e2, id_r);
|
||||
else
|
||||
// Rewrite (e1 op e2) as e2.opfunc(e1)
|
||||
e = build_overload(loc, sc, e2, e1, id);
|
||||
Expression *e;
|
||||
if (lastf && m.lastf == lastf ||
|
||||
id_r && m.last == MATCHnomatch)
|
||||
// Rewrite (e1 op e2) as e1.opfunc_r(e2)
|
||||
e = build_overload(loc, sc, e1, e2, id_r);
|
||||
else
|
||||
// Rewrite (e1 op e2) as e2.opfunc(e1)
|
||||
e = build_overload(loc, sc, e2, e1, id);
|
||||
|
||||
// When reversing operands of comparison operators,
|
||||
// need to reverse the sense of the op
|
||||
switch (op)
|
||||
{
|
||||
case TOKlt: op = TOKgt; break;
|
||||
case TOKgt: op = TOKlt; break;
|
||||
case TOKle: op = TOKge; break;
|
||||
case TOKge: op = TOKle; break;
|
||||
// When reversing operands of comparison operators,
|
||||
// need to reverse the sense of the op
|
||||
switch (op)
|
||||
{
|
||||
case TOKlt: op = TOKgt; break;
|
||||
case TOKgt: op = TOKlt; break;
|
||||
case TOKle: op = TOKge; break;
|
||||
case TOKge: op = TOKle; break;
|
||||
|
||||
// Floating point compares
|
||||
case TOKule: op = TOKuge; break;
|
||||
case TOKul: op = TOKug; break;
|
||||
case TOKuge: op = TOKule; break;
|
||||
case TOKug: op = TOKul; break;
|
||||
// Floating point compares
|
||||
case TOKule: op = TOKuge; break;
|
||||
case TOKul: op = TOKug; break;
|
||||
case TOKuge: op = TOKule; break;
|
||||
case TOKug: op = TOKul; break;
|
||||
|
||||
// These are symmetric
|
||||
case TOKunord:
|
||||
case TOKlg:
|
||||
case TOKleg:
|
||||
case TOKue:
|
||||
break;
|
||||
}
|
||||
// These are symmetric
|
||||
case TOKunord:
|
||||
case TOKlg:
|
||||
case TOKleg:
|
||||
case TOKue:
|
||||
break;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
#if DMDV2
|
||||
// Try alias this on first operand
|
||||
if (ad1 && ad1->aliasthis)
|
||||
{
|
||||
/* Rewrite (e1 op e2) as:
|
||||
* (e1.aliasthis op e2)
|
||||
*/
|
||||
Expression *e1 = new DotIdExp(loc, this->e1, ad1->aliasthis->ident);
|
||||
Expression *e = copy();
|
||||
((BinExp *)e)->e1 = e1;
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
/* Rewrite (e1 op e2) as:
|
||||
* (e1.aliasthis op e2)
|
||||
*/
|
||||
Expression *e1 = new DotIdExp(loc, this->e1, ad1->aliasthis->ident);
|
||||
Expression *e = copy();
|
||||
((BinExp *)e)->e1 = e1;
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
}
|
||||
|
||||
// Try alias this on second operand
|
||||
if (ad2 && ad2->aliasthis)
|
||||
{
|
||||
/* Rewrite (e1 op e2) as:
|
||||
* (e1 op e2.aliasthis)
|
||||
*/
|
||||
Expression *e2 = new DotIdExp(loc, this->e2, ad2->aliasthis->ident);
|
||||
Expression *e = copy();
|
||||
((BinExp *)e)->e2 = e2;
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
/* Rewrite (e1 op e2) as:
|
||||
* (e1 op e2.aliasthis)
|
||||
*/
|
||||
Expression *e2 = new DotIdExp(loc, this->e2, ad2->aliasthis->ident);
|
||||
Expression *e = copy();
|
||||
((BinExp *)e)->e2 = e2;
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
@@ -484,9 +484,9 @@ Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *ea
|
||||
e = new DotIdExp(loc, ethis, id);
|
||||
|
||||
if (earg)
|
||||
e = new CallExp(loc, e, earg);
|
||||
e = new CallExp(loc, e, earg);
|
||||
else
|
||||
e = new CallExp(loc, e);
|
||||
e = new CallExp(loc, e);
|
||||
|
||||
e = e->semantic(sc);
|
||||
return e;
|
||||
@@ -504,18 +504,18 @@ Dsymbol *search_function(AggregateDeclaration *ad, Identifier *funcid)
|
||||
|
||||
s = ad->search(0, funcid, 0);
|
||||
if (s)
|
||||
{ Dsymbol *s2;
|
||||
{ Dsymbol *s2;
|
||||
|
||||
//printf("search_function: s = '%s'\n", s->kind());
|
||||
s2 = s->toAlias();
|
||||
//printf("search_function: s2 = '%s'\n", s2->kind());
|
||||
fd = s2->isFuncDeclaration();
|
||||
if (fd && fd->type->ty == Tfunction)
|
||||
return fd;
|
||||
//printf("search_function: s = '%s'\n", s->kind());
|
||||
s2 = s->toAlias();
|
||||
//printf("search_function: s2 = '%s'\n", s2->kind());
|
||||
fd = s2->isFuncDeclaration();
|
||||
if (fd && fd->type->ty == Tfunction)
|
||||
return fd;
|
||||
|
||||
td = s2->isTemplateDeclaration();
|
||||
if (td)
|
||||
return td;
|
||||
td = s2->isTemplateDeclaration();
|
||||
if (td)
|
||||
return td;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -530,16 +530,16 @@ Dsymbol *search_function(AggregateDeclaration *ad, Identifier *funcid)
|
||||
void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr, Module* from)
|
||||
{
|
||||
if (!arguments || !arguments->dim)
|
||||
return;
|
||||
return;
|
||||
|
||||
/* Return if no arguments need types.
|
||||
*/
|
||||
for (size_t u = 0; 1; u++)
|
||||
{ if (u == arguments->dim)
|
||||
return;
|
||||
Parameter *arg = (Parameter *)arguments->data[u];
|
||||
if (!arg->type)
|
||||
break;
|
||||
{ if (u == arguments->dim)
|
||||
return;
|
||||
Parameter *arg = (Parameter *)arguments->data[u];
|
||||
if (!arg->type)
|
||||
break;
|
||||
}
|
||||
|
||||
AggregateDeclaration *ad;
|
||||
@@ -547,97 +547,97 @@ void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr, Mo
|
||||
Parameter *arg = (Parameter *)arguments->data[0];
|
||||
Type *taggr = aggr->type;
|
||||
if (!taggr)
|
||||
return;
|
||||
return;
|
||||
Type *tab = taggr->toBasetype();
|
||||
switch (tab->ty)
|
||||
{
|
||||
case Tarray:
|
||||
case Tsarray:
|
||||
case Ttuple:
|
||||
if (arguments->dim == 2)
|
||||
{
|
||||
if (!arg->type)
|
||||
arg->type = Type::tsize_t; // key type
|
||||
arg = (Parameter *)arguments->data[1];
|
||||
}
|
||||
if (!arg->type && tab->ty != Ttuple)
|
||||
arg->type = tab->nextOf(); // value type
|
||||
break;
|
||||
case Tarray:
|
||||
case Tsarray:
|
||||
case Ttuple:
|
||||
if (arguments->dim == 2)
|
||||
{
|
||||
if (!arg->type)
|
||||
arg->type = Type::tsize_t; // key type
|
||||
arg = (Parameter *)arguments->data[1];
|
||||
}
|
||||
if (!arg->type && tab->ty != Ttuple)
|
||||
arg->type = tab->nextOf(); // value type
|
||||
break;
|
||||
|
||||
case Taarray:
|
||||
{ TypeAArray *taa = (TypeAArray *)tab;
|
||||
case Taarray:
|
||||
{ TypeAArray *taa = (TypeAArray *)tab;
|
||||
|
||||
if (arguments->dim == 2)
|
||||
{
|
||||
if (!arg->type)
|
||||
arg->type = taa->index; // key type
|
||||
arg = (Parameter *)arguments->data[1];
|
||||
}
|
||||
if (!arg->type)
|
||||
arg->type = taa->next; // value type
|
||||
break;
|
||||
}
|
||||
if (arguments->dim == 2)
|
||||
{
|
||||
if (!arg->type)
|
||||
arg->type = taa->index; // key type
|
||||
arg = (Parameter *)arguments->data[1];
|
||||
}
|
||||
if (!arg->type)
|
||||
arg->type = taa->next; // value type
|
||||
break;
|
||||
}
|
||||
|
||||
case Tclass:
|
||||
ad = ((TypeClass *)tab)->sym;
|
||||
goto Laggr;
|
||||
case Tclass:
|
||||
ad = ((TypeClass *)tab)->sym;
|
||||
goto Laggr;
|
||||
|
||||
case Tstruct:
|
||||
ad = ((TypeStruct *)tab)->sym;
|
||||
goto Laggr;
|
||||
case Tstruct:
|
||||
ad = ((TypeStruct *)tab)->sym;
|
||||
goto Laggr;
|
||||
|
||||
Laggr:
|
||||
Laggr:
|
||||
#if 0
|
||||
if (arguments->dim == 1)
|
||||
{
|
||||
if (!arg->type)
|
||||
{
|
||||
/* Look for an opNext() overload
|
||||
*/
|
||||
Dsymbol *s = search_function(ad, Id::next);
|
||||
fd = s ? s->isFuncDeclaration() : NULL;
|
||||
if (!fd)
|
||||
goto Lapply;
|
||||
arg->type = fd->type->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (arguments->dim == 1)
|
||||
{
|
||||
if (!arg->type)
|
||||
{
|
||||
/* Look for an opNext() overload
|
||||
*/
|
||||
Dsymbol *s = search_function(ad, Id::next);
|
||||
fd = s ? s->isFuncDeclaration() : NULL;
|
||||
if (!fd)
|
||||
goto Lapply;
|
||||
arg->type = fd->type->next;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
Lapply:
|
||||
{ /* Look for an
|
||||
* int opApply(int delegate(ref Type [, ...]) dg);
|
||||
* overload
|
||||
*/
|
||||
Dsymbol *s = search_function(ad,
|
||||
(op == TOKforeach_reverse) ? Id::applyReverse
|
||||
: Id::apply);
|
||||
if (s)
|
||||
{
|
||||
FuncDeclaration *fd = s->isFuncDeclaration();
|
||||
if (fd)
|
||||
inferApplyArgTypesX(from, fd, arguments);
|
||||
}
|
||||
break;
|
||||
}
|
||||
Lapply:
|
||||
{ /* Look for an
|
||||
* int opApply(int delegate(ref Type [, ...]) dg);
|
||||
* overload
|
||||
*/
|
||||
Dsymbol *s = search_function(ad,
|
||||
(op == TOKforeach_reverse) ? Id::applyReverse
|
||||
: Id::apply);
|
||||
if (s)
|
||||
{
|
||||
FuncDeclaration *fd = s->isFuncDeclaration();
|
||||
if (fd)
|
||||
inferApplyArgTypesX(from, fd, arguments);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case Tdelegate:
|
||||
{
|
||||
if (0 && aggr->op == TOKdelegate)
|
||||
{ DelegateExp *de = (DelegateExp *)aggr;
|
||||
case Tdelegate:
|
||||
{
|
||||
if (0 && aggr->op == TOKdelegate)
|
||||
{ DelegateExp *de = (DelegateExp *)aggr;
|
||||
|
||||
FuncDeclaration *fd = de->func->isFuncDeclaration();
|
||||
if (fd)
|
||||
inferApplyArgTypesX(from, fd, arguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
inferApplyArgTypesY((TypeFunction *)tab->nextOf(), arguments);
|
||||
}
|
||||
break;
|
||||
}
|
||||
FuncDeclaration *fd = de->func->isFuncDeclaration();
|
||||
if (fd)
|
||||
inferApplyArgTypesX(from, fd, arguments);
|
||||
}
|
||||
else
|
||||
{
|
||||
inferApplyArgTypesY((TypeFunction *)tab->nextOf(), arguments);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break; // ignore error, caught later
|
||||
default:
|
||||
break; // ignore error, caught later
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,9 +651,9 @@ int fp3(void *param, FuncDeclaration *f)
|
||||
Parameters *arguments = (Parameters *)param;
|
||||
TypeFunction *tf = (TypeFunction *)f->type;
|
||||
if (inferApplyArgTypesY(tf, arguments) == 1)
|
||||
return 0;
|
||||
return 0;
|
||||
if (arguments->dim == 0)
|
||||
return 1;
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -670,39 +670,39 @@ static void inferApplyArgTypesX(FuncDeclaration *fstart, Parameters *arguments)
|
||||
|
||||
for (d = fstart; d; d = next)
|
||||
{
|
||||
FuncDeclaration *f;
|
||||
FuncAliasDeclaration *fa;
|
||||
AliasDeclaration *a;
|
||||
FuncDeclaration *f;
|
||||
FuncAliasDeclaration *fa;
|
||||
AliasDeclaration *a;
|
||||
|
||||
fa = d->isFuncAliasDeclaration();
|
||||
if (fa)
|
||||
{
|
||||
inferApplyArgTypesX(fa->funcalias, arguments);
|
||||
next = fa->overnext;
|
||||
}
|
||||
else if ((f = d->isFuncDeclaration()) != NULL)
|
||||
{
|
||||
next = f->overnext;
|
||||
fa = d->isFuncAliasDeclaration();
|
||||
if (fa)
|
||||
{
|
||||
inferApplyArgTypesX(fa->funcalias, arguments);
|
||||
next = fa->overnext;
|
||||
}
|
||||
else if ((f = d->isFuncDeclaration()) != NULL)
|
||||
{
|
||||
next = f->overnext;
|
||||
|
||||
TypeFunction *tf = (TypeFunction *)f->type;
|
||||
if (inferApplyArgTypesY(tf, arguments) == 1)
|
||||
continue;
|
||||
if (arguments->dim == 0)
|
||||
return;
|
||||
}
|
||||
else if ((a = d->isAliasDeclaration()) != NULL)
|
||||
{
|
||||
Dsymbol *s = a->toAlias();
|
||||
next = s->isDeclaration();
|
||||
if (next == a)
|
||||
break;
|
||||
if (next == fstart)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{ d->error("is aliased to a function");
|
||||
break;
|
||||
}
|
||||
TypeFunction *tf = (TypeFunction *)f->type;
|
||||
if (inferApplyArgTypesY(tf, arguments) == 1)
|
||||
continue;
|
||||
if (arguments->dim == 0)
|
||||
return;
|
||||
}
|
||||
else if ((a = d->isAliasDeclaration()) != NULL)
|
||||
{
|
||||
Dsymbol *s = a->toAlias();
|
||||
next = s->isDeclaration();
|
||||
if (next == a)
|
||||
break;
|
||||
if (next == fstart)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{ d->error("is aliased to a function");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -710,8 +710,8 @@ static void inferApplyArgTypesX(FuncDeclaration *fstart, Parameters *arguments)
|
||||
/******************************
|
||||
* Infer arguments from type of function.
|
||||
* Returns:
|
||||
* 0 match for this function
|
||||
* 1 no match for this function
|
||||
* 0 match for this function
|
||||
* 1 no match for this function
|
||||
*/
|
||||
|
||||
static int inferApplyArgTypesY(TypeFunction *tf, Parameters *arguments)
|
||||
@@ -719,10 +719,10 @@ static int inferApplyArgTypesY(TypeFunction *tf, Parameters *arguments)
|
||||
Parameter *p;
|
||||
|
||||
if (Parameter::dim(tf->parameters) != 1)
|
||||
goto Lnomatch;
|
||||
goto Lnomatch;
|
||||
p = Parameter::getNth(tf->parameters, 0);
|
||||
if (p->type->ty != Tdelegate)
|
||||
goto Lnomatch;
|
||||
goto Lnomatch;
|
||||
tf = (TypeFunction *)p->type->nextOf();
|
||||
assert(tf->ty == Tfunction);
|
||||
|
||||
@@ -731,26 +731,26 @@ static int inferApplyArgTypesY(TypeFunction *tf, Parameters *arguments)
|
||||
*/
|
||||
nparams = Parameter::dim(tf->parameters);
|
||||
if (nparams == 0 || tf->varargs)
|
||||
goto Lnomatch; // not enough parameters
|
||||
goto Lnomatch; // not enough parameters
|
||||
if (arguments->dim != nparams)
|
||||
goto Lnomatch; // not enough parameters
|
||||
goto Lnomatch; // not enough parameters
|
||||
|
||||
for (size_t u = 0; u < nparams; u++)
|
||||
{
|
||||
Parameter *arg = (Parameter *)arguments->data[u];
|
||||
Parameter *param = Parameter::getNth(tf->parameters, u);
|
||||
if (arg->type)
|
||||
{ if (!arg->type->equals(param->type))
|
||||
{
|
||||
/* Cannot resolve argument types. Indicate an
|
||||
* error by setting the number of arguments to 0.
|
||||
*/
|
||||
arguments->dim = 0;
|
||||
goto Lmatch;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
arg->type = param->type;
|
||||
Parameter *arg = (Parameter *)arguments->data[u];
|
||||
Parameter *param = Parameter::getNth(tf->parameters, u);
|
||||
if (arg->type)
|
||||
{ if (!arg->type->equals(param->type))
|
||||
{
|
||||
/* Cannot resolve argument types. Indicate an
|
||||
* error by setting the number of arguments to 0.
|
||||
*/
|
||||
arguments->dim = 0;
|
||||
goto Lmatch;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
arg->type = param->type;
|
||||
}
|
||||
Lmatch:
|
||||
return 0;
|
||||
@@ -769,18 +769,18 @@ static void templateResolve(Match *m, TemplateDeclaration *td, Scope *sc, Loc lo
|
||||
assert(td);
|
||||
fd = td->deduceFunctionTemplate(sc, loc, targsi, NULL, arguments);
|
||||
if (!fd)
|
||||
return;
|
||||
return;
|
||||
m->anyf = fd;
|
||||
if (m->last >= MATCHexact)
|
||||
{
|
||||
m->nextf = fd;
|
||||
m->count++;
|
||||
m->nextf = fd;
|
||||
m->count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
m->last = MATCHexact;
|
||||
m->lastf = fd;
|
||||
m->count = 1;
|
||||
m->last = MATCHexact;
|
||||
m->lastf = fd;
|
||||
m->count = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
536
dmd/optimize.c
536
dmd/optimize.c
@@ -32,7 +32,7 @@
|
||||
extern "C" bool real_isnan (const real_t *);
|
||||
#endif
|
||||
|
||||
static real_t zero; // work around DMC bug for now
|
||||
static real_t zero; // work around DMC bug for now
|
||||
|
||||
|
||||
/*************************************
|
||||
@@ -44,13 +44,13 @@ Expression *fromConstInitializer(Expression *e1)
|
||||
{
|
||||
//printf("fromConstInitializer(%s)\n", e1->toChars());
|
||||
if (e1->op == TOKvar)
|
||||
{ VarExp *ve = (VarExp *)e1;
|
||||
VarDeclaration *v = ve->var->isVarDeclaration();
|
||||
if (v && v->isConst() && v->init)
|
||||
{ Expression *ei = v->init->toExpression();
|
||||
if (ei && ei->type)
|
||||
e1 = ei;
|
||||
}
|
||||
{ VarExp *ve = (VarExp *)e1;
|
||||
VarDeclaration *v = ve->var->isVarDeclaration();
|
||||
if (v && v->isConst() && v->init)
|
||||
{ Expression *ei = v->init->toExpression();
|
||||
if (ei && ei->type)
|
||||
e1 = ei;
|
||||
}
|
||||
}
|
||||
return e1;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ Expression *VarExp::optimize(int result)
|
||||
{
|
||||
if (result & WANTinterpret)
|
||||
{
|
||||
return fromConstInitializer(this);
|
||||
return fromConstInitializer(this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -76,8 +76,8 @@ Expression *TupleExp::optimize(int result)
|
||||
for (size_t i = 0; i < exps->dim; i++)
|
||||
{ Expression *e = (Expression *)exps->data[i];
|
||||
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
exps->data[i] = (void *)e;
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
exps->data[i] = (void *)e;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -86,12 +86,12 @@ Expression *ArrayLiteralExp::optimize(int result)
|
||||
{
|
||||
if (elements)
|
||||
{
|
||||
for (size_t i = 0; i < elements->dim; i++)
|
||||
{ Expression *e = (Expression *)elements->data[i];
|
||||
for (size_t i = 0; i < elements->dim; i++)
|
||||
{ Expression *e = (Expression *)elements->data[i];
|
||||
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
elements->data[i] = (void *)e;
|
||||
}
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
elements->data[i] = (void *)e;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -102,12 +102,12 @@ Expression *AssocArrayLiteralExp::optimize(int result)
|
||||
for (size_t i = 0; i < keys->dim; i++)
|
||||
{ Expression *e = (Expression *)keys->data[i];
|
||||
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
keys->data[i] = (void *)e;
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
keys->data[i] = (void *)e;
|
||||
|
||||
e = (Expression *)values->data[i];
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
values->data[i] = (void *)e;
|
||||
e = (Expression *)values->data[i];
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
values->data[i] = (void *)e;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -116,13 +116,13 @@ Expression *StructLiteralExp::optimize(int result)
|
||||
{
|
||||
if (elements)
|
||||
{
|
||||
for (size_t i = 0; i < elements->dim; i++)
|
||||
{ Expression *e = (Expression *)elements->data[i];
|
||||
if (!e)
|
||||
continue;
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
elements->data[i] = (void *)e;
|
||||
}
|
||||
for (size_t i = 0; i < elements->dim; i++)
|
||||
{ Expression *e = (Expression *)elements->data[i];
|
||||
if (!e)
|
||||
continue;
|
||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||
elements->data[i] = (void *)e;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -144,10 +144,10 @@ Expression *NegExp::optimize(int result)
|
||||
e1 = e1->optimize(result);
|
||||
if (e1->isConst() == 1)
|
||||
{
|
||||
e = Neg(type, e1);
|
||||
e = Neg(type, e1);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -157,10 +157,10 @@ Expression *ComExp::optimize(int result)
|
||||
e1 = e1->optimize(result);
|
||||
if (e1->isConst() == 1)
|
||||
{
|
||||
e = Com(type, e1);
|
||||
e = Com(type, e1);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -170,10 +170,10 @@ Expression *NotExp::optimize(int result)
|
||||
e1 = e1->optimize(result);
|
||||
if (e1->isConst() == 1)
|
||||
{
|
||||
e = Not(type, e1);
|
||||
e = Not(type, e1);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -183,10 +183,10 @@ Expression *BoolExp::optimize(int result)
|
||||
e1 = e1->optimize(result);
|
||||
if (e1->isConst() == 1)
|
||||
{
|
||||
e = Bool(type, e1);
|
||||
e = Bool(type, e1);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -199,49 +199,49 @@ Expression *AddrExp::optimize(int result)
|
||||
e1 = e1->optimize(result & ~WANTinterpret);
|
||||
// Convert &*ex to ex
|
||||
if (e1->op == TOKstar)
|
||||
{ Expression *ex;
|
||||
{ Expression *ex;
|
||||
|
||||
ex = ((PtrExp *)e1)->e1;
|
||||
if (type->equals(ex->type))
|
||||
e = ex;
|
||||
else
|
||||
{
|
||||
e = ex->copy();
|
||||
e->type = type;
|
||||
}
|
||||
return e;
|
||||
ex = ((PtrExp *)e1)->e1;
|
||||
if (type->equals(ex->type))
|
||||
e = ex;
|
||||
else
|
||||
{
|
||||
e = ex->copy();
|
||||
e->type = type;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
#if !IN_LLVM
|
||||
if (e1->op == TOKvar)
|
||||
{ VarExp *ve = (VarExp *)e1;
|
||||
if (!ve->var->isOut() && !ve->var->isRef() &&
|
||||
!ve->var->isImportedSymbol())
|
||||
{
|
||||
e = new SymOffExp(loc, ve->var, 0);
|
||||
e->type = type;
|
||||
return e;
|
||||
}
|
||||
{ VarExp *ve = (VarExp *)e1;
|
||||
if (!ve->var->isOut() && !ve->var->isRef() &&
|
||||
!ve->var->isImportedSymbol())
|
||||
{
|
||||
e = new SymOffExp(loc, ve->var, 0);
|
||||
e->type = type;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
if (e1->op == TOKindex)
|
||||
{ // Convert &array[n] to &array+n
|
||||
IndexExp *ae = (IndexExp *)e1;
|
||||
{ // Convert &array[n] to &array+n
|
||||
IndexExp *ae = (IndexExp *)e1;
|
||||
|
||||
if (ae->e2->op == TOKint64 && ae->e1->op == TOKvar)
|
||||
{
|
||||
dinteger_t index = ae->e2->toInteger();
|
||||
VarExp *ve = (VarExp *)ae->e1;
|
||||
if (ve->type->ty == Tsarray && ve->type->next->ty != Tbit
|
||||
&& !ve->var->isImportedSymbol())
|
||||
{
|
||||
TypeSArray *ts = (TypeSArray *)ve->type;
|
||||
dinteger_t dim = ts->dim->toInteger();
|
||||
if (index < 0 || index >= dim)
|
||||
error("array index %jd is out of bounds [0..%jd]", index, dim);
|
||||
e = new SymOffExp(loc, ve->var, index * ts->next->size());
|
||||
e->type = type;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
if (ae->e2->op == TOKint64 && ae->e1->op == TOKvar)
|
||||
{
|
||||
dinteger_t index = ae->e2->toInteger();
|
||||
VarExp *ve = (VarExp *)ae->e1;
|
||||
if (ve->type->ty == Tsarray && ve->type->next->ty != Tbit
|
||||
&& !ve->var->isImportedSymbol())
|
||||
{
|
||||
TypeSArray *ts = (TypeSArray *)ve->type;
|
||||
dinteger_t dim = ts->dim->toInteger();
|
||||
if (index < 0 || index >= dim)
|
||||
error("array index %jd is out of bounds [0..%jd]", index, dim);
|
||||
e = new SymOffExp(loc, ve->var, index * ts->next->size());
|
||||
e->type = type;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return this;
|
||||
@@ -253,26 +253,26 @@ Expression *PtrExp::optimize(int result)
|
||||
e1 = e1->optimize(result);
|
||||
// Convert *&ex to ex
|
||||
if (e1->op == TOKaddress)
|
||||
{ Expression *e;
|
||||
Expression *ex;
|
||||
{ Expression *e;
|
||||
Expression *ex;
|
||||
|
||||
ex = ((AddrExp *)e1)->e1;
|
||||
if (type->equals(ex->type))
|
||||
e = ex;
|
||||
else
|
||||
{
|
||||
e = ex->copy();
|
||||
e->type = type;
|
||||
}
|
||||
return e;
|
||||
ex = ((AddrExp *)e1)->e1;
|
||||
if (type->equals(ex->type))
|
||||
e = ex;
|
||||
else
|
||||
{
|
||||
e = ex->copy();
|
||||
e->type = type;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
// Constant fold *(&structliteral + offset)
|
||||
if (e1->op == TOKadd)
|
||||
{
|
||||
Expression *e;
|
||||
e = Ptr(type, e1);
|
||||
if (e != EXP_CANT_INTERPRET)
|
||||
return e;
|
||||
Expression *e;
|
||||
e = Ptr(type, e1);
|
||||
if (e != EXP_CANT_INTERPRET)
|
||||
return e;
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -285,31 +285,31 @@ Expression *DotVarExp::optimize(int result)
|
||||
|
||||
#if DMDV2
|
||||
if (e1->op == TOKvar)
|
||||
{ VarExp *ve = (VarExp *)e1;
|
||||
VarDeclaration *v = ve->var->isVarDeclaration();
|
||||
Expression *e = expandVar(result, v);
|
||||
if (e && e->op == TOKstructliteral)
|
||||
{ StructLiteralExp *sle = (StructLiteralExp *)e;
|
||||
VarDeclaration *vf = var->isVarDeclaration();
|
||||
if (vf)
|
||||
{
|
||||
e = sle->getField(type, vf->offset);
|
||||
if (e && e != EXP_CANT_INTERPRET)
|
||||
return e;
|
||||
}
|
||||
}
|
||||
{ VarExp *ve = (VarExp *)e1;
|
||||
VarDeclaration *v = ve->var->isVarDeclaration();
|
||||
Expression *e = expandVar(result, v);
|
||||
if (e && e->op == TOKstructliteral)
|
||||
{ StructLiteralExp *sle = (StructLiteralExp *)e;
|
||||
VarDeclaration *vf = var->isVarDeclaration();
|
||||
if (vf)
|
||||
{
|
||||
e = sle->getField(type, vf->offset);
|
||||
if (e && e != EXP_CANT_INTERPRET)
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (e1->op == TOKstructliteral)
|
||||
{ StructLiteralExp *sle = (StructLiteralExp *)e1;
|
||||
VarDeclaration *vf = var->isVarDeclaration();
|
||||
if (vf)
|
||||
{
|
||||
Expression *e = sle->getField(type, vf->offset);
|
||||
if (e && e != EXP_CANT_INTERPRET)
|
||||
return e;
|
||||
}
|
||||
VarDeclaration *vf = var->isVarDeclaration();
|
||||
if (vf)
|
||||
{
|
||||
Expression *e = sle->getField(type, vf->offset);
|
||||
if (e && e != EXP_CANT_INTERPRET)
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
@@ -318,27 +318,27 @@ Expression *DotVarExp::optimize(int result)
|
||||
Expression *NewExp::optimize(int result)
|
||||
{
|
||||
if (thisexp)
|
||||
thisexp = thisexp->optimize(WANTvalue);
|
||||
thisexp = thisexp->optimize(WANTvalue);
|
||||
|
||||
// Optimize parameters
|
||||
if (newargs)
|
||||
{
|
||||
for (size_t i = 0; i < newargs->dim; i++)
|
||||
{ Expression *e = (Expression *)newargs->data[i];
|
||||
for (size_t i = 0; i < newargs->dim; i++)
|
||||
{ Expression *e = (Expression *)newargs->data[i];
|
||||
|
||||
e = e->optimize(WANTvalue);
|
||||
newargs->data[i] = (void *)e;
|
||||
}
|
||||
e = e->optimize(WANTvalue);
|
||||
newargs->data[i] = (void *)e;
|
||||
}
|
||||
}
|
||||
|
||||
if (arguments)
|
||||
{
|
||||
for (size_t i = 0; i < arguments->dim; i++)
|
||||
{ Expression *e = (Expression *)arguments->data[i];
|
||||
for (size_t i = 0; i < arguments->dim; i++)
|
||||
{ Expression *e = (Expression *)arguments->data[i];
|
||||
|
||||
e = e->optimize(WANTvalue);
|
||||
arguments->data[i] = (void *)e;
|
||||
}
|
||||
e = e->optimize(WANTvalue);
|
||||
arguments->data[i] = (void *)e;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -351,24 +351,24 @@ Expression *CallExp::optimize(int result)
|
||||
// Optimize parameters
|
||||
if (arguments)
|
||||
{
|
||||
for (size_t i = 0; i < arguments->dim; i++)
|
||||
{ Expression *e = (Expression *)arguments->data[i];
|
||||
for (size_t i = 0; i < arguments->dim; i++)
|
||||
{ Expression *e = (Expression *)arguments->data[i];
|
||||
|
||||
e = e->optimize(WANTvalue);
|
||||
arguments->data[i] = (void *)e;
|
||||
}
|
||||
e = e->optimize(WANTvalue);
|
||||
arguments->data[i] = (void *)e;
|
||||
}
|
||||
}
|
||||
|
||||
e1 = e1->optimize(result);
|
||||
if (result & WANTinterpret)
|
||||
{
|
||||
Expression *eresult = interpret(NULL);
|
||||
if (eresult == EXP_CANT_INTERPRET)
|
||||
return e;
|
||||
if (eresult && eresult != EXP_VOID_INTERPRET)
|
||||
e = eresult;
|
||||
else
|
||||
error("cannot evaluate %s at compile time", toChars());
|
||||
if (eresult == EXP_CANT_INTERPRET)
|
||||
return e;
|
||||
if (eresult && eresult != EXP_VOID_INTERPRET)
|
||||
e = eresult;
|
||||
else
|
||||
error("cannot evaluate %s at compile time", toChars());
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -386,67 +386,67 @@ Expression *CastExp::optimize(int result)
|
||||
|
||||
e1 = e1->optimize(result);
|
||||
if (result & WANTinterpret)
|
||||
e1 = fromConstInitializer(e1);
|
||||
e1 = fromConstInitializer(e1);
|
||||
|
||||
if ((e1->op == TOKstring || e1->op == TOKarrayliteral) &&
|
||||
(type->ty == Tpointer || type->ty == Tarray) &&
|
||||
type->next->equals(e1->type->next)
|
||||
(type->ty == Tpointer || type->ty == Tarray) &&
|
||||
type->next->equals(e1->type->next)
|
||||
)
|
||||
{
|
||||
// make a copy before adjusting type to avoid
|
||||
// messing up the type of an existing initializer
|
||||
e1 = e1->syntaxCopy();
|
||||
e1->type = type;
|
||||
return e1;
|
||||
// make a copy before adjusting type to avoid
|
||||
// messing up the type of an existing initializer
|
||||
e1 = e1->syntaxCopy();
|
||||
e1->type = type;
|
||||
return e1;
|
||||
}
|
||||
/* The first test here is to prevent infinite loops
|
||||
*/
|
||||
if (op1 != TOKarrayliteral && e1->op == TOKarrayliteral)
|
||||
return e1->castTo(NULL, to);
|
||||
return e1->castTo(NULL, to);
|
||||
if (e1->op == TOKnull &&
|
||||
(type->ty == Tpointer || type->ty == Tclass))
|
||||
(type->ty == Tpointer || type->ty == Tclass))
|
||||
{
|
||||
e1->type = type;
|
||||
return e1;
|
||||
e1->type = type;
|
||||
return e1;
|
||||
}
|
||||
|
||||
if (result & WANTflags && type->ty == Tclass && e1->type->ty == Tclass)
|
||||
{
|
||||
// See if we can remove an unnecessary cast
|
||||
ClassDeclaration *cdfrom;
|
||||
ClassDeclaration *cdto;
|
||||
int offset;
|
||||
// See if we can remove an unnecessary cast
|
||||
ClassDeclaration *cdfrom;
|
||||
ClassDeclaration *cdto;
|
||||
int offset;
|
||||
|
||||
cdfrom = e1->type->isClassHandle();
|
||||
cdto = type->isClassHandle();
|
||||
if (cdto->isBaseOf(cdfrom, &offset) && offset == 0)
|
||||
{
|
||||
e1->type = type;
|
||||
return e1;
|
||||
}
|
||||
cdfrom = e1->type->isClassHandle();
|
||||
cdto = type->isClassHandle();
|
||||
if (cdto->isBaseOf(cdfrom, &offset) && offset == 0)
|
||||
{
|
||||
e1->type = type;
|
||||
return e1;
|
||||
}
|
||||
}
|
||||
|
||||
Expression *e;
|
||||
|
||||
if (e1->isConst())
|
||||
{
|
||||
if (e1->op == TOKsymoff)
|
||||
{
|
||||
if (type->size() == e1->type->size() &&
|
||||
type->toBasetype()->ty != Tsarray)
|
||||
{
|
||||
e1->type = type;
|
||||
return e1;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
if (to->toBasetype()->ty == Tvoid)
|
||||
e = this;
|
||||
else
|
||||
e = Cast(type, to, e1);
|
||||
if (e1->op == TOKsymoff)
|
||||
{
|
||||
if (type->size() == e1->type->size() &&
|
||||
type->toBasetype()->ty != Tsarray)
|
||||
{
|
||||
e1->type = type;
|
||||
return e1;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
if (to->toBasetype()->ty == Tvoid)
|
||||
e = this;
|
||||
else
|
||||
e = Cast(type, to, e1);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -457,15 +457,15 @@ Expression *BinExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
if (op == TOKshlass || op == TOKshrass || op == TOKushrass)
|
||||
{
|
||||
if (e2->isConst() == 1)
|
||||
{
|
||||
dinteger_t i2 = e2->toInteger();
|
||||
d_uns64 sz = e1->type->size() * 8;
|
||||
if (i2 < 0 || i2 > sz)
|
||||
{ error("shift assign by %jd is outside the range 0..%zu", i2, sz);
|
||||
e2 = new IntegerExp(0);
|
||||
}
|
||||
}
|
||||
if (e2->isConst() == 1)
|
||||
{
|
||||
dinteger_t i2 = e2->toInteger();
|
||||
d_uns64 sz = e1->type->size() * 8;
|
||||
if (i2 < 0 || i2 > sz)
|
||||
{ error("shift assign by %jd is outside the range 0..%zu", i2, sz);
|
||||
e2 = new IntegerExp(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -478,12 +478,12 @@ Expression *AddExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() && e2->isConst())
|
||||
{
|
||||
if (e1->op == TOKsymoff && e2->op == TOKsymoff)
|
||||
return this;
|
||||
e = Add(type, e1, e2);
|
||||
if (e1->op == TOKsymoff && e2->op == TOKsymoff)
|
||||
return this;
|
||||
e = Add(type, e1, e2);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -494,12 +494,12 @@ Expression *MinExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() && e2->isConst())
|
||||
{
|
||||
if (e2->op == TOKsymoff)
|
||||
return this;
|
||||
e = Min(type, e1, e2);
|
||||
if (e2->op == TOKsymoff)
|
||||
return this;
|
||||
e = Min(type, e1, e2);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -511,10 +511,10 @@ Expression *MulExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() == 1 && e2->isConst() == 1)
|
||||
{
|
||||
e = Mul(type, e1, e2);
|
||||
e = Mul(type, e1, e2);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -526,10 +526,10 @@ Expression *DivExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() == 1 && e2->isConst() == 1)
|
||||
{
|
||||
e = Div(type, e1, e2);
|
||||
e = Div(type, e1, e2);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -540,10 +540,10 @@ Expression *ModExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() == 1 && e2->isConst() == 1)
|
||||
{
|
||||
e = Mod(type, e1, e2);
|
||||
e = Mod(type, e1, e2);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -554,14 +554,14 @@ Expression *shift_optimize(int result, BinExp *e, Expression *(*shift)(Type *, E
|
||||
e->e2 = e->e2->optimize(result);
|
||||
if (e->e2->isConst() == 1)
|
||||
{
|
||||
dinteger_t i2 = e->e2->toInteger();
|
||||
d_uns64 sz = e->e1->type->size() * 8;
|
||||
if (i2 < 0 || i2 > sz)
|
||||
{ e->error("shift by %jd is outside the range 0..%zu", i2, sz);
|
||||
e->e2 = new IntegerExp(0);
|
||||
}
|
||||
if (e->e1->isConst() == 1)
|
||||
ex = (*shift)(e->type, e->e1, e->e2);
|
||||
dinteger_t i2 = e->e2->toInteger();
|
||||
d_uns64 sz = e->e1->type->size() * 8;
|
||||
if (i2 < 0 || i2 > sz)
|
||||
{ e->error("shift by %jd is outside the range 0..%zu", i2, sz);
|
||||
e->e2 = new IntegerExp(0);
|
||||
}
|
||||
if (e->e1->isConst() == 1)
|
||||
ex = (*shift)(e->type, e->e1, e->e2);
|
||||
}
|
||||
return ex;
|
||||
}
|
||||
@@ -590,9 +590,9 @@ Expression *AndExp::optimize(int result)
|
||||
e1 = e1->optimize(result);
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() == 1 && e2->isConst() == 1)
|
||||
e = And(type, e1, e2);
|
||||
e = And(type, e1, e2);
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -602,9 +602,9 @@ Expression *OrExp::optimize(int result)
|
||||
e1 = e1->optimize(result);
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() == 1 && e2->isConst() == 1)
|
||||
e = Or(type, e1, e2);
|
||||
e = Or(type, e1, e2);
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -614,9 +614,9 @@ Expression *XorExp::optimize(int result)
|
||||
e1 = e1->optimize(result);
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() == 1 && e2->isConst() == 1)
|
||||
e = Xor(type, e1, e2);
|
||||
e = Xor(type, e1, e2);
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -633,8 +633,8 @@ Expression *CommaExp::optimize(int result)
|
||||
if (result & WANTinterpret)
|
||||
{ // Interpreting comma needs special treatment, because it may
|
||||
// contain compiler-generated declarations.
|
||||
e = interpret(NULL);
|
||||
return (e == EXP_CANT_INTERPRET) ? this : e;
|
||||
e = interpret(NULL);
|
||||
return (e == EXP_CANT_INTERPRET) ? this : e;
|
||||
}
|
||||
// Don't constant fold if it is a compiler-generated temporary.
|
||||
if (e1->op == TOKdeclaration)
|
||||
@@ -644,12 +644,12 @@ Expression *CommaExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
if (!e1 || e1->op == TOKint64 || e1->op == TOKfloat64 || !e1->checkSideEffect(2))
|
||||
{
|
||||
e = e2;
|
||||
if (e)
|
||||
e->type = type;
|
||||
e = e2;
|
||||
if (e)
|
||||
e->type = type;
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
//printf("-CommaExp::optimize(result = %d) %s\n", result, e->toChars());
|
||||
return e;
|
||||
}
|
||||
@@ -662,7 +662,7 @@ Expression *ArrayLengthExp::optimize(int result)
|
||||
e = this;
|
||||
if (e1->op == TOKstring || e1->op == TOKarrayliteral || e1->op == TOKassocarrayliteral)
|
||||
{
|
||||
e = ArrayLength(type, e1);
|
||||
e = ArrayLength(type, e1);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -680,7 +680,7 @@ Expression *EqualExp::optimize(int result)
|
||||
|
||||
e = Equal(op, type, e1, e2);
|
||||
if (e == EXP_CANT_INTERPRET)
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -692,11 +692,11 @@ Expression *IdentityExp::optimize(int result)
|
||||
Expression *e = this;
|
||||
|
||||
if ((this->e1->isConst() && this->e2->isConst()) ||
|
||||
(this->e1->op == TOKnull && this->e2->op == TOKnull))
|
||||
(this->e1->op == TOKnull && this->e2->op == TOKnull))
|
||||
{
|
||||
e = Identity(op, type, this->e1, this->e2);
|
||||
if (e == EXP_CANT_INTERPRET)
|
||||
e = this;
|
||||
e = Identity(op, type, this->e1, this->e2);
|
||||
if (e == EXP_CANT_INTERPRET)
|
||||
e = this;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -707,11 +707,11 @@ Expression *IndexExp::optimize(int result)
|
||||
//printf("IndexExp::optimize(result = %d) %s\n", result, toChars());
|
||||
Expression *e1 = this->e1->optimize(WANTvalue | (result & WANTinterpret));
|
||||
if (result & WANTinterpret)
|
||||
e1 = fromConstInitializer(e1);
|
||||
e1 = fromConstInitializer(e1);
|
||||
e2 = e2->optimize(WANTvalue | (result & WANTinterpret));
|
||||
e = Index(type, e1, e2);
|
||||
if (e == EXP_CANT_INTERPRET)
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -722,21 +722,21 @@ Expression *SliceExp::optimize(int result)
|
||||
e = this;
|
||||
e1 = e1->optimize(WANTvalue | (result & WANTinterpret));
|
||||
if (!lwr)
|
||||
{ if (e1->op == TOKstring)
|
||||
{ // Convert slice of string literal into dynamic array
|
||||
Type *t = e1->type->toBasetype();
|
||||
if (t->nextOf())
|
||||
e = e1->castTo(NULL, t->nextOf()->arrayOf());
|
||||
}
|
||||
return e;
|
||||
{ if (e1->op == TOKstring)
|
||||
{ // Convert slice of string literal into dynamic array
|
||||
Type *t = e1->type->toBasetype();
|
||||
if (t->nextOf())
|
||||
e = e1->castTo(NULL, t->nextOf()->arrayOf());
|
||||
}
|
||||
return e;
|
||||
}
|
||||
if (result & WANTinterpret)
|
||||
e1 = fromConstInitializer(e1);
|
||||
e1 = fromConstInitializer(e1);
|
||||
lwr = lwr->optimize(WANTvalue | (result & WANTinterpret));
|
||||
upr = upr->optimize(WANTvalue | (result & WANTinterpret));
|
||||
e = Slice(type, e1, lwr, upr);
|
||||
if (e == EXP_CANT_INTERPRET)
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -748,26 +748,26 @@ Expression *AndAndExp::optimize(int result)
|
||||
e = this;
|
||||
if (e1->isBool(FALSE))
|
||||
{
|
||||
e = new CommaExp(loc, e1, new IntegerExp(loc, 0, type));
|
||||
e->type = type;
|
||||
e = e->optimize(result);
|
||||
e = new CommaExp(loc, e1, new IntegerExp(loc, 0, type));
|
||||
e->type = type;
|
||||
e = e->optimize(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
e2 = e2->optimize(WANTflags | (result & WANTinterpret));
|
||||
if (result && e2->type->toBasetype()->ty == Tvoid && !global.errors)
|
||||
error("void has no value");
|
||||
if (e1->isConst())
|
||||
{
|
||||
if (e2->isConst())
|
||||
{ int n1 = e1->isBool(1);
|
||||
int n2 = e2->isBool(1);
|
||||
e2 = e2->optimize(WANTflags | (result & WANTinterpret));
|
||||
if (result && e2->type->toBasetype()->ty == Tvoid && !global.errors)
|
||||
error("void has no value");
|
||||
if (e1->isConst())
|
||||
{
|
||||
if (e2->isConst())
|
||||
{ int n1 = e1->isBool(1);
|
||||
int n2 = e2->isBool(1);
|
||||
|
||||
e = new IntegerExp(loc, n1 && n2, type);
|
||||
}
|
||||
else if (e1->isBool(TRUE))
|
||||
e = new BoolExp(loc, e2, type);
|
||||
}
|
||||
e = new IntegerExp(loc, n1 && n2, type);
|
||||
}
|
||||
else if (e1->isBool(TRUE))
|
||||
e = new BoolExp(loc, e2, type);
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -778,27 +778,27 @@ Expression *OrOrExp::optimize(int result)
|
||||
e1 = e1->optimize(WANTflags | (result & WANTinterpret));
|
||||
e = this;
|
||||
if (e1->isBool(TRUE))
|
||||
{ // Replace with (e1, 1)
|
||||
e = new CommaExp(loc, e1, new IntegerExp(loc, 1, type));
|
||||
e->type = type;
|
||||
e = e->optimize(result);
|
||||
{ // Replace with (e1, 1)
|
||||
e = new CommaExp(loc, e1, new IntegerExp(loc, 1, type));
|
||||
e->type = type;
|
||||
e = e->optimize(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
e2 = e2->optimize(WANTflags | (result & WANTinterpret));
|
||||
if (result && e2->type->toBasetype()->ty == Tvoid && !global.errors)
|
||||
error("void has no value");
|
||||
if (e1->isConst())
|
||||
{
|
||||
if (e2->isConst())
|
||||
{ int n1 = e1->isBool(1);
|
||||
int n2 = e2->isBool(1);
|
||||
e2 = e2->optimize(WANTflags | (result & WANTinterpret));
|
||||
if (result && e2->type->toBasetype()->ty == Tvoid && !global.errors)
|
||||
error("void has no value");
|
||||
if (e1->isConst())
|
||||
{
|
||||
if (e2->isConst())
|
||||
{ int n1 = e1->isBool(1);
|
||||
int n2 = e2->isBool(1);
|
||||
|
||||
e = new IntegerExp(loc, n1 || n2, type);
|
||||
}
|
||||
else if (e1->isBool(FALSE))
|
||||
e = new BoolExp(loc, e2, type);
|
||||
}
|
||||
e = new IntegerExp(loc, n1 || n2, type);
|
||||
}
|
||||
else if (e1->isBool(FALSE))
|
||||
e = new BoolExp(loc, e2, type);
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
@@ -811,10 +811,10 @@ Expression *CmpExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
if (e1->isConst() == 1 && e2->isConst() == 1)
|
||||
{
|
||||
e = Cmp(op, type, this->e1, this->e2);
|
||||
e = Cmp(op, type, this->e1, this->e2);
|
||||
}
|
||||
else
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -826,7 +826,7 @@ Expression *CatExp::optimize(int result)
|
||||
e2 = e2->optimize(result);
|
||||
e = Cat(type, e1, e2);
|
||||
if (e == EXP_CANT_INTERPRET)
|
||||
e = this;
|
||||
e = this;
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -836,13 +836,13 @@ Expression *CondExp::optimize(int result)
|
||||
|
||||
econd = econd->optimize(WANTflags | (result & WANTinterpret));
|
||||
if (econd->isBool(TRUE))
|
||||
e = e1->optimize(result);
|
||||
e = e1->optimize(result);
|
||||
else if (econd->isBool(FALSE))
|
||||
e = e2->optimize(result);
|
||||
e = e2->optimize(result);
|
||||
else
|
||||
{ e1 = e1->optimize(result);
|
||||
e2 = e2->optimize(result);
|
||||
e = this;
|
||||
{ e1 = e1->optimize(result);
|
||||
e2 = e2->optimize(result);
|
||||
e = this;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
7208
dmd/parse.c
7208
dmd/parse.c
File diff suppressed because it is too large
Load Diff
12
dmd/parse.h
12
dmd/parse.h
@@ -50,10 +50,10 @@ struct StaticAssert;
|
||||
|
||||
enum ParseStatementFlags
|
||||
{
|
||||
PSsemi = 1, // empty ';' statements are allowed
|
||||
PSscope = 2, // start a new scope
|
||||
PScurly = 4, // { } statement is required
|
||||
PScurlyscope = 8, // { } starts a new scope
|
||||
PSsemi = 1, // empty ';' statements are allowed
|
||||
PSscope = 2, // start a new scope
|
||||
PScurly = 4, // { } statement is required
|
||||
PScurlyscope = 8, // { } starts a new scope
|
||||
};
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ struct Parser : Lexer
|
||||
{
|
||||
ModuleDeclaration *md;
|
||||
enum LINK linkage;
|
||||
Loc endloc; // set to location of last right curly
|
||||
int inBrackets; // inside [] of array index or slice
|
||||
Loc endloc; // set to location of last right curly
|
||||
int inBrackets; // inside [] of array index or slice
|
||||
|
||||
Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#if (defined (__SVR4) && defined (__sun))
|
||||
#if (defined (__SVR4) && defined (__sun))
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
||||
@@ -63,7 +63,7 @@ void Array::mark()
|
||||
|
||||
mem.mark(data);
|
||||
for (u = 0; u < dim; u++)
|
||||
mem.mark(data[u]); // BUG: what if arrays of Object's?
|
||||
mem.mark(data[u]); // BUG: what if arrays of Object's?
|
||||
}
|
||||
|
||||
void Array::reserve(unsigned nentries)
|
||||
@@ -71,8 +71,8 @@ void Array::reserve(unsigned nentries)
|
||||
//printf("Array::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes);
|
||||
if (allocdim - dim < nentries)
|
||||
{
|
||||
allocdim = dim + nentries;
|
||||
data = (void **)mem.realloc(data, allocdim * sizeof(*data));
|
||||
allocdim = dim + nentries;
|
||||
data = (void **)mem.realloc(data, allocdim * sizeof(*data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ void Array::setDim(unsigned newdim)
|
||||
{
|
||||
if (dim < newdim)
|
||||
{
|
||||
reserve(newdim - dim);
|
||||
reserve(newdim - dim);
|
||||
}
|
||||
dim = newdim;
|
||||
}
|
||||
@@ -88,8 +88,8 @@ void Array::setDim(unsigned newdim)
|
||||
void Array::fixDim()
|
||||
{
|
||||
if (dim != allocdim)
|
||||
{ data = (void **)mem.realloc(data, dim * sizeof(*data));
|
||||
allocdim = dim;
|
||||
{ data = (void **)mem.realloc(data, dim * sizeof(*data));
|
||||
allocdim = dim;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,14 +124,14 @@ void Array::insert(unsigned index, void *ptr)
|
||||
void Array::insert(unsigned index, Array *a)
|
||||
{
|
||||
if (a)
|
||||
{ unsigned d;
|
||||
{ unsigned d;
|
||||
|
||||
d = a->dim;
|
||||
reserve(d);
|
||||
if (dim != index)
|
||||
memmove(data + index + d, data + index, (dim - index) * sizeof(*data));
|
||||
memcpy(data + index, a->data, d * sizeof(*data));
|
||||
dim += d;
|
||||
d = a->dim;
|
||||
reserve(d);
|
||||
if (dim != index)
|
||||
memmove(data + index + d, data + index, (dim - index) * sizeof(*data));
|
||||
memcpy(data + index, a->data, d * sizeof(*data));
|
||||
dim += d;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,8 +163,8 @@ char *Array::toChars()
|
||||
len = 2;
|
||||
for (u = 0; u < dim; u++)
|
||||
{
|
||||
buf[u] = ((Object *)data[u])->toChars();
|
||||
len += strlen(buf[u]) + 1;
|
||||
buf[u] = ((Object *)data[u])->toChars();
|
||||
len += strlen(buf[u]) + 1;
|
||||
}
|
||||
str = (char *)mem.malloc(len);
|
||||
|
||||
@@ -172,11 +172,11 @@ char *Array::toChars()
|
||||
p = str + 1;
|
||||
for (u = 0; u < dim; u++)
|
||||
{
|
||||
if (u)
|
||||
*p++ = ',';
|
||||
len = strlen(buf[u]);
|
||||
memcpy(p,buf[u],len);
|
||||
p += len;
|
||||
if (u)
|
||||
*p++ = ',';
|
||||
len = strlen(buf[u]);
|
||||
memcpy(p,buf[u],len);
|
||||
p += len;
|
||||
}
|
||||
*p++ = ']';
|
||||
*p = 0;
|
||||
@@ -197,7 +197,7 @@ int
|
||||
#if _WIN32
|
||||
__cdecl
|
||||
#endif
|
||||
Array_sort_compare(const void *x, const void *y)
|
||||
Array_sort_compare(const void *x, const void *y)
|
||||
{
|
||||
Object *ox = *(Object **)x;
|
||||
Object *oy = *(Object **)y;
|
||||
@@ -209,7 +209,7 @@ void Array::sort()
|
||||
{
|
||||
if (dim)
|
||||
{
|
||||
qsort(data, dim, sizeof(Object *), Array_sort_compare);
|
||||
qsort(data, dim, sizeof(Object *), Array_sort_compare);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ struct AsyncRead
|
||||
AsyncRead *AsyncRead::create(size_t nfiles)
|
||||
{
|
||||
AsyncRead *aw = (AsyncRead *)mem.calloc(1, sizeof(AsyncRead) +
|
||||
(nfiles - 1) * sizeof(FileData));
|
||||
(nfiles - 1) * sizeof(FileData));
|
||||
aw->filesmax = nfiles;
|
||||
return aw;
|
||||
}
|
||||
@@ -64,22 +64,22 @@ void AsyncRead::start()
|
||||
//printf("aw->filesdim = %p %d\n", this, filesdim);
|
||||
if (filesdim)
|
||||
{
|
||||
unsigned threadaddr;
|
||||
hThread = (HANDLE) _beginthreadex(NULL,
|
||||
0,
|
||||
&startthread,
|
||||
this,
|
||||
0,
|
||||
(unsigned *)&threadaddr);
|
||||
unsigned threadaddr;
|
||||
hThread = (HANDLE) _beginthreadex(NULL,
|
||||
0,
|
||||
&startthread,
|
||||
this,
|
||||
0,
|
||||
(unsigned *)&threadaddr);
|
||||
|
||||
if (hThread)
|
||||
{
|
||||
SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
if (hThread)
|
||||
{
|
||||
SetThreadPriority(hThread, THREAD_PRIORITY_HIGHEST);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ int AsyncRead::read(size_t i)
|
||||
{
|
||||
FileData *f = &files[i];
|
||||
WaitForSingleObject(f->event, INFINITE);
|
||||
Sleep(0); // give up time slice
|
||||
Sleep(0); // give up time slice
|
||||
return f->result;
|
||||
}
|
||||
|
||||
@@ -104,13 +104,13 @@ unsigned __stdcall startthread(void *p)
|
||||
|
||||
//printf("aw->filesdim = %p %d\n", aw, aw->filesdim);
|
||||
for (size_t i = 0; i < aw->filesdim; i++)
|
||||
{ FileData *f = &aw->files[i];
|
||||
{ FileData *f = &aw->files[i];
|
||||
|
||||
f->result = f->file->read();
|
||||
SetEvent(f->event);
|
||||
f->result = f->file->read();
|
||||
SetEvent(f->event);
|
||||
}
|
||||
_endthreadex(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS; // if skidding
|
||||
return EXIT_SUCCESS; // if skidding
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -147,7 +147,7 @@ struct AsyncRead
|
||||
AsyncRead *AsyncRead::create(size_t nfiles)
|
||||
{
|
||||
AsyncRead *aw = (AsyncRead *)mem.calloc(1, sizeof(AsyncRead) +
|
||||
(nfiles - 1) * sizeof(FileData));
|
||||
(nfiles - 1) * sizeof(FileData));
|
||||
aw->filesmax = nfiles;
|
||||
return aw;
|
||||
}
|
||||
|
||||
470
dmd/root/dchar.c
470
dmd/root/dchar.c
@@ -26,12 +26,12 @@ dchar *Dchar::dup(char *p)
|
||||
size_t len;
|
||||
|
||||
if (!p)
|
||||
return NULL;
|
||||
return NULL;
|
||||
len = strlen(p);
|
||||
s = (dchar *)mem.malloc((len + 1) * sizeof(dchar));
|
||||
for (unsigned i = 0; i < len; i++)
|
||||
{
|
||||
s[i] = (dchar)(p[i] & 0xFF);
|
||||
s[i] = (dchar)(p[i] & 0xFF);
|
||||
}
|
||||
s[len] = 0;
|
||||
return s;
|
||||
@@ -43,8 +43,8 @@ dchar *Dchar::memchr(dchar *p, int c, int count)
|
||||
|
||||
for (u = 0; u < count; u++)
|
||||
{
|
||||
if (p[u] == c)
|
||||
return p + u;
|
||||
if (p[u] == c)
|
||||
return p + u;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -55,31 +55,31 @@ unsigned Dchar::calcHash(const dchar *str, unsigned len)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov ECX,4[ESP]
|
||||
mov EDX,8[ESP]
|
||||
xor EAX,EAX
|
||||
test EDX,EDX
|
||||
je L92
|
||||
mov ECX,4[ESP]
|
||||
mov EDX,8[ESP]
|
||||
xor EAX,EAX
|
||||
test EDX,EDX
|
||||
je L92
|
||||
|
||||
LC8: cmp EDX,1
|
||||
je L98
|
||||
cmp EDX,2
|
||||
je LAE
|
||||
LC8: cmp EDX,1
|
||||
je L98
|
||||
cmp EDX,2
|
||||
je LAE
|
||||
|
||||
add EAX,[ECX]
|
||||
// imul EAX,EAX,025h
|
||||
lea EAX,[EAX][EAX*8]
|
||||
add ECX,4
|
||||
sub EDX,2
|
||||
jmp LC8
|
||||
add EAX,[ECX]
|
||||
// imul EAX,EAX,025h
|
||||
lea EAX,[EAX][EAX*8]
|
||||
add ECX,4
|
||||
sub EDX,2
|
||||
jmp LC8
|
||||
|
||||
L98: mov DX,[ECX]
|
||||
and EDX,0FFFFh
|
||||
add EAX,EDX
|
||||
ret
|
||||
L98: mov DX,[ECX]
|
||||
and EDX,0FFFFh
|
||||
add EAX,EDX
|
||||
ret
|
||||
|
||||
LAE: add EAX,[ECX]
|
||||
L92: ret
|
||||
LAE: add EAX,[ECX]
|
||||
L92: ret
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -89,26 +89,26 @@ hash_t Dchar::calcHash(const dchar *str, size_t len)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
|
||||
case 1:
|
||||
hash += *(const uint16_t *)str;
|
||||
return hash;
|
||||
case 1:
|
||||
hash += *(const uint16_t *)str;
|
||||
return hash;
|
||||
|
||||
case 2:
|
||||
hash += *(const uint32_t *)str;
|
||||
return hash;
|
||||
case 2:
|
||||
hash += *(const uint32_t *)str;
|
||||
return hash;
|
||||
|
||||
default:
|
||||
hash += *(const uint32_t *)str;
|
||||
hash *= 37;
|
||||
str += 2;
|
||||
len -= 2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
hash += *(const uint32_t *)str;
|
||||
hash *= 37;
|
||||
str += 2;
|
||||
len -= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -119,26 +119,26 @@ hash_t Dchar::icalcHash(const dchar *str, size_t len)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
|
||||
case 1:
|
||||
hash += *(const uint16_t *)str | 0x20;
|
||||
return hash;
|
||||
case 1:
|
||||
hash += *(const uint16_t *)str | 0x20;
|
||||
return hash;
|
||||
|
||||
case 2:
|
||||
hash += *(const uint32_t *)str | 0x200020;
|
||||
return hash;
|
||||
case 2:
|
||||
hash += *(const uint32_t *)str | 0x200020;
|
||||
return hash;
|
||||
|
||||
default:
|
||||
hash += *(const uint32_t *)str | 0x200020;
|
||||
hash *= 37;
|
||||
str += 2;
|
||||
len -= 2;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
hash += *(const uint32_t *)str | 0x200020;
|
||||
hash *= 37;
|
||||
str += 2;
|
||||
len -= 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,34 +150,34 @@ hash_t Dchar::calcHash(const dchar *str, size_t len)
|
||||
|
||||
while (1)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(const uint8_t *)str;
|
||||
return hash;
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(const uint8_t *)str;
|
||||
return hash;
|
||||
|
||||
case 2:
|
||||
hash *= 37;
|
||||
hash += *(const uint16_t *)str;
|
||||
return hash;
|
||||
case 2:
|
||||
hash *= 37;
|
||||
hash += *(const uint16_t *)str;
|
||||
return hash;
|
||||
|
||||
case 3:
|
||||
hash *= 37;
|
||||
hash += (*(const uint16_t *)str << 8) +
|
||||
((const uint8_t *)str)[2];
|
||||
return hash;
|
||||
case 3:
|
||||
hash *= 37;
|
||||
hash += (*(const uint16_t *)str << 8) +
|
||||
((const uint8_t *)str)[2];
|
||||
return hash;
|
||||
|
||||
default:
|
||||
hash *= 37;
|
||||
hash += *(const uint32_t *)str;
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
hash *= 37;
|
||||
hash += *(const uint32_t *)str;
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ char Dchar::mblen[256] =
|
||||
dchar *Dchar::dec(dchar *pstart, dchar *p)
|
||||
{
|
||||
while ((p[-1] & 0xC0) == 0x80)
|
||||
p--;
|
||||
p--;
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -220,40 +220,40 @@ int Dchar::get(dchar *p)
|
||||
c = q[0];
|
||||
switch (mblen[c])
|
||||
{
|
||||
case 2:
|
||||
c = ((c - 0xC0) << 6) |
|
||||
(q[1] - 0x80);
|
||||
break;
|
||||
case 2:
|
||||
c = ((c - 0xC0) << 6) |
|
||||
(q[1] - 0x80);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
c = ((c - 0xE0) << 12) |
|
||||
((q[1] - 0x80) << 6) |
|
||||
(q[2] - 0x80);
|
||||
break;
|
||||
case 3:
|
||||
c = ((c - 0xE0) << 12) |
|
||||
((q[1] - 0x80) << 6) |
|
||||
(q[2] - 0x80);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
c = ((c - 0xF0) << 18) |
|
||||
((q[1] - 0x80) << 12) |
|
||||
((q[2] - 0x80) << 6) |
|
||||
(q[3] - 0x80);
|
||||
break;
|
||||
case 4:
|
||||
c = ((c - 0xF0) << 18) |
|
||||
((q[1] - 0x80) << 12) |
|
||||
((q[2] - 0x80) << 6) |
|
||||
(q[3] - 0x80);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
c = ((c - 0xF8) << 24) |
|
||||
((q[1] - 0x80) << 18) |
|
||||
((q[2] - 0x80) << 12) |
|
||||
((q[3] - 0x80) << 6) |
|
||||
(q[4] - 0x80);
|
||||
break;
|
||||
case 5:
|
||||
c = ((c - 0xF8) << 24) |
|
||||
((q[1] - 0x80) << 18) |
|
||||
((q[2] - 0x80) << 12) |
|
||||
((q[3] - 0x80) << 6) |
|
||||
(q[4] - 0x80);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
c = ((c - 0xFC) << 30) |
|
||||
((q[1] - 0x80) << 24) |
|
||||
((q[2] - 0x80) << 18) |
|
||||
((q[3] - 0x80) << 12) |
|
||||
((q[4] - 0x80) << 6) |
|
||||
(q[5] - 0x80);
|
||||
break;
|
||||
case 6:
|
||||
c = ((c - 0xFC) << 30) |
|
||||
((q[1] - 0x80) << 24) |
|
||||
((q[2] - 0x80) << 18) |
|
||||
((q[3] - 0x80) << 12) |
|
||||
((q[4] - 0x80) << 6) |
|
||||
(q[5] - 0x80);
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
@@ -262,50 +262,50 @@ dchar *Dchar::put(dchar *p, unsigned c)
|
||||
{
|
||||
if (c <= 0x7F)
|
||||
{
|
||||
*p++ = c;
|
||||
*p++ = c;
|
||||
}
|
||||
else if (c <= 0x7FF)
|
||||
{
|
||||
p[0] = 0xC0 + (c >> 6);
|
||||
p[1] = 0x80 + (c & 0x3F);
|
||||
p += 2;
|
||||
p[0] = 0xC0 + (c >> 6);
|
||||
p[1] = 0x80 + (c & 0x3F);
|
||||
p += 2;
|
||||
}
|
||||
else if (c <= 0xFFFF)
|
||||
{
|
||||
p[0] = 0xE0 + (c >> 12);
|
||||
p[1] = 0x80 + ((c >> 6) & 0x3F);
|
||||
p[2] = 0x80 + (c & 0x3F);
|
||||
p += 3;
|
||||
p[0] = 0xE0 + (c >> 12);
|
||||
p[1] = 0x80 + ((c >> 6) & 0x3F);
|
||||
p[2] = 0x80 + (c & 0x3F);
|
||||
p += 3;
|
||||
}
|
||||
else if (c <= 0x1FFFFF)
|
||||
{
|
||||
p[0] = 0xF0 + (c >> 18);
|
||||
p[1] = 0x80 + ((c >> 12) & 0x3F);
|
||||
p[2] = 0x80 + ((c >> 6) & 0x3F);
|
||||
p[3] = 0x80 + (c & 0x3F);
|
||||
p += 4;
|
||||
p[0] = 0xF0 + (c >> 18);
|
||||
p[1] = 0x80 + ((c >> 12) & 0x3F);
|
||||
p[2] = 0x80 + ((c >> 6) & 0x3F);
|
||||
p[3] = 0x80 + (c & 0x3F);
|
||||
p += 4;
|
||||
}
|
||||
else if (c <= 0x3FFFFFF)
|
||||
{
|
||||
p[0] = 0xF8 + (c >> 24);
|
||||
p[1] = 0x80 + ((c >> 18) & 0x3F);
|
||||
p[2] = 0x80 + ((c >> 12) & 0x3F);
|
||||
p[3] = 0x80 + ((c >> 6) & 0x3F);
|
||||
p[4] = 0x80 + (c & 0x3F);
|
||||
p += 5;
|
||||
p[0] = 0xF8 + (c >> 24);
|
||||
p[1] = 0x80 + ((c >> 18) & 0x3F);
|
||||
p[2] = 0x80 + ((c >> 12) & 0x3F);
|
||||
p[3] = 0x80 + ((c >> 6) & 0x3F);
|
||||
p[4] = 0x80 + (c & 0x3F);
|
||||
p += 5;
|
||||
}
|
||||
else if (c <= 0x7FFFFFFF)
|
||||
{
|
||||
p[0] = 0xFC + (c >> 30);
|
||||
p[1] = 0x80 + ((c >> 24) & 0x3F);
|
||||
p[2] = 0x80 + ((c >> 18) & 0x3F);
|
||||
p[3] = 0x80 + ((c >> 12) & 0x3F);
|
||||
p[4] = 0x80 + ((c >> 6) & 0x3F);
|
||||
p[5] = 0x80 + (c & 0x3F);
|
||||
p += 6;
|
||||
p[0] = 0xFC + (c >> 30);
|
||||
p[1] = 0x80 + ((c >> 24) & 0x3F);
|
||||
p[2] = 0x80 + ((c >> 18) & 0x3F);
|
||||
p[3] = 0x80 + ((c >> 12) & 0x3F);
|
||||
p[4] = 0x80 + ((c >> 6) & 0x3F);
|
||||
p[5] = 0x80 + (c & 0x3F);
|
||||
p += 6;
|
||||
}
|
||||
else
|
||||
assert(0); // not a UCS-4 character
|
||||
assert(0); // not a UCS-4 character
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -315,47 +315,47 @@ hash_t Dchar::calcHash(const dchar *str, size_t len)
|
||||
|
||||
while (1)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(const uint8_t *)str;
|
||||
return hash;
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(const uint8_t *)str;
|
||||
return hash;
|
||||
|
||||
case 2:
|
||||
hash *= 37;
|
||||
case 2:
|
||||
hash *= 37;
|
||||
#if __I86__
|
||||
hash += *(const uint16_t *)str;
|
||||
hash += *(const uint16_t *)str;
|
||||
#else
|
||||
hash += str[0] * 256 + str[1];
|
||||
hash += str[0] * 256 + str[1];
|
||||
#endif
|
||||
return hash;
|
||||
return hash;
|
||||
|
||||
case 3:
|
||||
hash *= 37;
|
||||
case 3:
|
||||
hash *= 37;
|
||||
#if __I86__
|
||||
hash += (*(const uint16_t *)str << 8) +
|
||||
((const uint8_t *)str)[2];
|
||||
hash += (*(const uint16_t *)str << 8) +
|
||||
((const uint8_t *)str)[2];
|
||||
#else
|
||||
hash += (str[0] * 256 + str[1]) * 256 + str[2];
|
||||
hash += (str[0] * 256 + str[1]) * 256 + str[2];
|
||||
#endif
|
||||
return hash;
|
||||
return hash;
|
||||
|
||||
default:
|
||||
hash *= 37;
|
||||
default:
|
||||
hash *= 37;
|
||||
#if __I86__
|
||||
hash += *(const uint32_t *)str;
|
||||
hash += *(const uint32_t *)str;
|
||||
#else
|
||||
hash += ((str[0] * 256 + str[1]) * 256 + str[2]) * 256 + str[3];
|
||||
hash += ((str[0] * 256 + str[1]) * 256 + str[2]) * 256 + str[3];
|
||||
#endif
|
||||
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -367,46 +367,46 @@ hash_t Dchar::calcHash(const dchar *str, size_t len)
|
||||
|
||||
while (1)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(const uint8_t *)str;
|
||||
return hash;
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(const uint8_t *)str;
|
||||
return hash;
|
||||
|
||||
case 2:
|
||||
hash *= 37;
|
||||
case 2:
|
||||
hash *= 37;
|
||||
#if __I86__
|
||||
hash += *(const uint16_t *)str;
|
||||
hash += *(const uint16_t *)str;
|
||||
#else
|
||||
hash += str[0] * 256 + str[1];
|
||||
hash += str[0] * 256 + str[1];
|
||||
#endif
|
||||
return hash;
|
||||
return hash;
|
||||
|
||||
case 3:
|
||||
hash *= 37;
|
||||
case 3:
|
||||
hash *= 37;
|
||||
#if __I86__
|
||||
hash += (*(const uint16_t *)str << 8) +
|
||||
((const uint8_t *)str)[2];
|
||||
hash += (*(const uint16_t *)str << 8) +
|
||||
((const uint8_t *)str)[2];
|
||||
#else
|
||||
hash += (str[0] * 256 + str[1]) * 256 + str[2];
|
||||
hash += (str[0] * 256 + str[1]) * 256 + str[2];
|
||||
#endif
|
||||
return hash;
|
||||
return hash;
|
||||
|
||||
default:
|
||||
hash *= 37;
|
||||
default:
|
||||
hash *= 37;
|
||||
#if __I86__
|
||||
hash += *(const uint32_t *)str;
|
||||
hash += *(const uint32_t *)str;
|
||||
#else
|
||||
hash += ((str[0] * 256 + str[1]) * 256 + str[2]) * 256 + str[3];
|
||||
hash += ((str[0] * 256 + str[1]) * 256 + str[2]) * 256 + str[3];
|
||||
#endif
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,34 +416,34 @@ hash_t Dchar::icalcHash(const dchar *str, size_t len)
|
||||
|
||||
while (1)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
switch (len)
|
||||
{
|
||||
case 0:
|
||||
return hash;
|
||||
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(const uint8_t *)str | 0x20;
|
||||
return hash;
|
||||
case 1:
|
||||
hash *= 37;
|
||||
hash += *(const uint8_t *)str | 0x20;
|
||||
return hash;
|
||||
|
||||
case 2:
|
||||
hash *= 37;
|
||||
hash += *(const uint16_t *)str | 0x2020;
|
||||
return hash;
|
||||
case 2:
|
||||
hash *= 37;
|
||||
hash += *(const uint16_t *)str | 0x2020;
|
||||
return hash;
|
||||
|
||||
case 3:
|
||||
hash *= 37;
|
||||
hash += ((*(const uint16_t *)str << 8) +
|
||||
((const uint8_t *)str)[2]) | 0x202020;
|
||||
return hash;
|
||||
case 3:
|
||||
hash *= 37;
|
||||
hash += ((*(const uint16_t *)str << 8) +
|
||||
((const uint8_t *)str)[2]) | 0x202020;
|
||||
return hash;
|
||||
|
||||
default:
|
||||
hash *= 37;
|
||||
hash += *(const uint32_t *)str | 0x20202020;
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
hash *= 37;
|
||||
hash += *(const uint32_t *)str | 0x20202020;
|
||||
str += 4;
|
||||
len -= 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,23 +460,23 @@ void main()
|
||||
|
||||
for (c = 0; c < 256; c++)
|
||||
{
|
||||
s = 1;
|
||||
if (c >= 0xC0 && c <= 0xDF)
|
||||
s = 2;
|
||||
if (c >= 0xE0 && c <= 0xEF)
|
||||
s = 3;
|
||||
if (c >= 0xF0 && c <= 0xF7)
|
||||
s = 4;
|
||||
if (c >= 0xF8 && c <= 0xFB)
|
||||
s = 5;
|
||||
if (c >= 0xFC && c <= 0xFD)
|
||||
s = 6;
|
||||
s = 1;
|
||||
if (c >= 0xC0 && c <= 0xDF)
|
||||
s = 2;
|
||||
if (c >= 0xE0 && c <= 0xEF)
|
||||
s = 3;
|
||||
if (c >= 0xF0 && c <= 0xF7)
|
||||
s = 4;
|
||||
if (c >= 0xF8 && c <= 0xFB)
|
||||
s = 5;
|
||||
if (c >= 0xFC && c <= 0xFD)
|
||||
s = 6;
|
||||
|
||||
printf("%d", s);
|
||||
if ((c & 15) == 15)
|
||||
printf(",\n");
|
||||
else
|
||||
printf(",");
|
||||
printf("%d", s);
|
||||
if ((c & 15) == 15)
|
||||
printf(",\n");
|
||||
else
|
||||
printf(",");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,9 +33,9 @@ typedef size_t hash_t;
|
||||
#include <wchar.h>
|
||||
|
||||
typedef wchar_t dchar;
|
||||
#define TEXT(x) L##x
|
||||
#define TEXT(x) L##x
|
||||
|
||||
#define Dchar_mbmax 1
|
||||
#define Dchar_mbmax 1
|
||||
|
||||
struct Dchar
|
||||
{
|
||||
@@ -48,14 +48,14 @@ struct Dchar
|
||||
static int cmp(dchar *s1, dchar *s2)
|
||||
{
|
||||
#if __DMC__
|
||||
if (!*s1 && !*s2) // wcscmp is broken
|
||||
return 0;
|
||||
if (!*s1 && !*s2) // wcscmp is broken
|
||||
return 0;
|
||||
#endif
|
||||
return wcscmp(s1, s2);
|
||||
return wcscmp(s1, s2);
|
||||
#if 0
|
||||
return (*s1 == *s2)
|
||||
? wcscmp(s1, s2)
|
||||
: ((int)*s1 - (int)*s2);
|
||||
return (*s1 == *s2)
|
||||
? wcscmp(s1, s2)
|
||||
: ((int)*s1 - (int)*s2);
|
||||
#endif
|
||||
}
|
||||
static int memcmp(const dchar *s1, const dchar *s2, int nchars) { return ::memcmp(s1, s2, nchars * sizeof(dchar)); }
|
||||
@@ -68,7 +68,7 @@ struct Dchar
|
||||
static int toLower(dchar c) { return isUpper(c) ? towlower(c) : c; }
|
||||
static int toLower(dchar *p) { return toLower(*p); }
|
||||
static int toUpper(dchar c) { return isLower(c) ? towupper(c) : c; }
|
||||
static dchar *dup(dchar *p) { return ::_wcsdup(p); } // BUG: out of memory?
|
||||
static dchar *dup(dchar *p) { return ::_wcsdup(p); } // BUG: out of memory?
|
||||
static dchar *dup(char *p);
|
||||
static dchar *chr(dchar *p, unsigned c) { return wcschr(p, (dchar)c); }
|
||||
static dchar *rchr(dchar *p, unsigned c) { return wcsrchr(p, (dchar)c); }
|
||||
@@ -89,16 +89,16 @@ struct Dchar
|
||||
#include <mbstring.h>
|
||||
|
||||
typedef char dchar;
|
||||
#define TEXT(x) x
|
||||
#define TEXT(x) x
|
||||
|
||||
#define Dchar_mbmax MB_LEN_MAX
|
||||
#define Dchar_mbmax MB_LEN_MAX
|
||||
|
||||
#elif UTF8
|
||||
|
||||
typedef char dchar;
|
||||
#define TEXT(x) x
|
||||
#define TEXT(x) x
|
||||
|
||||
#define Dchar_mbmax 6
|
||||
#define Dchar_mbmax 6
|
||||
|
||||
struct Dchar
|
||||
{
|
||||
@@ -109,7 +109,7 @@ struct Dchar
|
||||
static int len(const dchar *p) { return strlen(p); }
|
||||
static int get(dchar *p);
|
||||
static int getprev(dchar *pstart, dchar *p)
|
||||
{ return *dec(pstart, p) & 0xFF; }
|
||||
{ return *dec(pstart, p) & 0xFF; }
|
||||
static dchar *put(dchar *p, unsigned c);
|
||||
static int cmp(dchar *s1, dchar *s2) { return strcmp(s1, s2); }
|
||||
static int memcmp(const dchar *s1, const dchar *s2, int nchars) { return ::memcmp(s1, s2, nchars); }
|
||||
@@ -122,11 +122,11 @@ struct Dchar
|
||||
static int toLower(dchar c) { return isUpper(c) ? tolower(c) : c; }
|
||||
static int toLower(dchar *p) { return toLower(*p); }
|
||||
static int toUpper(dchar c) { return isLower(c) ? toupper(c) : c; }
|
||||
static dchar *dup(dchar *p) { return ::strdup(p); } // BUG: out of memory?
|
||||
static dchar *dup(dchar *p) { return ::strdup(p); } // BUG: out of memory?
|
||||
static dchar *chr(dchar *p, int c) { return strchr(p, c); }
|
||||
static dchar *rchr(dchar *p, int c) { return strrchr(p, c); }
|
||||
static dchar *memchr(dchar *p, int c, int count)
|
||||
{ return (dchar *)::memchr(p, c, count); }
|
||||
{ return (dchar *)::memchr(p, c, count); }
|
||||
static dchar *cpy(dchar *s1, dchar *s2) { return strcpy(s1, s2); }
|
||||
static dchar *str(dchar *s1, dchar *s2) { return strstr(s1, s2); }
|
||||
static hash_t calcHash(const dchar *str, size_t len);
|
||||
@@ -145,9 +145,9 @@ struct Dchar
|
||||
#endif
|
||||
|
||||
typedef char dchar;
|
||||
#define TEXT(x) x
|
||||
#define TEXT(x) x
|
||||
|
||||
#define Dchar_mbmax 1
|
||||
#define Dchar_mbmax 1
|
||||
|
||||
struct Dchar
|
||||
{
|
||||
@@ -169,12 +169,12 @@ struct Dchar
|
||||
static int toLower(dchar c) { return isupper(c) ? tolower(c) : c; }
|
||||
static int toLower(dchar *p) { return toLower(*p); }
|
||||
static int toUpper(dchar c) { return islower(c) ? toupper(c) : c; }
|
||||
static dchar *dup(dchar *p) { return ::strdup(p); } // BUG: out of memory?
|
||||
static dchar *dup(dchar *p) { return ::strdup(p); } // BUG: out of memory?
|
||||
#endif
|
||||
static dchar *chr(dchar *p, int c) { return strchr(p, c); }
|
||||
static dchar *rchr(dchar *p, int c) { return strrchr(p, c); }
|
||||
static dchar *memchr(dchar *p, int c, int count)
|
||||
{ return (dchar *)::memchr(p, c, count); }
|
||||
{ return (dchar *)::memchr(p, c, count); }
|
||||
static dchar *cpy(dchar *s1, dchar *s2) { return strcpy(s1, s2); }
|
||||
static dchar *str(dchar *s1, dchar *s2) { return strstr(s1, s2); }
|
||||
static hash_t calcHash(const dchar *str, size_t len);
|
||||
|
||||
@@ -8,20 +8,20 @@ int memicmp(const char *s1, const char *s2, int n)
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{ char c1 = s1[i];
|
||||
char c2 = s2[i];
|
||||
{ char c1 = s1[i];
|
||||
char c2 = s2[i];
|
||||
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
if ('A' <= c1 && c1 <= 'Z')
|
||||
c1 += 'a' - 'A';
|
||||
if ('A' <= c2 && c2 <= 'Z')
|
||||
c2 += 'a' - 'A';
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
if ('A' <= c1 && c1 <= 'Z')
|
||||
c1 += 'a' - 'A';
|
||||
if ('A' <= c2 && c2 <= 'Z')
|
||||
c2 += 'a' - 'A';
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -31,24 +31,24 @@ int stricmp(const char *s1, const char *s2)
|
||||
int result = 0;
|
||||
|
||||
for (;;)
|
||||
{ char c1 = *s1;
|
||||
char c2 = *s2;
|
||||
{ char c1 = *s1;
|
||||
char c2 = *s2;
|
||||
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
if ('A' <= c1 && c1 <= 'Z')
|
||||
c1 += 'a' - 'A';
|
||||
if ('A' <= c2 && c2 <= 'Z')
|
||||
c2 += 'a' - 'A';
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
if (!c1)
|
||||
break;
|
||||
s1++;
|
||||
s2++;
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
{
|
||||
if ('A' <= c1 && c1 <= 'Z')
|
||||
c1 += 'a' - 'A';
|
||||
if ('A' <= c2 && c2 <= 'Z')
|
||||
c2 += 'a' - 'A';
|
||||
result = c1 - c2;
|
||||
if (result)
|
||||
break;
|
||||
}
|
||||
if (!c1)
|
||||
break;
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ Lstring *Lstring::append(const Lstring *s)
|
||||
Lstring *t;
|
||||
|
||||
if (!s->length)
|
||||
return this;
|
||||
return this;
|
||||
t = alloc(length + s->length);
|
||||
memcpy(t->string, string, length * sizeof(dchar));
|
||||
memcpy(t->string + length, s->string, s->length * sizeof(dchar));
|
||||
@@ -56,7 +56,7 @@ Lstring *Lstring::substring(int start, int end)
|
||||
Lstring *t;
|
||||
|
||||
if (start == end)
|
||||
return &zero;
|
||||
return &zero;
|
||||
t = alloc(end - start);
|
||||
memcpy(t->string, string + start, (end - start) * sizeof(dchar));
|
||||
return t;
|
||||
|
||||
@@ -23,7 +23,7 @@ struct Lstring
|
||||
#pragma warning (disable : 4200)
|
||||
dchar string[];
|
||||
|
||||
static Lstring zero; // 0 length string
|
||||
static Lstring zero; // 0 length string
|
||||
|
||||
// No constructors because we want to be able to statically
|
||||
// initialize Lstring's, and Lstrings are of variable size.
|
||||
@@ -55,14 +55,14 @@ struct Lstring
|
||||
|
||||
static int cmp(const Lstring *s1, const Lstring *s2)
|
||||
{
|
||||
int c = s2->length - s1->length;
|
||||
return c ? c : Dchar::memcmp(s1->string, s2->string, s1->length);
|
||||
int c = s2->length - s1->length;
|
||||
return c ? c : Dchar::memcmp(s1->string, s2->string, s1->length);
|
||||
}
|
||||
|
||||
static int icmp(const Lstring *s1, const Lstring *s2)
|
||||
{
|
||||
int c = s2->length - s1->length;
|
||||
return c ? c : Dchar::memicmp(s1->string, s2->string, s1->length);
|
||||
int c = s2->length - s1->length;
|
||||
return c ? c : Dchar::memicmp(s1->string, s2->string, s1->length);
|
||||
}
|
||||
|
||||
Lstring *append(const Lstring *s);
|
||||
|
||||
@@ -28,9 +28,9 @@ void browse(const char *url)
|
||||
|
||||
#if linux || __FreeBSD__ || __sun&&__SVR4
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void browse(const char *url)
|
||||
{
|
||||
@@ -39,9 +39,9 @@ void browse(const char *url)
|
||||
|
||||
const char *browser = getenv("BROWSER");
|
||||
if (browser)
|
||||
browser = strdup(browser);
|
||||
browser = strdup(browser);
|
||||
else
|
||||
browser = "x-www-browser";
|
||||
browser = "x-www-browser";
|
||||
|
||||
args[0] = browser;
|
||||
args[1] = url;
|
||||
@@ -50,9 +50,9 @@ void browse(const char *url)
|
||||
childpid = fork();
|
||||
if (childpid == 0)
|
||||
{
|
||||
execvp(args[0], (char**)args);
|
||||
perror(args[0]); // failed to execute
|
||||
return;
|
||||
execvp(args[0], (char**)args);
|
||||
perror(args[0]); // failed to execute
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +60,9 @@ void browse(const char *url)
|
||||
|
||||
#if __APPLE__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void browse(const char *url)
|
||||
{
|
||||
@@ -71,27 +71,27 @@ void browse(const char *url)
|
||||
|
||||
char *browser = getenv("BROWSER");
|
||||
if (browser)
|
||||
{ browser = strdup(browser);
|
||||
args[0] = browser;
|
||||
args[1] = url;
|
||||
args[2] = NULL;
|
||||
{ browser = strdup(browser);
|
||||
args[0] = browser;
|
||||
args[1] = url;
|
||||
args[2] = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
//browser = "/Applications/Safari.app/Contents/MacOS/Safari";
|
||||
args[0] = "open";
|
||||
args[1] = "-a";
|
||||
args[2] = "/Applications/Safari.app";
|
||||
args[3] = url;
|
||||
args[4] = NULL;
|
||||
//browser = "/Applications/Safari.app/Contents/MacOS/Safari";
|
||||
args[0] = "open";
|
||||
args[1] = "-a";
|
||||
args[2] = "/Applications/Safari.app";
|
||||
args[3] = url;
|
||||
args[4] = NULL;
|
||||
}
|
||||
|
||||
childpid = fork();
|
||||
if (childpid == 0)
|
||||
{
|
||||
execvp(args[0], (char**)args);
|
||||
perror(args[0]); // failed to execute
|
||||
return;
|
||||
execvp(args[0], (char**)args);
|
||||
perror(args[0]); // failed to execute
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
126
dmd/root/port.c
126
dmd/root/port.c
@@ -197,7 +197,7 @@ double Port::floor(double d)
|
||||
double Port::pow(double x, double y)
|
||||
{
|
||||
if (y == 0)
|
||||
return 1; // even if x is NAN
|
||||
return 1; // even if x is NAN
|
||||
return ::pow(x, y);
|
||||
}
|
||||
|
||||
@@ -208,64 +208,64 @@ unsigned _int64 Port::strtoull(const char *p, char **pend, int base)
|
||||
int error;
|
||||
#define ULLONG_MAX ((unsigned _int64)~0I64)
|
||||
|
||||
while (isspace(*p)) /* skip leading white space */
|
||||
p++;
|
||||
while (isspace(*p)) /* skip leading white space */
|
||||
p++;
|
||||
if (*p == '+')
|
||||
p++;
|
||||
p++;
|
||||
switch (base)
|
||||
{ case 0:
|
||||
base = 10; /* assume decimal base */
|
||||
if (*p == '0')
|
||||
{ base = 8; /* could be octal */
|
||||
p++;
|
||||
switch (*p)
|
||||
{ case 'x':
|
||||
case 'X':
|
||||
base = 16; /* hex */
|
||||
p++;
|
||||
break;
|
||||
base = 10; /* assume decimal base */
|
||||
if (*p == '0')
|
||||
{ base = 8; /* could be octal */
|
||||
p++;
|
||||
switch (*p)
|
||||
{ case 'x':
|
||||
case 'X':
|
||||
base = 16; /* hex */
|
||||
p++;
|
||||
break;
|
||||
#if BINARY
|
||||
case 'b':
|
||||
case 'B':
|
||||
base = 2; /* binary */
|
||||
p++;
|
||||
break;
|
||||
case 'b':
|
||||
case 'B':
|
||||
base = 2; /* binary */
|
||||
p++;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 16: /* skip over '0x' and '0X' */
|
||||
if (*p == '0' && (p[1] == 'x' || p[1] == 'X'))
|
||||
p += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 16: /* skip over '0x' and '0X' */
|
||||
if (*p == '0' && (p[1] == 'x' || p[1] == 'X'))
|
||||
p += 2;
|
||||
break;
|
||||
#if BINARY
|
||||
case 2: /* skip over '0b' and '0B' */
|
||||
if (*p == '0' && (p[1] == 'b' || p[1] == 'B'))
|
||||
p += 2;
|
||||
break;
|
||||
case 2: /* skip over '0b' and '0B' */
|
||||
if (*p == '0' && (p[1] == 'b' || p[1] == 'B'))
|
||||
p += 2;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
error = 0;
|
||||
for (;;)
|
||||
{ c = *p;
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c = (c & ~0x20) - ('A' - 10);
|
||||
else /* unrecognized character */
|
||||
break;
|
||||
if (c >= base) /* not in number base */
|
||||
break;
|
||||
if ((ULLONG_MAX - c) / base < number)
|
||||
error = 1;
|
||||
number = number * base + c;
|
||||
p++;
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c = (c & ~0x20) - ('A' - 10);
|
||||
else /* unrecognized character */
|
||||
break;
|
||||
if (c >= base) /* not in number base */
|
||||
break;
|
||||
if ((ULLONG_MAX - c) / base < number)
|
||||
error = 1;
|
||||
number = number * base + c;
|
||||
p++;
|
||||
}
|
||||
if (pend)
|
||||
*pend = (char *)p;
|
||||
*pend = (char *)p;
|
||||
if (error)
|
||||
{ number = ULLONG_MAX;
|
||||
errno = ERANGE;
|
||||
errno = ERANGE;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
@@ -287,12 +287,12 @@ double Port::ull_to_double(ulonglong ull)
|
||||
|
||||
if ((__int64) ull < 0)
|
||||
{
|
||||
// MSVC doesn't implement the conversion
|
||||
d = (double) (__int64)(ull - 0x8000000000000000i64);
|
||||
d += (double)(signed __int64)(0x7FFFFFFFFFFFFFFFi64) + 1.0;
|
||||
// MSVC doesn't implement the conversion
|
||||
d = (double) (__int64)(ull - 0x8000000000000000i64);
|
||||
d += (double)(signed __int64)(0x7FFFFFFFFFFFFFFFi64) + 1.0;
|
||||
}
|
||||
else
|
||||
d = (double)(__int64)ull;
|
||||
d = (double)(__int64)ull;
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -351,14 +351,14 @@ PortInitializer::PortInitializer()
|
||||
// constant folding.
|
||||
volatile long double foo;
|
||||
foo = NAN;
|
||||
if (signbit(foo)) // signbit sometimes, not always, set
|
||||
foo = -foo; // turn off sign bit
|
||||
if (signbit(foo)) // signbit sometimes, not always, set
|
||||
foo = -foo; // turn off sign bit
|
||||
Port::nan = foo;
|
||||
|
||||
#if __FreeBSD__
|
||||
// LDBL_MAX comes out as infinity. Fix.
|
||||
static unsigned char x[sizeof(long double)] =
|
||||
{ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x7F };
|
||||
{ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x7F };
|
||||
Port::ldbl_max = *(long double *)&x[0];
|
||||
#endif
|
||||
}
|
||||
@@ -479,11 +479,11 @@ const wchar_t *Port::wlist_separator()
|
||||
char *Port::strupr(char *s)
|
||||
{
|
||||
char *t = s;
|
||||
|
||||
|
||||
while (*s)
|
||||
{
|
||||
*s = toupper(*s);
|
||||
s++;
|
||||
*s = toupper(*s);
|
||||
s++;
|
||||
}
|
||||
|
||||
return t;
|
||||
@@ -493,7 +493,7 @@ char *Port::strupr(char *s)
|
||||
|
||||
#if __sun&&__SVR4
|
||||
|
||||
#define __C99FEATURES__ 1 // Needed on Solaris for NaN and more
|
||||
#define __C99FEATURES__ 1 // Needed on Solaris for NaN and more
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
@@ -525,8 +525,8 @@ PortInitializer::PortInitializer()
|
||||
// constant folding.
|
||||
volatile long double foo;
|
||||
foo = NAN;
|
||||
if (signbit(foo)) // signbit sometimes, not always, set
|
||||
foo = -foo; // turn off sign bit
|
||||
if (signbit(foo)) // signbit sometimes, not always, set
|
||||
foo = -foo; // turn off sign bit
|
||||
Port::nan = foo;
|
||||
}
|
||||
|
||||
@@ -618,11 +618,11 @@ const wchar_t *Port::wlist_separator()
|
||||
char *Port::strupr(char *s)
|
||||
{
|
||||
char *t = s;
|
||||
|
||||
|
||||
while (*s)
|
||||
{
|
||||
*s = toupper(*s);
|
||||
s++;
|
||||
*s = toupper(*s);
|
||||
s++;
|
||||
}
|
||||
|
||||
return t;
|
||||
@@ -759,11 +759,11 @@ const wchar_t *Port::wlist_separator()
|
||||
char *Port::strupr(char *s)
|
||||
{
|
||||
char *t = s;
|
||||
|
||||
|
||||
while (*s)
|
||||
{
|
||||
*s = toupper(*s);
|
||||
s++;
|
||||
*s = toupper(*s);
|
||||
s++;
|
||||
}
|
||||
|
||||
return t;
|
||||
|
||||
882
dmd/root/root.c
882
dmd/root/root.c
File diff suppressed because it is too large
Load Diff
@@ -106,14 +106,14 @@ struct Object
|
||||
/**
|
||||
* Marks pointers for garbage collector by calling mem.mark() for all pointers into heap.
|
||||
*/
|
||||
/*virtual*/ // not used, disable for now
|
||||
void mark();
|
||||
/*virtual*/ // not used, disable for now
|
||||
void mark();
|
||||
};
|
||||
|
||||
struct String : Object
|
||||
{
|
||||
int ref; // != 0 if this is a reference to someone else's string
|
||||
char *str; // the string itself
|
||||
int ref; // != 0 if this is a reference to someone else's string
|
||||
char *str; // the string itself
|
||||
|
||||
String(char *str, int ref = 1);
|
||||
|
||||
@@ -164,12 +164,12 @@ struct FileName : String
|
||||
|
||||
struct File : Object
|
||||
{
|
||||
int ref; // != 0 if this is a reference to someone else's buffer
|
||||
unsigned char *buffer; // data for our file
|
||||
unsigned len; // amount of data in buffer[]
|
||||
void *touchtime; // system time to use for file
|
||||
int ref; // != 0 if this is a reference to someone else's buffer
|
||||
unsigned char *buffer; // data for our file
|
||||
unsigned len; // amount of data in buffer[]
|
||||
void *touchtime; // system time to use for file
|
||||
|
||||
FileName *name; // name of our file
|
||||
FileName *name; // name of our file
|
||||
|
||||
File(char *);
|
||||
File(FileName *);
|
||||
@@ -213,9 +213,9 @@ struct File : Object
|
||||
void writev();
|
||||
|
||||
/* Return !=0 if file exists.
|
||||
* 0: file doesn't exist
|
||||
* 1: normal file
|
||||
* 2: directory
|
||||
* 0: file doesn't exist
|
||||
* 1: normal file
|
||||
* 2: directory
|
||||
*/
|
||||
|
||||
/* Append to file, return !=0 if error
|
||||
@@ -230,9 +230,9 @@ struct File : Object
|
||||
void appendv();
|
||||
|
||||
/* Return !=0 if file exists.
|
||||
* 0: file doesn't exist
|
||||
* 1: normal file
|
||||
* 2: directory
|
||||
* 0: file doesn't exist
|
||||
* 1: normal file
|
||||
* 2: directory
|
||||
*/
|
||||
|
||||
int exists();
|
||||
@@ -245,9 +245,9 @@ struct File : Object
|
||||
static Array *match(FileName *);
|
||||
|
||||
// Compare file times.
|
||||
// Return <0 this < f
|
||||
// =0 this == f
|
||||
// >0 this > f
|
||||
// Return <0 this < f
|
||||
// =0 this == f
|
||||
// >0 this > f
|
||||
int compareTime(File *f);
|
||||
|
||||
// Read system file statistics
|
||||
@@ -258,13 +258,13 @@ struct File : Object
|
||||
|
||||
void setbuffer(void *buffer, unsigned len)
|
||||
{
|
||||
this->buffer = (unsigned char *)buffer;
|
||||
this->len = len;
|
||||
this->buffer = (unsigned char *)buffer;
|
||||
this->len = len;
|
||||
}
|
||||
|
||||
void checkoffset(size_t offset, size_t nbytes);
|
||||
|
||||
void remove(); // delete file
|
||||
void remove(); // delete file
|
||||
};
|
||||
|
||||
struct OutBuffer : Object
|
||||
@@ -287,7 +287,7 @@ struct OutBuffer : Object
|
||||
void writedstring(const char *string);
|
||||
void writedstring(const wchar_t *string);
|
||||
void prependstring(const char *string);
|
||||
void writenl(); // write newline
|
||||
void writenl(); // write newline
|
||||
void writeByte(unsigned b);
|
||||
void writebyte(unsigned b) { writeByte(b); }
|
||||
void writeUTF8(unsigned b);
|
||||
|
||||
@@ -32,7 +32,7 @@ StringTable::~StringTable()
|
||||
// Zero out dangling pointers to help garbage collector.
|
||||
// Should zero out StringEntry's too.
|
||||
for (i = 0; i < count; i++)
|
||||
table[i] = NULL;
|
||||
table[i] = NULL;
|
||||
|
||||
mem.free(table);
|
||||
table = NULL;
|
||||
@@ -74,21 +74,21 @@ void **StringTable::search(const dchar *s, unsigned len)
|
||||
//printf("\thash = %d, u = %d\n",hash,u);
|
||||
while (*se)
|
||||
{
|
||||
cmp = (*se)->hash - hash;
|
||||
if (cmp == 0)
|
||||
{
|
||||
cmp = (*se)->value.lstring.len() - len;
|
||||
if (cmp == 0)
|
||||
{
|
||||
cmp = Dchar::memcmp(s,(*se)->value.lstring.toDchars(),len);
|
||||
if (cmp == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cmp < 0)
|
||||
se = &(*se)->left;
|
||||
else
|
||||
se = &(*se)->right;
|
||||
cmp = (*se)->hash - hash;
|
||||
if (cmp == 0)
|
||||
{
|
||||
cmp = (*se)->value.lstring.len() - len;
|
||||
if (cmp == 0)
|
||||
{
|
||||
cmp = Dchar::memcmp(s,(*se)->value.lstring.toDchars(),len);
|
||||
if (cmp == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cmp < 0)
|
||||
se = &(*se)->left;
|
||||
else
|
||||
se = &(*se)->right;
|
||||
}
|
||||
//printf("\treturn %p, %p\n",se, (*se));
|
||||
return (void **)se;
|
||||
@@ -99,9 +99,9 @@ StringValue *StringTable::lookup(const dchar *s, unsigned len)
|
||||
|
||||
se = *(StringEntry **)search(s,len);
|
||||
if (se)
|
||||
return &se->value;
|
||||
return &se->value;
|
||||
else
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
StringValue *StringTable::update(const dchar *s, unsigned len)
|
||||
@@ -110,10 +110,10 @@ StringValue *StringTable::update(const dchar *s, unsigned len)
|
||||
|
||||
pse = (StringEntry **)search(s,len);
|
||||
se = *pse;
|
||||
if (!se) // not in table: so create new entry
|
||||
if (!se) // not in table: so create new entry
|
||||
{
|
||||
se = StringEntry::alloc(s, len);
|
||||
*pse = se;
|
||||
se = StringEntry::alloc(s, len);
|
||||
*pse = se;
|
||||
}
|
||||
return &se->value;
|
||||
}
|
||||
@@ -125,11 +125,11 @@ StringValue *StringTable::insert(const dchar *s, unsigned len)
|
||||
pse = (StringEntry **)search(s,len);
|
||||
se = *pse;
|
||||
if (se)
|
||||
return NULL; // error: already in table
|
||||
return NULL; // error: already in table
|
||||
else
|
||||
{
|
||||
se = StringEntry::alloc(s, len);
|
||||
*pse = se;
|
||||
se = StringEntry::alloc(s, len);
|
||||
*pse = se;
|
||||
}
|
||||
return &se->value;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
struct StringValue
|
||||
{
|
||||
union
|
||||
{ int intvalue;
|
||||
void *ptrvalue;
|
||||
dchar *string;
|
||||
{ int intvalue;
|
||||
void *ptrvalue;
|
||||
dchar *string;
|
||||
};
|
||||
Lstring lstring;
|
||||
};
|
||||
|
||||
216
dmd/scope.c
216
dmd/scope.c
@@ -30,12 +30,12 @@ void *Scope::operator new(size_t size)
|
||||
{
|
||||
if (freelist)
|
||||
{
|
||||
Scope *s = freelist;
|
||||
freelist = s->enclosing;
|
||||
//printf("freelist %p\n", s);
|
||||
assert(s->flags & SCOPEfree);
|
||||
s->flags &= ~SCOPEfree;
|
||||
return s;
|
||||
Scope *s = freelist;
|
||||
freelist = s->enclosing;
|
||||
//printf("freelist %p\n", s);
|
||||
assert(s->flags & SCOPEfree);
|
||||
s->flags &= ~SCOPEfree;
|
||||
return s;
|
||||
}
|
||||
|
||||
void *p = ::operator new(size);
|
||||
@@ -103,10 +103,10 @@ Scope::Scope(Scope *enclosing)
|
||||
this->enclosing = enclosing;
|
||||
#ifdef DEBUG
|
||||
if (enclosing->enclosing)
|
||||
assert(!(enclosing->enclosing->flags & SCOPEfree));
|
||||
assert(!(enclosing->enclosing->flags & SCOPEfree));
|
||||
if (this == enclosing->enclosing)
|
||||
{
|
||||
printf("this = %p, enclosing = %p, enclosing->enclosing = %p\n", this, enclosing, enclosing->enclosing);
|
||||
printf("this = %p, enclosing = %p, enclosing->enclosing = %p\n", this, enclosing, enclosing->enclosing);
|
||||
}
|
||||
assert(this != enclosing->enclosing);
|
||||
#endif
|
||||
@@ -145,9 +145,9 @@ Scope *Scope::createGlobal(Module *module)
|
||||
// Add top level package as member of this global scope
|
||||
Dsymbol *m = module;
|
||||
while (m->parent)
|
||||
m = m->parent;
|
||||
m = m->parent;
|
||||
m->addMember(NULL, sc->scopesym, 1);
|
||||
m->parent = NULL; // got changed by addMember()
|
||||
m->parent = NULL; // got changed by addMember()
|
||||
|
||||
// Create the module scope underneath the global scope
|
||||
sc = sc->push(module);
|
||||
@@ -177,12 +177,12 @@ Scope *Scope::pop()
|
||||
Scope *enc = enclosing;
|
||||
|
||||
if (enclosing)
|
||||
enclosing->callSuper |= callSuper;
|
||||
enclosing->callSuper |= callSuper;
|
||||
|
||||
if (!nofree)
|
||||
{ enclosing = freelist;
|
||||
freelist = this;
|
||||
flags |= SCOPEfree;
|
||||
{ enclosing = freelist;
|
||||
freelist = this;
|
||||
flags |= SCOPEfree;
|
||||
}
|
||||
|
||||
return enc;
|
||||
@@ -196,25 +196,25 @@ void Scope::mergeCallSuper(Loc loc, unsigned cs)
|
||||
// The two paths are callSuper and cs; the result is merged into callSuper.
|
||||
|
||||
if (cs != callSuper)
|
||||
{ int a;
|
||||
int b;
|
||||
{ int a;
|
||||
int b;
|
||||
|
||||
callSuper |= cs & (CSXany_ctor | CSXlabel);
|
||||
if (cs & CSXreturn)
|
||||
{
|
||||
}
|
||||
else if (callSuper & CSXreturn)
|
||||
{
|
||||
callSuper = cs | (callSuper & (CSXany_ctor | CSXlabel));
|
||||
}
|
||||
else
|
||||
{
|
||||
a = (cs & (CSXthis_ctor | CSXsuper_ctor)) != 0;
|
||||
b = (callSuper & (CSXthis_ctor | CSXsuper_ctor)) != 0;
|
||||
if (a != b)
|
||||
error(loc, "one path skips constructor");
|
||||
callSuper |= cs;
|
||||
}
|
||||
callSuper |= cs & (CSXany_ctor | CSXlabel);
|
||||
if (cs & CSXreturn)
|
||||
{
|
||||
}
|
||||
else if (callSuper & CSXreturn)
|
||||
{
|
||||
callSuper = cs | (callSuper & (CSXany_ctor | CSXlabel));
|
||||
}
|
||||
else
|
||||
{
|
||||
a = (cs & (CSXthis_ctor | CSXsuper_ctor)) != 0;
|
||||
b = (callSuper & (CSXthis_ctor | CSXsuper_ctor)) != 0;
|
||||
if (a != b)
|
||||
error(loc, "one path skips constructor");
|
||||
callSuper |= cs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,50 +225,50 @@ Dsymbol *Scope::search(Loc loc, Identifier *ident, Dsymbol **pscopesym)
|
||||
//printf("Scope::search(%p, '%s')\n", this, ident->toChars());
|
||||
if (ident == Id::empty)
|
||||
{
|
||||
// Look for module scope
|
||||
for (sc = this; sc; sc = sc->enclosing)
|
||||
{
|
||||
assert(sc != sc->enclosing);
|
||||
if (sc->scopesym)
|
||||
{
|
||||
s = sc->scopesym->isModule();
|
||||
if (s)
|
||||
{
|
||||
//printf("\tfound %s.%s\n", s->parent ? s->parent->toChars() : "", s->toChars());
|
||||
if (pscopesym)
|
||||
*pscopesym = sc->scopesym;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
// Look for module scope
|
||||
for (sc = this; sc; sc = sc->enclosing)
|
||||
{
|
||||
assert(sc != sc->enclosing);
|
||||
if (sc->scopesym)
|
||||
{
|
||||
s = sc->scopesym->isModule();
|
||||
if (s)
|
||||
{
|
||||
//printf("\tfound %s.%s\n", s->parent ? s->parent->toChars() : "", s->toChars());
|
||||
if (pscopesym)
|
||||
*pscopesym = sc->scopesym;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (sc = this; sc; sc = sc->enclosing)
|
||||
{
|
||||
assert(sc != sc->enclosing);
|
||||
if (sc->scopesym)
|
||||
{
|
||||
//printf("\tlooking in scopesym '%s', kind = '%s'\n", sc->scopesym->toChars(), sc->scopesym->kind());
|
||||
s = sc->scopesym->search(loc, ident, 0);
|
||||
if (s)
|
||||
{
|
||||
if ((global.params.warnings ||
|
||||
global.params.Dversion > 1) &&
|
||||
ident == Id::length &&
|
||||
sc->scopesym->isArrayScopeSymbol() &&
|
||||
sc->enclosing &&
|
||||
sc->enclosing->search(loc, ident, NULL))
|
||||
{
|
||||
warning(s->loc, "array 'length' hides other 'length' name in outer scope");
|
||||
}
|
||||
assert(sc != sc->enclosing);
|
||||
if (sc->scopesym)
|
||||
{
|
||||
//printf("\tlooking in scopesym '%s', kind = '%s'\n", sc->scopesym->toChars(), sc->scopesym->kind());
|
||||
s = sc->scopesym->search(loc, ident, 0);
|
||||
if (s)
|
||||
{
|
||||
if ((global.params.warnings ||
|
||||
global.params.Dversion > 1) &&
|
||||
ident == Id::length &&
|
||||
sc->scopesym->isArrayScopeSymbol() &&
|
||||
sc->enclosing &&
|
||||
sc->enclosing->search(loc, ident, NULL))
|
||||
{
|
||||
warning(s->loc, "array 'length' hides other 'length' name in outer scope");
|
||||
}
|
||||
|
||||
//printf("\tfound %s.%s, kind = '%s'\n", s->parent ? s->parent->toChars() : "", s->toChars(), s->kind());
|
||||
if (pscopesym)
|
||||
*pscopesym = sc->scopesym;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
//printf("\tfound %s.%s, kind = '%s'\n", s->parent ? s->parent->toChars() : "", s->toChars(), s->kind());
|
||||
if (pscopesym)
|
||||
*pscopesym = sc->scopesym;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -279,14 +279,14 @@ Dsymbol *Scope::insert(Dsymbol *s)
|
||||
|
||||
for (sc = this; sc; sc = sc->enclosing)
|
||||
{
|
||||
//printf("\tsc = %p\n", sc);
|
||||
if (sc->scopesym)
|
||||
{
|
||||
//printf("\t\tsc->scopesym = %p\n", sc->scopesym);
|
||||
if (!sc->scopesym->symtab)
|
||||
sc->scopesym->symtab = new DsymbolTable();
|
||||
return sc->scopesym->symtabInsert(s);
|
||||
}
|
||||
//printf("\tsc = %p\n", sc);
|
||||
if (sc->scopesym)
|
||||
{
|
||||
//printf("\t\tsc->scopesym = %p\n", sc->scopesym);
|
||||
if (!sc->scopesym->symtab)
|
||||
sc->scopesym->symtab = new DsymbolTable();
|
||||
return sc->scopesym->symtabInsert(s);
|
||||
}
|
||||
}
|
||||
assert(0);
|
||||
return NULL;
|
||||
@@ -301,14 +301,14 @@ ClassDeclaration *Scope::getClassScope()
|
||||
|
||||
for (sc = this; sc; sc = sc->enclosing)
|
||||
{
|
||||
ClassDeclaration *cd;
|
||||
|
||||
if (sc->scopesym)
|
||||
{
|
||||
cd = sc->scopesym->isClassDeclaration();
|
||||
if (cd)
|
||||
return cd;
|
||||
}
|
||||
ClassDeclaration *cd;
|
||||
|
||||
if (sc->scopesym)
|
||||
{
|
||||
cd = sc->scopesym->isClassDeclaration();
|
||||
if (cd)
|
||||
return cd;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -322,19 +322,19 @@ AggregateDeclaration *Scope::getStructClassScope()
|
||||
|
||||
for (sc = this; sc; sc = sc->enclosing)
|
||||
{
|
||||
AggregateDeclaration *ad;
|
||||
|
||||
if (sc->scopesym)
|
||||
{
|
||||
ad = sc->scopesym->isClassDeclaration();
|
||||
if (ad)
|
||||
return ad;
|
||||
else
|
||||
{ ad = sc->scopesym->isStructDeclaration();
|
||||
if (ad)
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
AggregateDeclaration *ad;
|
||||
|
||||
if (sc->scopesym)
|
||||
{
|
||||
ad = sc->scopesym->isClassDeclaration();
|
||||
if (ad)
|
||||
return ad;
|
||||
else
|
||||
{ ad = sc->scopesym->isStructDeclaration();
|
||||
if (ad)
|
||||
return ad;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -352,14 +352,14 @@ void Scope::setNoFree()
|
||||
//printf("Scope::setNoFree(this = %p)\n", this);
|
||||
for (sc = this; sc; sc = sc->enclosing)
|
||||
{
|
||||
//printf("\tsc = %p\n", sc);
|
||||
sc->nofree = 1;
|
||||
//printf("\tsc = %p\n", sc);
|
||||
sc->nofree = 1;
|
||||
|
||||
assert(!(flags & SCOPEfree));
|
||||
//assert(sc != sc->enclosing);
|
||||
//assert(!sc->enclosing || sc != sc->enclosing->enclosing);
|
||||
//if (++i == 10)
|
||||
//assert(0);
|
||||
assert(!(flags & SCOPEfree));
|
||||
//assert(sc != sc->enclosing);
|
||||
//assert(!sc->enclosing || sc != sc->enclosing->enclosing);
|
||||
//if (++i == 10)
|
||||
//assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ void *scope_search_fp(void *arg, const char *seed)
|
||||
Dsymbol *Scope::search_correct(Identifier *ident)
|
||||
{
|
||||
if (global.gag)
|
||||
return NULL; // don't do it for speculative compiles; too time consuming
|
||||
return NULL; // don't do it for speculative compiles; too time consuming
|
||||
|
||||
return (Dsymbol *)speller(ident->toChars(), &scope_search_fp, this, idchars);
|
||||
}
|
||||
|
||||
84
dmd/scope.h
84
dmd/scope.h
@@ -43,63 +43,63 @@ struct AnonDeclaration;
|
||||
#else
|
||||
enum LINK;
|
||||
enum PROT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct Scope
|
||||
{
|
||||
Scope *enclosing; // enclosing Scope
|
||||
Scope *enclosing; // enclosing Scope
|
||||
|
||||
Module *module; // Root module
|
||||
ScopeDsymbol *scopesym; // current symbol
|
||||
ScopeDsymbol *sd; // if in static if, and declaring new symbols,
|
||||
// sd gets the addMember()
|
||||
FuncDeclaration *func; // function we are in
|
||||
Dsymbol *parent; // parent to use
|
||||
LabelStatement *slabel; // enclosing labelled statement
|
||||
SwitchStatement *sw; // enclosing switch statement
|
||||
TryFinallyStatement *enclosingFinally; // enclosing try finally statement; set inside its finally block
|
||||
Module *module; // Root module
|
||||
ScopeDsymbol *scopesym; // current symbol
|
||||
ScopeDsymbol *sd; // if in static if, and declaring new symbols,
|
||||
// sd gets the addMember()
|
||||
FuncDeclaration *func; // function we are in
|
||||
Dsymbol *parent; // parent to use
|
||||
LabelStatement *slabel; // enclosing labelled statement
|
||||
SwitchStatement *sw; // enclosing switch statement
|
||||
TryFinallyStatement *enclosingFinally; // enclosing try finally statement; set inside its finally block
|
||||
TemplateInstance *tinst; // enclosing template instance
|
||||
Statement *enclosingScopeExit; // enclosing statement that wants to do something on scope exit
|
||||
Statement *sbreak; // enclosing statement that supports "break"
|
||||
Statement *scontinue; // enclosing statement that supports "continue"
|
||||
ForeachStatement *fes; // if nested function for ForeachStatement, this is it
|
||||
unsigned offset; // next offset to use in aggregate
|
||||
int inunion; // we're processing members of a union
|
||||
int incontract; // we're inside contract code
|
||||
int nofree; // set if shouldn't free it
|
||||
int noctor; // set if constructor calls aren't allowed
|
||||
int intypeof; // in typeof(exp)
|
||||
Statement *sbreak; // enclosing statement that supports "break"
|
||||
Statement *scontinue; // enclosing statement that supports "continue"
|
||||
ForeachStatement *fes; // if nested function for ForeachStatement, this is it
|
||||
unsigned offset; // next offset to use in aggregate
|
||||
int inunion; // we're processing members of a union
|
||||
int incontract; // we're inside contract code
|
||||
int nofree; // set if shouldn't free it
|
||||
int noctor; // set if constructor calls aren't allowed
|
||||
int intypeof; // in typeof(exp)
|
||||
int parameterSpecialization; // if in template parameter specialization
|
||||
int noaccesscheck; // don't do access checks
|
||||
int mustsemantic; // cannot defer semantic()
|
||||
int noaccesscheck; // don't do access checks
|
||||
int mustsemantic; // cannot defer semantic()
|
||||
|
||||
unsigned callSuper; // primitive flow analysis for constructors
|
||||
#define CSXthis_ctor 1 // called this()
|
||||
#define CSXsuper_ctor 2 // called super()
|
||||
#define CSXthis 4 // referenced this
|
||||
#define CSXsuper 8 // referenced super
|
||||
#define CSXlabel 0x10 // seen a label
|
||||
#define CSXreturn 0x20 // seen a return statement
|
||||
#define CSXany_ctor 0x40 // either this() or super() was called
|
||||
unsigned callSuper; // primitive flow analysis for constructors
|
||||
#define CSXthis_ctor 1 // called this()
|
||||
#define CSXsuper_ctor 2 // called super()
|
||||
#define CSXthis 4 // referenced this
|
||||
#define CSXsuper 8 // referenced super
|
||||
#define CSXlabel 0x10 // seen a label
|
||||
#define CSXreturn 0x20 // seen a return statement
|
||||
#define CSXany_ctor 0x40 // either this() or super() was called
|
||||
|
||||
unsigned structalign; // alignment for struct members
|
||||
enum LINK linkage; // linkage for external functions
|
||||
unsigned structalign; // alignment for struct members
|
||||
enum LINK linkage; // linkage for external functions
|
||||
|
||||
enum PROT protection; // protection for class members
|
||||
int explicitProtection; // set if in an explicit protection attribute
|
||||
enum PROT protection; // protection for class members
|
||||
int explicitProtection; // set if in an explicit protection attribute
|
||||
|
||||
StorageClass stc; // storage class
|
||||
StorageClass stc; // storage class
|
||||
|
||||
unsigned flags;
|
||||
#define SCOPEctor 1 // constructor type
|
||||
#define SCOPEstaticif 2 // inside static if
|
||||
#define SCOPEfree 4 // is on free list
|
||||
#define SCOPEctor 1 // constructor type
|
||||
#define SCOPEstaticif 2 // inside static if
|
||||
#define SCOPEfree 4 // is on free list
|
||||
|
||||
AnonymousAggregateDeclaration *anonAgg; // for temporary analysis
|
||||
AnonymousAggregateDeclaration *anonAgg; // for temporary analysis
|
||||
|
||||
DocComment *lastdc; // documentation comment for last symbol at this scope
|
||||
unsigned lastoffset; // offset in docbuf of where to insert next dec
|
||||
OutBuffer *docbuf; // buffer for documentation output
|
||||
DocComment *lastdc; // documentation comment for last symbol at this scope
|
||||
unsigned lastoffset; // offset in docbuf of where to insert next dec
|
||||
OutBuffer *docbuf; // buffer for documentation output
|
||||
|
||||
static Scope *freelist;
|
||||
static void *operator new(size_t sz);
|
||||
|
||||
3360
dmd/statement.c
3360
dmd/statement.c
File diff suppressed because it is too large
Load Diff
@@ -84,13 +84,13 @@ struct code;
|
||||
*/
|
||||
enum BE
|
||||
{
|
||||
BEnone = 0,
|
||||
BEnone = 0,
|
||||
BEfallthru = 1,
|
||||
BEthrow = 2,
|
||||
BEreturn = 4,
|
||||
BEgoto = 8,
|
||||
BEhalt = 0x10,
|
||||
BEbreak = 0x20,
|
||||
BEhalt = 0x10,
|
||||
BEbreak = 0x20,
|
||||
BEcontinue = 0x40,
|
||||
BEany = (BEfallthru | BEthrow | BEreturn | BEgoto | BEhalt),
|
||||
};
|
||||
@@ -357,18 +357,18 @@ struct ForStatement : Statement
|
||||
|
||||
struct ForeachStatement : Statement
|
||||
{
|
||||
enum TOK op; // TOKforeach or TOKforeach_reverse
|
||||
Parameters *arguments; // array of Parameter*'s
|
||||
enum TOK op; // TOKforeach or TOKforeach_reverse
|
||||
Parameters *arguments; // array of Parameter*'s
|
||||
Expression *aggr;
|
||||
Statement *body;
|
||||
|
||||
VarDeclaration *key;
|
||||
VarDeclaration *value;
|
||||
|
||||
FuncDeclaration *func; // function we're lexically in
|
||||
FuncDeclaration *func; // function we're lexically in
|
||||
|
||||
Array cases; // put breaks, continues, gotos and returns here
|
||||
Array gotos; // forward referenced goto's go here
|
||||
Array cases; // put breaks, continues, gotos and returns here
|
||||
Array gotos; // forward referenced goto's go here
|
||||
|
||||
ForeachStatement(Loc loc, enum TOK op, Parameters *arguments, Expression *aggr, Statement *body);
|
||||
Statement *syntaxCopy();
|
||||
@@ -389,8 +389,8 @@ struct ForeachStatement : Statement
|
||||
#if DMDV2
|
||||
struct ForeachRangeStatement : Statement
|
||||
{
|
||||
enum TOK op; // TOKforeach or TOKforeach_reverse
|
||||
Parameter *arg; // loop index variable
|
||||
enum TOK op; // TOKforeach or TOKforeach_reverse
|
||||
Parameter *arg; // loop index variable
|
||||
Expression *lwr;
|
||||
Expression *upr;
|
||||
Statement *body;
|
||||
@@ -398,7 +398,7 @@ struct ForeachRangeStatement : Statement
|
||||
VarDeclaration *key;
|
||||
|
||||
ForeachRangeStatement(Loc loc, enum TOK op, Parameter *arg,
|
||||
Expression *lwr, Expression *upr, Statement *body);
|
||||
Expression *lwr, Expression *upr, Statement *body);
|
||||
Statement *syntaxCopy();
|
||||
Statement *semantic(Scope *sc);
|
||||
int hasBreak();
|
||||
@@ -422,7 +422,7 @@ struct IfStatement : Statement
|
||||
Statement *ifbody;
|
||||
Statement *elsebody;
|
||||
|
||||
VarDeclaration *match; // for MatchExpression results
|
||||
VarDeclaration *match; // for MatchExpression results
|
||||
|
||||
IfStatement(Loc loc, Parameter *arg, Expression *condition, Statement *ifbody, Statement *elsebody);
|
||||
Statement *syntaxCopy();
|
||||
@@ -459,7 +459,7 @@ struct ConditionalStatement : Statement
|
||||
struct PragmaStatement : Statement
|
||||
{
|
||||
Identifier *ident;
|
||||
Expressions *args; // array of Expression's
|
||||
Expressions *args; // array of Expression's
|
||||
Statement *body;
|
||||
|
||||
PragmaStatement(Loc loc, Identifier *ident, Expressions *args, Statement *body);
|
||||
@@ -490,9 +490,9 @@ struct SwitchStatement : Statement
|
||||
|
||||
DefaultStatement *sdefault;
|
||||
|
||||
Array gotoCases; // array of unresolved GotoCaseStatement's
|
||||
Array *cases; // array of CaseStatement's
|
||||
int hasNoDefault; // !=0 if no default statement
|
||||
Array gotoCases; // array of unresolved GotoCaseStatement's
|
||||
Array *cases; // array of CaseStatement's
|
||||
int hasNoDefault; // !=0 if no default statement
|
||||
|
||||
// LDC
|
||||
Statement *enclosingScopeExit;
|
||||
@@ -516,8 +516,8 @@ struct CaseStatement : Statement
|
||||
Expression *exp;
|
||||
Statement *statement;
|
||||
|
||||
int index; // which case it is (since we sort this)
|
||||
block *cblock; // back end: label for the block
|
||||
int index; // which case it is (since we sort this)
|
||||
block *cblock; // back end: label for the block
|
||||
|
||||
// LDC
|
||||
Statement *enclosingScopeExit;
|
||||
@@ -563,7 +563,7 @@ struct DefaultStatement : Statement
|
||||
{
|
||||
Statement *statement;
|
||||
#if IN_GCC
|
||||
block *cblock; // back end: label for the block
|
||||
block *cblock; // back end: label for the block
|
||||
#endif
|
||||
|
||||
// LDC
|
||||
@@ -602,8 +602,8 @@ struct GotoDefaultStatement : Statement
|
||||
|
||||
struct GotoCaseStatement : Statement
|
||||
{
|
||||
Expression *exp; // NULL, or which case to goto
|
||||
CaseStatement *cs; // case statement it resolves to
|
||||
Expression *exp; // NULL, or which case to goto
|
||||
CaseStatement *cs; // case statement it resolves to
|
||||
SwitchStatement *sw;
|
||||
|
||||
GotoCaseStatement(Loc loc, Expression *exp);
|
||||
@@ -844,7 +844,7 @@ struct LabelStatement : Statement
|
||||
Statement *statement;
|
||||
TryFinallyStatement *enclosingFinally;
|
||||
Statement* enclosingScopeExit;
|
||||
block *lblock; // back end
|
||||
block *lblock; // back end
|
||||
int isReturnLabel;
|
||||
|
||||
LabelStatement(Loc loc, Identifier *ident, Statement *statement);
|
||||
@@ -880,9 +880,9 @@ struct AsmStatement : Statement
|
||||
{
|
||||
Token *tokens;
|
||||
code *asmcode;
|
||||
unsigned asmalign; // alignment of this statement
|
||||
unsigned refparam; // !=0 if function parameter is referenced
|
||||
unsigned naked; // !=0 if function is to be naked
|
||||
unsigned asmalign; // alignment of this statement
|
||||
unsigned refparam; // !=0 if function parameter is referenced
|
||||
unsigned naked; // !=0 if function is to be naked
|
||||
|
||||
AsmStatement(Loc loc, Token *tokens);
|
||||
Statement *syntaxCopy();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
/********************************* AttribDeclaration ****************************/
|
||||
|
||||
StaticAssert::StaticAssert(Loc loc, Expression *exp, Expression *msg)
|
||||
: Dsymbol(Id::empty)
|
||||
: Dsymbol(Id::empty)
|
||||
{
|
||||
this->loc = loc;
|
||||
this->exp = exp;
|
||||
@@ -42,7 +42,7 @@ Dsymbol *StaticAssert::syntaxCopy(Dsymbol *s)
|
||||
|
||||
int StaticAssert::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
||||
{
|
||||
return 0; // we didn't add anything
|
||||
return 0; // we didn't add anything
|
||||
}
|
||||
|
||||
void StaticAssert::semantic(Scope *sc)
|
||||
@@ -58,26 +58,26 @@ void StaticAssert::semantic2(Scope *sc)
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
if (e->isBool(FALSE))
|
||||
{
|
||||
if (msg)
|
||||
{ HdrGenState hgs;
|
||||
OutBuffer buf;
|
||||
if (msg)
|
||||
{ HdrGenState hgs;
|
||||
OutBuffer buf;
|
||||
|
||||
msg = msg->semantic(sc);
|
||||
msg = msg->optimize(WANTvalue | WANTinterpret);
|
||||
hgs.console = 1;
|
||||
msg->toCBuffer(&buf, &hgs);
|
||||
error("%s", buf.toChars());
|
||||
}
|
||||
else
|
||||
error("(%s) is false", exp->toChars());
|
||||
if (sc->tinst)
|
||||
sc->tinst->printInstantiationTrace();
|
||||
if (!global.gag)
|
||||
fatal();
|
||||
msg = msg->semantic(sc);
|
||||
msg = msg->optimize(WANTvalue | WANTinterpret);
|
||||
hgs.console = 1;
|
||||
msg->toCBuffer(&buf, &hgs);
|
||||
error("%s", buf.toChars());
|
||||
}
|
||||
else
|
||||
error("(%s) is false", exp->toChars());
|
||||
if (sc->tinst)
|
||||
sc->tinst->printInstantiationTrace();
|
||||
if (!global.gag)
|
||||
fatal();
|
||||
}
|
||||
else if (!e->isBool(TRUE))
|
||||
{
|
||||
error("(%s) is not evaluatable at compile time", exp->toChars());
|
||||
error("(%s) is not evaluatable at compile time", exp->toChars());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ void StaticAssert::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
exp->toCBuffer(buf, hgs);
|
||||
if (msg)
|
||||
{
|
||||
buf->writeByte(',');
|
||||
msg->toCBuffer(buf, hgs);
|
||||
buf->writeByte(',');
|
||||
msg->toCBuffer(buf, hgs);
|
||||
}
|
||||
buf->writestring(");");
|
||||
buf->writenl();
|
||||
|
||||
346
dmd/struct.c
346
dmd/struct.c
@@ -32,11 +32,11 @@ AggregateDeclaration::AggregateDeclaration(Loc loc, Identifier *id)
|
||||
protection = PROTpublic;
|
||||
type = NULL;
|
||||
handle = NULL;
|
||||
structsize = 0; // size of struct
|
||||
alignsize = 0; // size of struct for alignment purposes
|
||||
structalign = 0; // struct member alignment in effect
|
||||
structsize = 0; // size of struct
|
||||
alignsize = 0; // size of struct for alignment purposes
|
||||
structalign = 0; // struct member alignment in effect
|
||||
hasUnions = 0;
|
||||
sizeok = 0; // size not determined yet
|
||||
sizeok = 0; // size not determined yet
|
||||
isdeprecated = 0;
|
||||
inv = NULL;
|
||||
aggNew = NULL;
|
||||
@@ -67,18 +67,18 @@ void AggregateDeclaration::semantic2(Scope *sc)
|
||||
{
|
||||
//printf("AggregateDeclaration::semantic2(%s)\n", toChars());
|
||||
if (scope && members)
|
||||
{ error("has forward references");
|
||||
return;
|
||||
{ error("has forward references");
|
||||
return;
|
||||
}
|
||||
if (members)
|
||||
{
|
||||
sc = sc->push(this);
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
s->semantic2(sc);
|
||||
}
|
||||
sc->pop();
|
||||
sc = sc->push(this);
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
s->semantic2(sc);
|
||||
}
|
||||
sc->pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,13 +92,13 @@ void AggregateDeclaration::semantic3(Scope *sc)
|
||||
//printf("AggregateDeclaration::semantic3(%s)\n", toChars());
|
||||
if (members)
|
||||
{
|
||||
sc = sc->push(this);
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
s->semantic3(sc);
|
||||
}
|
||||
sc->pop();
|
||||
sc = sc->push(this);
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
s->semantic3(sc);
|
||||
}
|
||||
sc->pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,12 +108,12 @@ void AggregateDeclaration::inlineScan()
|
||||
//printf("AggregateDeclaration::inlineScan(%s)\n", toChars());
|
||||
if (members)
|
||||
{
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
//printf("inline scan aggregate symbol '%s'\n", s->toChars());
|
||||
s->inlineScan();
|
||||
}
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
//printf("inline scan aggregate symbol '%s'\n", s->toChars());
|
||||
s->inlineScan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,10 +121,10 @@ unsigned AggregateDeclaration::size(Loc loc)
|
||||
{
|
||||
//printf("AggregateDeclaration::size() = %d\n", structsize);
|
||||
if (!members)
|
||||
error(loc, "unknown size");
|
||||
error(loc, "unknown size");
|
||||
if (sizeok != 1)
|
||||
{ error(loc, "no size yet for forward reference");
|
||||
//*(char*)0=0;
|
||||
{ error(loc, "no size yet for forward reference");
|
||||
//*(char*)0=0;
|
||||
}
|
||||
return structsize;
|
||||
}
|
||||
@@ -145,18 +145,18 @@ int AggregateDeclaration::isDeprecated()
|
||||
*/
|
||||
|
||||
void AggregateDeclaration::alignmember(
|
||||
unsigned salign, // struct alignment that is in effect
|
||||
unsigned size, // alignment requirement of field
|
||||
unsigned *poffset)
|
||||
unsigned salign, // struct alignment that is in effect
|
||||
unsigned size, // alignment requirement of field
|
||||
unsigned *poffset)
|
||||
{
|
||||
//printf("salign = %d, size = %d, offset = %d\n",salign,size,offset);
|
||||
if (salign > 1)
|
||||
{
|
||||
assert(size != 3);
|
||||
int sa = size;
|
||||
if (sa == 0 || salign < sa)
|
||||
sa = salign;
|
||||
*poffset = (*poffset + sa - 1) & ~(sa - 1);
|
||||
assert(size != 3);
|
||||
int sa = size;
|
||||
if (sa == 0 || salign < sa)
|
||||
sa = salign;
|
||||
*poffset = (*poffset + sa - 1) & ~(sa - 1);
|
||||
}
|
||||
//printf("result = %d\n",offset);
|
||||
}
|
||||
@@ -164,33 +164,33 @@ void AggregateDeclaration::alignmember(
|
||||
|
||||
void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
|
||||
{
|
||||
unsigned memsize; // size of member
|
||||
unsigned memalignsize; // size of member for alignment purposes
|
||||
unsigned xalign; // alignment boundaries
|
||||
unsigned memsize; // size of member
|
||||
unsigned memalignsize; // size of member for alignment purposes
|
||||
unsigned xalign; // alignment boundaries
|
||||
|
||||
//printf("AggregateDeclaration::addField('%s') %s\n", v->toChars(), toChars());
|
||||
|
||||
// Check for forward referenced types which will fail the size() call
|
||||
Type *t = v->type->toBasetype();
|
||||
if (t->ty == Tstruct /*&& isStructDeclaration()*/)
|
||||
{ TypeStruct *ts = (TypeStruct *)t;
|
||||
{ TypeStruct *ts = (TypeStruct *)t;
|
||||
#if DMDV2
|
||||
if (ts->sym == this)
|
||||
{
|
||||
error("cannot have field %s with same struct type", v->toChars());
|
||||
}
|
||||
if (ts->sym == this)
|
||||
{
|
||||
error("cannot have field %s with same struct type", v->toChars());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ts->sym->sizeok != 1)
|
||||
{
|
||||
sizeok = 2; // cannot finish; flag as forward referenced
|
||||
return;
|
||||
}
|
||||
if (ts->sym->sizeok != 1)
|
||||
{
|
||||
sizeok = 2; // cannot finish; flag as forward referenced
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (t->ty == Tident)
|
||||
{
|
||||
sizeok = 2; // cannot finish; flag as forward referenced
|
||||
return;
|
||||
sizeok = 2; // cannot finish; flag as forward referenced
|
||||
return;
|
||||
}
|
||||
|
||||
memsize = v->type->size(loc);
|
||||
@@ -200,11 +200,11 @@ void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
|
||||
v->offset = sc->offset;
|
||||
sc->offset += memsize;
|
||||
if (sc->offset > structsize)
|
||||
structsize = sc->offset;
|
||||
structsize = sc->offset;
|
||||
if (sc->structalign < memalignsize)
|
||||
memalignsize = sc->structalign;
|
||||
memalignsize = sc->structalign;
|
||||
if (alignsize < memalignsize)
|
||||
alignsize = memalignsize;
|
||||
alignsize = memalignsize;
|
||||
//printf("\talignsize = %d\n", alignsize);
|
||||
|
||||
v->storage_class |= STCfield;
|
||||
@@ -218,7 +218,7 @@ void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
|
||||
StructDeclaration::StructDeclaration(Loc loc, Identifier *id)
|
||||
: AggregateDeclaration(loc, id)
|
||||
{
|
||||
zeroInit = 0; // assume false until we do semantic processing
|
||||
zeroInit = 0; // assume false until we do semantic processing
|
||||
#if DMDV2
|
||||
hasIdentityAssign = 0;
|
||||
cpctor = NULL;
|
||||
@@ -234,9 +234,9 @@ Dsymbol *StructDeclaration::syntaxCopy(Dsymbol *s)
|
||||
StructDeclaration *sd;
|
||||
|
||||
if (s)
|
||||
sd = (StructDeclaration *)s;
|
||||
sd = (StructDeclaration *)s;
|
||||
else
|
||||
sd = new StructDeclaration(loc, ident);
|
||||
sd = new StructDeclaration(loc, ident);
|
||||
ScopeDsymbol::syntaxCopy(sd);
|
||||
return sd;
|
||||
}
|
||||
@@ -250,15 +250,15 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
//static int count; if (++count == 20) *(char*)0=0;
|
||||
|
||||
assert(type);
|
||||
if (!members) // if forward reference
|
||||
return;
|
||||
if (!members) // if forward reference
|
||||
return;
|
||||
|
||||
if (symtab)
|
||||
{ if (sizeok == 1 || !scope)
|
||||
{ //printf("already completed\n");
|
||||
scope = NULL;
|
||||
{ //printf("already completed\n");
|
||||
scope = NULL;
|
||||
return; // semantic() already completed
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
symtab = new DsymbolTable();
|
||||
@@ -282,10 +282,10 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
structalign = sc->structalign;
|
||||
protection = sc->protection;
|
||||
if (sc->stc & STCdeprecated)
|
||||
isdeprecated = 1;
|
||||
isdeprecated = 1;
|
||||
assert(!isAnonymous());
|
||||
if (sc->stc & STCabstract)
|
||||
error("structs, unions cannot be abstract");
|
||||
error("structs, unions cannot be abstract");
|
||||
#if DMDV2
|
||||
if (storage_class & STCimmutable)
|
||||
type = type->invariantOf();
|
||||
@@ -293,14 +293,14 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
type = type->constOf();
|
||||
#endif
|
||||
|
||||
if (sizeok == 0) // if not already done the addMember step
|
||||
if (sizeok == 0) // if not already done the addMember step
|
||||
{
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
//printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars());
|
||||
s->addMember(sc, this, 1);
|
||||
}
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
//printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars());
|
||||
s->addMember(sc, this, 1);
|
||||
}
|
||||
}
|
||||
|
||||
sizeok = 0;
|
||||
@@ -308,7 +308,7 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
sc2->stc = 0;
|
||||
sc2->parent = this;
|
||||
if (isUnionDeclaration())
|
||||
sc2->inunion = 1;
|
||||
sc2->inunion = 1;
|
||||
sc2->protection = PROTpublic;
|
||||
sc2->explicitProtection = 0;
|
||||
|
||||
@@ -318,28 +318,28 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
* resolve individual members like enums.
|
||||
*/
|
||||
for (int i = 0; i < members_dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
/* There are problems doing this in the general case because
|
||||
* Scope keeps track of things like 'offset'
|
||||
*/
|
||||
if (s->isEnumDeclaration() || (s->isAggregateDeclaration() && s->ident))
|
||||
{
|
||||
//printf("setScope %s %s\n", s->kind(), s->toChars());
|
||||
s->setScope(sc2);
|
||||
}
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
/* There are problems doing this in the general case because
|
||||
* Scope keeps track of things like 'offset'
|
||||
*/
|
||||
if (s->isEnumDeclaration() || (s->isAggregateDeclaration() && s->ident))
|
||||
{
|
||||
//printf("setScope %s %s\n", s->kind(), s->toChars());
|
||||
s->setScope(sc2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < members_dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
s->semantic(sc2);
|
||||
if (isUnionDeclaration())
|
||||
sc2->offset = 0;
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
s->semantic(sc2);
|
||||
if (isUnionDeclaration())
|
||||
sc2->offset = 0;
|
||||
#if 0
|
||||
if (sizeok == 2)
|
||||
{ //printf("forward reference\n");
|
||||
break;
|
||||
}
|
||||
if (sizeok == 2)
|
||||
{ //printf("forward reference\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -347,58 +347,58 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
* a parameter that is a pointer to the struct. But if there
|
||||
* isn't one, but is an opEquals or opCmp with a value, write
|
||||
* another that is a shell around the value:
|
||||
* int opCmp(struct *p) { return opCmp(*p); }
|
||||
* int opCmp(struct *p) { return opCmp(*p); }
|
||||
*/
|
||||
|
||||
TypeFunction *tfeqptr;
|
||||
{
|
||||
Parameters *arguments = new Parameters;
|
||||
Parameter *arg = new Parameter(STCin, handle, Id::p, NULL);
|
||||
Parameters *arguments = new Parameters;
|
||||
Parameter *arg = new Parameter(STCin, handle, Id::p, NULL);
|
||||
|
||||
arguments->push(arg);
|
||||
tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
||||
tfeqptr = (TypeFunction *)tfeqptr->semantic(0, sc);
|
||||
arguments->push(arg);
|
||||
tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
||||
tfeqptr = (TypeFunction *)tfeqptr->semantic(0, sc);
|
||||
}
|
||||
|
||||
TypeFunction *tfeq;
|
||||
{
|
||||
Parameters *arguments = new Parameters;
|
||||
Parameter *arg = new Parameter(STCin, type, NULL, NULL);
|
||||
Parameters *arguments = new Parameters;
|
||||
Parameter *arg = new Parameter(STCin, type, NULL, NULL);
|
||||
|
||||
arguments->push(arg);
|
||||
tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
||||
tfeq = (TypeFunction *)tfeq->semantic(0, sc);
|
||||
arguments->push(arg);
|
||||
tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
||||
tfeq = (TypeFunction *)tfeq->semantic(0, sc);
|
||||
}
|
||||
|
||||
Identifier *id = Id::eq;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Dsymbol *s = search_function(this, id);
|
||||
FuncDeclaration *fdx = s ? s->isFuncDeclaration() : NULL;
|
||||
if (fdx)
|
||||
{ FuncDeclaration *fd = fdx->overloadExactMatch(tfeqptr, getModule());
|
||||
if (!fd)
|
||||
{ fd = fdx->overloadExactMatch(tfeq, getModule());
|
||||
if (fd)
|
||||
{ // Create the thunk, fdptr
|
||||
FuncDeclaration *fdptr = new FuncDeclaration(loc, loc, fdx->ident, STCundefined, tfeqptr);
|
||||
Expression *e = new IdentifierExp(loc, Id::p);
|
||||
e = new PtrExp(loc, e);
|
||||
Expressions *args = new Expressions();
|
||||
args->push(e);
|
||||
e = new IdentifierExp(loc, id);
|
||||
e = new CallExp(loc, e, args);
|
||||
fdptr->fbody = new ReturnStatement(loc, e);
|
||||
ScopeDsymbol *s = fdx->parent->isScopeDsymbol();
|
||||
assert(s);
|
||||
s->members->push(fdptr);
|
||||
fdptr->addMember(sc, s, 1);
|
||||
fdptr->semantic(sc2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Dsymbol *s = search_function(this, id);
|
||||
FuncDeclaration *fdx = s ? s->isFuncDeclaration() : NULL;
|
||||
if (fdx)
|
||||
{ FuncDeclaration *fd = fdx->overloadExactMatch(tfeqptr, getModule());
|
||||
if (!fd)
|
||||
{ fd = fdx->overloadExactMatch(tfeq, getModule());
|
||||
if (fd)
|
||||
{ // Create the thunk, fdptr
|
||||
FuncDeclaration *fdptr = new FuncDeclaration(loc, loc, fdx->ident, STCundefined, tfeqptr);
|
||||
Expression *e = new IdentifierExp(loc, Id::p);
|
||||
e = new PtrExp(loc, e);
|
||||
Expressions *args = new Expressions();
|
||||
args->push(e);
|
||||
e = new IdentifierExp(loc, id);
|
||||
e = new CallExp(loc, e, args);
|
||||
fdptr->fbody = new ReturnStatement(loc, e);
|
||||
ScopeDsymbol *s = fdx->parent->isScopeDsymbol();
|
||||
assert(s);
|
||||
s->members->push(fdptr);
|
||||
fdptr->addMember(sc, s, 1);
|
||||
fdptr->semantic(sc2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
id = Id::cmp;
|
||||
id = Id::cmp;
|
||||
}
|
||||
#if DMDV2
|
||||
dtor = buildDtor(sc2);
|
||||
@@ -410,27 +410,27 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
sc2->pop();
|
||||
|
||||
if (sizeok == 2)
|
||||
{ // semantic() failed because of forward references.
|
||||
// Unwind what we did, and defer it for later
|
||||
fields.setDim(0);
|
||||
structsize = 0;
|
||||
alignsize = 0;
|
||||
structalign = 0;
|
||||
{ // semantic() failed because of forward references.
|
||||
// Unwind what we did, and defer it for later
|
||||
fields.setDim(0);
|
||||
structsize = 0;
|
||||
alignsize = 0;
|
||||
structalign = 0;
|
||||
|
||||
scope = scx ? scx : new Scope(*sc);
|
||||
scope->setNoFree();
|
||||
scope->module->addDeferredSemantic(this);
|
||||
scope = scx ? scx : new Scope(*sc);
|
||||
scope->setNoFree();
|
||||
scope->module->addDeferredSemantic(this);
|
||||
|
||||
Module::dprogress = dprogress_save;
|
||||
//printf("\tdeferring %s\n", toChars());
|
||||
return;
|
||||
Module::dprogress = dprogress_save;
|
||||
//printf("\tdeferring %s\n", toChars());
|
||||
return;
|
||||
}
|
||||
|
||||
// 0 sized struct's are set to 1 byte
|
||||
if (structsize == 0)
|
||||
{
|
||||
structsize = 1;
|
||||
alignsize = 1;
|
||||
structsize = 1;
|
||||
alignsize = 1;
|
||||
}
|
||||
|
||||
// Round struct size up to next alignsize boundary.
|
||||
@@ -447,25 +447,25 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
zeroInit = 1;
|
||||
for (i = 0; i < fields.dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||
VarDeclaration *vd = s->isVarDeclaration();
|
||||
if (vd && !vd->isDataseg())
|
||||
{
|
||||
if (vd->init)
|
||||
{
|
||||
// Should examine init to see if it is really all 0's
|
||||
zeroInit = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!vd->type->isZeroInit(loc))
|
||||
{
|
||||
zeroInit = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||
VarDeclaration *vd = s->isVarDeclaration();
|
||||
if (vd && !vd->isDataseg())
|
||||
{
|
||||
if (vd->init)
|
||||
{
|
||||
// Should examine init to see if it is really all 0's
|
||||
zeroInit = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!vd->type->isZeroInit(loc))
|
||||
{
|
||||
zeroInit = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for special member functions.
|
||||
@@ -479,8 +479,8 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
|
||||
if (sc->func)
|
||||
{
|
||||
semantic2(sc);
|
||||
semantic3(sc);
|
||||
semantic2(sc);
|
||||
semantic3(sc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,12 +489,12 @@ Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags)
|
||||
//printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars());
|
||||
|
||||
if (scope)
|
||||
semantic(scope);
|
||||
semantic(scope);
|
||||
|
||||
if (!members || !symtab)
|
||||
{
|
||||
error("is forward referenced when looking for '%s'", ident->toChars());
|
||||
return NULL;
|
||||
error("is forward referenced when looking for '%s'", ident->toChars());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ScopeDsymbol::search(loc, ident, flags);
|
||||
@@ -505,22 +505,22 @@ void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
|
||||
buf->printf("%s ", kind());
|
||||
if (!isAnonymous())
|
||||
buf->writestring(toChars());
|
||||
buf->writestring(toChars());
|
||||
if (!members)
|
||||
{
|
||||
buf->writeByte(';');
|
||||
buf->writenl();
|
||||
return;
|
||||
buf->writeByte(';');
|
||||
buf->writenl();
|
||||
return;
|
||||
}
|
||||
buf->writenl();
|
||||
buf->writeByte('{');
|
||||
buf->writenl();
|
||||
for (i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
|
||||
buf->writestring(" ");
|
||||
s->toCBuffer(buf, hgs);
|
||||
buf->writestring(" ");
|
||||
s->toCBuffer(buf, hgs);
|
||||
}
|
||||
buf->writeByte('}');
|
||||
buf->writenl();
|
||||
@@ -544,9 +544,9 @@ Dsymbol *UnionDeclaration::syntaxCopy(Dsymbol *s)
|
||||
UnionDeclaration *ud;
|
||||
|
||||
if (s)
|
||||
ud = (UnionDeclaration *)s;
|
||||
ud = (UnionDeclaration *)s;
|
||||
else
|
||||
ud = new UnionDeclaration(loc, ident);
|
||||
ud = new UnionDeclaration(loc, ident);
|
||||
StructDeclaration::syntaxCopy(ud);
|
||||
return ud;
|
||||
}
|
||||
|
||||
4512
dmd/template.c
4512
dmd/template.c
File diff suppressed because it is too large
Load Diff
@@ -51,21 +51,21 @@ struct Tuple : Object
|
||||
|
||||
struct TemplateDeclaration : ScopeDsymbol
|
||||
{
|
||||
TemplateParameters *parameters; // array of TemplateParameter's
|
||||
TemplateParameters *parameters; // array of TemplateParameter's
|
||||
|
||||
TemplateParameters *origParameters; // originals for Ddoc
|
||||
TemplateParameters *origParameters; // originals for Ddoc
|
||||
Expression *constraint;
|
||||
Array instances; // array of TemplateInstance's
|
||||
Array instances; // array of TemplateInstance's
|
||||
|
||||
TemplateDeclaration *overnext; // next overloaded TemplateDeclaration
|
||||
TemplateDeclaration *overroot; // first in overnext list
|
||||
TemplateDeclaration *overnext; // next overloaded TemplateDeclaration
|
||||
TemplateDeclaration *overroot; // first in overnext list
|
||||
|
||||
int semanticRun; // 1 semantic() run
|
||||
int semanticRun; // 1 semantic() run
|
||||
|
||||
Dsymbol *onemember; // if !=NULL then one member of this template
|
||||
Dsymbol *onemember; // if !=NULL then one member of this template
|
||||
|
||||
TemplateDeclaration(Loc loc, Identifier *id, TemplateParameters *parameters,
|
||||
Expression *constraint, Array *decldefs);
|
||||
Expression *constraint, Array *decldefs);
|
||||
Dsymbol *syntaxCopy(Dsymbol *);
|
||||
void semantic(Scope *sc);
|
||||
int overloadInsert(Dsymbol *s);
|
||||
@@ -100,15 +100,15 @@ struct TemplateDeclaration : ScopeDsymbol
|
||||
struct TemplateParameter
|
||||
{
|
||||
/* For type-parameter:
|
||||
* template Foo(ident) // specType is set to NULL
|
||||
* template Foo(ident : specType)
|
||||
* template Foo(ident) // specType is set to NULL
|
||||
* template Foo(ident : specType)
|
||||
* For value-parameter:
|
||||
* template Foo(valType ident) // specValue is set to NULL
|
||||
* template Foo(valType ident : specValue)
|
||||
* template Foo(valType ident) // specValue is set to NULL
|
||||
* template Foo(valType ident : specValue)
|
||||
* For alias-parameter:
|
||||
* template Foo(alias ident)
|
||||
* template Foo(alias ident)
|
||||
* For this-parameter:
|
||||
* template Foo(this ident)
|
||||
* template Foo(this ident)
|
||||
*/
|
||||
|
||||
Loc loc;
|
||||
@@ -150,9 +150,9 @@ struct TemplateParameter
|
||||
struct TemplateTypeParameter : TemplateParameter
|
||||
{
|
||||
/* Syntax:
|
||||
* ident : specType = defaultType
|
||||
* ident : specType = defaultType
|
||||
*/
|
||||
Type *specType; // type parameter: if !=NULL, this is the type specialization
|
||||
Type *specType; // type parameter: if !=NULL, this is the type specialization
|
||||
Type *defaultType;
|
||||
|
||||
TemplateTypeParameter(Loc loc, Identifier *ident, Type *specType, Type *defaultType);
|
||||
@@ -174,9 +174,9 @@ struct TemplateTypeParameter : TemplateParameter
|
||||
struct TemplateThisParameter : TemplateTypeParameter
|
||||
{
|
||||
/* Syntax:
|
||||
* this ident : specType = defaultType
|
||||
* this ident : specType = defaultType
|
||||
*/
|
||||
Type *specType; // type parameter: if !=NULL, this is the type specialization
|
||||
Type *specType; // type parameter: if !=NULL, this is the type specialization
|
||||
Type *defaultType;
|
||||
|
||||
TemplateThisParameter(Loc loc, Identifier *ident, Type *specType, Type *defaultType);
|
||||
@@ -190,7 +190,7 @@ struct TemplateThisParameter : TemplateTypeParameter
|
||||
struct TemplateValueParameter : TemplateParameter
|
||||
{
|
||||
/* Syntax:
|
||||
* valType ident : specValue = defaultValue
|
||||
* valType ident : specValue = defaultValue
|
||||
*/
|
||||
|
||||
Type *valType;
|
||||
@@ -217,7 +217,7 @@ struct TemplateValueParameter : TemplateParameter
|
||||
struct TemplateAliasParameter : TemplateParameter
|
||||
{
|
||||
/* Syntax:
|
||||
* specType ident : specAlias = defaultAlias
|
||||
* specType ident : specAlias = defaultAlias
|
||||
*/
|
||||
|
||||
Type *specAliasT;
|
||||
@@ -245,7 +245,7 @@ struct TemplateAliasParameter : TemplateParameter
|
||||
struct TemplateTupleParameter : TemplateParameter
|
||||
{
|
||||
/* Syntax:
|
||||
* ident ...
|
||||
* ident ...
|
||||
*/
|
||||
|
||||
TemplateTupleParameter(Loc loc, Identifier *ident);
|
||||
@@ -266,32 +266,32 @@ struct TemplateTupleParameter : TemplateParameter
|
||||
struct TemplateInstance : ScopeDsymbol
|
||||
{
|
||||
/* Given:
|
||||
* foo!(args) =>
|
||||
* name = foo
|
||||
* tiargs = args
|
||||
* foo!(args) =>
|
||||
* name = foo
|
||||
* tiargs = args
|
||||
*/
|
||||
Identifier *name;
|
||||
//Array idents;
|
||||
Objects *tiargs; // Array of Types/Expressions of template
|
||||
// instance arguments [int*, char, 10*10]
|
||||
Objects *tiargs; // Array of Types/Expressions of template
|
||||
// instance arguments [int*, char, 10*10]
|
||||
|
||||
Objects tdtypes; // Array of Types/Expressions corresponding
|
||||
// to TemplateDeclaration.parameters
|
||||
// [int, char, 100]
|
||||
Objects tdtypes; // Array of Types/Expressions corresponding
|
||||
// to TemplateDeclaration.parameters
|
||||
// [int, char, 100]
|
||||
|
||||
TemplateDeclaration *tempdecl; // referenced by foo.bar.abc
|
||||
TemplateInstance *inst; // refer to existing instance
|
||||
TemplateInstance *tinst; // enclosing template instance
|
||||
ScopeDsymbol *argsym; // argument symbol table
|
||||
AliasDeclaration *aliasdecl; // !=NULL if instance is an alias for its
|
||||
// sole member
|
||||
WithScopeSymbol *withsym; // if a member of a with statement
|
||||
int semanticRun; // has semantic() been done?
|
||||
int semantictiargsdone; // has semanticTiargs() been done?
|
||||
int nest; // for recursion detection
|
||||
int havetempdecl; // 1 if used second constructor
|
||||
Dsymbol *isnested; // if referencing local symbols, this is the context
|
||||
int errors; // 1 if compiled with errors
|
||||
TemplateDeclaration *tempdecl; // referenced by foo.bar.abc
|
||||
TemplateInstance *inst; // refer to existing instance
|
||||
TemplateInstance *tinst; // enclosing template instance
|
||||
ScopeDsymbol *argsym; // argument symbol table
|
||||
AliasDeclaration *aliasdecl; // !=NULL if instance is an alias for its
|
||||
// sole member
|
||||
WithScopeSymbol *withsym; // if a member of a with statement
|
||||
int semanticRun; // has semantic() been done?
|
||||
int semantictiargsdone; // has semanticTiargs() been done?
|
||||
int nest; // for recursion detection
|
||||
int havetempdecl; // 1 if used second constructor
|
||||
Dsymbol *isnested; // if referencing local symbols, this is the context
|
||||
int errors; // 1 if compiled with errors
|
||||
#ifdef IN_GCC
|
||||
/* On some targets, it is necessary to know whether a symbol
|
||||
will be emitted in the output or not before the symbol
|
||||
@@ -308,7 +308,7 @@ struct TemplateInstance : ScopeDsymbol
|
||||
void semantic3(Scope *sc);
|
||||
void inlineScan();
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
Dsymbol *toAlias(); // resolve real symbol
|
||||
Dsymbol *toAlias(); // resolve real symbol
|
||||
const char *kind();
|
||||
int oneMember(Dsymbol **ps);
|
||||
int needsTypeInference(Scope *sc);
|
||||
@@ -317,7 +317,7 @@ struct TemplateInstance : ScopeDsymbol
|
||||
void printInstantiationTrace();
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
#endif
|
||||
|
||||
// Internal
|
||||
@@ -360,7 +360,7 @@ struct TemplateMixin : TemplateInstance
|
||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||
|
||||
#if IN_DMD
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
void toObjFile(int multiobj); // compile to .obj file
|
||||
#endif
|
||||
|
||||
TemplateMixin *isTemplateMixin() { return this; }
|
||||
|
||||
530
dmd/unialpha.c
530
dmd/unialpha.c
@@ -18,269 +18,269 @@ int isUniAlpha(unsigned u)
|
||||
{
|
||||
static unsigned short table[][2] =
|
||||
{
|
||||
{ 0x00AA, 0x00AA },
|
||||
{ 0x00B5, 0x00B5 },
|
||||
{ 0x00B7, 0x00B7 },
|
||||
{ 0x00BA, 0x00BA },
|
||||
{ 0x00C0, 0x00D6 },
|
||||
{ 0x00D8, 0x00F6 },
|
||||
{ 0x00F8, 0x01F5 },
|
||||
{ 0x01FA, 0x0217 },
|
||||
{ 0x0250, 0x02A8 },
|
||||
{ 0x02B0, 0x02B8 },
|
||||
{ 0x02BB, 0x02BB },
|
||||
{ 0x02BD, 0x02C1 },
|
||||
{ 0x02D0, 0x02D1 },
|
||||
{ 0x02E0, 0x02E4 },
|
||||
{ 0x037A, 0x037A },
|
||||
{ 0x0386, 0x0386 },
|
||||
{ 0x0388, 0x038A },
|
||||
{ 0x038C, 0x038C },
|
||||
{ 0x038E, 0x03A1 },
|
||||
{ 0x03A3, 0x03CE },
|
||||
{ 0x03D0, 0x03D6 },
|
||||
{ 0x03DA, 0x03DA },
|
||||
{ 0x03DC, 0x03DC },
|
||||
{ 0x03DE, 0x03DE },
|
||||
{ 0x03E0, 0x03E0 },
|
||||
{ 0x03E2, 0x03F3 },
|
||||
{ 0x0401, 0x040C },
|
||||
{ 0x040E, 0x044F },
|
||||
{ 0x0451, 0x045C },
|
||||
{ 0x045E, 0x0481 },
|
||||
{ 0x0490, 0x04C4 },
|
||||
{ 0x04C7, 0x04C8 },
|
||||
{ 0x04CB, 0x04CC },
|
||||
{ 0x04D0, 0x04EB },
|
||||
{ 0x04EE, 0x04F5 },
|
||||
{ 0x04F8, 0x04F9 },
|
||||
{ 0x0531, 0x0556 },
|
||||
{ 0x0559, 0x0559 },
|
||||
{ 0x0561, 0x0587 },
|
||||
{ 0x05B0, 0x05B9 },
|
||||
{ 0x05BB, 0x05BD },
|
||||
{ 0x05BF, 0x05BF },
|
||||
{ 0x05C1, 0x05C2 },
|
||||
{ 0x05D0, 0x05EA },
|
||||
{ 0x05F0, 0x05F2 },
|
||||
{ 0x0621, 0x063A },
|
||||
{ 0x0640, 0x0652 },
|
||||
{ 0x0660, 0x0669 },
|
||||
{ 0x0670, 0x06B7 },
|
||||
{ 0x06BA, 0x06BE },
|
||||
{ 0x06C0, 0x06CE },
|
||||
{ 0x06D0, 0x06DC },
|
||||
{ 0x06E5, 0x06E8 },
|
||||
{ 0x06EA, 0x06ED },
|
||||
{ 0x06F0, 0x06F9 },
|
||||
{ 0x0901, 0x0903 },
|
||||
{ 0x0905, 0x0939 },
|
||||
{ 0x093D, 0x093D },
|
||||
{ 0x093E, 0x094D },
|
||||
{ 0x0950, 0x0952 },
|
||||
{ 0x0958, 0x0963 },
|
||||
{ 0x0966, 0x096F },
|
||||
{ 0x0981, 0x0983 },
|
||||
{ 0x0985, 0x098C },
|
||||
{ 0x098F, 0x0990 },
|
||||
{ 0x0993, 0x09A8 },
|
||||
{ 0x09AA, 0x09B0 },
|
||||
{ 0x09B2, 0x09B2 },
|
||||
{ 0x09B6, 0x09B9 },
|
||||
{ 0x09BE, 0x09C4 },
|
||||
{ 0x09C7, 0x09C8 },
|
||||
{ 0x09CB, 0x09CD },
|
||||
{ 0x09DC, 0x09DD },
|
||||
{ 0x09DF, 0x09E3 },
|
||||
{ 0x09E6, 0x09EF },
|
||||
{ 0x09F0, 0x09F1 },
|
||||
{ 0x0A02, 0x0A02 },
|
||||
{ 0x0A05, 0x0A0A },
|
||||
{ 0x0A0F, 0x0A10 },
|
||||
{ 0x0A13, 0x0A28 },
|
||||
{ 0x0A2A, 0x0A30 },
|
||||
{ 0x0A32, 0x0A33 },
|
||||
{ 0x0A35, 0x0A36 },
|
||||
{ 0x0A38, 0x0A39 },
|
||||
{ 0x0A3E, 0x0A42 },
|
||||
{ 0x0A47, 0x0A48 },
|
||||
{ 0x0A4B, 0x0A4D },
|
||||
{ 0x0A59, 0x0A5C },
|
||||
{ 0x0A5E, 0x0A5E },
|
||||
{ 0x0A66, 0x0A6F },
|
||||
{ 0x0A74, 0x0A74 },
|
||||
{ 0x0A81, 0x0A83 },
|
||||
{ 0x0A85, 0x0A8B },
|
||||
{ 0x0A8D, 0x0A8D },
|
||||
{ 0x0A8F, 0x0A91 },
|
||||
{ 0x0A93, 0x0AA8 },
|
||||
{ 0x0AAA, 0x0AB0 },
|
||||
{ 0x0AB2, 0x0AB3 },
|
||||
{ 0x0AB5, 0x0AB9 },
|
||||
{ 0x0ABD, 0x0AC5 },
|
||||
{ 0x0AC7, 0x0AC9 },
|
||||
{ 0x0ACB, 0x0ACD },
|
||||
{ 0x0AD0, 0x0AD0 },
|
||||
{ 0x0AE0, 0x0AE0 },
|
||||
{ 0x0AE6, 0x0AEF },
|
||||
{ 0x0B01, 0x0B03 },
|
||||
{ 0x0B05, 0x0B0C },
|
||||
{ 0x0B0F, 0x0B10 },
|
||||
{ 0x0B13, 0x0B28 },
|
||||
{ 0x0B2A, 0x0B30 },
|
||||
{ 0x0B32, 0x0B33 },
|
||||
{ 0x0B36, 0x0B39 },
|
||||
{ 0x0B3D, 0x0B3D },
|
||||
{ 0x0B3E, 0x0B43 },
|
||||
{ 0x0B47, 0x0B48 },
|
||||
{ 0x0B4B, 0x0B4D },
|
||||
{ 0x0B5C, 0x0B5D },
|
||||
{ 0x0B5F, 0x0B61 },
|
||||
{ 0x0B66, 0x0B6F },
|
||||
{ 0x0B82, 0x0B83 },
|
||||
{ 0x0B85, 0x0B8A },
|
||||
{ 0x0B8E, 0x0B90 },
|
||||
{ 0x0B92, 0x0B95 },
|
||||
{ 0x0B99, 0x0B9A },
|
||||
{ 0x0B9C, 0x0B9C },
|
||||
{ 0x0B9E, 0x0B9F },
|
||||
{ 0x0BA3, 0x0BA4 },
|
||||
{ 0x0BA8, 0x0BAA },
|
||||
{ 0x0BAE, 0x0BB5 },
|
||||
{ 0x0BB7, 0x0BB9 },
|
||||
{ 0x0BBE, 0x0BC2 },
|
||||
{ 0x0BC6, 0x0BC8 },
|
||||
{ 0x0BCA, 0x0BCD },
|
||||
{ 0x0BE7, 0x0BEF },
|
||||
{ 0x0C01, 0x0C03 },
|
||||
{ 0x0C05, 0x0C0C },
|
||||
{ 0x0C0E, 0x0C10 },
|
||||
{ 0x0C12, 0x0C28 },
|
||||
{ 0x0C2A, 0x0C33 },
|
||||
{ 0x0C35, 0x0C39 },
|
||||
{ 0x0C3E, 0x0C44 },
|
||||
{ 0x0C46, 0x0C48 },
|
||||
{ 0x0C4A, 0x0C4D },
|
||||
{ 0x0C60, 0x0C61 },
|
||||
{ 0x0C66, 0x0C6F },
|
||||
{ 0x0C82, 0x0C83 },
|
||||
{ 0x0C85, 0x0C8C },
|
||||
{ 0x0C8E, 0x0C90 },
|
||||
{ 0x0C92, 0x0CA8 },
|
||||
{ 0x0CAA, 0x0CB3 },
|
||||
{ 0x0CB5, 0x0CB9 },
|
||||
{ 0x0CBE, 0x0CC4 },
|
||||
{ 0x0CC6, 0x0CC8 },
|
||||
{ 0x0CCA, 0x0CCD },
|
||||
{ 0x0CDE, 0x0CDE },
|
||||
{ 0x0CE0, 0x0CE1 },
|
||||
{ 0x0CE6, 0x0CEF },
|
||||
{ 0x0D02, 0x0D03 },
|
||||
{ 0x0D05, 0x0D0C },
|
||||
{ 0x0D0E, 0x0D10 },
|
||||
{ 0x0D12, 0x0D28 },
|
||||
{ 0x0D2A, 0x0D39 },
|
||||
{ 0x0D3E, 0x0D43 },
|
||||
{ 0x0D46, 0x0D48 },
|
||||
{ 0x0D4A, 0x0D4D },
|
||||
{ 0x0D60, 0x0D61 },
|
||||
{ 0x0D66, 0x0D6F },
|
||||
{ 0x0E01, 0x0E3A },
|
||||
{ 0x0E40, 0x0E5B },
|
||||
// { 0x0E50, 0x0E59 },
|
||||
{ 0x0E81, 0x0E82 },
|
||||
{ 0x0E84, 0x0E84 },
|
||||
{ 0x0E87, 0x0E88 },
|
||||
{ 0x0E8A, 0x0E8A },
|
||||
{ 0x0E8D, 0x0E8D },
|
||||
{ 0x0E94, 0x0E97 },
|
||||
{ 0x0E99, 0x0E9F },
|
||||
{ 0x0EA1, 0x0EA3 },
|
||||
{ 0x0EA5, 0x0EA5 },
|
||||
{ 0x0EA7, 0x0EA7 },
|
||||
{ 0x0EAA, 0x0EAB },
|
||||
{ 0x0EAD, 0x0EAE },
|
||||
{ 0x0EB0, 0x0EB9 },
|
||||
{ 0x0EBB, 0x0EBD },
|
||||
{ 0x0EC0, 0x0EC4 },
|
||||
{ 0x0EC6, 0x0EC6 },
|
||||
{ 0x0EC8, 0x0ECD },
|
||||
{ 0x0ED0, 0x0ED9 },
|
||||
{ 0x0EDC, 0x0EDD },
|
||||
{ 0x0F00, 0x0F00 },
|
||||
{ 0x0F18, 0x0F19 },
|
||||
{ 0x0F20, 0x0F33 },
|
||||
{ 0x0F35, 0x0F35 },
|
||||
{ 0x0F37, 0x0F37 },
|
||||
{ 0x0F39, 0x0F39 },
|
||||
{ 0x0F3E, 0x0F47 },
|
||||
{ 0x0F49, 0x0F69 },
|
||||
{ 0x0F71, 0x0F84 },
|
||||
{ 0x0F86, 0x0F8B },
|
||||
{ 0x0F90, 0x0F95 },
|
||||
{ 0x0F97, 0x0F97 },
|
||||
{ 0x0F99, 0x0FAD },
|
||||
{ 0x0FB1, 0x0FB7 },
|
||||
{ 0x0FB9, 0x0FB9 },
|
||||
{ 0x10A0, 0x10C5 },
|
||||
{ 0x10D0, 0x10F6 },
|
||||
{ 0x1E00, 0x1E9B },
|
||||
{ 0x1EA0, 0x1EF9 },
|
||||
{ 0x1F00, 0x1F15 },
|
||||
{ 0x1F18, 0x1F1D },
|
||||
{ 0x1F20, 0x1F45 },
|
||||
{ 0x1F48, 0x1F4D },
|
||||
{ 0x1F50, 0x1F57 },
|
||||
{ 0x1F59, 0x1F59 },
|
||||
{ 0x1F5B, 0x1F5B },
|
||||
{ 0x1F5D, 0x1F5D },
|
||||
{ 0x1F5F, 0x1F7D },
|
||||
{ 0x1F80, 0x1FB4 },
|
||||
{ 0x1FB6, 0x1FBC },
|
||||
{ 0x1FBE, 0x1FBE },
|
||||
{ 0x1FC2, 0x1FC4 },
|
||||
{ 0x1FC6, 0x1FCC },
|
||||
{ 0x1FD0, 0x1FD3 },
|
||||
{ 0x1FD6, 0x1FDB },
|
||||
{ 0x1FE0, 0x1FEC },
|
||||
{ 0x1FF2, 0x1FF4 },
|
||||
{ 0x1FF6, 0x1FFC },
|
||||
{ 0x203F, 0x2040 },
|
||||
{ 0x207F, 0x207F },
|
||||
{ 0x2102, 0x2102 },
|
||||
{ 0x2107, 0x2107 },
|
||||
{ 0x210A, 0x2113 },
|
||||
{ 0x2115, 0x2115 },
|
||||
{ 0x2118, 0x211D },
|
||||
{ 0x2124, 0x2124 },
|
||||
{ 0x2126, 0x2126 },
|
||||
{ 0x2128, 0x2128 },
|
||||
{ 0x212A, 0x2131 },
|
||||
{ 0x2133, 0x2138 },
|
||||
{ 0x2160, 0x2182 },
|
||||
{ 0x3005, 0x3007 },
|
||||
{ 0x3021, 0x3029 },
|
||||
{ 0x3041, 0x3093 },
|
||||
{ 0x309B, 0x309C },
|
||||
{ 0x30A1, 0x30F6 },
|
||||
{ 0x30FB, 0x30FC },
|
||||
{ 0x3105, 0x312C },
|
||||
{ 0x4E00, 0x9FA5 },
|
||||
{ 0xAC00, 0xD7A3 },
|
||||
{ 0x00AA, 0x00AA },
|
||||
{ 0x00B5, 0x00B5 },
|
||||
{ 0x00B7, 0x00B7 },
|
||||
{ 0x00BA, 0x00BA },
|
||||
{ 0x00C0, 0x00D6 },
|
||||
{ 0x00D8, 0x00F6 },
|
||||
{ 0x00F8, 0x01F5 },
|
||||
{ 0x01FA, 0x0217 },
|
||||
{ 0x0250, 0x02A8 },
|
||||
{ 0x02B0, 0x02B8 },
|
||||
{ 0x02BB, 0x02BB },
|
||||
{ 0x02BD, 0x02C1 },
|
||||
{ 0x02D0, 0x02D1 },
|
||||
{ 0x02E0, 0x02E4 },
|
||||
{ 0x037A, 0x037A },
|
||||
{ 0x0386, 0x0386 },
|
||||
{ 0x0388, 0x038A },
|
||||
{ 0x038C, 0x038C },
|
||||
{ 0x038E, 0x03A1 },
|
||||
{ 0x03A3, 0x03CE },
|
||||
{ 0x03D0, 0x03D6 },
|
||||
{ 0x03DA, 0x03DA },
|
||||
{ 0x03DC, 0x03DC },
|
||||
{ 0x03DE, 0x03DE },
|
||||
{ 0x03E0, 0x03E0 },
|
||||
{ 0x03E2, 0x03F3 },
|
||||
{ 0x0401, 0x040C },
|
||||
{ 0x040E, 0x044F },
|
||||
{ 0x0451, 0x045C },
|
||||
{ 0x045E, 0x0481 },
|
||||
{ 0x0490, 0x04C4 },
|
||||
{ 0x04C7, 0x04C8 },
|
||||
{ 0x04CB, 0x04CC },
|
||||
{ 0x04D0, 0x04EB },
|
||||
{ 0x04EE, 0x04F5 },
|
||||
{ 0x04F8, 0x04F9 },
|
||||
{ 0x0531, 0x0556 },
|
||||
{ 0x0559, 0x0559 },
|
||||
{ 0x0561, 0x0587 },
|
||||
{ 0x05B0, 0x05B9 },
|
||||
{ 0x05BB, 0x05BD },
|
||||
{ 0x05BF, 0x05BF },
|
||||
{ 0x05C1, 0x05C2 },
|
||||
{ 0x05D0, 0x05EA },
|
||||
{ 0x05F0, 0x05F2 },
|
||||
{ 0x0621, 0x063A },
|
||||
{ 0x0640, 0x0652 },
|
||||
{ 0x0660, 0x0669 },
|
||||
{ 0x0670, 0x06B7 },
|
||||
{ 0x06BA, 0x06BE },
|
||||
{ 0x06C0, 0x06CE },
|
||||
{ 0x06D0, 0x06DC },
|
||||
{ 0x06E5, 0x06E8 },
|
||||
{ 0x06EA, 0x06ED },
|
||||
{ 0x06F0, 0x06F9 },
|
||||
{ 0x0901, 0x0903 },
|
||||
{ 0x0905, 0x0939 },
|
||||
{ 0x093D, 0x093D },
|
||||
{ 0x093E, 0x094D },
|
||||
{ 0x0950, 0x0952 },
|
||||
{ 0x0958, 0x0963 },
|
||||
{ 0x0966, 0x096F },
|
||||
{ 0x0981, 0x0983 },
|
||||
{ 0x0985, 0x098C },
|
||||
{ 0x098F, 0x0990 },
|
||||
{ 0x0993, 0x09A8 },
|
||||
{ 0x09AA, 0x09B0 },
|
||||
{ 0x09B2, 0x09B2 },
|
||||
{ 0x09B6, 0x09B9 },
|
||||
{ 0x09BE, 0x09C4 },
|
||||
{ 0x09C7, 0x09C8 },
|
||||
{ 0x09CB, 0x09CD },
|
||||
{ 0x09DC, 0x09DD },
|
||||
{ 0x09DF, 0x09E3 },
|
||||
{ 0x09E6, 0x09EF },
|
||||
{ 0x09F0, 0x09F1 },
|
||||
{ 0x0A02, 0x0A02 },
|
||||
{ 0x0A05, 0x0A0A },
|
||||
{ 0x0A0F, 0x0A10 },
|
||||
{ 0x0A13, 0x0A28 },
|
||||
{ 0x0A2A, 0x0A30 },
|
||||
{ 0x0A32, 0x0A33 },
|
||||
{ 0x0A35, 0x0A36 },
|
||||
{ 0x0A38, 0x0A39 },
|
||||
{ 0x0A3E, 0x0A42 },
|
||||
{ 0x0A47, 0x0A48 },
|
||||
{ 0x0A4B, 0x0A4D },
|
||||
{ 0x0A59, 0x0A5C },
|
||||
{ 0x0A5E, 0x0A5E },
|
||||
{ 0x0A66, 0x0A6F },
|
||||
{ 0x0A74, 0x0A74 },
|
||||
{ 0x0A81, 0x0A83 },
|
||||
{ 0x0A85, 0x0A8B },
|
||||
{ 0x0A8D, 0x0A8D },
|
||||
{ 0x0A8F, 0x0A91 },
|
||||
{ 0x0A93, 0x0AA8 },
|
||||
{ 0x0AAA, 0x0AB0 },
|
||||
{ 0x0AB2, 0x0AB3 },
|
||||
{ 0x0AB5, 0x0AB9 },
|
||||
{ 0x0ABD, 0x0AC5 },
|
||||
{ 0x0AC7, 0x0AC9 },
|
||||
{ 0x0ACB, 0x0ACD },
|
||||
{ 0x0AD0, 0x0AD0 },
|
||||
{ 0x0AE0, 0x0AE0 },
|
||||
{ 0x0AE6, 0x0AEF },
|
||||
{ 0x0B01, 0x0B03 },
|
||||
{ 0x0B05, 0x0B0C },
|
||||
{ 0x0B0F, 0x0B10 },
|
||||
{ 0x0B13, 0x0B28 },
|
||||
{ 0x0B2A, 0x0B30 },
|
||||
{ 0x0B32, 0x0B33 },
|
||||
{ 0x0B36, 0x0B39 },
|
||||
{ 0x0B3D, 0x0B3D },
|
||||
{ 0x0B3E, 0x0B43 },
|
||||
{ 0x0B47, 0x0B48 },
|
||||
{ 0x0B4B, 0x0B4D },
|
||||
{ 0x0B5C, 0x0B5D },
|
||||
{ 0x0B5F, 0x0B61 },
|
||||
{ 0x0B66, 0x0B6F },
|
||||
{ 0x0B82, 0x0B83 },
|
||||
{ 0x0B85, 0x0B8A },
|
||||
{ 0x0B8E, 0x0B90 },
|
||||
{ 0x0B92, 0x0B95 },
|
||||
{ 0x0B99, 0x0B9A },
|
||||
{ 0x0B9C, 0x0B9C },
|
||||
{ 0x0B9E, 0x0B9F },
|
||||
{ 0x0BA3, 0x0BA4 },
|
||||
{ 0x0BA8, 0x0BAA },
|
||||
{ 0x0BAE, 0x0BB5 },
|
||||
{ 0x0BB7, 0x0BB9 },
|
||||
{ 0x0BBE, 0x0BC2 },
|
||||
{ 0x0BC6, 0x0BC8 },
|
||||
{ 0x0BCA, 0x0BCD },
|
||||
{ 0x0BE7, 0x0BEF },
|
||||
{ 0x0C01, 0x0C03 },
|
||||
{ 0x0C05, 0x0C0C },
|
||||
{ 0x0C0E, 0x0C10 },
|
||||
{ 0x0C12, 0x0C28 },
|
||||
{ 0x0C2A, 0x0C33 },
|
||||
{ 0x0C35, 0x0C39 },
|
||||
{ 0x0C3E, 0x0C44 },
|
||||
{ 0x0C46, 0x0C48 },
|
||||
{ 0x0C4A, 0x0C4D },
|
||||
{ 0x0C60, 0x0C61 },
|
||||
{ 0x0C66, 0x0C6F },
|
||||
{ 0x0C82, 0x0C83 },
|
||||
{ 0x0C85, 0x0C8C },
|
||||
{ 0x0C8E, 0x0C90 },
|
||||
{ 0x0C92, 0x0CA8 },
|
||||
{ 0x0CAA, 0x0CB3 },
|
||||
{ 0x0CB5, 0x0CB9 },
|
||||
{ 0x0CBE, 0x0CC4 },
|
||||
{ 0x0CC6, 0x0CC8 },
|
||||
{ 0x0CCA, 0x0CCD },
|
||||
{ 0x0CDE, 0x0CDE },
|
||||
{ 0x0CE0, 0x0CE1 },
|
||||
{ 0x0CE6, 0x0CEF },
|
||||
{ 0x0D02, 0x0D03 },
|
||||
{ 0x0D05, 0x0D0C },
|
||||
{ 0x0D0E, 0x0D10 },
|
||||
{ 0x0D12, 0x0D28 },
|
||||
{ 0x0D2A, 0x0D39 },
|
||||
{ 0x0D3E, 0x0D43 },
|
||||
{ 0x0D46, 0x0D48 },
|
||||
{ 0x0D4A, 0x0D4D },
|
||||
{ 0x0D60, 0x0D61 },
|
||||
{ 0x0D66, 0x0D6F },
|
||||
{ 0x0E01, 0x0E3A },
|
||||
{ 0x0E40, 0x0E5B },
|
||||
// { 0x0E50, 0x0E59 },
|
||||
{ 0x0E81, 0x0E82 },
|
||||
{ 0x0E84, 0x0E84 },
|
||||
{ 0x0E87, 0x0E88 },
|
||||
{ 0x0E8A, 0x0E8A },
|
||||
{ 0x0E8D, 0x0E8D },
|
||||
{ 0x0E94, 0x0E97 },
|
||||
{ 0x0E99, 0x0E9F },
|
||||
{ 0x0EA1, 0x0EA3 },
|
||||
{ 0x0EA5, 0x0EA5 },
|
||||
{ 0x0EA7, 0x0EA7 },
|
||||
{ 0x0EAA, 0x0EAB },
|
||||
{ 0x0EAD, 0x0EAE },
|
||||
{ 0x0EB0, 0x0EB9 },
|
||||
{ 0x0EBB, 0x0EBD },
|
||||
{ 0x0EC0, 0x0EC4 },
|
||||
{ 0x0EC6, 0x0EC6 },
|
||||
{ 0x0EC8, 0x0ECD },
|
||||
{ 0x0ED0, 0x0ED9 },
|
||||
{ 0x0EDC, 0x0EDD },
|
||||
{ 0x0F00, 0x0F00 },
|
||||
{ 0x0F18, 0x0F19 },
|
||||
{ 0x0F20, 0x0F33 },
|
||||
{ 0x0F35, 0x0F35 },
|
||||
{ 0x0F37, 0x0F37 },
|
||||
{ 0x0F39, 0x0F39 },
|
||||
{ 0x0F3E, 0x0F47 },
|
||||
{ 0x0F49, 0x0F69 },
|
||||
{ 0x0F71, 0x0F84 },
|
||||
{ 0x0F86, 0x0F8B },
|
||||
{ 0x0F90, 0x0F95 },
|
||||
{ 0x0F97, 0x0F97 },
|
||||
{ 0x0F99, 0x0FAD },
|
||||
{ 0x0FB1, 0x0FB7 },
|
||||
{ 0x0FB9, 0x0FB9 },
|
||||
{ 0x10A0, 0x10C5 },
|
||||
{ 0x10D0, 0x10F6 },
|
||||
{ 0x1E00, 0x1E9B },
|
||||
{ 0x1EA0, 0x1EF9 },
|
||||
{ 0x1F00, 0x1F15 },
|
||||
{ 0x1F18, 0x1F1D },
|
||||
{ 0x1F20, 0x1F45 },
|
||||
{ 0x1F48, 0x1F4D },
|
||||
{ 0x1F50, 0x1F57 },
|
||||
{ 0x1F59, 0x1F59 },
|
||||
{ 0x1F5B, 0x1F5B },
|
||||
{ 0x1F5D, 0x1F5D },
|
||||
{ 0x1F5F, 0x1F7D },
|
||||
{ 0x1F80, 0x1FB4 },
|
||||
{ 0x1FB6, 0x1FBC },
|
||||
{ 0x1FBE, 0x1FBE },
|
||||
{ 0x1FC2, 0x1FC4 },
|
||||
{ 0x1FC6, 0x1FCC },
|
||||
{ 0x1FD0, 0x1FD3 },
|
||||
{ 0x1FD6, 0x1FDB },
|
||||
{ 0x1FE0, 0x1FEC },
|
||||
{ 0x1FF2, 0x1FF4 },
|
||||
{ 0x1FF6, 0x1FFC },
|
||||
{ 0x203F, 0x2040 },
|
||||
{ 0x207F, 0x207F },
|
||||
{ 0x2102, 0x2102 },
|
||||
{ 0x2107, 0x2107 },
|
||||
{ 0x210A, 0x2113 },
|
||||
{ 0x2115, 0x2115 },
|
||||
{ 0x2118, 0x211D },
|
||||
{ 0x2124, 0x2124 },
|
||||
{ 0x2126, 0x2126 },
|
||||
{ 0x2128, 0x2128 },
|
||||
{ 0x212A, 0x2131 },
|
||||
{ 0x2133, 0x2138 },
|
||||
{ 0x2160, 0x2182 },
|
||||
{ 0x3005, 0x3007 },
|
||||
{ 0x3021, 0x3029 },
|
||||
{ 0x3041, 0x3093 },
|
||||
{ 0x309B, 0x309C },
|
||||
{ 0x30A1, 0x30F6 },
|
||||
{ 0x30FB, 0x30FC },
|
||||
{ 0x3105, 0x312C },
|
||||
{ 0x4E00, 0x9FA5 },
|
||||
{ 0xAC00, 0xD7A3 },
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++)
|
||||
{
|
||||
//printf("%x\n", table[i][0]);
|
||||
assert(table[i][0] <= table[i][1]);
|
||||
if (i < sizeof(table) / sizeof(table[0]) - 1)
|
||||
assert(table[i][1] < table[i + 1][0]);
|
||||
//printf("%x\n", table[i][0]);
|
||||
assert(table[i][0] <= table[i][1]);
|
||||
if (i < sizeof(table) / sizeof(table[0]) - 1)
|
||||
assert(table[i][1] < table[i + 1][0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (u > 0xD7A3)
|
||||
goto Lisnot;
|
||||
goto Lisnot;
|
||||
|
||||
// Binary search
|
||||
int mid;
|
||||
@@ -291,20 +291,20 @@ int isUniAlpha(unsigned u)
|
||||
high = sizeof(table) / sizeof(table[0]) - 1;
|
||||
while (low <= high)
|
||||
{
|
||||
mid = (low + high) >> 1;
|
||||
if (u < table[mid][0])
|
||||
high = mid - 1;
|
||||
else if (u > table[mid][1])
|
||||
low = mid + 1;
|
||||
else
|
||||
goto Lis;
|
||||
mid = (low + high) >> 1;
|
||||
if (u < table[mid][0])
|
||||
high = mid - 1;
|
||||
else if (u > table[mid][1])
|
||||
low = mid + 1;
|
||||
else
|
||||
goto Lis;
|
||||
}
|
||||
|
||||
Lisnot:
|
||||
#ifdef DEBUG
|
||||
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++)
|
||||
{
|
||||
assert(u < table[i][0] || u > table[i][1]);
|
||||
assert(u < table[i][0] || u > table[i][1]);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
@@ -313,10 +313,10 @@ Lis:
|
||||
#ifdef DEBUG
|
||||
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++)
|
||||
{
|
||||
if (u >= table[i][0] && u <= table[i][1])
|
||||
return 1;
|
||||
if (u >= table[i][0] && u <= table[i][1])
|
||||
return 1;
|
||||
}
|
||||
assert(0); // should have been in table
|
||||
assert(0); // should have been in table
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
170
dmd/utf.c
170
dmd/utf.c
@@ -18,14 +18,14 @@
|
||||
int utf_isValidDchar(dchar_t c)
|
||||
{
|
||||
return c < 0xD800 ||
|
||||
(c > 0xDFFF && c <= 0x10FFFF && c != 0xFFFE && c != 0xFFFF);
|
||||
(c > 0xDFFF && c <= 0x10FFFF && c != 0xFFFE && c != 0xFFFF);
|
||||
}
|
||||
|
||||
/********************************************
|
||||
* Decode a single UTF-8 character sequence.
|
||||
* Returns:
|
||||
* NULL success
|
||||
* !=NULL error message string
|
||||
* NULL success
|
||||
* !=NULL error message string
|
||||
*/
|
||||
|
||||
char *utf_decodeChar(unsigned char *s, size_t len, size_t *pidx, dchar_t *presult)
|
||||
@@ -38,65 +38,65 @@ char *utf_decodeChar(unsigned char *s, size_t len, size_t *pidx, dchar_t *presul
|
||||
|
||||
if (u & 0x80)
|
||||
{ unsigned n;
|
||||
unsigned char u2;
|
||||
unsigned char u2;
|
||||
|
||||
/* The following encodings are valid, except for the 5 and 6 byte
|
||||
* combinations:
|
||||
* 0xxxxxxx
|
||||
* 110xxxxx 10xxxxxx
|
||||
* 1110xxxx 10xxxxxx 10xxxxxx
|
||||
* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
*/
|
||||
for (n = 1; ; n++)
|
||||
{
|
||||
if (n > 4)
|
||||
goto Lerr; // only do the first 4 of 6 encodings
|
||||
if (((u << n) & 0x80) == 0)
|
||||
{
|
||||
if (n == 1)
|
||||
goto Lerr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* The following encodings are valid, except for the 5 and 6 byte
|
||||
* combinations:
|
||||
* 0xxxxxxx
|
||||
* 110xxxxx 10xxxxxx
|
||||
* 1110xxxx 10xxxxxx 10xxxxxx
|
||||
* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
*/
|
||||
for (n = 1; ; n++)
|
||||
{
|
||||
if (n > 4)
|
||||
goto Lerr; // only do the first 4 of 6 encodings
|
||||
if (((u << n) & 0x80) == 0)
|
||||
{
|
||||
if (n == 1)
|
||||
goto Lerr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Pick off (7 - n) significant bits of B from first byte of octet
|
||||
V = (dchar_t)(u & ((1 << (7 - n)) - 1));
|
||||
// Pick off (7 - n) significant bits of B from first byte of octet
|
||||
V = (dchar_t)(u & ((1 << (7 - n)) - 1));
|
||||
|
||||
if (i + (n - 1) >= len)
|
||||
goto Lerr; // off end of string
|
||||
if (i + (n - 1) >= len)
|
||||
goto Lerr; // off end of string
|
||||
|
||||
/* The following combinations are overlong, and illegal:
|
||||
* 1100000x (10xxxxxx)
|
||||
* 11100000 100xxxxx (10xxxxxx)
|
||||
* 11110000 1000xxxx (10xxxxxx 10xxxxxx)
|
||||
* 11111000 10000xxx (10xxxxxx 10xxxxxx 10xxxxxx)
|
||||
* 11111100 100000xx (10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
|
||||
*/
|
||||
u2 = s[i + 1];
|
||||
if ((u & 0xFE) == 0xC0 ||
|
||||
(u == 0xE0 && (u2 & 0xE0) == 0x80) ||
|
||||
(u == 0xF0 && (u2 & 0xF0) == 0x80) ||
|
||||
(u == 0xF8 && (u2 & 0xF8) == 0x80) ||
|
||||
(u == 0xFC && (u2 & 0xFC) == 0x80))
|
||||
goto Lerr; // overlong combination
|
||||
/* The following combinations are overlong, and illegal:
|
||||
* 1100000x (10xxxxxx)
|
||||
* 11100000 100xxxxx (10xxxxxx)
|
||||
* 11110000 1000xxxx (10xxxxxx 10xxxxxx)
|
||||
* 11111000 10000xxx (10xxxxxx 10xxxxxx 10xxxxxx)
|
||||
* 11111100 100000xx (10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
|
||||
*/
|
||||
u2 = s[i + 1];
|
||||
if ((u & 0xFE) == 0xC0 ||
|
||||
(u == 0xE0 && (u2 & 0xE0) == 0x80) ||
|
||||
(u == 0xF0 && (u2 & 0xF0) == 0x80) ||
|
||||
(u == 0xF8 && (u2 & 0xF8) == 0x80) ||
|
||||
(u == 0xFC && (u2 & 0xFC) == 0x80))
|
||||
goto Lerr; // overlong combination
|
||||
|
||||
for (unsigned j = 1; j != n; j++)
|
||||
{
|
||||
u = s[i + j];
|
||||
if ((u & 0xC0) != 0x80)
|
||||
goto Lerr; // trailing bytes are 10xxxxxx
|
||||
V = (V << 6) | (u & 0x3F);
|
||||
}
|
||||
if (!utf_isValidDchar(V))
|
||||
goto Lerr;
|
||||
i += n;
|
||||
for (unsigned j = 1; j != n; j++)
|
||||
{
|
||||
u = s[i + j];
|
||||
if ((u & 0xC0) != 0x80)
|
||||
goto Lerr; // trailing bytes are 10xxxxxx
|
||||
V = (V << 6) | (u & 0x3F);
|
||||
}
|
||||
if (!utf_isValidDchar(V))
|
||||
goto Lerr;
|
||||
i += n;
|
||||
}
|
||||
else
|
||||
{
|
||||
V = (dchar_t) u;
|
||||
i++;
|
||||
V = (dchar_t) u;
|
||||
i++;
|
||||
}
|
||||
|
||||
assert(utf_isValidDchar(V));
|
||||
@@ -113,8 +113,8 @@ char *utf_decodeChar(unsigned char *s, size_t len, size_t *pidx, dchar_t *presul
|
||||
/***************************************************
|
||||
* Validate a UTF-8 string.
|
||||
* Returns:
|
||||
* NULL success
|
||||
* !=NULL error message string
|
||||
* NULL success
|
||||
* !=NULL error message string
|
||||
*/
|
||||
|
||||
char *utf_validateString(unsigned char *s, size_t len)
|
||||
@@ -125,9 +125,9 @@ char *utf_validateString(unsigned char *s, size_t len)
|
||||
|
||||
for (idx = 0; idx < len; )
|
||||
{
|
||||
err = utf_decodeChar(s, len, &idx, &dc);
|
||||
if (err)
|
||||
break;
|
||||
err = utf_decodeChar(s, len, &idx, &dc);
|
||||
if (err)
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@@ -136,8 +136,8 @@ char *utf_validateString(unsigned char *s, size_t len)
|
||||
/********************************************
|
||||
* Decode a single UTF-16 character sequence.
|
||||
* Returns:
|
||||
* NULL success
|
||||
* !=NULL error message string
|
||||
* NULL success
|
||||
* !=NULL error message string
|
||||
*/
|
||||
|
||||
|
||||
@@ -150,34 +150,34 @@ char *utf_decodeWchar(unsigned short *s, size_t len, size_t *pidx, dchar_t *pres
|
||||
assert(i >= 0 && i < len);
|
||||
if (u & ~0x7F)
|
||||
{ if (u >= 0xD800 && u <= 0xDBFF)
|
||||
{ unsigned u2;
|
||||
{ unsigned u2;
|
||||
|
||||
if (i + 1 == len)
|
||||
{ msg = "surrogate UTF-16 high value past end of string";
|
||||
goto Lerr;
|
||||
}
|
||||
u2 = s[i + 1];
|
||||
if (u2 < 0xDC00 || u2 > 0xDFFF)
|
||||
{ msg = "surrogate UTF-16 low value out of range";
|
||||
goto Lerr;
|
||||
}
|
||||
u = ((u - 0xD7C0) << 10) + (u2 - 0xDC00);
|
||||
i += 2;
|
||||
}
|
||||
else if (u >= 0xDC00 && u <= 0xDFFF)
|
||||
{ msg = "unpaired surrogate UTF-16 value";
|
||||
goto Lerr;
|
||||
}
|
||||
else if (u == 0xFFFE || u == 0xFFFF)
|
||||
{ msg = "illegal UTF-16 value";
|
||||
goto Lerr;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
if (i + 1 == len)
|
||||
{ msg = "surrogate UTF-16 high value past end of string";
|
||||
goto Lerr;
|
||||
}
|
||||
u2 = s[i + 1];
|
||||
if (u2 < 0xDC00 || u2 > 0xDFFF)
|
||||
{ msg = "surrogate UTF-16 low value out of range";
|
||||
goto Lerr;
|
||||
}
|
||||
u = ((u - 0xD7C0) << 10) + (u2 - 0xDC00);
|
||||
i += 2;
|
||||
}
|
||||
else if (u >= 0xDC00 && u <= 0xDFFF)
|
||||
{ msg = "unpaired surrogate UTF-16 value";
|
||||
goto Lerr;
|
||||
}
|
||||
else if (u == 0xFFFE || u == 0xFFFF)
|
||||
{ msg = "illegal UTF-16 value";
|
||||
goto Lerr;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
i++;
|
||||
}
|
||||
|
||||
assert(utf_isValidDchar(u));
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
/* ================================================== */
|
||||
|
||||
/* DebugSymbol's happen for statements like:
|
||||
* debug = identifier;
|
||||
* debug = integer;
|
||||
* debug = identifier;
|
||||
* debug = integer;
|
||||
*/
|
||||
|
||||
DebugSymbol::DebugSymbol(Loc loc, Identifier *ident)
|
||||
@@ -56,23 +56,23 @@ int DebugSymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
||||
m = sd->isModule();
|
||||
if (ident)
|
||||
{
|
||||
if (!m)
|
||||
error("declaration must be at module level");
|
||||
else
|
||||
{
|
||||
if (findCondition(m->debugidsNot, ident))
|
||||
error("defined after use");
|
||||
if (!m->debugids)
|
||||
m->debugids = new Array();
|
||||
m->debugids->push(ident->toChars());
|
||||
}
|
||||
if (!m)
|
||||
error("declaration must be at module level");
|
||||
else
|
||||
{
|
||||
if (findCondition(m->debugidsNot, ident))
|
||||
error("defined after use");
|
||||
if (!m->debugids)
|
||||
m->debugids = new Array();
|
||||
m->debugids->push(ident->toChars());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m)
|
||||
error("level declaration must be at module level");
|
||||
else
|
||||
m->debuglevel = level;
|
||||
if (!m)
|
||||
error("level declaration must be at module level");
|
||||
else
|
||||
m->debuglevel = level;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -86,9 +86,9 @@ void DebugSymbol::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
buf->writestring("debug = ");
|
||||
if (ident)
|
||||
buf->writestring(ident->toChars());
|
||||
buf->writestring(ident->toChars());
|
||||
else
|
||||
buf->printf("%u", level);
|
||||
buf->printf("%u", level);
|
||||
buf->writestring(";");
|
||||
buf->writenl();
|
||||
}
|
||||
@@ -101,8 +101,8 @@ const char *DebugSymbol::kind()
|
||||
/* ================================================== */
|
||||
|
||||
/* VersionSymbol's happen for statements like:
|
||||
* version = identifier;
|
||||
* version = integer;
|
||||
* version = identifier;
|
||||
* version = integer;
|
||||
*/
|
||||
|
||||
VersionSymbol::VersionSymbol(Loc loc, Identifier *ident)
|
||||
@@ -136,24 +136,24 @@ int VersionSymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
||||
m = sd->isModule();
|
||||
if (ident)
|
||||
{
|
||||
VersionCondition::checkPredefined(loc, ident->toChars());
|
||||
if (!m)
|
||||
error("declaration must be at module level");
|
||||
else
|
||||
{
|
||||
if (findCondition(m->versionidsNot, ident))
|
||||
error("defined after use");
|
||||
if (!m->versionids)
|
||||
m->versionids = new Array();
|
||||
m->versionids->push(ident->toChars());
|
||||
}
|
||||
VersionCondition::checkPredefined(loc, ident->toChars());
|
||||
if (!m)
|
||||
error("declaration must be at module level");
|
||||
else
|
||||
{
|
||||
if (findCondition(m->versionidsNot, ident))
|
||||
error("defined after use");
|
||||
if (!m->versionids)
|
||||
m->versionids = new Array();
|
||||
m->versionids->push(ident->toChars());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m)
|
||||
error("level declaration must be at module level");
|
||||
else
|
||||
m->versionlevel = level;
|
||||
if (!m)
|
||||
error("level declaration must be at module level");
|
||||
else
|
||||
m->versionlevel = level;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -166,9 +166,9 @@ void VersionSymbol::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
buf->writestring("version = ");
|
||||
if (ident)
|
||||
buf->writestring(ident->toChars());
|
||||
buf->writestring(ident->toChars());
|
||||
else
|
||||
buf->printf("%u", level);
|
||||
buf->printf("%u", level);
|
||||
buf->writestring(";");
|
||||
buf->writenl();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user