mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-09-20 04:10:18 +02:00
Fix white space.
This commit is contained in:
+13
-13
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
// Copyright (c) 1999-2012 by Digital Mars
|
// Copyright (c) 1999-2012 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -81,17 +81,17 @@ enum PROT ClassDeclaration::getAccess(Dsymbol *smember)
|
|||||||
access_ret = smember->prot();
|
access_ret = smember->prot();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||||
{ BaseClass *b = (*baseclasses)[i];
|
{ BaseClass *b = (*baseclasses)[i];
|
||||||
|
|
||||||
enum PROT access = b->base->getAccess(smember);
|
enum PROT access = b->base->getAccess(smember);
|
||||||
switch (access)
|
switch (access)
|
||||||
{
|
{
|
||||||
case PROTnone:
|
case PROTnone:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROTprivate:
|
case PROTprivate:
|
||||||
access_ret = PROTnone; // private members of base class not accessible
|
access_ret = PROTnone; // private members of base class not accessible
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROTpackage:
|
case PROTpackage:
|
||||||
@@ -150,9 +150,9 @@ static int accessCheckX(
|
|||||||
ClassDeclaration *cdthis = dthis->isClassDeclaration();
|
ClassDeclaration *cdthis = dthis->isClassDeclaration();
|
||||||
if (cdthis)
|
if (cdthis)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < cdthis->baseclasses->dim; i++)
|
for (size_t i = 0; i < cdthis->baseclasses->dim; i++)
|
||||||
{ BaseClass *b = (*cdthis->baseclasses)[i];
|
{ BaseClass *b = (*cdthis->baseclasses)[i];
|
||||||
enum PROT access = b->base->getAccess(smember);
|
enum PROT access = b->base->getAccess(smember);
|
||||||
if (access >= PROTprotected ||
|
if (access >= PROTprotected ||
|
||||||
accessCheckX(smember, sfunc, b->base, cdscope)
|
accessCheckX(smember, sfunc, b->base, cdscope)
|
||||||
)
|
)
|
||||||
@@ -169,8 +169,8 @@ static int accessCheckX(
|
|||||||
ClassDeclaration *cdthis = dthis->isClassDeclaration();
|
ClassDeclaration *cdthis = dthis->isClassDeclaration();
|
||||||
if (cdthis)
|
if (cdthis)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < cdthis->baseclasses->dim; i++)
|
for (size_t i = 0; i < cdthis->baseclasses->dim; i++)
|
||||||
{ BaseClass *b = (*cdthis->baseclasses)[i];
|
{ BaseClass *b = (*cdthis->baseclasses)[i];
|
||||||
|
|
||||||
if (accessCheckX(smember, sfunc, b->base, cdscope))
|
if (accessCheckX(smember, sfunc, b->base, cdscope))
|
||||||
return 1;
|
return 1;
|
||||||
@@ -214,12 +214,12 @@ void AggregateDeclaration::accessCheck(Loc loc, Scope *sc, Dsymbol *smember)
|
|||||||
//assert(smember->parent->isBaseOf(this, NULL));
|
//assert(smember->parent->isBaseOf(this, NULL));
|
||||||
|
|
||||||
if (smemberparent == this)
|
if (smemberparent == this)
|
||||||
{ enum PROT access2 = smember->prot();
|
{ enum PROT access2 = smember->prot();
|
||||||
|
|
||||||
result = access2 >= PROTpublic ||
|
result = access2 >= PROTpublic ||
|
||||||
hasPrivateAccess(f) ||
|
hasPrivateAccess(f) ||
|
||||||
isFriendOf(cdscope) ||
|
isFriendOf(cdscope) ||
|
||||||
(access2 == PROTpackage && hasPackageAccess(sc, this));
|
(access2 == PROTpackage && hasPackageAccess(sc, this));
|
||||||
#if LOG
|
#if LOG
|
||||||
printf("result1 = %d\n", result);
|
printf("result1 = %d\n", result);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+15
-15
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -61,7 +61,7 @@ struct AggregateDeclaration : ScopeDsymbol
|
|||||||
unsigned alignsize; // size of struct for alignment purposes
|
unsigned alignsize; // size of struct for alignment purposes
|
||||||
unsigned structalign; // struct member alignment in effect
|
unsigned structalign; // struct member alignment in effect
|
||||||
int hasUnions; // set if aggregate has overlapping fields
|
int hasUnions; // set if aggregate has overlapping fields
|
||||||
VarDeclarations fields; // VarDeclaration fields
|
VarDeclarations fields; // VarDeclaration fields
|
||||||
unsigned sizeok; // set when structsize contains valid data
|
unsigned sizeok; // set when structsize contains valid data
|
||||||
// 0: no size
|
// 0: no size
|
||||||
// 1: size is correct
|
// 1: size is correct
|
||||||
@@ -82,7 +82,7 @@ struct AggregateDeclaration : ScopeDsymbol
|
|||||||
Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration
|
Dsymbol *ctor; // CtorDeclaration or TemplateDeclaration
|
||||||
CtorDeclaration *defaultCtor; // default constructor
|
CtorDeclaration *defaultCtor; // default constructor
|
||||||
Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
|
Dsymbol *aliasthis; // forward unresolved lookups to aliasthis
|
||||||
bool noDefaultCtor; // no default construction
|
bool noDefaultCtor; // no default construction
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FuncDeclarations dtors; // Array of destructors
|
FuncDeclarations dtors; // Array of destructors
|
||||||
@@ -100,12 +100,12 @@ struct AggregateDeclaration : ScopeDsymbol
|
|||||||
static void alignmember(unsigned salign, unsigned size, unsigned *poffset);
|
static void alignmember(unsigned salign, unsigned size, unsigned *poffset);
|
||||||
Type *getType();
|
Type *getType();
|
||||||
void addField(Scope *sc, VarDeclaration *v);
|
void addField(Scope *sc, VarDeclaration *v);
|
||||||
int firstFieldInUnion(int indx); // first field in union that includes indx
|
int firstFieldInUnion(int indx); // first field in union that includes indx
|
||||||
int numFieldsInUnion(int firstIndex); // #fields in union starting at index
|
int numFieldsInUnion(int firstIndex); // #fields in union starting at index
|
||||||
int isDeprecated(); // is aggregate deprecated?
|
int isDeprecated(); // is aggregate deprecated?
|
||||||
FuncDeclaration *buildDtor(Scope *sc);
|
FuncDeclaration *buildDtor(Scope *sc);
|
||||||
int isNested();
|
int isNested();
|
||||||
int isExport();
|
int isExport();
|
||||||
|
|
||||||
void emitComment(Scope *sc);
|
void emitComment(Scope *sc);
|
||||||
void toJsonBuffer(OutBuffer *buf);
|
void toJsonBuffer(OutBuffer *buf);
|
||||||
@@ -150,7 +150,7 @@ struct StructDeclaration : AggregateDeclaration
|
|||||||
#if DMDV2
|
#if DMDV2
|
||||||
int hasIdentityAssign; // !=0 if has identity opAssign
|
int hasIdentityAssign; // !=0 if has identity opAssign
|
||||||
FuncDeclaration *cpctor; // generated copy-constructor, if any
|
FuncDeclaration *cpctor; // generated copy-constructor, if any
|
||||||
FuncDeclaration *eq; // bool opEquals(ref const T), if any
|
FuncDeclaration *eq; // bool opEquals(ref const T), if any
|
||||||
|
|
||||||
FuncDeclarations postblits; // Array of postblit functions
|
FuncDeclarations postblits; // Array of postblit functions
|
||||||
FuncDeclaration *postblit; // aggregate postblit
|
FuncDeclaration *postblit; // aggregate postblit
|
||||||
@@ -207,17 +207,17 @@ struct BaseClass
|
|||||||
|
|
||||||
ClassDeclaration *base;
|
ClassDeclaration *base;
|
||||||
int offset; // 'this' pointer offset
|
int offset; // 'this' pointer offset
|
||||||
FuncDeclarations vtbl; // for interfaces: Array of FuncDeclaration's
|
FuncDeclarations vtbl; // for interfaces: Array of FuncDeclaration's
|
||||||
// making up the vtbl[]
|
// making up the vtbl[]
|
||||||
|
|
||||||
size_t baseInterfaces_dim;
|
size_t baseInterfaces_dim;
|
||||||
BaseClass *baseInterfaces; // if BaseClass is an interface, these
|
BaseClass *baseInterfaces; // if BaseClass is an interface, these
|
||||||
// are a copy of the InterfaceDeclaration::interfaces
|
// are a copy of the InterfaceDeclaration::interfaces
|
||||||
|
|
||||||
BaseClass();
|
BaseClass();
|
||||||
BaseClass(Type *type, enum PROT protection);
|
BaseClass(Type *type, enum PROT protection);
|
||||||
|
|
||||||
int fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newinstance);
|
int fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newinstance);
|
||||||
void copyBaseInterfaces(BaseClasses *);
|
void copyBaseInterfaces(BaseClasses *);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ struct ClassDeclaration : AggregateDeclaration
|
|||||||
{
|
{
|
||||||
static ClassDeclaration *object;
|
static ClassDeclaration *object;
|
||||||
static ClassDeclaration *classinfo;
|
static ClassDeclaration *classinfo;
|
||||||
static ClassDeclaration *errorException;
|
static ClassDeclaration *errorException;
|
||||||
|
|
||||||
ClassDeclaration *baseClass; // NULL only if this is Object
|
ClassDeclaration *baseClass; // NULL only if this is Object
|
||||||
#if DMDV1
|
#if DMDV1
|
||||||
@@ -241,13 +241,13 @@ struct ClassDeclaration : AggregateDeclaration
|
|||||||
#endif
|
#endif
|
||||||
FuncDeclaration *staticCtor;
|
FuncDeclaration *staticCtor;
|
||||||
FuncDeclaration *staticDtor;
|
FuncDeclaration *staticDtor;
|
||||||
Dsymbols vtbl; // Array of FuncDeclaration's making up the vtbl[]
|
Dsymbols vtbl; // Array of FuncDeclaration's making up the vtbl[]
|
||||||
Dsymbols vtblFinal; // More FuncDeclaration's that aren't in vtbl[]
|
Dsymbols vtblFinal; // More FuncDeclaration's that aren't in vtbl[]
|
||||||
|
|
||||||
BaseClasses *baseclasses; // Array of BaseClass's; first is super,
|
BaseClasses *baseclasses; // Array of BaseClass's; first is super,
|
||||||
// rest are Interface's
|
// rest are Interface's
|
||||||
|
|
||||||
size_t interfaces_dim;
|
size_t interfaces_dim;
|
||||||
BaseClass **interfaces; // interfaces[interfaces_dim] for this class
|
BaseClass **interfaces; // interfaces[interfaces_dim] for this class
|
||||||
// (does not include baseClass)
|
// (does not include baseClass)
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ struct ClassDeclaration : AggregateDeclaration
|
|||||||
|
|
||||||
virtual int isBaseInfoComplete();
|
virtual int isBaseInfoComplete();
|
||||||
Dsymbol *search(Loc, Identifier *ident, int flags);
|
Dsymbol *search(Loc, Identifier *ident, int flags);
|
||||||
Dsymbol *searchBase(Loc, Identifier *ident);
|
Dsymbol *searchBase(Loc, Identifier *ident);
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
int isFuncHidden(FuncDeclaration *fd);
|
int isFuncHidden(FuncDeclaration *fd);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+216
-216
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "rmem.h"
|
#include "rmem.h"
|
||||||
|
|
||||||
#include "aav.h"
|
#include "aav.h"
|
||||||
|
|
||||||
#include "expression.h"
|
#include "expression.h"
|
||||||
#include "statement.h"
|
#include "statement.h"
|
||||||
@@ -31,7 +31,7 @@ extern int binary(const char *p , const char **tab, int high);
|
|||||||
* Hash table of array op functions already generated or known about.
|
* Hash table of array op functions already generated or known about.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
AA *arrayfuncs;
|
AA *arrayfuncs;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**********************************************
|
/**********************************************
|
||||||
@@ -125,195 +125,195 @@ Expression *BinExp::arrayOp(Scope *sc)
|
|||||||
|
|
||||||
size_t namelen = buf.offset;
|
size_t namelen = buf.offset;
|
||||||
buf.writeByte(0);
|
buf.writeByte(0);
|
||||||
char *name = buf.toChars();
|
char *name = buf.toChars();
|
||||||
Identifier *ident = Lexer::idPool(name);
|
Identifier *ident = Lexer::idPool(name);
|
||||||
|
|
||||||
/* Look up name in hash table
|
/* Look up name in hash table
|
||||||
*/
|
*/
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
FuncDeclaration **pfd = (FuncDeclaration **)_aaGet(&arrayfuncs, ident);
|
FuncDeclaration **pfd = (FuncDeclaration **)_aaGet(&arrayfuncs, ident);
|
||||||
FuncDeclaration *fd = (FuncDeclaration *)*pfd;
|
FuncDeclaration *fd = (FuncDeclaration *)*pfd;
|
||||||
#elif IN_LLVM
|
#elif IN_LLVM
|
||||||
StringValue *sv = sc->module->arrayfuncs.update(name, namelen);
|
StringValue *sv = sc->module->arrayfuncs.update(name, namelen);
|
||||||
FuncDeclaration *fd = (FuncDeclaration *)sv->ptrvalue;
|
FuncDeclaration *fd = (FuncDeclaration *)sv->ptrvalue;
|
||||||
#endif
|
#endif
|
||||||
if (!fd)
|
if (!fd)
|
||||||
{
|
{
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
static const char *libArrayopFuncs[] =
|
static const char *libArrayopFuncs[] =
|
||||||
{
|
{
|
||||||
"_arrayExpSliceAddass_a",
|
"_arrayExpSliceAddass_a",
|
||||||
"_arrayExpSliceAddass_d", // T[]+=T
|
"_arrayExpSliceAddass_d", // T[]+=T
|
||||||
"_arrayExpSliceAddass_f", // T[]+=T
|
"_arrayExpSliceAddass_f", // T[]+=T
|
||||||
"_arrayExpSliceAddass_g",
|
"_arrayExpSliceAddass_g",
|
||||||
"_arrayExpSliceAddass_h",
|
"_arrayExpSliceAddass_h",
|
||||||
"_arrayExpSliceAddass_i",
|
"_arrayExpSliceAddass_i",
|
||||||
"_arrayExpSliceAddass_k",
|
"_arrayExpSliceAddass_k",
|
||||||
"_arrayExpSliceAddass_s",
|
"_arrayExpSliceAddass_s",
|
||||||
"_arrayExpSliceAddass_t",
|
"_arrayExpSliceAddass_t",
|
||||||
"_arrayExpSliceAddass_u",
|
"_arrayExpSliceAddass_u",
|
||||||
"_arrayExpSliceAddass_w",
|
"_arrayExpSliceAddass_w",
|
||||||
|
|
||||||
"_arrayExpSliceDivass_d", // T[]/=T
|
"_arrayExpSliceDivass_d", // T[]/=T
|
||||||
"_arrayExpSliceDivass_f", // T[]/=T
|
"_arrayExpSliceDivass_f", // T[]/=T
|
||||||
|
|
||||||
"_arrayExpSliceMinSliceAssign_a",
|
"_arrayExpSliceMinSliceAssign_a",
|
||||||
"_arrayExpSliceMinSliceAssign_d", // T[]=T-T[]
|
"_arrayExpSliceMinSliceAssign_d", // T[]=T-T[]
|
||||||
"_arrayExpSliceMinSliceAssign_f", // T[]=T-T[]
|
"_arrayExpSliceMinSliceAssign_f", // T[]=T-T[]
|
||||||
"_arrayExpSliceMinSliceAssign_g",
|
"_arrayExpSliceMinSliceAssign_g",
|
||||||
"_arrayExpSliceMinSliceAssign_h",
|
"_arrayExpSliceMinSliceAssign_h",
|
||||||
"_arrayExpSliceMinSliceAssign_i",
|
"_arrayExpSliceMinSliceAssign_i",
|
||||||
"_arrayExpSliceMinSliceAssign_k",
|
"_arrayExpSliceMinSliceAssign_k",
|
||||||
"_arrayExpSliceMinSliceAssign_s",
|
"_arrayExpSliceMinSliceAssign_s",
|
||||||
"_arrayExpSliceMinSliceAssign_t",
|
"_arrayExpSliceMinSliceAssign_t",
|
||||||
"_arrayExpSliceMinSliceAssign_u",
|
"_arrayExpSliceMinSliceAssign_u",
|
||||||
"_arrayExpSliceMinSliceAssign_w",
|
"_arrayExpSliceMinSliceAssign_w",
|
||||||
|
|
||||||
"_arrayExpSliceMinass_a",
|
"_arrayExpSliceMinass_a",
|
||||||
"_arrayExpSliceMinass_d", // T[]-=T
|
"_arrayExpSliceMinass_d", // T[]-=T
|
||||||
"_arrayExpSliceMinass_f", // T[]-=T
|
"_arrayExpSliceMinass_f", // T[]-=T
|
||||||
"_arrayExpSliceMinass_g",
|
"_arrayExpSliceMinass_g",
|
||||||
"_arrayExpSliceMinass_h",
|
"_arrayExpSliceMinass_h",
|
||||||
"_arrayExpSliceMinass_i",
|
"_arrayExpSliceMinass_i",
|
||||||
"_arrayExpSliceMinass_k",
|
"_arrayExpSliceMinass_k",
|
||||||
"_arrayExpSliceMinass_s",
|
"_arrayExpSliceMinass_s",
|
||||||
"_arrayExpSliceMinass_t",
|
"_arrayExpSliceMinass_t",
|
||||||
"_arrayExpSliceMinass_u",
|
"_arrayExpSliceMinass_u",
|
||||||
"_arrayExpSliceMinass_w",
|
"_arrayExpSliceMinass_w",
|
||||||
|
|
||||||
"_arrayExpSliceMulass_d", // T[]*=T
|
"_arrayExpSliceMulass_d", // T[]*=T
|
||||||
"_arrayExpSliceMulass_f", // T[]*=T
|
"_arrayExpSliceMulass_f", // T[]*=T
|
||||||
"_arrayExpSliceMulass_i",
|
"_arrayExpSliceMulass_i",
|
||||||
"_arrayExpSliceMulass_k",
|
"_arrayExpSliceMulass_k",
|
||||||
"_arrayExpSliceMulass_s",
|
"_arrayExpSliceMulass_s",
|
||||||
"_arrayExpSliceMulass_t",
|
"_arrayExpSliceMulass_t",
|
||||||
"_arrayExpSliceMulass_u",
|
"_arrayExpSliceMulass_u",
|
||||||
"_arrayExpSliceMulass_w",
|
"_arrayExpSliceMulass_w",
|
||||||
|
|
||||||
"_arraySliceExpAddSliceAssign_a",
|
"_arraySliceExpAddSliceAssign_a",
|
||||||
"_arraySliceExpAddSliceAssign_d", // T[]=T[]+T
|
"_arraySliceExpAddSliceAssign_d", // T[]=T[]+T
|
||||||
"_arraySliceExpAddSliceAssign_f", // T[]=T[]+T
|
"_arraySliceExpAddSliceAssign_f", // T[]=T[]+T
|
||||||
"_arraySliceExpAddSliceAssign_g",
|
"_arraySliceExpAddSliceAssign_g",
|
||||||
"_arraySliceExpAddSliceAssign_h",
|
"_arraySliceExpAddSliceAssign_h",
|
||||||
"_arraySliceExpAddSliceAssign_i",
|
"_arraySliceExpAddSliceAssign_i",
|
||||||
"_arraySliceExpAddSliceAssign_k",
|
"_arraySliceExpAddSliceAssign_k",
|
||||||
"_arraySliceExpAddSliceAssign_s",
|
"_arraySliceExpAddSliceAssign_s",
|
||||||
"_arraySliceExpAddSliceAssign_t",
|
"_arraySliceExpAddSliceAssign_t",
|
||||||
"_arraySliceExpAddSliceAssign_u",
|
"_arraySliceExpAddSliceAssign_u",
|
||||||
"_arraySliceExpAddSliceAssign_w",
|
"_arraySliceExpAddSliceAssign_w",
|
||||||
|
|
||||||
"_arraySliceExpDivSliceAssign_d", // T[]=T[]/T
|
"_arraySliceExpDivSliceAssign_d", // T[]=T[]/T
|
||||||
"_arraySliceExpDivSliceAssign_f", // T[]=T[]/T
|
"_arraySliceExpDivSliceAssign_f", // T[]=T[]/T
|
||||||
|
|
||||||
"_arraySliceExpMinSliceAssign_a",
|
"_arraySliceExpMinSliceAssign_a",
|
||||||
"_arraySliceExpMinSliceAssign_d", // T[]=T[]-T
|
"_arraySliceExpMinSliceAssign_d", // T[]=T[]-T
|
||||||
"_arraySliceExpMinSliceAssign_f", // T[]=T[]-T
|
"_arraySliceExpMinSliceAssign_f", // T[]=T[]-T
|
||||||
"_arraySliceExpMinSliceAssign_g",
|
"_arraySliceExpMinSliceAssign_g",
|
||||||
"_arraySliceExpMinSliceAssign_h",
|
"_arraySliceExpMinSliceAssign_h",
|
||||||
"_arraySliceExpMinSliceAssign_i",
|
"_arraySliceExpMinSliceAssign_i",
|
||||||
"_arraySliceExpMinSliceAssign_k",
|
"_arraySliceExpMinSliceAssign_k",
|
||||||
"_arraySliceExpMinSliceAssign_s",
|
"_arraySliceExpMinSliceAssign_s",
|
||||||
"_arraySliceExpMinSliceAssign_t",
|
"_arraySliceExpMinSliceAssign_t",
|
||||||
"_arraySliceExpMinSliceAssign_u",
|
"_arraySliceExpMinSliceAssign_u",
|
||||||
"_arraySliceExpMinSliceAssign_w",
|
"_arraySliceExpMinSliceAssign_w",
|
||||||
|
|
||||||
"_arraySliceExpMulSliceAddass_d", // T[] += T[]*T
|
"_arraySliceExpMulSliceAddass_d", // T[] += T[]*T
|
||||||
"_arraySliceExpMulSliceAddass_f",
|
"_arraySliceExpMulSliceAddass_f",
|
||||||
"_arraySliceExpMulSliceAddass_r",
|
"_arraySliceExpMulSliceAddass_r",
|
||||||
|
|
||||||
"_arraySliceExpMulSliceAssign_d", // T[]=T[]*T
|
"_arraySliceExpMulSliceAssign_d", // T[]=T[]*T
|
||||||
"_arraySliceExpMulSliceAssign_f", // T[]=T[]*T
|
"_arraySliceExpMulSliceAssign_f", // T[]=T[]*T
|
||||||
"_arraySliceExpMulSliceAssign_i",
|
"_arraySliceExpMulSliceAssign_i",
|
||||||
"_arraySliceExpMulSliceAssign_k",
|
"_arraySliceExpMulSliceAssign_k",
|
||||||
"_arraySliceExpMulSliceAssign_s",
|
"_arraySliceExpMulSliceAssign_s",
|
||||||
"_arraySliceExpMulSliceAssign_t",
|
"_arraySliceExpMulSliceAssign_t",
|
||||||
"_arraySliceExpMulSliceAssign_u",
|
"_arraySliceExpMulSliceAssign_u",
|
||||||
"_arraySliceExpMulSliceAssign_w",
|
"_arraySliceExpMulSliceAssign_w",
|
||||||
|
|
||||||
"_arraySliceExpMulSliceMinass_d", // T[] -= T[]*T
|
"_arraySliceExpMulSliceMinass_d", // T[] -= T[]*T
|
||||||
"_arraySliceExpMulSliceMinass_f",
|
"_arraySliceExpMulSliceMinass_f",
|
||||||
"_arraySliceExpMulSliceMinass_r",
|
"_arraySliceExpMulSliceMinass_r",
|
||||||
|
|
||||||
"_arraySliceSliceAddSliceAssign_a",
|
"_arraySliceSliceAddSliceAssign_a",
|
||||||
"_arraySliceSliceAddSliceAssign_d", // T[]=T[]+T[]
|
"_arraySliceSliceAddSliceAssign_d", // T[]=T[]+T[]
|
||||||
"_arraySliceSliceAddSliceAssign_f", // T[]=T[]+T[]
|
"_arraySliceSliceAddSliceAssign_f", // T[]=T[]+T[]
|
||||||
"_arraySliceSliceAddSliceAssign_g",
|
"_arraySliceSliceAddSliceAssign_g",
|
||||||
"_arraySliceSliceAddSliceAssign_h",
|
"_arraySliceSliceAddSliceAssign_h",
|
||||||
"_arraySliceSliceAddSliceAssign_i",
|
"_arraySliceSliceAddSliceAssign_i",
|
||||||
"_arraySliceSliceAddSliceAssign_k",
|
"_arraySliceSliceAddSliceAssign_k",
|
||||||
"_arraySliceSliceAddSliceAssign_r", // T[]=T[]+T[]
|
"_arraySliceSliceAddSliceAssign_r", // T[]=T[]+T[]
|
||||||
"_arraySliceSliceAddSliceAssign_s",
|
"_arraySliceSliceAddSliceAssign_s",
|
||||||
"_arraySliceSliceAddSliceAssign_t",
|
"_arraySliceSliceAddSliceAssign_t",
|
||||||
"_arraySliceSliceAddSliceAssign_u",
|
"_arraySliceSliceAddSliceAssign_u",
|
||||||
"_arraySliceSliceAddSliceAssign_w",
|
"_arraySliceSliceAddSliceAssign_w",
|
||||||
|
|
||||||
"_arraySliceSliceAddass_a",
|
"_arraySliceSliceAddass_a",
|
||||||
"_arraySliceSliceAddass_d", // T[]+=T[]
|
"_arraySliceSliceAddass_d", // T[]+=T[]
|
||||||
"_arraySliceSliceAddass_f", // T[]+=T[]
|
"_arraySliceSliceAddass_f", // T[]+=T[]
|
||||||
"_arraySliceSliceAddass_g",
|
"_arraySliceSliceAddass_g",
|
||||||
"_arraySliceSliceAddass_h",
|
"_arraySliceSliceAddass_h",
|
||||||
"_arraySliceSliceAddass_i",
|
"_arraySliceSliceAddass_i",
|
||||||
"_arraySliceSliceAddass_k",
|
"_arraySliceSliceAddass_k",
|
||||||
"_arraySliceSliceAddass_s",
|
"_arraySliceSliceAddass_s",
|
||||||
"_arraySliceSliceAddass_t",
|
"_arraySliceSliceAddass_t",
|
||||||
"_arraySliceSliceAddass_u",
|
"_arraySliceSliceAddass_u",
|
||||||
"_arraySliceSliceAddass_w",
|
"_arraySliceSliceAddass_w",
|
||||||
|
|
||||||
"_arraySliceSliceMinSliceAssign_a",
|
"_arraySliceSliceMinSliceAssign_a",
|
||||||
"_arraySliceSliceMinSliceAssign_d", // T[]=T[]-T[]
|
"_arraySliceSliceMinSliceAssign_d", // T[]=T[]-T[]
|
||||||
"_arraySliceSliceMinSliceAssign_f", // T[]=T[]-T[]
|
"_arraySliceSliceMinSliceAssign_f", // T[]=T[]-T[]
|
||||||
"_arraySliceSliceMinSliceAssign_g",
|
"_arraySliceSliceMinSliceAssign_g",
|
||||||
"_arraySliceSliceMinSliceAssign_h",
|
"_arraySliceSliceMinSliceAssign_h",
|
||||||
"_arraySliceSliceMinSliceAssign_i",
|
"_arraySliceSliceMinSliceAssign_i",
|
||||||
"_arraySliceSliceMinSliceAssign_k",
|
"_arraySliceSliceMinSliceAssign_k",
|
||||||
"_arraySliceSliceMinSliceAssign_r", // T[]=T[]-T[]
|
"_arraySliceSliceMinSliceAssign_r", // T[]=T[]-T[]
|
||||||
"_arraySliceSliceMinSliceAssign_s",
|
"_arraySliceSliceMinSliceAssign_s",
|
||||||
"_arraySliceSliceMinSliceAssign_t",
|
"_arraySliceSliceMinSliceAssign_t",
|
||||||
"_arraySliceSliceMinSliceAssign_u",
|
"_arraySliceSliceMinSliceAssign_u",
|
||||||
"_arraySliceSliceMinSliceAssign_w",
|
"_arraySliceSliceMinSliceAssign_w",
|
||||||
|
|
||||||
"_arraySliceSliceMinass_a",
|
"_arraySliceSliceMinass_a",
|
||||||
"_arraySliceSliceMinass_d", // T[]-=T[]
|
"_arraySliceSliceMinass_d", // T[]-=T[]
|
||||||
"_arraySliceSliceMinass_f", // T[]-=T[]
|
"_arraySliceSliceMinass_f", // T[]-=T[]
|
||||||
"_arraySliceSliceMinass_g",
|
"_arraySliceSliceMinass_g",
|
||||||
"_arraySliceSliceMinass_h",
|
"_arraySliceSliceMinass_h",
|
||||||
"_arraySliceSliceMinass_i",
|
"_arraySliceSliceMinass_i",
|
||||||
"_arraySliceSliceMinass_k",
|
"_arraySliceSliceMinass_k",
|
||||||
"_arraySliceSliceMinass_s",
|
"_arraySliceSliceMinass_s",
|
||||||
"_arraySliceSliceMinass_t",
|
"_arraySliceSliceMinass_t",
|
||||||
"_arraySliceSliceMinass_u",
|
"_arraySliceSliceMinass_u",
|
||||||
"_arraySliceSliceMinass_w",
|
"_arraySliceSliceMinass_w",
|
||||||
|
|
||||||
"_arraySliceSliceMulSliceAssign_d", // T[]=T[]*T[]
|
"_arraySliceSliceMulSliceAssign_d", // T[]=T[]*T[]
|
||||||
"_arraySliceSliceMulSliceAssign_f", // T[]=T[]*T[]
|
"_arraySliceSliceMulSliceAssign_f", // T[]=T[]*T[]
|
||||||
"_arraySliceSliceMulSliceAssign_i",
|
"_arraySliceSliceMulSliceAssign_i",
|
||||||
"_arraySliceSliceMulSliceAssign_k",
|
"_arraySliceSliceMulSliceAssign_k",
|
||||||
"_arraySliceSliceMulSliceAssign_s",
|
"_arraySliceSliceMulSliceAssign_s",
|
||||||
"_arraySliceSliceMulSliceAssign_t",
|
"_arraySliceSliceMulSliceAssign_t",
|
||||||
"_arraySliceSliceMulSliceAssign_u",
|
"_arraySliceSliceMulSliceAssign_u",
|
||||||
"_arraySliceSliceMulSliceAssign_w",
|
"_arraySliceSliceMulSliceAssign_w",
|
||||||
|
|
||||||
"_arraySliceSliceMulass_d", // T[]*=T[]
|
"_arraySliceSliceMulass_d", // T[]*=T[]
|
||||||
"_arraySliceSliceMulass_f", // T[]*=T[]
|
"_arraySliceSliceMulass_f", // T[]*=T[]
|
||||||
"_arraySliceSliceMulass_i",
|
"_arraySliceSliceMulass_i",
|
||||||
"_arraySliceSliceMulass_k",
|
"_arraySliceSliceMulass_k",
|
||||||
"_arraySliceSliceMulass_s",
|
"_arraySliceSliceMulass_s",
|
||||||
"_arraySliceSliceMulass_t",
|
"_arraySliceSliceMulass_t",
|
||||||
"_arraySliceSliceMulass_u",
|
"_arraySliceSliceMulass_u",
|
||||||
"_arraySliceSliceMulass_w",
|
"_arraySliceSliceMulass_w",
|
||||||
};
|
};
|
||||||
|
|
||||||
int i = binary(name, libArrayopFuncs, sizeof(libArrayopFuncs) / sizeof(char *));
|
int i = binary(name, libArrayopFuncs, sizeof(libArrayopFuncs) / sizeof(char *));
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG // Make sure our array is alphabetized
|
#ifdef DEBUG // Make sure our array is alphabetized
|
||||||
for (i = 0; i < sizeof(libArrayopFuncs) / sizeof(char *); i++)
|
for (i = 0; i < sizeof(libArrayopFuncs) / sizeof(char *); i++)
|
||||||
{
|
{
|
||||||
if (strcmp(name, libArrayopFuncs[i]) == 0)
|
if (strcmp(name, libArrayopFuncs[i]) == 0)
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/* Not in library, so generate it.
|
/* Not in library, so generate it.
|
||||||
* Construct the function body:
|
* Construct the function body:
|
||||||
* foreach (i; 0 .. p.length) for (size_t i = 0; i < p.length; i++)
|
* foreach (i; 0 .. p.length) for (size_t i = 0; i < p.length; i++)
|
||||||
@@ -323,13 +323,13 @@ Expression *BinExp::arrayOp(Scope *sc)
|
|||||||
|
|
||||||
Parameters *fparams = new Parameters();
|
Parameters *fparams = new Parameters();
|
||||||
Expression *loopbody = buildArrayLoop(fparams);
|
Expression *loopbody = buildArrayLoop(fparams);
|
||||||
Parameter *p = (*fparams)[0 /*fparams->dim - 1*/];
|
Parameter *p = (*fparams)[0 /*fparams->dim - 1*/];
|
||||||
#if DMDV1
|
#if DMDV1
|
||||||
// for (size_t i = 0; i < p.length; i++)
|
// for (size_t i = 0; i < p.length; i++)
|
||||||
Initializer *init = new ExpInitializer(0, new IntegerExp(0, 0, Type::tsize_t));
|
Initializer *init = new ExpInitializer(0, new IntegerExp(0, 0, Type::tsize_t));
|
||||||
Dsymbol *d = new VarDeclaration(0, Type::tsize_t, Id::p, init);
|
Dsymbol *d = new VarDeclaration(0, Type::tsize_t, Id::p, init);
|
||||||
Statement *s1 = new ForStatement(0,
|
Statement *s1 = new ForStatement(0,
|
||||||
new ExpStatement(0, d),
|
new ExpStatement(0, d),
|
||||||
new CmpExp(TOKlt, 0, new IdentifierExp(0, Id::p), new ArrayLengthExp(0, new IdentifierExp(0, p->ident))),
|
new CmpExp(TOKlt, 0, new IdentifierExp(0, Id::p), new ArrayLengthExp(0, new IdentifierExp(0, p->ident))),
|
||||||
new PostExp(TOKplusplus, 0, new IdentifierExp(0, Id::p)),
|
new PostExp(TOKplusplus, 0, new IdentifierExp(0, Id::p)),
|
||||||
new ExpStatement(0, loopbody));
|
new ExpStatement(0, loopbody));
|
||||||
@@ -349,33 +349,33 @@ Expression *BinExp::arrayOp(Scope *sc)
|
|||||||
*/
|
*/
|
||||||
TypeFunction *ftype = new TypeFunction(fparams, type, 0, LINKc);
|
TypeFunction *ftype = new TypeFunction(fparams, type, 0, LINKc);
|
||||||
//printf("ftype: %s\n", ftype->toChars());
|
//printf("ftype: %s\n", ftype->toChars());
|
||||||
fd = new FuncDeclaration(loc, 0, ident, STCundefined, ftype);
|
fd = new FuncDeclaration(loc, 0, ident, STCundefined, ftype);
|
||||||
fd->fbody = fbody;
|
fd->fbody = fbody;
|
||||||
fd->protection = PROTpublic;
|
fd->protection = PROTpublic;
|
||||||
fd->linkage = LINKc;
|
fd->linkage = LINKc;
|
||||||
fd->isArrayOp = 1;
|
fd->isArrayOp = 1;
|
||||||
|
|
||||||
sc->module->importedFrom->members->push(fd);
|
sc->module->importedFrom->members->push(fd);
|
||||||
|
|
||||||
sc = sc->push();
|
sc = sc->push();
|
||||||
sc->parent = sc->module->importedFrom;
|
sc->parent = sc->module->importedFrom;
|
||||||
sc->stc = 0;
|
sc->stc = 0;
|
||||||
sc->linkage = LINKc;
|
sc->linkage = LINKc;
|
||||||
fd->semantic(sc);
|
fd->semantic(sc);
|
||||||
fd->semantic2(sc);
|
fd->semantic2(sc);
|
||||||
fd->semantic3(sc);
|
fd->semantic3(sc);
|
||||||
sc->pop();
|
sc->pop();
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* In library, refer to it.
|
{ /* In library, refer to it.
|
||||||
*/
|
*/
|
||||||
fd = FuncDeclaration::genCfunc(type, ident);
|
fd = FuncDeclaration::genCfunc(type, ident);
|
||||||
}
|
}
|
||||||
*pfd = fd; // cache symbol in hash table
|
*pfd = fd; // cache symbol in hash table
|
||||||
#elif IN_LLVM
|
#elif IN_LLVM
|
||||||
sv->ptrvalue = fd; // cache symbol in hash table
|
sv->ptrvalue = fd; // cache symbol in hash table
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Call the function fd(arguments)
|
/* Call the function fd(arguments)
|
||||||
@@ -442,9 +442,9 @@ X(Mod)
|
|||||||
X(Xor)
|
X(Xor)
|
||||||
X(And)
|
X(And)
|
||||||
X(Or)
|
X(Or)
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
X(Pow)
|
X(Pow)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
@@ -478,9 +478,9 @@ X(Mod)
|
|||||||
X(Xor)
|
X(Xor)
|
||||||
X(And)
|
X(And)
|
||||||
X(Or)
|
X(Or)
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
X(Pow)
|
X(Pow)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
@@ -536,7 +536,7 @@ Expression *AssignExp::buildArrayLoop(Parameters *fparams)
|
|||||||
ex2 = new CastExp(0, ex2, e1->type->nextOf());
|
ex2 = new CastExp(0, ex2, e1->type->nextOf());
|
||||||
#endif
|
#endif
|
||||||
Expression *ex1 = e1->buildArrayLoop(fparams);
|
Expression *ex1 = e1->buildArrayLoop(fparams);
|
||||||
Parameter *param = (*fparams)[0];
|
Parameter *param = (*fparams)[0];
|
||||||
param->storageClass = 0;
|
param->storageClass = 0;
|
||||||
Expression *e = new AssignExp(0, ex1, ex2);
|
Expression *e = new AssignExp(0, ex1, ex2);
|
||||||
return e;
|
return e;
|
||||||
@@ -549,9 +549,9 @@ Expression *Str##AssignExp::buildArrayLoop(Parameters *fparams) \
|
|||||||
*/ \
|
*/ \
|
||||||
Expression *ex2 = e2->buildArrayLoop(fparams); \
|
Expression *ex2 = e2->buildArrayLoop(fparams); \
|
||||||
Expression *ex1 = e1->buildArrayLoop(fparams); \
|
Expression *ex1 = e1->buildArrayLoop(fparams); \
|
||||||
Parameter *param = (*fparams)[0]; \
|
Parameter *param = (*fparams)[0]; \
|
||||||
param->storageClass = 0; \
|
param->storageClass = 0; \
|
||||||
Expression *e = new Str##AssignExp(loc, ex1, ex2); \
|
Expression *e = new Str##AssignExp(loc, ex1, ex2); \
|
||||||
return e; \
|
return e; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,9 +563,9 @@ X(Mod)
|
|||||||
X(Xor)
|
X(Xor)
|
||||||
X(And)
|
X(And)
|
||||||
X(Or)
|
X(Or)
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
X(Pow)
|
X(Pow)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
@@ -602,9 +602,9 @@ X(Mod)
|
|||||||
X(Xor)
|
X(Xor)
|
||||||
X(And)
|
X(And)
|
||||||
X(Or)
|
X(Or)
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
X(Pow)
|
X(Pow)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
|
|||||||
+34
-34
@@ -26,49 +26,49 @@ struct FuncDeclaration;
|
|||||||
struct Identifier;
|
struct Identifier;
|
||||||
struct Initializer;
|
struct Initializer;
|
||||||
|
|
||||||
typedef ArrayBase<struct TemplateParameter> TemplateParameters;
|
typedef ArrayBase<struct TemplateParameter> TemplateParameters;
|
||||||
|
|
||||||
typedef ArrayBase<struct Expression> Expressions;
|
typedef ArrayBase<struct Expression> Expressions;
|
||||||
|
|
||||||
typedef ArrayBase<struct Statement> Statements;
|
typedef ArrayBase<struct Statement> Statements;
|
||||||
|
|
||||||
typedef ArrayBase<struct BaseClass> BaseClasses;
|
typedef ArrayBase<struct BaseClass> BaseClasses;
|
||||||
|
|
||||||
typedef ArrayBase<struct ClassDeclaration> ClassDeclarations;
|
typedef ArrayBase<struct ClassDeclaration> ClassDeclarations;
|
||||||
|
|
||||||
typedef ArrayBase<struct Dsymbol> Dsymbols;
|
typedef ArrayBase<struct Dsymbol> Dsymbols;
|
||||||
|
|
||||||
typedef ArrayBase<struct Object> Objects;
|
typedef ArrayBase<struct Object> Objects;
|
||||||
|
|
||||||
typedef ArrayBase<struct FuncDeclaration> FuncDeclarations;
|
typedef ArrayBase<struct FuncDeclaration> FuncDeclarations;
|
||||||
|
|
||||||
typedef ArrayBase<struct Parameter> Parameters;
|
typedef ArrayBase<struct Parameter> Parameters;
|
||||||
|
|
||||||
typedef ArrayBase<struct Identifier> Identifiers;
|
typedef ArrayBase<struct Identifier> Identifiers;
|
||||||
|
|
||||||
typedef ArrayBase<struct Initializer> Initializers;
|
typedef ArrayBase<struct Initializer> Initializers;
|
||||||
|
|
||||||
typedef ArrayBase<struct VarDeclaration> VarDeclarations;
|
typedef ArrayBase<struct VarDeclaration> VarDeclarations;
|
||||||
|
|
||||||
typedef ArrayBase<struct Type> Types;
|
typedef ArrayBase<struct Type> Types;
|
||||||
|
|
||||||
typedef ArrayBase<struct ScopeDsymbol> ScopeDsymbols;
|
typedef ArrayBase<struct ScopeDsymbol> ScopeDsymbols;
|
||||||
|
|
||||||
typedef ArrayBase<struct Catch> Catches;
|
typedef ArrayBase<struct Catch> Catches;
|
||||||
|
|
||||||
typedef ArrayBase<struct StaticDtorDeclaration> StaticDtorDeclarations;
|
typedef ArrayBase<struct StaticDtorDeclaration> StaticDtorDeclarations;
|
||||||
|
|
||||||
typedef ArrayBase<struct SharedStaticDtorDeclaration> SharedStaticDtorDeclarations;
|
typedef ArrayBase<struct SharedStaticDtorDeclaration> SharedStaticDtorDeclarations;
|
||||||
typedef ArrayBase<struct Module> Modules;
|
typedef ArrayBase<struct Module> Modules;
|
||||||
typedef ArrayBase<struct CaseStatement> CaseStatements;
|
typedef ArrayBase<struct CaseStatement> CaseStatements;
|
||||||
|
|
||||||
typedef ArrayBase<struct CompoundStatement> CompoundStatements;
|
typedef ArrayBase<struct CompoundStatement> CompoundStatements;
|
||||||
|
|
||||||
typedef ArrayBase<struct GotoCaseStatement> GotoCaseStatements;
|
typedef ArrayBase<struct GotoCaseStatement> GotoCaseStatements;
|
||||||
|
|
||||||
typedef ArrayBase<struct TemplateInstance> TemplateInstances;
|
typedef ArrayBase<struct TemplateInstance> TemplateInstances;
|
||||||
typedef ArrayBase<struct block> Blocks;
|
typedef ArrayBase<struct block> Blocks;
|
||||||
|
|
||||||
typedef ArrayBase<struct Symbol> Symbols;
|
typedef ArrayBase<struct Symbol> Symbols;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+4
-4
@@ -1142,7 +1142,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
|||||||
else
|
else
|
||||||
error("unrecognized pragma(%s)", ident->toChars());
|
error("unrecognized pragma(%s)", ident->toChars());
|
||||||
|
|
||||||
Ldecl:
|
Ldecl:
|
||||||
if (decl)
|
if (decl)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < decl->dim; i++)
|
for (unsigned i = 0; i < decl->dim; i++)
|
||||||
@@ -1160,10 +1160,10 @@ Ldecl:
|
|||||||
|
|
||||||
Lnodecl:
|
Lnodecl:
|
||||||
if (decl)
|
if (decl)
|
||||||
{
|
{
|
||||||
error("pragma is missing closing ';'");
|
error("pragma is missing closing ';'");
|
||||||
goto Ldecl; // do them anyway, to avoid segfaults.
|
goto Ldecl; // do them anyway, to avoid segfaults.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PragmaDeclaration::oneMember(Dsymbol **ps)
|
int PragmaDeclaration::oneMember(Dsymbol **ps)
|
||||||
|
|||||||
+15
-15
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -29,10 +29,10 @@ struct HdrGenState;
|
|||||||
|
|
||||||
struct AttribDeclaration : Dsymbol
|
struct AttribDeclaration : Dsymbol
|
||||||
{
|
{
|
||||||
Dsymbols *decl; // array of Dsymbol's
|
Dsymbols *decl; // array of Dsymbol's
|
||||||
|
|
||||||
AttribDeclaration(Dsymbols *decl);
|
AttribDeclaration(Dsymbols *decl);
|
||||||
virtual Dsymbols *include(Scope *sc, ScopeDsymbol *s);
|
virtual Dsymbols *include(Scope *sc, ScopeDsymbol *s);
|
||||||
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
||||||
void setScopeNewSc(Scope *sc,
|
void setScopeNewSc(Scope *sc,
|
||||||
StorageClass newstc, enum LINK linkage, enum PROT protection, int explictProtection,
|
StorageClass newstc, enum LINK linkage, enum PROT protection, int explictProtection,
|
||||||
@@ -49,7 +49,7 @@ struct AttribDeclaration : Dsymbol
|
|||||||
const char *kind();
|
const char *kind();
|
||||||
int oneMember(Dsymbol **ps);
|
int oneMember(Dsymbol **ps);
|
||||||
int hasPointers();
|
int hasPointers();
|
||||||
bool hasStaticCtorOrDtor();
|
bool hasStaticCtorOrDtor();
|
||||||
void checkCtorConstInit();
|
void checkCtorConstInit();
|
||||||
void addLocalClass(ClassDeclarations *);
|
void addLocalClass(ClassDeclarations *);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -70,7 +70,7 @@ struct StorageClassDeclaration: AttribDeclaration
|
|||||||
{
|
{
|
||||||
StorageClass stc;
|
StorageClass stc;
|
||||||
|
|
||||||
StorageClassDeclaration(StorageClass stc, Dsymbols *decl);
|
StorageClassDeclaration(StorageClass stc, Dsymbols *decl);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
void setScope(Scope *sc);
|
void setScope(Scope *sc);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
@@ -83,7 +83,7 @@ struct LinkDeclaration : AttribDeclaration
|
|||||||
{
|
{
|
||||||
enum LINK linkage;
|
enum LINK linkage;
|
||||||
|
|
||||||
LinkDeclaration(enum LINK p, Dsymbols *decl);
|
LinkDeclaration(enum LINK p, Dsymbols *decl);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
void setScope(Scope *sc);
|
void setScope(Scope *sc);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
@@ -96,7 +96,7 @@ struct ProtDeclaration : AttribDeclaration
|
|||||||
{
|
{
|
||||||
enum PROT protection;
|
enum PROT protection;
|
||||||
|
|
||||||
ProtDeclaration(enum PROT p, Dsymbols *decl);
|
ProtDeclaration(enum PROT p, Dsymbols *decl);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
void importAll(Scope *sc);
|
void importAll(Scope *sc);
|
||||||
void setScope(Scope *sc);
|
void setScope(Scope *sc);
|
||||||
@@ -110,7 +110,7 @@ struct AlignDeclaration : AttribDeclaration
|
|||||||
{
|
{
|
||||||
unsigned salign;
|
unsigned salign;
|
||||||
|
|
||||||
AlignDeclaration(Loc loc, unsigned sa, Dsymbols *decl);
|
AlignDeclaration(Loc loc, unsigned sa, Dsymbols *decl);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
void setScope(Scope *sc);
|
void setScope(Scope *sc);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
@@ -122,7 +122,7 @@ struct AnonDeclaration : AttribDeclaration
|
|||||||
int isunion;
|
int isunion;
|
||||||
int sem; // 1 if successful semantic()
|
int sem; // 1 if successful semantic()
|
||||||
|
|
||||||
AnonDeclaration(Loc loc, int isunion, Dsymbols *decl);
|
AnonDeclaration(Loc loc, int isunion, Dsymbols *decl);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -133,7 +133,7 @@ struct PragmaDeclaration : AttribDeclaration
|
|||||||
{
|
{
|
||||||
Expressions *args; // array of Expression's
|
Expressions *args; // array of Expression's
|
||||||
|
|
||||||
PragmaDeclaration(Loc loc, Identifier *ident, Expressions *args, Dsymbols *decl);
|
PragmaDeclaration(Loc loc, Identifier *ident, Expressions *args, Dsymbols *decl);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void setScope(Scope *sc);
|
void setScope(Scope *sc);
|
||||||
@@ -153,13 +153,13 @@ struct PragmaDeclaration : AttribDeclaration
|
|||||||
struct ConditionalDeclaration : AttribDeclaration
|
struct ConditionalDeclaration : AttribDeclaration
|
||||||
{
|
{
|
||||||
Condition *condition;
|
Condition *condition;
|
||||||
Dsymbols *elsedecl; // array of Dsymbol's for else block
|
Dsymbols *elsedecl; // array of Dsymbol's for else block
|
||||||
|
|
||||||
ConditionalDeclaration(Condition *condition, Dsymbols *decl, Dsymbols *elsedecl);
|
ConditionalDeclaration(Condition *condition, Dsymbols *decl, Dsymbols *elsedecl);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
int oneMember(Dsymbol **ps);
|
int oneMember(Dsymbol **ps);
|
||||||
void emitComment(Scope *sc);
|
void emitComment(Scope *sc);
|
||||||
Dsymbols *include(Scope *sc, ScopeDsymbol *s);
|
Dsymbols *include(Scope *sc, ScopeDsymbol *s);
|
||||||
void addComment(unsigned char *comment);
|
void addComment(unsigned char *comment);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void toJsonBuffer(OutBuffer *buf);
|
void toJsonBuffer(OutBuffer *buf);
|
||||||
@@ -172,7 +172,7 @@ struct StaticIfDeclaration : ConditionalDeclaration
|
|||||||
ScopeDsymbol *sd;
|
ScopeDsymbol *sd;
|
||||||
int addisdone;
|
int addisdone;
|
||||||
|
|
||||||
StaticIfDeclaration(Condition *condition, Dsymbols *decl, Dsymbols *elsedecl);
|
StaticIfDeclaration(Condition *condition, Dsymbols *decl, Dsymbols *elsedecl);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
|
|||||||
+34
-34
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -123,8 +123,8 @@ MATCH Expression::implicitConvTo(Type *t)
|
|||||||
toChars(), type->toChars(), t->toChars());
|
toChars(), type->toChars(), t->toChars());
|
||||||
#endif
|
#endif
|
||||||
//static int nest; if (++nest == 10) halt();
|
//static int nest; if (++nest == 10) halt();
|
||||||
if (t == Type::terror)
|
if (t == Type::terror)
|
||||||
return MATCHnomatch;
|
return MATCHnomatch;
|
||||||
if (!type)
|
if (!type)
|
||||||
{ error("%s is not an expression", toChars());
|
{ error("%s is not an expression", toChars());
|
||||||
type = Type::terror;
|
type = Type::terror;
|
||||||
@@ -379,8 +379,8 @@ MATCH StructLiteralExp::implicitConvTo(Type *t)
|
|||||||
((TypeStruct *)type)->sym == ((TypeStruct *)t)->sym)
|
((TypeStruct *)type)->sym == ((TypeStruct *)t)->sym)
|
||||||
{
|
{
|
||||||
m = MATCHconst;
|
m = MATCHconst;
|
||||||
for (size_t i = 0; i < elements->dim; i++)
|
for (size_t i = 0; i < elements->dim; i++)
|
||||||
{ Expression *e = (*elements)[i];
|
{ Expression *e = (*elements)[i];
|
||||||
Type *te = e->type;
|
Type *te = e->type;
|
||||||
if (t->mod == 0)
|
if (t->mod == 0)
|
||||||
te = te->mutableOf();
|
te = te->mutableOf();
|
||||||
@@ -399,7 +399,7 @@ MATCH StructLiteralExp::implicitConvTo(Type *t)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
MATCH StringExp::implicitConvTo(Type *t)
|
MATCH StringExp::implicitConvTo(Type *t)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n",
|
printf("StringExp::implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n",
|
||||||
toChars(), committed, type->toChars(), t->toChars());
|
toChars(), committed, type->toChars(), t->toChars());
|
||||||
@@ -467,18 +467,18 @@ MATCH ArrayLiteralExp::implicitConvTo(Type *t)
|
|||||||
result = MATCHnomatch;
|
result = MATCHnomatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < elements->dim; i++)
|
for (size_t i = 0; i < elements->dim; i++)
|
||||||
{ Expression *e = (*elements)[i];
|
{ Expression *e = (*elements)[i];
|
||||||
MATCH m = (MATCH)e->implicitConvTo(tb->nextOf());
|
MATCH m = (MATCH)e->implicitConvTo(tb->nextOf());
|
||||||
if (m < result)
|
if (m < result)
|
||||||
result = m; // remember worst match
|
result = m; // remember worst match
|
||||||
if (result == MATCHnomatch)
|
if (result == MATCHnomatch)
|
||||||
break; // no need to check for worse
|
break; // no need to check for worse
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
result = type->implicitConvTo(t);
|
result = type->implicitConvTo(t);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -667,12 +667,12 @@ Expression *Expression::castTo(Scope *sc, Type *t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Expression *ErrorExp::castTo(Scope *sc, Type *t)
|
Expression *ErrorExp::castTo(Scope *sc, Type *t)
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Expression *RealExp::castTo(Scope *sc, Type *t)
|
Expression *RealExp::castTo(Scope *sc, Type *t)
|
||||||
{ Expression *e = this;
|
{ Expression *e = this;
|
||||||
if (type != t)
|
if (type != t)
|
||||||
@@ -765,7 +765,7 @@ Expression *StringExp::castTo(Scope *sc, Type *t)
|
|||||||
return new ErrorExp();
|
return new ErrorExp();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringExp *se = this;
|
StringExp *se = this;
|
||||||
if (!committed)
|
if (!committed)
|
||||||
{ se = (StringExp *)copy();
|
{ se = (StringExp *)copy();
|
||||||
se->committed = 1;
|
se->committed = 1;
|
||||||
@@ -777,7 +777,7 @@ Expression *StringExp::castTo(Scope *sc, Type *t)
|
|||||||
return se;
|
return se;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type *tb = t->toBasetype();
|
Type *tb = t->toBasetype();
|
||||||
//printf("\ttype = %s\n", type->toChars());
|
//printf("\ttype = %s\n", type->toChars());
|
||||||
if (tb->ty == Tdelegate && type->toBasetype()->ty != Tdelegate)
|
if (tb->ty == Tdelegate && type->toBasetype()->ty != Tdelegate)
|
||||||
return Expression::castTo(sc, t);
|
return Expression::castTo(sc, t);
|
||||||
@@ -921,11 +921,11 @@ Expression *StringExp::castTo(Scope *sc, Type *t)
|
|||||||
}
|
}
|
||||||
se->string = buffer.extractData();
|
se->string = buffer.extractData();
|
||||||
se->len = newlen;
|
se->len = newlen;
|
||||||
{
|
{
|
||||||
d_uns64 szx = tb->nextOf()->size();
|
d_uns64 szx = tb->nextOf()->size();
|
||||||
assert(szx <= 255);
|
assert(szx <= 255);
|
||||||
se->sz = (unsigned char)szx;
|
se->sz = (unsigned char)szx;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -940,9 +940,9 @@ L2:
|
|||||||
// See if need to truncate or extend the literal
|
// See if need to truncate or extend the literal
|
||||||
if (tb->ty == Tsarray)
|
if (tb->ty == Tsarray)
|
||||||
{
|
{
|
||||||
dinteger_t dim2 = ((TypeSArray *)tb)->dim->toInteger();
|
dinteger_t dim2 = ((TypeSArray *)tb)->dim->toInteger();
|
||||||
|
|
||||||
//printf("dim from = %d, to = %d\n", (int)se->len, (int)dim2);
|
//printf("dim from = %d, to = %d\n", (int)se->len, (int)dim2);
|
||||||
|
|
||||||
// Changing dimensions
|
// Changing dimensions
|
||||||
if (dim2 != se->len)
|
if (dim2 != se->len)
|
||||||
@@ -1050,10 +1050,10 @@ Expression *ArrayLiteralExp::castTo(Scope *sc, Type *t)
|
|||||||
|
|
||||||
e = (ArrayLiteralExp *)copy();
|
e = (ArrayLiteralExp *)copy();
|
||||||
e->elements = (Expressions *)elements->copy();
|
e->elements = (Expressions *)elements->copy();
|
||||||
for (size_t i = 0; i < elements->dim; i++)
|
for (size_t i = 0; i < elements->dim; i++)
|
||||||
{ Expression *ex = (*elements)[i];
|
{ Expression *ex = (*elements)[i];
|
||||||
ex = ex->castTo(sc, tb->nextOf());
|
ex = ex->castTo(sc, tb->nextOf());
|
||||||
(*e->elements)[i] = ex;
|
(*e->elements)[i] = ex;
|
||||||
}
|
}
|
||||||
e->type = t;
|
e->type = t;
|
||||||
return e;
|
return e;
|
||||||
@@ -1451,14 +1451,14 @@ Expression *BinExp::typeCombine(Scope *sc)
|
|||||||
}
|
}
|
||||||
else if ((t1->ty == Tsarray || t1->ty == Tarray) && t1->implicitConvTo(t2))
|
else if ((t1->ty == Tsarray || t1->ty == Tarray) && t1->implicitConvTo(t2))
|
||||||
{
|
{
|
||||||
if (t1->ty == Tsarray && e2->op == TOKarrayliteral)
|
if (t1->ty == Tsarray && e2->op == TOKarrayliteral)
|
||||||
goto Lt1;
|
goto Lt1;
|
||||||
goto Lt2;
|
goto Lt2;
|
||||||
}
|
}
|
||||||
else if ((t2->ty == Tsarray || t2->ty == Tarray) && t2->implicitConvTo(t1))
|
else if ((t2->ty == Tsarray || t2->ty == Tarray) && t2->implicitConvTo(t1))
|
||||||
{
|
{
|
||||||
if (t2->ty == Tsarray && e1->op == TOKarrayliteral)
|
if (t2->ty == Tsarray && e1->op == TOKarrayliteral)
|
||||||
goto Lt2;
|
goto Lt2;
|
||||||
goto Lt1;
|
goto Lt1;
|
||||||
}
|
}
|
||||||
else if (t1->ty == Tclass || t2->ty == Tclass)
|
else if (t1->ty == Tclass || t2->ty == Tclass)
|
||||||
|
|||||||
+122
-122
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
ClassDeclaration *ClassDeclaration::classinfo;
|
ClassDeclaration *ClassDeclaration::classinfo;
|
||||||
ClassDeclaration *ClassDeclaration::object;
|
ClassDeclaration *ClassDeclaration::object;
|
||||||
ClassDeclaration *ClassDeclaration::errorException;
|
ClassDeclaration *ClassDeclaration::errorException;
|
||||||
|
|
||||||
ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses)
|
ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses)
|
||||||
: AggregateDeclaration(loc, id)
|
: AggregateDeclaration(loc, id)
|
||||||
@@ -171,12 +171,12 @@ ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *basecla
|
|||||||
Type::typeinfoshared->error("%s", msg);
|
Type::typeinfoshared->error("%s", msg);
|
||||||
Type::typeinfoshared = this;
|
Type::typeinfoshared = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == Id::TypeInfo_Wild)
|
if (id == Id::TypeInfo_Wild)
|
||||||
{ if (Type::typeinfowild)
|
{ if (Type::typeinfowild)
|
||||||
Type::typeinfowild->error("%s", msg);
|
Type::typeinfowild->error("%s", msg);
|
||||||
Type::typeinfowild = this;
|
Type::typeinfowild = this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,12 +186,12 @@ ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *basecla
|
|||||||
object = this;
|
object = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == Id::Error)
|
if (id == Id::Error)
|
||||||
{ if (errorException)
|
{ if (errorException)
|
||||||
errorException->error("%s", msg);
|
errorException->error("%s", msg);
|
||||||
errorException = this;
|
errorException = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == Id::ClassInfo)
|
if (id == Id::ClassInfo)
|
||||||
{ if (classinfo)
|
{ if (classinfo)
|
||||||
classinfo->error("%s", msg);
|
classinfo->error("%s", msg);
|
||||||
@@ -226,7 +226,7 @@ Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s)
|
|||||||
cd->storage_class |= storage_class;
|
cd->storage_class |= storage_class;
|
||||||
|
|
||||||
cd->baseclasses->setDim(this->baseclasses->dim);
|
cd->baseclasses->setDim(this->baseclasses->dim);
|
||||||
for (size_t i = 0; i < cd->baseclasses->dim; i++)
|
for (size_t i = 0; i < cd->baseclasses->dim; i++)
|
||||||
{
|
{
|
||||||
BaseClass *b = (BaseClass *)this->baseclasses->data[i];
|
BaseClass *b = (BaseClass *)this->baseclasses->data[i];
|
||||||
BaseClass *b2 = new BaseClass(b->type->syntaxCopy(), b->protection);
|
BaseClass *b2 = new BaseClass(b->type->syntaxCopy(), b->protection);
|
||||||
@@ -238,7 +238,7 @@ Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ClassDeclaration::semantic(Scope *sc)
|
void ClassDeclaration::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
//printf("ClassDeclaration::semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this);
|
//printf("ClassDeclaration::semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this);
|
||||||
//printf("\tparent = %p, '%s'\n", sc->parent, sc->parent ? sc->parent->toChars() : "");
|
//printf("\tparent = %p, '%s'\n", sc->parent, sc->parent ? sc->parent->toChars() : "");
|
||||||
//printf("sc->stc = %x\n", sc->stc);
|
//printf("sc->stc = %x\n", sc->stc);
|
||||||
@@ -289,7 +289,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expand any tuples in baseclasses[]
|
// Expand any tuples in baseclasses[]
|
||||||
for (size_t i = 0; i < baseclasses->dim; )
|
for (size_t i = 0; i < baseclasses->dim; )
|
||||||
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||||
b->type = b->type->semantic(loc, sc);
|
b->type = b->type->semantic(loc, sc);
|
||||||
Type *tb = b->type->toBasetype();
|
Type *tb = b->type->toBasetype();
|
||||||
@@ -379,7 +379,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
|||||||
|
|
||||||
// Treat the remaining entries in baseclasses as interfaces
|
// Treat the remaining entries in baseclasses as interfaces
|
||||||
// Check for errors, handle forward references
|
// Check for errors, handle forward references
|
||||||
for (size_t i = (baseClass ? 1 : 0); i < baseclasses->dim; )
|
for (size_t i = (baseClass ? 1 : 0); i < baseclasses->dim; )
|
||||||
{ TypeClass *tc;
|
{ TypeClass *tc;
|
||||||
BaseClass *b;
|
BaseClass *b;
|
||||||
Type *tb;
|
Type *tb;
|
||||||
@@ -501,7 +501,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
|||||||
{
|
{
|
||||||
interfaceSemantic(sc);
|
interfaceSemantic(sc);
|
||||||
|
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||||
s->addMember(sc, this, 1);
|
s->addMember(sc, this, 1);
|
||||||
@@ -547,9 +547,9 @@ void ClassDeclaration::semantic(Scope *sc)
|
|||||||
if (ad)
|
if (ad)
|
||||||
t = ad->handle;
|
t = ad->handle;
|
||||||
else if (fd)
|
else if (fd)
|
||||||
{ AggregateDeclaration *ad2 = fd->isMember2();
|
{ AggregateDeclaration *ad2 = fd->isMember2();
|
||||||
if (ad2)
|
if (ad2)
|
||||||
t = ad2->handle;
|
t = ad2->handle;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = new TypePointer(Type::tvoid);
|
t = new TypePointer(Type::tvoid);
|
||||||
@@ -605,13 +605,13 @@ void ClassDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
structsize = sc->offset;
|
structsize = sc->offset;
|
||||||
Scope scsave = *sc;
|
Scope scsave = *sc;
|
||||||
size_t members_dim = members->dim;
|
size_t members_dim = members->dim;
|
||||||
sizeok = 0;
|
sizeok = 0;
|
||||||
|
|
||||||
/* Set scope so if there are forward references, we still might be able to
|
/* Set scope so if there are forward references, we still might be able to
|
||||||
* resolve individual members like enums.
|
* resolve individual members like enums.
|
||||||
*/
|
*/
|
||||||
for (size_t i = 0; i < members_dim; i++)
|
for (size_t i = 0; i < members_dim; i++)
|
||||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||||
/* There are problems doing this in the general case because
|
/* There are problems doing this in the general case because
|
||||||
* Scope keeps track of things like 'offset'
|
* Scope keeps track of things like 'offset'
|
||||||
@@ -623,7 +623,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < members_dim; i++)
|
for (size_t i = 0; i < members_dim; i++)
|
||||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||||
s->semantic(sc);
|
s->semantic(sc);
|
||||||
}
|
}
|
||||||
@@ -699,7 +699,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Allocate instance of each new interface
|
// Allocate instance of each new interface
|
||||||
for (size_t i = 0; i < vtblInterfaces->dim; i++)
|
for (size_t i = 0; i < vtblInterfaces->dim; i++)
|
||||||
{
|
{
|
||||||
BaseClass *b = (BaseClass *)vtblInterfaces->data[i];
|
BaseClass *b = (BaseClass *)vtblInterfaces->data[i];
|
||||||
unsigned thissize = PTRSIZE;
|
unsigned thissize = PTRSIZE;
|
||||||
@@ -748,7 +748,7 @@ void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
|||||||
if (baseclasses->dim)
|
if (baseclasses->dim)
|
||||||
buf->writestring(" : ");
|
buf->writestring(" : ");
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||||
{
|
{
|
||||||
BaseClass *b = (BaseClass *)baseclasses->data[i];
|
BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||||
|
|
||||||
@@ -762,7 +762,7 @@ void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
|||||||
buf->writenl();
|
buf->writenl();
|
||||||
buf->writeByte('{');
|
buf->writeByte('{');
|
||||||
buf->writenl();
|
buf->writenl();
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||||
|
|
||||||
@@ -798,7 +798,7 @@ int ClassDeclaration::isBaseOf2(ClassDeclaration *cd)
|
|||||||
if (!cd)
|
if (!cd)
|
||||||
return 0;
|
return 0;
|
||||||
//printf("ClassDeclaration::isBaseOf2(this = '%s', cd = '%s')\n", toChars(), cd->toChars());
|
//printf("ClassDeclaration::isBaseOf2(this = '%s', cd = '%s')\n", toChars(), cd->toChars());
|
||||||
for (size_t i = 0; i < cd->baseclasses->dim; i++)
|
for (size_t i = 0; i < cd->baseclasses->dim; i++)
|
||||||
{ BaseClass *b = (BaseClass *)cd->baseclasses->data[i];
|
{ BaseClass *b = (BaseClass *)cd->baseclasses->data[i];
|
||||||
|
|
||||||
if (b->base == this || isBaseOf2(b->base))
|
if (b->base == this || isBaseOf2(b->base))
|
||||||
@@ -822,14 +822,14 @@ int ClassDeclaration::isBaseOf(ClassDeclaration *cd, int *poffset)
|
|||||||
*/
|
*/
|
||||||
if (!cd->baseClass && cd->baseclasses->dim && !cd->isInterfaceDeclaration())
|
if (!cd->baseClass && cd->baseclasses->dim && !cd->isInterfaceDeclaration())
|
||||||
{
|
{
|
||||||
cd->semantic(NULL);
|
cd->semantic(NULL);
|
||||||
if (!cd->baseClass)
|
if (!cd->baseClass)
|
||||||
cd->error("base class is forward referenced by %s", toChars());
|
cd->error("base class is forward referenced by %s", toChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this == cd->baseClass)
|
if (this == cd->baseClass)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
cd = cd->baseClass;
|
cd = cd->baseClass;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -844,7 +844,7 @@ int ClassDeclaration::isBaseInfoComplete()
|
|||||||
{
|
{
|
||||||
if (!baseClass)
|
if (!baseClass)
|
||||||
return ident == Id::Object;
|
return ident == Id::Object;
|
||||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||||
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||||
if (!b->base || !b->base->isBaseInfoComplete())
|
if (!b->base || !b->base->isBaseInfoComplete())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -857,14 +857,14 @@ Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags)
|
|||||||
Dsymbol *s;
|
Dsymbol *s;
|
||||||
//printf("%s.ClassDeclaration::search('%s')\n", toChars(), ident->toChars());
|
//printf("%s.ClassDeclaration::search('%s')\n", toChars(), ident->toChars());
|
||||||
|
|
||||||
if (scope && !symtab)
|
if (scope && !symtab)
|
||||||
{ Scope *sc = scope;
|
{ Scope *sc = scope;
|
||||||
sc->mustsemantic++;
|
sc->mustsemantic++;
|
||||||
semantic(sc);
|
semantic(sc);
|
||||||
sc->mustsemantic--;
|
sc->mustsemantic--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!members || !symtab)
|
if (!members || !symtab)
|
||||||
{
|
{
|
||||||
error("is forward referenced when looking for '%s'", ident->toChars());
|
error("is forward referenced when looking for '%s'", ident->toChars());
|
||||||
//*(char*)0=0;
|
//*(char*)0=0;
|
||||||
@@ -876,7 +876,7 @@ Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags)
|
|||||||
{
|
{
|
||||||
// Search bases classes in depth-first, left to right order
|
// Search bases classes in depth-first, left to right order
|
||||||
|
|
||||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||||
{
|
{
|
||||||
BaseClass *b = (BaseClass *)baseclasses->data[i];
|
BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||||
|
|
||||||
@@ -898,23 +898,23 @@ Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dsymbol *ClassDeclaration::searchBase(Loc loc, Identifier *ident)
|
Dsymbol *ClassDeclaration::searchBase(Loc loc, Identifier *ident)
|
||||||
{
|
{
|
||||||
// Search bases classes in depth-first, left to right order
|
// Search bases classes in depth-first, left to right order
|
||||||
|
|
||||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||||
{
|
{
|
||||||
BaseClass *b = (*baseclasses)[i];
|
BaseClass *b = (*baseclasses)[i];
|
||||||
Dsymbol *cdb = b->type->isClassHandle();
|
Dsymbol *cdb = b->type->isClassHandle();
|
||||||
if (cdb->ident->equals(ident))
|
if (cdb->ident->equals(ident))
|
||||||
return cdb;
|
return cdb;
|
||||||
cdb = ((ClassDeclaration *)cdb)->searchBase(loc, ident);
|
cdb = ((ClassDeclaration *)cdb)->searchBase(loc, ident);
|
||||||
if (cdb)
|
if (cdb)
|
||||||
return cdb;
|
return cdb;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************
|
/**********************************************************
|
||||||
* fd is in the vtbl[] for this class.
|
* fd is in the vtbl[] for this class.
|
||||||
* Return 1 if function is hidden (not findable through search).
|
* Return 1 if function is hidden (not findable through search).
|
||||||
@@ -940,10 +940,10 @@ int ClassDeclaration::isFuncHidden(FuncDeclaration *fd)
|
|||||||
}
|
}
|
||||||
FuncDeclaration *fdstart = s->toAlias()->isFuncDeclaration();
|
FuncDeclaration *fdstart = s->toAlias()->isFuncDeclaration();
|
||||||
//printf("%s fdstart = %p\n", s->kind(), fdstart);
|
//printf("%s fdstart = %p\n", s->kind(), fdstart);
|
||||||
if (overloadApply(fdstart, &isf, fd))
|
if (overloadApply(fdstart, &isf, fd))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return !fd->parent->isTemplateMixin();
|
return !fd->parent->isTemplateMixin();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -955,58 +955,58 @@ int ClassDeclaration::isFuncHidden(FuncDeclaration *fd)
|
|||||||
FuncDeclaration *ClassDeclaration::findFunc(Identifier *ident, TypeFunction *tf)
|
FuncDeclaration *ClassDeclaration::findFunc(Identifier *ident, TypeFunction *tf)
|
||||||
{
|
{
|
||||||
//printf("ClassDeclaration::findFunc(%s, %s) %s\n", ident->toChars(), tf->toChars(), toChars());
|
//printf("ClassDeclaration::findFunc(%s, %s) %s\n", ident->toChars(), tf->toChars(), toChars());
|
||||||
FuncDeclaration *fdmatch = NULL;
|
FuncDeclaration *fdmatch = NULL;
|
||||||
FuncDeclaration *fdambig = NULL;
|
FuncDeclaration *fdambig = NULL;
|
||||||
|
|
||||||
ClassDeclaration *cd = this;
|
ClassDeclaration *cd = this;
|
||||||
Dsymbols *vtbl = &cd->vtbl;
|
Dsymbols *vtbl = &cd->vtbl;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < vtbl->dim; i++)
|
for (size_t i = 0; i < vtbl->dim; i++)
|
||||||
{
|
{
|
||||||
FuncDeclaration *fd = (*vtbl)[i]->isFuncDeclaration();
|
FuncDeclaration *fd = (*vtbl)[i]->isFuncDeclaration();
|
||||||
if (!fd)
|
if (!fd)
|
||||||
continue; // the first entry might be a ClassInfo
|
continue; // the first entry might be a ClassInfo
|
||||||
|
|
||||||
//printf("\t[%d] = %s\n", i, fd->toChars());
|
//printf("\t[%d] = %s\n", i, fd->toChars());
|
||||||
if (ident == fd->ident &&
|
if (ident == fd->ident &&
|
||||||
fd->type->covariant(tf) == 1)
|
fd->type->covariant(tf) == 1)
|
||||||
{ //printf("fd->parent->isClassDeclaration() = %p", fd->parent->isClassDeclaration());
|
{ //printf("fd->parent->isClassDeclaration() = %p", fd->parent->isClassDeclaration());
|
||||||
if (!fdmatch)
|
if (!fdmatch)
|
||||||
goto Lfd;
|
goto Lfd;
|
||||||
|
|
||||||
{
|
{
|
||||||
// Function type matcing: exact > covariant
|
// Function type matcing: exact > covariant
|
||||||
int m1 = tf->equals(fd ->type) ? MATCHexact : MATCHnomatch;
|
int m1 = tf->equals(fd ->type) ? MATCHexact : MATCHnomatch;
|
||||||
int m2 = tf->equals(fdmatch->type) ? MATCHexact : MATCHnomatch;
|
int m2 = tf->equals(fdmatch->type) ? MATCHexact : MATCHnomatch;
|
||||||
if (m1 > m2)
|
if (m1 > m2)
|
||||||
goto Lfd;
|
goto Lfd;
|
||||||
else if (m1 < m2)
|
else if (m1 < m2)
|
||||||
goto Lfdmatch;
|
goto Lfdmatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// The way of definition: non-mixin > mixin
|
// The way of definition: non-mixin > mixin
|
||||||
int m1 = fd ->parent->isClassDeclaration() ? MATCHexact : MATCHnomatch;
|
int m1 = fd ->parent->isClassDeclaration() ? MATCHexact : MATCHnomatch;
|
||||||
int m2 = fdmatch->parent->isClassDeclaration() ? MATCHexact : MATCHnomatch;
|
int m2 = fdmatch->parent->isClassDeclaration() ? MATCHexact : MATCHnomatch;
|
||||||
if (m1 > m2)
|
if (m1 > m2)
|
||||||
goto Lfd;
|
goto Lfd;
|
||||||
else if (m1 < m2)
|
else if (m1 < m2)
|
||||||
goto Lfdmatch;
|
goto Lfdmatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lambig:
|
Lambig:
|
||||||
fdambig = fd;
|
fdambig = fd;
|
||||||
//printf("Lambig fdambig = %s %s [%s]\n", fdambig->toChars(), fdambig->type->toChars(), fdambig->loc.toChars());
|
//printf("Lambig fdambig = %s %s [%s]\n", fdambig->toChars(), fdambig->type->toChars(), fdambig->loc.toChars());
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Lfd:
|
Lfd:
|
||||||
fdmatch = fd, fdambig = NULL;
|
fdmatch = fd, fdambig = NULL;
|
||||||
//printf("Lfd fdmatch = %s %s [%s]\n", fdmatch->toChars(), fdmatch->type->toChars(), fdmatch->loc.toChars());
|
//printf("Lfd fdmatch = %s %s [%s]\n", fdmatch->toChars(), fdmatch->type->toChars(), fdmatch->loc.toChars());
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Lfdmatch:
|
Lfdmatch:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//else printf("\t\t%d\n", fd->type->covariant(tf));
|
//else printf("\t\t%d\n", fd->type->covariant(tf));
|
||||||
}
|
}
|
||||||
@@ -1016,9 +1016,9 @@ FuncDeclaration *ClassDeclaration::findFunc(Identifier *ident, TypeFunction *tf)
|
|||||||
cd = cd->baseClass;
|
cd = cd->baseClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fdambig)
|
if (fdambig)
|
||||||
error("ambiguous virtual function %s", fdambig->toChars());
|
error("ambiguous virtual function %s", fdambig->toChars());
|
||||||
return fdmatch;
|
return fdmatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassDeclaration::interfaceSemantic(Scope *sc)
|
void ClassDeclaration::interfaceSemantic(Scope *sc)
|
||||||
@@ -1068,7 +1068,7 @@ int ClassDeclaration::isAbstract()
|
|||||||
{
|
{
|
||||||
if (isabstract)
|
if (isabstract)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
for (size_t i = 1; i < vtbl.dim; i++)
|
for (size_t i = 1; i < vtbl.dim; i++)
|
||||||
{
|
{
|
||||||
FuncDeclaration *fd = ((Dsymbol *)vtbl.data[i])->isFuncDeclaration();
|
FuncDeclaration *fd = ((Dsymbol *)vtbl.data[i])->isFuncDeclaration();
|
||||||
|
|
||||||
@@ -1145,7 +1145,7 @@ Dsymbol *InterfaceDeclaration::syntaxCopy(Dsymbol *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InterfaceDeclaration::semantic(Scope *sc)
|
void InterfaceDeclaration::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
//printf("InterfaceDeclaration::semantic(%s), type = %p\n", toChars(), type);
|
//printf("InterfaceDeclaration::semantic(%s), type = %p\n", toChars(), type);
|
||||||
if (inuse)
|
if (inuse)
|
||||||
return;
|
return;
|
||||||
@@ -1182,7 +1182,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expand any tuples in baseclasses[]
|
// Expand any tuples in baseclasses[]
|
||||||
for (size_t i = 0; i < baseclasses->dim; )
|
for (size_t i = 0; i < baseclasses->dim; )
|
||||||
{ BaseClass *b = (BaseClass *)baseclasses->data[0];
|
{ BaseClass *b = (BaseClass *)baseclasses->data[0];
|
||||||
b->type = b->type->semantic(loc, sc);
|
b->type = b->type->semantic(loc, sc);
|
||||||
Type *tb = b->type->toBasetype();
|
Type *tb = b->type->toBasetype();
|
||||||
@@ -1203,7 +1203,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for errors, handle forward references
|
// Check for errors, handle forward references
|
||||||
for (size_t i = 0; i < baseclasses->dim; )
|
for (size_t i = 0; i < baseclasses->dim; )
|
||||||
{ TypeClass *tc;
|
{ TypeClass *tc;
|
||||||
BaseClass *b;
|
BaseClass *b;
|
||||||
Type *tb;
|
Type *tb;
|
||||||
@@ -1266,11 +1266,11 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
|||||||
vtbl.push(this); // leave room at vtbl[0] for classinfo
|
vtbl.push(this); // leave room at vtbl[0] for classinfo
|
||||||
|
|
||||||
// Cat together the vtbl[]'s from base interfaces
|
// Cat together the vtbl[]'s from base interfaces
|
||||||
for (size_t i = 0; i < interfaces_dim; i++)
|
for (size_t i = 0; i < interfaces_dim; i++)
|
||||||
{ BaseClass *b = interfaces[i];
|
{ BaseClass *b = interfaces[i];
|
||||||
|
|
||||||
// Skip if b has already appeared
|
// Skip if b has already appeared
|
||||||
for (size_t k = 0; k < i; k++)
|
for (size_t k = 0; k < i; k++)
|
||||||
{
|
{
|
||||||
if (b == interfaces[k])
|
if (b == interfaces[k])
|
||||||
goto Lcontinue;
|
goto Lcontinue;
|
||||||
@@ -1278,12 +1278,12 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
|||||||
|
|
||||||
// Copy vtbl[] from base class
|
// Copy vtbl[] from base class
|
||||||
if (b->base->vtblOffset())
|
if (b->base->vtblOffset())
|
||||||
{ size_t d = b->base->vtbl.dim;
|
{ size_t d = b->base->vtbl.dim;
|
||||||
if (d > 1)
|
if (d > 1)
|
||||||
{
|
{
|
||||||
vtbl.reserve(d - 1);
|
vtbl.reserve(d - 1);
|
||||||
for (size_t j = 1; j < d; j++)
|
for (size_t j = 1; j < d; j++)
|
||||||
vtbl.push((Dsymbol *)b->base->vtbl.data[j]);
|
vtbl.push((Dsymbol *)b->base->vtbl.data[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1295,26 +1295,26 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (*members)[i];
|
Dsymbol *s = (*members)[i];
|
||||||
s->addMember(sc, this, 1);
|
s->addMember(sc, this, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
sc = sc->push(this);
|
sc = sc->push(this);
|
||||||
sc->stc &= STCsafe | STCtrusted | STCsystem;
|
sc->stc &= STCsafe | STCtrusted | STCsystem;
|
||||||
sc->parent = this;
|
sc->parent = this;
|
||||||
if (isCOMinterface())
|
if (isCOMinterface())
|
||||||
sc->linkage = LINKwindows;
|
sc->linkage = LINKwindows;
|
||||||
sc->structalign = 8;
|
sc->structalign = 8;
|
||||||
sc->protection = PROTpublic;
|
sc->protection = PROTpublic;
|
||||||
sc->explicitProtection = 0;
|
sc->explicitProtection = 0;
|
||||||
structalign = sc->structalign;
|
structalign = sc->structalign;
|
||||||
sc->offset = PTRSIZE * 2;
|
sc->offset = PTRSIZE * 2;
|
||||||
inuse++;
|
inuse++;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (*members)[i];
|
Dsymbol *s = (*members)[i];
|
||||||
s->semantic(sc);
|
s->semantic(sc);
|
||||||
}
|
}
|
||||||
inuse--;
|
inuse--;
|
||||||
@@ -1407,7 +1407,7 @@ int InterfaceDeclaration::isBaseOf(BaseClass *bc, int *poffset)
|
|||||||
int InterfaceDeclaration::isBaseInfoComplete()
|
int InterfaceDeclaration::isBaseInfoComplete()
|
||||||
{
|
{
|
||||||
assert(!baseClass);
|
assert(!baseClass);
|
||||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||||
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||||
if (!b->base || !b->base->isBaseInfoComplete ())
|
if (!b->base || !b->base->isBaseInfoComplete ())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1480,7 +1480,7 @@ BaseClass::BaseClass(Type *type, enum PROT protection)
|
|||||||
* by base classes)
|
* by base classes)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newinstance)
|
int BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newinstance)
|
||||||
{
|
{
|
||||||
ClassDeclaration *id = base;
|
ClassDeclaration *id = base;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@@ -1490,7 +1490,7 @@ int BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newins
|
|||||||
vtbl->setDim(base->vtbl.dim);
|
vtbl->setDim(base->vtbl.dim);
|
||||||
|
|
||||||
// first entry is ClassInfo reference
|
// first entry is ClassInfo reference
|
||||||
for (size_t j = base->vtblOffset(); j < base->vtbl.dim; j++)
|
for (size_t j = base->vtblOffset(); j < base->vtbl.dim; j++)
|
||||||
{
|
{
|
||||||
FuncDeclaration *ifd = ((Dsymbol *)base->vtbl.data[j])->isFuncDeclaration();
|
FuncDeclaration *ifd = ((Dsymbol *)base->vtbl.data[j])->isFuncDeclaration();
|
||||||
FuncDeclaration *fd;
|
FuncDeclaration *fd;
|
||||||
|
|||||||
+175
-175
@@ -1,175 +1,175 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "root.h"
|
#include "root.h"
|
||||||
#include "aggregate.h"
|
#include "aggregate.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "declaration.h"
|
#include "declaration.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "expression.h"
|
#include "expression.h"
|
||||||
#include "statement.h"
|
#include "statement.h"
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* Generate expression that calls opClone()
|
* Generate expression that calls opClone()
|
||||||
* for each member of the struct
|
* for each member of the struct
|
||||||
* (can be NULL for members that don't need one)
|
* (can be NULL for members that don't need one)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
Expression *StructDeclaration::cloneMembers()
|
Expression *StructDeclaration::cloneMembers()
|
||||||
{
|
{
|
||||||
Expression *e = NULL;
|
Expression *e = NULL;
|
||||||
|
|
||||||
for (size_t i = 0; i < fields.dim; i++)
|
for (size_t i = 0; i < fields.dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||||
VarDeclaration *v = s->isVarDeclaration();
|
VarDeclaration *v = s->isVarDeclaration();
|
||||||
assert(v && v->storage_class & STCfield);
|
assert(v && v->storage_class & STCfield);
|
||||||
Type *tv = v->type->toBasetype();
|
Type *tv = v->type->toBasetype();
|
||||||
dinteger_t dim = (tv->ty == Tsarray ? 1 : 0);
|
dinteger_t dim = (tv->ty == Tsarray ? 1 : 0);
|
||||||
while (tv->ty == Tsarray)
|
while (tv->ty == Tsarray)
|
||||||
{ TypeSArray *ta = (TypeSArray *)tv;
|
{ TypeSArray *ta = (TypeSArray *)tv;
|
||||||
dim *= ((TypeSArray *)tv)->dim->toInteger();
|
dim *= ((TypeSArray *)tv)->dim->toInteger();
|
||||||
tv = tv->nextOf()->toBasetype();
|
tv = tv->nextOf()->toBasetype();
|
||||||
}
|
}
|
||||||
if (tv->ty == Tstruct)
|
if (tv->ty == Tstruct)
|
||||||
{ TypeStruct *ts = (TypeStruct *)tv;
|
{ TypeStruct *ts = (TypeStruct *)tv;
|
||||||
StructDeclaration *sd = ts->sym;
|
StructDeclaration *sd = ts->sym;
|
||||||
if (sd->opclone)
|
if (sd->opclone)
|
||||||
{
|
{
|
||||||
|
|
||||||
// this.v
|
// this.v
|
||||||
Expression *ex = new ThisExp(0);
|
Expression *ex = new ThisExp(0);
|
||||||
ex = new DotVarExp(0, ex, v, 0);
|
ex = new DotVarExp(0, ex, v, 0);
|
||||||
|
|
||||||
if (dim == 1)
|
if (dim == 1)
|
||||||
{ // this.v.opClone()
|
{ // this.v.opClone()
|
||||||
ex = new DotVarExp(0, ex, sd->opclone, 0);
|
ex = new DotVarExp(0, ex, sd->opclone, 0);
|
||||||
ex = new CallExp(0, ex);
|
ex = new CallExp(0, ex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// _callOpClones(&this.v, opclone, dim)
|
// _callOpClones(&this.v, opclone, dim)
|
||||||
Expressions *args = new Expressions();
|
Expressions *args = new Expressions();
|
||||||
args->push(new AddrExp(0, ex));
|
args->push(new AddrExp(0, ex));
|
||||||
args->push(new SymOffExp(0, sd->opclone, 0));
|
args->push(new SymOffExp(0, sd->opclone, 0));
|
||||||
args->push(new IntegerExp(dim));
|
args->push(new IntegerExp(dim));
|
||||||
FuncDeclaration *ec = FuncDeclaration::genCfunc(Type::tvoid, "_callOpClones");
|
FuncDeclaration *ec = FuncDeclaration::genCfunc(Type::tvoid, "_callOpClones");
|
||||||
ex = new CallExp(0, new VarExp(0, ec), args);
|
ex = new CallExp(0, new VarExp(0, ec), args);
|
||||||
}
|
}
|
||||||
e = Expression::combine(e, ex);
|
e = Expression::combine(e, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* Create inclusive destructor for struct by aggregating
|
* Create inclusive destructor for struct by aggregating
|
||||||
* all the destructors in dtors[] with the destructors for
|
* all the destructors in dtors[] with the destructors for
|
||||||
* all the members.
|
* all the members.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FuncDeclaration *AggregateDeclaration::buildDtor(Scope *sc)
|
FuncDeclaration *AggregateDeclaration::buildDtor(Scope *sc)
|
||||||
{
|
{
|
||||||
//printf("StructDeclaration::buildDtor() %s\n", toChars());
|
//printf("StructDeclaration::buildDtor() %s\n", toChars());
|
||||||
Expression *e = NULL;
|
Expression *e = NULL;
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
for (size_t i = 0; i < fields.dim; i++)
|
for (size_t i = 0; i < fields.dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||||
VarDeclaration *v = s->isVarDeclaration();
|
VarDeclaration *v = s->isVarDeclaration();
|
||||||
assert(v && v->storage_class & STCfield);
|
assert(v && v->storage_class & STCfield);
|
||||||
Type *tv = v->type->toBasetype();
|
Type *tv = v->type->toBasetype();
|
||||||
dinteger_t dim = (tv->ty == Tsarray ? 1 : 0);
|
dinteger_t dim = (tv->ty == Tsarray ? 1 : 0);
|
||||||
while (tv->ty == Tsarray)
|
while (tv->ty == Tsarray)
|
||||||
{ TypeSArray *ta = (TypeSArray *)tv;
|
{ TypeSArray *ta = (TypeSArray *)tv;
|
||||||
dim *= ((TypeSArray *)tv)->dim->toInteger();
|
dim *= ((TypeSArray *)tv)->dim->toInteger();
|
||||||
tv = tv->nextOf()->toBasetype();
|
tv = tv->nextOf()->toBasetype();
|
||||||
}
|
}
|
||||||
if (tv->ty == Tstruct)
|
if (tv->ty == Tstruct)
|
||||||
{ TypeStruct *ts = (TypeStruct *)tv;
|
{ TypeStruct *ts = (TypeStruct *)tv;
|
||||||
StructDeclaration *sd = ts->sym;
|
StructDeclaration *sd = ts->sym;
|
||||||
if (sd->dtor)
|
if (sd->dtor)
|
||||||
{ Expression *ex;
|
{ Expression *ex;
|
||||||
|
|
||||||
// this.v
|
// this.v
|
||||||
ex = new ThisExp(0);
|
ex = new ThisExp(0);
|
||||||
ex = new DotVarExp(0, ex, v, 0);
|
ex = new DotVarExp(0, ex, v, 0);
|
||||||
|
|
||||||
if (dim == 1)
|
if (dim == 1)
|
||||||
{ // this.v.dtor()
|
{ // this.v.dtor()
|
||||||
ex = new DotVarExp(0, ex, sd->dtor, 0);
|
ex = new DotVarExp(0, ex, sd->dtor, 0);
|
||||||
ex = new CallExp(0, ex);
|
ex = new CallExp(0, ex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Typeinfo.destroy(cast(void*)&this.v);
|
// Typeinfo.destroy(cast(void*)&this.v);
|
||||||
Expression *ea = new AddrExp(0, ex);
|
Expression *ea = new AddrExp(0, ex);
|
||||||
ea = new CastExp(0, ea, Type::tvoid->pointerTo());
|
ea = new CastExp(0, ea, Type::tvoid->pointerTo());
|
||||||
Expressions *args = new Expressions();
|
Expressions *args = new Expressions();
|
||||||
args->push(ea);
|
args->push(ea);
|
||||||
|
|
||||||
Expression *et = v->type->getTypeInfo(sc);
|
Expression *et = v->type->getTypeInfo(sc);
|
||||||
et = new DotIdExp(0, et, Id::destroy);
|
et = new DotIdExp(0, et, Id::destroy);
|
||||||
|
|
||||||
ex = new CallExp(0, et, args);
|
ex = new CallExp(0, et, args);
|
||||||
}
|
}
|
||||||
e = Expression::combine(ex, e); // combine in reverse order
|
e = Expression::combine(ex, e); // combine in reverse order
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build our own "destructor" which executes e
|
/* Build our own "destructor" which executes e
|
||||||
*/
|
*/
|
||||||
if (e)
|
if (e)
|
||||||
{ //printf("Building __fieldDtor()\n");
|
{ //printf("Building __fieldDtor()\n");
|
||||||
DtorDeclaration *dd = new DtorDeclaration(loc, 0, Lexer::idPool("__fieldDtor"));
|
DtorDeclaration *dd = new DtorDeclaration(loc, 0, Lexer::idPool("__fieldDtor"));
|
||||||
dd->fbody = new ExpStatement(0, e);
|
dd->fbody = new ExpStatement(0, e);
|
||||||
dtors.shift(dd);
|
dtors.shift(dd);
|
||||||
members->push(dd);
|
members->push(dd);
|
||||||
dd->semantic(sc);
|
dd->semantic(sc);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (dtors.dim)
|
switch (dtors.dim)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
return (FuncDeclaration *)dtors.data[0];
|
return (FuncDeclaration *)dtors.data[0];
|
||||||
|
|
||||||
default:
|
default:
|
||||||
e = NULL;
|
e = NULL;
|
||||||
for (size_t i = 0; i < dtors.dim; i++)
|
for (size_t i = 0; i < dtors.dim; i++)
|
||||||
{ FuncDeclaration *fd = (FuncDeclaration *)dtors.data[i];
|
{ FuncDeclaration *fd = (FuncDeclaration *)dtors.data[i];
|
||||||
Expression *ex = new ThisExp(0);
|
Expression *ex = new ThisExp(0);
|
||||||
ex = new DotVarExp(0, ex, fd);
|
ex = new DotVarExp(0, ex, fd);
|
||||||
ex = new CallExp(0, ex);
|
ex = new CallExp(0, ex);
|
||||||
e = Expression::combine(ex, e);
|
e = Expression::combine(ex, e);
|
||||||
}
|
}
|
||||||
DtorDeclaration *dd = new DtorDeclaration(loc, 0, Lexer::idPool("__aggrDtor"));
|
DtorDeclaration *dd = new DtorDeclaration(loc, 0, Lexer::idPool("__aggrDtor"));
|
||||||
dd->fbody = new ExpStatement(0, e);
|
dd->fbody = new ExpStatement(0, e);
|
||||||
members->push(dd);
|
members->push(dd);
|
||||||
dd->semantic(sc);
|
dd->semantic(sc);
|
||||||
return dd;
|
return dd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+74
-74
@@ -1,74 +1,74 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright and Burton Radons
|
// written by Walter Bright and Burton Radons
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_COMPLEX_T_H
|
#ifndef DMD_COMPLEX_T_H
|
||||||
#define DMD_COMPLEX_T_H
|
#define DMD_COMPLEX_T_H
|
||||||
|
|
||||||
/* Roll our own complex type for compilers that don't support complex
|
/* Roll our own complex type for compilers that don't support complex
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct complex_t
|
struct complex_t
|
||||||
{
|
{
|
||||||
long double re;
|
long double re;
|
||||||
long double im;
|
long double im;
|
||||||
|
|
||||||
complex_t() { this->re = 0; this->im = 0; }
|
complex_t() { this->re = 0; this->im = 0; }
|
||||||
complex_t(long double re) { this->re = re; this->im = 0; }
|
complex_t(long double re) { this->re = re; this->im = 0; }
|
||||||
complex_t(long double re, long double im) { this->re = re; this->im = im; }
|
complex_t(long double re, long double im) { this->re = re; this->im = im; }
|
||||||
|
|
||||||
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 y) { complex_t r; r.re = re + y.re; r.im = im + y.im; return r; }
|
||||||
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 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 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) { return complex_t(re * y.re - im * y.im, im * y.re + re * y.im); }
|
||||||
|
|
||||||
complex_t operator / (complex_t y)
|
complex_t operator / (complex_t y)
|
||||||
{
|
{
|
||||||
long double abs_y_re = y.re < 0 ? -y.re : y.re;
|
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 abs_y_im = y.im < 0 ? -y.im : y.im;
|
||||||
long double r, den;
|
long double r, den;
|
||||||
|
|
||||||
if (abs_y_re < abs_y_im)
|
if (abs_y_re < abs_y_im)
|
||||||
{
|
{
|
||||||
r = y.re / y.im;
|
r = y.re / y.im;
|
||||||
den = y.im + r * y.re;
|
den = y.im + r * y.re;
|
||||||
return complex_t((re * r + im) / den,
|
return complex_t((re * r + im) / den,
|
||||||
(im * r - re) / den);
|
(im * r - re) / den);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r = y.im / y.re;
|
r = y.im / y.re;
|
||||||
den = y.re + r * y.im;
|
den = y.re + r * y.im;
|
||||||
return complex_t((re + r * im) / den,
|
return complex_t((re + r * im) / den,
|
||||||
(im - r * re) / den);
|
(im - r * re) / den);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
operator bool () { return re || im; }
|
operator bool () { return re || im; }
|
||||||
|
|
||||||
int operator == (complex_t y) { return re == y.re && im == y.im; }
|
int operator == (complex_t y) { return re == y.re && im == y.im; }
|
||||||
int operator != (complex_t y) { return re != y.re || im != y.im; }
|
int operator != (complex_t y) { return re != y.re || im != y.im; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline complex_t operator * (long double x, complex_t y) { return complex_t(x) * y; }
|
inline complex_t operator * (long double x, complex_t y) { return complex_t(x) * y; }
|
||||||
inline complex_t operator * (complex_t x, long double y) { return x * complex_t(y); }
|
inline complex_t operator * (complex_t x, long double y) { return x * complex_t(y); }
|
||||||
inline complex_t operator / (complex_t x, long double y) { return x / complex_t(y); }
|
inline complex_t operator / (complex_t x, long double y) { return x / complex_t(y); }
|
||||||
|
|
||||||
|
|
||||||
inline long double creall(complex_t x)
|
inline long double creall(complex_t x)
|
||||||
{
|
{
|
||||||
return x.re;
|
return x.re;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline long double cimagl(complex_t x)
|
inline long double cimagl(complex_t x)
|
||||||
{
|
{
|
||||||
return x.im;
|
return x.im;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+24
-24
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -22,15 +22,15 @@
|
|||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "arraytypes.h"
|
#include "arraytypes.h"
|
||||||
|
|
||||||
int findCondition(Strings *ids, Identifier *ident)
|
int findCondition(Strings *ids, Identifier *ident)
|
||||||
{
|
{
|
||||||
if (ids)
|
if (ids)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < ids->dim; i++)
|
for (size_t i = 0; i < ids->dim; i++)
|
||||||
{
|
{
|
||||||
const char *id = (*ids)[i];
|
const char *id = (*ids)[i];
|
||||||
|
|
||||||
if (strcmp(id, ident->toChars()) == 0)
|
if (strcmp(id, ident->toChars()) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -73,8 +73,8 @@ void DebugCondition::setGlobalLevel(unsigned level)
|
|||||||
void DebugCondition::addGlobalIdent(const char *ident)
|
void DebugCondition::addGlobalIdent(const char *ident)
|
||||||
{
|
{
|
||||||
if (!global.params.debugids)
|
if (!global.params.debugids)
|
||||||
global.params.debugids = new Strings();
|
global.params.debugids = new Strings();
|
||||||
global.params.debugids->push((char *)ident);
|
global.params.debugids->push((char *)ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ int DebugCondition::include(Scope *sc, ScopeDsymbol *s)
|
|||||||
inc = 1;
|
inc = 1;
|
||||||
else
|
else
|
||||||
{ if (!mod->debugidsNot)
|
{ if (!mod->debugidsNot)
|
||||||
mod->debugidsNot = new Strings();
|
mod->debugidsNot = new Strings();
|
||||||
mod->debugidsNot->push(ident->toChars());
|
mod->debugidsNot->push(ident->toChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,10 +134,10 @@ void VersionCondition::checkPredefined(Loc loc, const char *ident)
|
|||||||
* redefinition breaks makefiles and older builds.
|
* redefinition breaks makefiles and older builds.
|
||||||
*/
|
*/
|
||||||
"Posix",
|
"Posix",
|
||||||
"D_NET",
|
"D_NET",
|
||||||
#endif
|
#endif
|
||||||
"OSX", "FreeBSD",
|
"OSX", "FreeBSD",
|
||||||
"OpenBSD",
|
"OpenBSD",
|
||||||
"Solaris",
|
"Solaris",
|
||||||
"LittleEndian", "BigEndian",
|
"LittleEndian", "BigEndian",
|
||||||
"all",
|
"all",
|
||||||
@@ -174,8 +174,8 @@ void VersionCondition::addGlobalIdent(const char *ident)
|
|||||||
void VersionCondition::addPredefinedGlobalIdent(const char *ident)
|
void VersionCondition::addPredefinedGlobalIdent(const char *ident)
|
||||||
{
|
{
|
||||||
if (!global.params.versionids)
|
if (!global.params.versionids)
|
||||||
global.params.versionids = new Strings();
|
global.params.versionids = new Strings();
|
||||||
global.params.versionids->push((char *)ident);
|
global.params.versionids->push((char *)ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ int VersionCondition::include(Scope *sc, ScopeDsymbol *s)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!mod->versionidsNot)
|
if (!mod->versionidsNot)
|
||||||
mod->versionidsNot = new Strings();
|
mod->versionidsNot = new Strings();
|
||||||
mod->versionidsNot->push(ident->toChars());
|
mod->versionidsNot->push(ident->toChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -308,14 +308,14 @@ int IftypeCondition::include(Scope *sc, ScopeDsymbol *sd)
|
|||||||
inc = 2;
|
inc = 2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Type *t = targ->trySemantic(loc, sc);
|
Type *t = targ->trySemantic(loc, sc);
|
||||||
if (t)
|
if (t)
|
||||||
targ = t;
|
targ = t;
|
||||||
else
|
else
|
||||||
inc = 2; // condition is false
|
inc = 2; // condition is false
|
||||||
|
|
||||||
if (!t)
|
if (!t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (id && tspec)
|
else if (id && tspec)
|
||||||
{
|
{
|
||||||
@@ -328,19 +328,19 @@ int IftypeCondition::include(Scope *sc, ScopeDsymbol *sd)
|
|||||||
|
|
||||||
TemplateParameters parameters;
|
TemplateParameters parameters;
|
||||||
parameters.setDim(1);
|
parameters.setDim(1);
|
||||||
parameters[0] = &tp;
|
parameters[0] = &tp;
|
||||||
|
|
||||||
Objects dedtypes;
|
Objects dedtypes;
|
||||||
dedtypes.setDim(1);
|
dedtypes.setDim(1);
|
||||||
|
|
||||||
m = targ->deduceType(sc, tspec, ¶meters, &dedtypes);
|
m = targ->deduceType(sc, tspec, ¶meters, &dedtypes);
|
||||||
if (m == MATCHnomatch ||
|
if (m == MATCHnomatch ||
|
||||||
(m != MATCHexact && tok == TOKequal))
|
(m != MATCHexact && tok == TOKequal))
|
||||||
inc = 2;
|
inc = 2;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inc = 1;
|
inc = 1;
|
||||||
Type *tded = (Type *)dedtypes[0];
|
Type *tded = (Type *)dedtypes[0];
|
||||||
if (!tded)
|
if (!tded)
|
||||||
tded = targ;
|
tded = targ;
|
||||||
Dsymbol *s = new AliasDeclaration(loc, id, tded);
|
Dsymbol *s = new AliasDeclaration(loc, id, tded);
|
||||||
|
|||||||
+103
-103
@@ -1,103 +1,103 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_DEBCOND_H
|
#ifndef DMD_DEBCOND_H
|
||||||
#define DMD_DEBCOND_H
|
#define DMD_DEBCOND_H
|
||||||
|
|
||||||
struct Expression;
|
struct Expression;
|
||||||
struct Identifier;
|
struct Identifier;
|
||||||
struct OutBuffer;
|
struct OutBuffer;
|
||||||
struct Module;
|
struct Module;
|
||||||
struct Scope;
|
struct Scope;
|
||||||
struct ScopeDsymbol;
|
struct ScopeDsymbol;
|
||||||
struct DebugCondition;
|
struct DebugCondition;
|
||||||
#include "lexer.h" // dmdhg
|
#include "lexer.h" // dmdhg
|
||||||
enum TOK;
|
enum TOK;
|
||||||
struct HdrGenState;
|
struct HdrGenState;
|
||||||
|
|
||||||
int findCondition(Strings *ids, Identifier *ident);
|
int findCondition(Strings *ids, Identifier *ident);
|
||||||
|
|
||||||
struct Condition
|
struct Condition
|
||||||
{
|
{
|
||||||
Loc loc;
|
Loc loc;
|
||||||
int inc; // 0: not computed yet
|
int inc; // 0: not computed yet
|
||||||
// 1: include
|
// 1: include
|
||||||
// 2: do not include
|
// 2: do not include
|
||||||
|
|
||||||
Condition(Loc loc);
|
Condition(Loc loc);
|
||||||
|
|
||||||
virtual Condition *syntaxCopy() = 0;
|
virtual Condition *syntaxCopy() = 0;
|
||||||
virtual int include(Scope *sc, ScopeDsymbol *s) = 0;
|
virtual int include(Scope *sc, ScopeDsymbol *s) = 0;
|
||||||
virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0;
|
virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DVCondition : Condition
|
struct DVCondition : Condition
|
||||||
{
|
{
|
||||||
unsigned level;
|
unsigned level;
|
||||||
Identifier *ident;
|
Identifier *ident;
|
||||||
Module *mod;
|
Module *mod;
|
||||||
|
|
||||||
DVCondition(Module *mod, unsigned level, Identifier *ident);
|
DVCondition(Module *mod, unsigned level, Identifier *ident);
|
||||||
|
|
||||||
Condition *syntaxCopy();
|
Condition *syntaxCopy();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DebugCondition : DVCondition
|
struct DebugCondition : DVCondition
|
||||||
{
|
{
|
||||||
static void setGlobalLevel(unsigned level);
|
static void setGlobalLevel(unsigned level);
|
||||||
static void addGlobalIdent(const char *ident);
|
static void addGlobalIdent(const char *ident);
|
||||||
static void addPredefinedGlobalIdent(const char *ident);
|
static void addPredefinedGlobalIdent(const char *ident);
|
||||||
|
|
||||||
DebugCondition(Module *mod, unsigned level, Identifier *ident);
|
DebugCondition(Module *mod, unsigned level, Identifier *ident);
|
||||||
|
|
||||||
int include(Scope *sc, ScopeDsymbol *s);
|
int include(Scope *sc, ScopeDsymbol *s);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VersionCondition : DVCondition
|
struct VersionCondition : DVCondition
|
||||||
{
|
{
|
||||||
static void setGlobalLevel(unsigned level);
|
static void setGlobalLevel(unsigned level);
|
||||||
static void checkPredefined(Loc loc, const char *ident);
|
static void checkPredefined(Loc loc, const char *ident);
|
||||||
static void addGlobalIdent(const char *ident);
|
static void addGlobalIdent(const char *ident);
|
||||||
static void addPredefinedGlobalIdent(const char *ident);
|
static void addPredefinedGlobalIdent(const char *ident);
|
||||||
|
|
||||||
VersionCondition(Module *mod, unsigned level, Identifier *ident);
|
VersionCondition(Module *mod, unsigned level, Identifier *ident);
|
||||||
|
|
||||||
int include(Scope *sc, ScopeDsymbol *s);
|
int include(Scope *sc, ScopeDsymbol *s);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StaticIfCondition : Condition
|
struct StaticIfCondition : Condition
|
||||||
{
|
{
|
||||||
Expression *exp;
|
Expression *exp;
|
||||||
|
|
||||||
StaticIfCondition(Loc loc, Expression *exp);
|
StaticIfCondition(Loc loc, Expression *exp);
|
||||||
Condition *syntaxCopy();
|
Condition *syntaxCopy();
|
||||||
int include(Scope *sc, ScopeDsymbol *s);
|
int include(Scope *sc, ScopeDsymbol *s);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IftypeCondition : Condition
|
struct IftypeCondition : Condition
|
||||||
{
|
{
|
||||||
/* iftype (targ id tok tspec)
|
/* iftype (targ id tok tspec)
|
||||||
*/
|
*/
|
||||||
Type *targ;
|
Type *targ;
|
||||||
Identifier *id; // can be NULL
|
Identifier *id; // can be NULL
|
||||||
enum TOK tok; // ':' or '=='
|
enum TOK tok; // ':' or '=='
|
||||||
Type *tspec; // can be NULL
|
Type *tspec; // can be NULL
|
||||||
|
|
||||||
IftypeCondition(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec);
|
IftypeCondition(Loc loc, Type *targ, Identifier *id, enum TOK tok, Type *tspec);
|
||||||
Condition *syntaxCopy();
|
Condition *syntaxCopy();
|
||||||
int include(Scope *sc, ScopeDsymbol *s);
|
int include(Scope *sc, ScopeDsymbol *s);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+211
-211
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -38,8 +38,8 @@ static real_t zero; // work around DMC bug for now
|
|||||||
|
|
||||||
#define LOG 0
|
#define LOG 0
|
||||||
|
|
||||||
int RealEquals(real_t x1, real_t x2);
|
int RealEquals(real_t x1, real_t x2);
|
||||||
|
|
||||||
Expression *expType(Type *type, Expression *e)
|
Expression *expType(Type *type, Expression *e)
|
||||||
{
|
{
|
||||||
if (type != e->type)
|
if (type != e->type)
|
||||||
@@ -493,7 +493,7 @@ Expression *Mod(Type *type, Expression *e1, Expression *e2)
|
|||||||
{ real_t r2 = e2->toReal();
|
{ real_t r2 = e2->toReal();
|
||||||
|
|
||||||
#ifdef __DMC__
|
#ifdef __DMC__
|
||||||
c = Port::fmodl(e1->toReal(), r2) + Port::fmodl(e1->toImaginary(), r2) * I;
|
c = Port::fmodl(e1->toReal(), r2) + Port::fmodl(e1->toImaginary(), r2) * I;
|
||||||
#elif defined(IN_GCC)
|
#elif defined(IN_GCC)
|
||||||
c = complex_t(e1->toReal() % r2, e1->toImaginary() % r2);
|
c = complex_t(e1->toReal() % r2, e1->toImaginary() % r2);
|
||||||
#elif (defined(__FreeBSD__) && __FreeBSD_version < 800000) || defined(__arm__) || defined(__thumb__)
|
#elif (defined(__FreeBSD__) && __FreeBSD_version < 800000) || defined(__arm__) || defined(__thumb__)
|
||||||
@@ -501,14 +501,14 @@ Expression *Mod(Type *type, Expression *e1, Expression *e2)
|
|||||||
// arm also doesn't like fmodl
|
// arm also doesn't like fmodl
|
||||||
c = complex_t(fmod(e1->toReal(), r2), fmod(e1->toImaginary(), r2));
|
c = complex_t(fmod(e1->toReal(), r2), fmod(e1->toImaginary(), r2));
|
||||||
#else
|
#else
|
||||||
c = complex_t(Port::fmodl(e1->toReal(), r2), Port::fmodl(e1->toImaginary(), r2));
|
c = complex_t(Port::fmodl(e1->toReal(), r2), Port::fmodl(e1->toImaginary(), r2));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (e2->type->isimaginary())
|
else if (e2->type->isimaginary())
|
||||||
{ real_t i2 = e2->toImaginary();
|
{ real_t i2 = e2->toImaginary();
|
||||||
|
|
||||||
#ifdef __DMC__
|
#ifdef __DMC__
|
||||||
c = Port::fmodl(e1->toReal(), i2) + Port::fmodl(e1->toImaginary(), i2) * I;
|
c = Port::fmodl(e1->toReal(), i2) + Port::fmodl(e1->toImaginary(), i2) * I;
|
||||||
#elif defined(IN_GCC)
|
#elif defined(IN_GCC)
|
||||||
c = complex_t(e1->toReal() % i2, e1->toImaginary() % i2);
|
c = complex_t(e1->toReal() % i2, e1->toImaginary() % i2);
|
||||||
#elif (defined(__FreeBSD__) && __FreeBSD_version < 800000) || defined(__arm__) || defined(__thumb__)
|
#elif (defined(__FreeBSD__) && __FreeBSD_version < 800000) || defined(__arm__) || defined(__thumb__)
|
||||||
@@ -516,7 +516,7 @@ Expression *Mod(Type *type, Expression *e1, Expression *e2)
|
|||||||
// arm also doesn't like fmodl
|
// arm also doesn't like fmodl
|
||||||
c = complex_t(fmod(e1->toReal(), i2), fmod(e1->toImaginary(), i2));
|
c = complex_t(fmod(e1->toReal(), i2), fmod(e1->toImaginary(), i2));
|
||||||
#else
|
#else
|
||||||
c = complex_t(Port::fmodl(e1->toReal(), i2), Port::fmodl(e1->toImaginary(), i2));
|
c = complex_t(Port::fmodl(e1->toReal(), i2), Port::fmodl(e1->toImaginary(), i2));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -543,21 +543,21 @@ Expression *Mod(Type *type, Expression *e1, Expression *e2)
|
|||||||
e2 = new IntegerExp(loc, 1, e2->type);
|
e2 = new IntegerExp(loc, 1, e2->type);
|
||||||
n2 = 1;
|
n2 = 1;
|
||||||
}
|
}
|
||||||
if (n2 == -1 && !type->isunsigned())
|
if (n2 == -1 && !type->isunsigned())
|
||||||
{ // Check for int.min % -1
|
{ // Check for int.min % -1
|
||||||
if (n1 == 0xFFFFFFFF80000000ULL && type->toBasetype()->ty != Tint64)
|
if (n1 == 0xFFFFFFFF80000000ULL && type->toBasetype()->ty != Tint64)
|
||||||
{
|
{
|
||||||
e2->error("integer overflow: int.min % -1");
|
e2->error("integer overflow: int.min % -1");
|
||||||
e2 = new IntegerExp(loc, 1, e2->type);
|
e2 = new IntegerExp(loc, 1, e2->type);
|
||||||
n2 = 1;
|
n2 = 1;
|
||||||
}
|
}
|
||||||
else if (n1 == 0x8000000000000000LL) // long.min % -1
|
else if (n1 == 0x8000000000000000LL) // long.min % -1
|
||||||
{
|
{
|
||||||
e2->error("integer overflow: long.min % -1");
|
e2->error("integer overflow: long.min % -1");
|
||||||
e2 = new IntegerExp(loc, 1, e2->type);
|
e2 = new IntegerExp(loc, 1, e2->type);
|
||||||
n2 = 1;
|
n2 = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (e1->type->isunsigned() || e2->type->isunsigned())
|
if (e1->type->isunsigned() || e2->type->isunsigned())
|
||||||
n = ((d_uns64) n1) % ((d_uns64) n2);
|
n = ((d_uns64) n1) % ((d_uns64) n2);
|
||||||
else
|
else
|
||||||
@@ -580,9 +580,9 @@ Expression *Shr(Type *type, Expression *e1, Expression *e2)
|
|||||||
Loc loc = e1->loc;
|
Loc loc = e1->loc;
|
||||||
|
|
||||||
dinteger_t value = e1->toInteger();
|
dinteger_t value = e1->toInteger();
|
||||||
dinteger_t dcount = e2->toInteger();
|
dinteger_t dcount = e2->toInteger();
|
||||||
assert(dcount <= 0xFFFFFFFF);
|
assert(dcount <= 0xFFFFFFFF);
|
||||||
unsigned count = (unsigned)dcount;
|
unsigned count = (unsigned)dcount;
|
||||||
switch (e1->type->toBasetype()->ty)
|
switch (e1->type->toBasetype()->ty)
|
||||||
{
|
{
|
||||||
case Tint8:
|
case Tint8:
|
||||||
@@ -590,7 +590,7 @@ Expression *Shr(Type *type, Expression *e1, Expression *e2)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Tuns8:
|
case Tuns8:
|
||||||
case Tchar:
|
case Tchar:
|
||||||
value = (d_uns8)(value) >> count;
|
value = (d_uns8)(value) >> count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -599,7 +599,7 @@ Expression *Shr(Type *type, Expression *e1, Expression *e2)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Tuns16:
|
case Tuns16:
|
||||||
case Twchar:
|
case Twchar:
|
||||||
value = (d_uns16)(value) >> count;
|
value = (d_uns16)(value) >> count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ Expression *Shr(Type *type, Expression *e1, Expression *e2)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Tuns32:
|
case Tuns32:
|
||||||
case Tdchar:
|
case Tdchar:
|
||||||
value = (d_uns32)(value) >> count;
|
value = (d_uns32)(value) >> count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -635,28 +635,28 @@ Expression *Ushr(Type *type, Expression *e1, Expression *e2)
|
|||||||
Loc loc = e1->loc;
|
Loc loc = e1->loc;
|
||||||
|
|
||||||
dinteger_t value = e1->toInteger();
|
dinteger_t value = e1->toInteger();
|
||||||
dinteger_t dcount = e2->toInteger();
|
dinteger_t dcount = e2->toInteger();
|
||||||
assert(dcount <= 0xFFFFFFFF);
|
assert(dcount <= 0xFFFFFFFF);
|
||||||
unsigned count = (unsigned)dcount;
|
unsigned count = (unsigned)dcount;
|
||||||
switch (e1->type->toBasetype()->ty)
|
switch (e1->type->toBasetype()->ty)
|
||||||
{
|
{
|
||||||
case Tint8:
|
case Tint8:
|
||||||
case Tuns8:
|
case Tuns8:
|
||||||
case Tchar:
|
case Tchar:
|
||||||
// Possible only with >>>=. >>> always gets promoted to int.
|
// Possible only with >>>=. >>> always gets promoted to int.
|
||||||
value = (value & 0xFF) >> count;
|
value = (value & 0xFF) >> count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Tint16:
|
case Tint16:
|
||||||
case Tuns16:
|
case Tuns16:
|
||||||
case Twchar:
|
case Twchar:
|
||||||
// Possible only with >>>=. >>> always gets promoted to int.
|
// Possible only with >>>=. >>> always gets promoted to int.
|
||||||
value = (value & 0xFFFF) >> count;
|
value = (value & 0xFFFF) >> count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Tint32:
|
case Tint32:
|
||||||
case Tuns32:
|
case Tuns32:
|
||||||
case Tdchar:
|
case Tdchar:
|
||||||
value = (value & 0xFFFFFFFF) >> count;
|
value = (value & 0xFFFFFFFF) >> count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -764,8 +764,8 @@ Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < es1->elements->dim; i++)
|
for (size_t i = 0; i < es1->elements->dim; i++)
|
||||||
{ Expression *ee1 = (*es1->elements)[i];
|
{ Expression *ee1 = (*es1->elements)[i];
|
||||||
Expression *ee2 = (*es2->elements)[i];
|
Expression *ee2 = (*es2->elements)[i];
|
||||||
|
|
||||||
Expression *v = Equal(TOKequal, Type::tint32, ee1, ee2);
|
Expression *v = Equal(TOKequal, Type::tint32, ee1, ee2);
|
||||||
if (v == EXP_CANT_INTERPRET)
|
if (v == EXP_CANT_INTERPRET)
|
||||||
@@ -778,9 +778,9 @@ Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2)
|
|||||||
}
|
}
|
||||||
else if (e1->op == TOKarrayliteral && e2->op == TOKstring)
|
else if (e1->op == TOKarrayliteral && e2->op == TOKstring)
|
||||||
{ // Swap operands and use common code
|
{ // Swap operands and use common code
|
||||||
Expression *etmp = e1;
|
Expression *etmp = e1;
|
||||||
e1 = e2;
|
e1 = e2;
|
||||||
e2 = etmp;
|
e2 = etmp;
|
||||||
goto Lsa;
|
goto Lsa;
|
||||||
}
|
}
|
||||||
else if (e1->op == TOKstring && e2->op == TOKarrayliteral)
|
else if (e1->op == TOKstring && e2->op == TOKarrayliteral)
|
||||||
@@ -794,11 +794,11 @@ Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2)
|
|||||||
cmp = 0;
|
cmp = 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cmp = 1; // if dim1 winds up being 0
|
cmp = 1; // if dim1 winds up being 0
|
||||||
for (size_t i = 0; i < dim1; i++)
|
for (size_t i = 0; i < dim1; i++)
|
||||||
{
|
{
|
||||||
uinteger_t c = es1->charAt(i);
|
uinteger_t c = es1->charAt(i);
|
||||||
Expression *ee2 = (*es2->elements)[i];
|
Expression *ee2 = (*es2->elements)[i];
|
||||||
if (ee2->isConst() != 1)
|
if (ee2->isConst() != 1)
|
||||||
return EXP_CANT_INTERPRET;
|
return EXP_CANT_INTERPRET;
|
||||||
cmp = (c == ee2->toInteger());
|
cmp = (c == ee2->toInteger());
|
||||||
@@ -824,8 +824,8 @@ Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2)
|
|||||||
{
|
{
|
||||||
cmp = 1;
|
cmp = 1;
|
||||||
for (size_t i = 0; i < es1->elements->dim; i++)
|
for (size_t i = 0; i < es1->elements->dim; i++)
|
||||||
{ Expression *ee1 = (*es1->elements)[i];
|
{ Expression *ee1 = (*es1->elements)[i];
|
||||||
Expression *ee2 = (*es2->elements)[i];
|
Expression *ee2 = (*es2->elements)[i];
|
||||||
|
|
||||||
if (ee1 == ee2)
|
if (ee1 == ee2)
|
||||||
continue;
|
continue;
|
||||||
@@ -909,11 +909,11 @@ Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2)
|
|||||||
|
|
||||||
cmp = (es1->var == es2->var && es1->offset == es2->offset);
|
cmp = (es1->var == es2->var && es1->offset == es2->offset);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Equal((op == TOKidentity) ? TOKequal : TOKnotequal,
|
return Equal((op == TOKidentity) ? TOKequal : TOKnotequal,
|
||||||
type, e1, e2);
|
type, e1, e2);
|
||||||
}
|
}
|
||||||
if (op == TOKnotidentity)
|
if (op == TOKnotidentity)
|
||||||
cmp ^= 1;
|
cmp ^= 1;
|
||||||
return new IntegerExp(loc, cmp, type);
|
return new IntegerExp(loc, cmp, type);
|
||||||
@@ -1158,7 +1158,7 @@ Expression *Cast(Type *type, Type *to, Expression *e1)
|
|||||||
assert(sd);
|
assert(sd);
|
||||||
Expressions *elements = new Expressions;
|
Expressions *elements = new Expressions;
|
||||||
for (size_t i = 0; i < sd->fields.dim; i++)
|
for (size_t i = 0; i < sd->fields.dim; i++)
|
||||||
{ Dsymbol *s = sd->fields.tdata()[i];
|
{ Dsymbol *s = sd->fields.tdata()[i];
|
||||||
VarDeclaration *v = s->isVarDeclaration();
|
VarDeclaration *v = s->isVarDeclaration();
|
||||||
assert(v);
|
assert(v);
|
||||||
|
|
||||||
@@ -1221,13 +1221,13 @@ Expression *Index(Type *type, Expression *e1, Expression *e2)
|
|||||||
uinteger_t i = e2->toInteger();
|
uinteger_t i = e2->toInteger();
|
||||||
|
|
||||||
if (i >= es1->len)
|
if (i >= es1->len)
|
||||||
{
|
{
|
||||||
e1->error("string index %ju is out of bounds [0 .. %zu]", i, es1->len);
|
e1->error("string index %ju is out of bounds [0 .. %zu]", i, es1->len);
|
||||||
e = new ErrorExp();
|
e = new ErrorExp();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e = new IntegerExp(loc, es1->charAt(i), type);
|
e = new IntegerExp(loc, es1->charAt(i), type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e1->type->toBasetype()->ty == Tsarray && e2->op == TOKint64)
|
else if (e1->type->toBasetype()->ty == Tsarray && e2->op == TOKint64)
|
||||||
@@ -1236,38 +1236,38 @@ Expression *Index(Type *type, Expression *e1, Expression *e2)
|
|||||||
uinteger_t i = e2->toInteger();
|
uinteger_t i = e2->toInteger();
|
||||||
|
|
||||||
if (i >= length)
|
if (i >= length)
|
||||||
{
|
{
|
||||||
e1->error("array index %ju is out of bounds %s[0 .. %ju]", i, e1->toChars(), length);
|
e1->error("array index %ju is out of bounds %s[0 .. %ju]", i, e1->toChars(), length);
|
||||||
e = new ErrorExp();
|
e = new ErrorExp();
|
||||||
}
|
}
|
||||||
else if (e1->op == TOKarrayliteral)
|
else if (e1->op == TOKarrayliteral)
|
||||||
{ ArrayLiteralExp *ale = (ArrayLiteralExp *)e1;
|
{ ArrayLiteralExp *ale = (ArrayLiteralExp *)e1;
|
||||||
e = ale->elements->tdata()[i];
|
e = ale->elements->tdata()[i];
|
||||||
e->type = type;
|
e->type = type;
|
||||||
if (e->hasSideEffect())
|
if (e->hasSideEffect())
|
||||||
e = EXP_CANT_INTERPRET;
|
e = EXP_CANT_INTERPRET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e1->type->toBasetype()->ty == Tarray && e2->op == TOKint64)
|
else if (e1->type->toBasetype()->ty == Tarray && e2->op == TOKint64)
|
||||||
{
|
{
|
||||||
uinteger_t i = e2->toInteger();
|
uinteger_t i = e2->toInteger();
|
||||||
|
|
||||||
if (e1->op == TOKarrayliteral)
|
if (e1->op == TOKarrayliteral)
|
||||||
{ ArrayLiteralExp *ale = (ArrayLiteralExp *)e1;
|
{ ArrayLiteralExp *ale = (ArrayLiteralExp *)e1;
|
||||||
if (i >= ale->elements->dim)
|
if (i >= ale->elements->dim)
|
||||||
{
|
{
|
||||||
e1->error("array index %ju is out of bounds %s[0 .. %u]", i, e1->toChars(), ale->elements->dim);
|
e1->error("array index %ju is out of bounds %s[0 .. %u]", i, e1->toChars(), ale->elements->dim);
|
||||||
e = new ErrorExp();
|
e = new ErrorExp();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ e = ale->elements->tdata()[i];
|
{ e = ale->elements->tdata()[i];
|
||||||
e->type = type;
|
e->type = type;
|
||||||
if (e->hasSideEffect())
|
if (e->hasSideEffect())
|
||||||
e = EXP_CANT_INTERPRET;
|
e = EXP_CANT_INTERPRET;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e1->op == TOKassocarrayliteral)
|
else if (e1->op == TOKassocarrayliteral)
|
||||||
{
|
{
|
||||||
AssocArrayLiteralExp *ae = (AssocArrayLiteralExp *)e1;
|
AssocArrayLiteralExp *ae = (AssocArrayLiteralExp *)e1;
|
||||||
/* Search the keys backwards, in case there are duplicate keys
|
/* Search the keys backwards, in case there are duplicate keys
|
||||||
@@ -1275,15 +1275,15 @@ Expression *Index(Type *type, Expression *e1, Expression *e2)
|
|||||||
for (size_t i = ae->keys->dim; i;)
|
for (size_t i = ae->keys->dim; i;)
|
||||||
{
|
{
|
||||||
i--;
|
i--;
|
||||||
Expression *ekey = ae->keys->tdata()[i];
|
Expression *ekey = ae->keys->tdata()[i];
|
||||||
Expression *ex = Equal(TOKequal, Type::tbool, ekey, e2);
|
Expression *ex = Equal(TOKequal, Type::tbool, ekey, e2);
|
||||||
if (ex == EXP_CANT_INTERPRET)
|
if (ex == EXP_CANT_INTERPRET)
|
||||||
return ex;
|
return ex;
|
||||||
if (ex->isBool(TRUE))
|
if (ex->isBool(TRUE))
|
||||||
{ e = ae->values->tdata()[i];
|
{ e = ae->values->tdata()[i];
|
||||||
e->type = type;
|
e->type = type;
|
||||||
if (e->hasSideEffect())
|
if (e->hasSideEffect())
|
||||||
e = EXP_CANT_INTERPRET;
|
e = EXP_CANT_INTERPRET;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1311,12 +1311,12 @@ Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr)
|
|||||||
uinteger_t iupr = upr->toInteger();
|
uinteger_t iupr = upr->toInteger();
|
||||||
|
|
||||||
if (iupr > es1->len || ilwr > iupr)
|
if (iupr > es1->len || ilwr > iupr)
|
||||||
{
|
{
|
||||||
e1->error("string slice [%ju .. %ju] is out of bounds", ilwr, iupr);
|
e1->error("string slice [%ju .. %ju] is out of bounds", ilwr, iupr);
|
||||||
e = new ErrorExp();
|
e = new ErrorExp();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
void *s;
|
void *s;
|
||||||
size_t len = iupr - ilwr;
|
size_t len = iupr - ilwr;
|
||||||
int sz = es1->sz;
|
int sz = es1->sz;
|
||||||
@@ -1335,23 +1335,23 @@ Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr)
|
|||||||
}
|
}
|
||||||
else if (e1->op == TOKarrayliteral &&
|
else if (e1->op == TOKarrayliteral &&
|
||||||
lwr->op == TOKint64 && upr->op == TOKint64 &&
|
lwr->op == TOKint64 && upr->op == TOKint64 &&
|
||||||
!e1->hasSideEffect())
|
!e1->hasSideEffect())
|
||||||
{ ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1;
|
{ ArrayLiteralExp *es1 = (ArrayLiteralExp *)e1;
|
||||||
uinteger_t ilwr = lwr->toInteger();
|
uinteger_t ilwr = lwr->toInteger();
|
||||||
uinteger_t iupr = upr->toInteger();
|
uinteger_t iupr = upr->toInteger();
|
||||||
|
|
||||||
if (iupr > es1->elements->dim || ilwr > iupr)
|
if (iupr > es1->elements->dim || ilwr > iupr)
|
||||||
{
|
{
|
||||||
e1->error("array slice [%ju .. %ju] is out of bounds", ilwr, iupr);
|
e1->error("array slice [%ju .. %ju] is out of bounds", ilwr, iupr);
|
||||||
e = new ErrorExp();
|
e = new ErrorExp();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Expressions *elements = new Expressions();
|
Expressions *elements = new Expressions();
|
||||||
elements->setDim(iupr - ilwr);
|
elements->setDim(iupr - ilwr);
|
||||||
memcpy(elements->tdata(),
|
memcpy(elements->tdata(),
|
||||||
es1->elements->tdata() + ilwr,
|
es1->elements->tdata() + ilwr,
|
||||||
(iupr - ilwr) * sizeof(es1->elements->tdata()[0]));
|
(iupr - ilwr) * sizeof(es1->elements->tdata()[0]));
|
||||||
e = new ArrayLiteralExp(e1->loc, elements);
|
e = new ArrayLiteralExp(e1->loc, elements);
|
||||||
e->type = type;
|
e->type = type;
|
||||||
}
|
}
|
||||||
@@ -1359,64 +1359,64 @@ Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr)
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a slice of char array literal 'existingAE' from a string 'newval'.
|
/* Set a slice of char array literal 'existingAE' from a string 'newval'.
|
||||||
* existingAE[firstIndex..firstIndex+newval.length] = newval.
|
* existingAE[firstIndex..firstIndex+newval.length] = newval.
|
||||||
*/
|
*/
|
||||||
void sliceAssignArrayLiteralFromString(ArrayLiteralExp *existingAE, StringExp *newval, int firstIndex)
|
void sliceAssignArrayLiteralFromString(ArrayLiteralExp *existingAE, StringExp *newval, int firstIndex)
|
||||||
{
|
{
|
||||||
size_t newlen = newval->len;
|
size_t newlen = newval->len;
|
||||||
size_t sz = newval->sz;
|
size_t sz = newval->sz;
|
||||||
unsigned char *s = (unsigned char *)newval->string;
|
unsigned char *s = (unsigned char *)newval->string;
|
||||||
Type *elemType = existingAE->type->nextOf();
|
Type *elemType = existingAE->type->nextOf();
|
||||||
for (size_t j = 0; j < newlen; j++)
|
for (size_t j = 0; j < newlen; j++)
|
||||||
{
|
{
|
||||||
dinteger_t val;
|
dinteger_t val;
|
||||||
switch (sz)
|
switch (sz)
|
||||||
{
|
{
|
||||||
case 1: val = s[j]; break;
|
case 1: val = s[j]; break;
|
||||||
case 2: val = ((unsigned short *)s)[j]; break;
|
case 2: val = ((unsigned short *)s)[j]; break;
|
||||||
case 4: val = ((unsigned *)s)[j]; break;
|
case 4: val = ((unsigned *)s)[j]; break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
existingAE->elements->tdata()[j+firstIndex]
|
existingAE->elements->tdata()[j+firstIndex]
|
||||||
= new IntegerExp(newval->loc, val, elemType);
|
= new IntegerExp(newval->loc, val, elemType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a slice of string 'existingSE' from a char array literal 'newae'.
|
/* Set a slice of string 'existingSE' from a char array literal 'newae'.
|
||||||
* existingSE[firstIndex..firstIndex+newae.length] = newae.
|
* existingSE[firstIndex..firstIndex+newae.length] = newae.
|
||||||
*/
|
*/
|
||||||
void sliceAssignStringFromArrayLiteral(StringExp *existingSE, ArrayLiteralExp *newae, int firstIndex)
|
void sliceAssignStringFromArrayLiteral(StringExp *existingSE, ArrayLiteralExp *newae, int firstIndex)
|
||||||
{
|
{
|
||||||
unsigned char *s = (unsigned char *)existingSE->string;
|
unsigned char *s = (unsigned char *)existingSE->string;
|
||||||
for (size_t j = 0; j < newae->elements->dim; j++)
|
for (size_t j = 0; j < newae->elements->dim; j++)
|
||||||
{
|
{
|
||||||
unsigned value = (unsigned)(newae->elements->tdata()[j]->toInteger());
|
unsigned value = (unsigned)(newae->elements->tdata()[j]->toInteger());
|
||||||
switch (existingSE->sz)
|
switch (existingSE->sz)
|
||||||
{
|
{
|
||||||
case 1: s[j+firstIndex] = value; break;
|
case 1: s[j+firstIndex] = value; break;
|
||||||
case 2: ((unsigned short *)s)[j+firstIndex] = value; break;
|
case 2: ((unsigned short *)s)[j+firstIndex] = value; break;
|
||||||
case 4: ((unsigned *)s)[j+firstIndex] = value; break;
|
case 4: ((unsigned *)s)[j+firstIndex] = value; break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set a slice of string 'existingSE' from a string 'newstr'.
|
/* Set a slice of string 'existingSE' from a string 'newstr'.
|
||||||
* existingSE[firstIndex..firstIndex+newstr.length] = newstr.
|
* existingSE[firstIndex..firstIndex+newstr.length] = newstr.
|
||||||
*/
|
*/
|
||||||
void sliceAssignStringFromString(StringExp *existingSE, StringExp *newstr, int firstIndex)
|
void sliceAssignStringFromString(StringExp *existingSE, StringExp *newstr, int firstIndex)
|
||||||
{
|
{
|
||||||
unsigned char *s = (unsigned char *)existingSE->string;
|
unsigned char *s = (unsigned char *)existingSE->string;
|
||||||
size_t sz = existingSE->sz;
|
size_t sz = existingSE->sz;
|
||||||
assert(sz == newstr->sz);
|
assert(sz == newstr->sz);
|
||||||
memcpy(s + firstIndex * sz, newstr->string, sz * newstr->len);
|
memcpy(s + firstIndex * sz, newstr->string, sz * newstr->len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Also return EXP_CANT_INTERPRET if this fails
|
/* Also return EXP_CANT_INTERPRET if this fails
|
||||||
*/
|
*/
|
||||||
Expression *Cat(Type *type, Expression *e1, Expression *e2)
|
Expression *Cat(Type *type, Expression *e1, Expression *e2)
|
||||||
@@ -1450,11 +1450,11 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2)
|
|||||||
|
|
||||||
dinteger_t v = e->toInteger();
|
dinteger_t v = e->toInteger();
|
||||||
|
|
||||||
size_t len = (t->ty == tn->ty) ? 1 : utf_codeLength(sz, v);
|
size_t len = (t->ty == tn->ty) ? 1 : utf_codeLength(sz, v);
|
||||||
s = mem.malloc((len + 1) * sz);
|
s = mem.malloc((len + 1) * sz);
|
||||||
if (t->ty == tn->ty)
|
if (t->ty == tn->ty)
|
||||||
memcpy((unsigned char *)s, &v, sz);
|
memcpy((unsigned char *)s, &v, sz);
|
||||||
else
|
else
|
||||||
utf_encode(sz, s, v);
|
utf_encode(sz, s, v);
|
||||||
|
|
||||||
// Add terminating 0
|
// Add terminating 0
|
||||||
@@ -1474,24 +1474,24 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2)
|
|||||||
e->type = type;
|
e->type = type;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
else if (e1->op == TOKnull && e2->op == TOKnull)
|
else if (e1->op == TOKnull && e2->op == TOKnull)
|
||||||
{
|
{
|
||||||
if (type == e1->type)
|
if (type == e1->type)
|
||||||
{
|
{
|
||||||
// Handle null ~= null
|
// Handle null ~= null
|
||||||
if (t1->ty == Tarray && t2 == t1->nextOf())
|
if (t1->ty == Tarray && t2 == t1->nextOf())
|
||||||
{
|
{
|
||||||
e = new ArrayLiteralExp(e1->loc, e2);
|
e = new ArrayLiteralExp(e1->loc, e2);
|
||||||
e->type = type;
|
e->type = type;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return e1;
|
return e1;
|
||||||
}
|
}
|
||||||
if (type == e2->type)
|
if (type == e2->type)
|
||||||
return e2;
|
return e2;
|
||||||
return new NullExp(e1->loc, type);
|
return new NullExp(e1->loc, type);
|
||||||
}
|
}
|
||||||
else if (e1->op == TOKstring && e2->op == TOKstring)
|
else if (e1->op == TOKstring && e2->op == TOKstring)
|
||||||
{
|
{
|
||||||
// Concatenate the strings
|
// Concatenate the strings
|
||||||
@@ -1520,65 +1520,65 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2)
|
|||||||
es = new StringExp(loc, s, len);
|
es = new StringExp(loc, s, len);
|
||||||
es->sz = sz;
|
es->sz = sz;
|
||||||
es->committed = es1->committed | es2->committed;
|
es->committed = es1->committed | es2->committed;
|
||||||
es->type = type;
|
es->type = type;
|
||||||
e = es;
|
e = es;
|
||||||
}
|
}
|
||||||
else if (e2->op == TOKstring && e1->op == TOKarrayliteral &&
|
else if (e2->op == TOKstring && e1->op == TOKarrayliteral &&
|
||||||
t1->nextOf()->isintegral())
|
t1->nextOf()->isintegral())
|
||||||
{
|
{
|
||||||
// [chars] ~ string --> [chars]
|
// [chars] ~ string --> [chars]
|
||||||
StringExp *es = (StringExp *)e2;
|
StringExp *es = (StringExp *)e2;
|
||||||
ArrayLiteralExp *ea = (ArrayLiteralExp *)e1;
|
ArrayLiteralExp *ea = (ArrayLiteralExp *)e1;
|
||||||
size_t len = es->len + ea->elements->dim;
|
size_t len = es->len + ea->elements->dim;
|
||||||
Expressions * elems = new Expressions;
|
Expressions * elems = new Expressions;
|
||||||
elems->setDim(len);
|
elems->setDim(len);
|
||||||
for (size_t i= 0; i < ea->elements->dim; ++i)
|
for (size_t i= 0; i < ea->elements->dim; ++i)
|
||||||
{
|
{
|
||||||
elems->tdata()[i] = ea->elements->tdata()[i];
|
elems->tdata()[i] = ea->elements->tdata()[i];
|
||||||
}
|
}
|
||||||
ArrayLiteralExp *dest = new ArrayLiteralExp(e1->loc, elems);
|
ArrayLiteralExp *dest = new ArrayLiteralExp(e1->loc, elems);
|
||||||
dest->type = type;
|
dest->type = type;
|
||||||
sliceAssignArrayLiteralFromString(dest, es, ea->elements->dim);
|
sliceAssignArrayLiteralFromString(dest, es, ea->elements->dim);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
else if (e1->op == TOKstring && e2->op == TOKarrayliteral &&
|
else if (e1->op == TOKstring && e2->op == TOKarrayliteral &&
|
||||||
t2->nextOf()->isintegral())
|
t2->nextOf()->isintegral())
|
||||||
{
|
{
|
||||||
// string ~ [chars] --> [chars]
|
// string ~ [chars] --> [chars]
|
||||||
StringExp *es = (StringExp *)e1;
|
StringExp *es = (StringExp *)e1;
|
||||||
ArrayLiteralExp *ea = (ArrayLiteralExp *)e2;
|
ArrayLiteralExp *ea = (ArrayLiteralExp *)e2;
|
||||||
size_t len = es->len + ea->elements->dim;
|
size_t len = es->len + ea->elements->dim;
|
||||||
Expressions * elems = new Expressions;
|
Expressions * elems = new Expressions;
|
||||||
elems->setDim(len);
|
elems->setDim(len);
|
||||||
for (size_t i= 0; i < ea->elements->dim; ++i)
|
for (size_t i= 0; i < ea->elements->dim; ++i)
|
||||||
{
|
{
|
||||||
elems->tdata()[es->len + i] = ea->elements->tdata()[i];
|
elems->tdata()[es->len + i] = ea->elements->tdata()[i];
|
||||||
}
|
}
|
||||||
ArrayLiteralExp *dest = new ArrayLiteralExp(e1->loc, elems);
|
ArrayLiteralExp *dest = new ArrayLiteralExp(e1->loc, elems);
|
||||||
dest->type = type;
|
dest->type = type;
|
||||||
sliceAssignArrayLiteralFromString(dest, es, 0);
|
sliceAssignArrayLiteralFromString(dest, es, 0);
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
else if (e1->op == TOKstring && e2->op == TOKint64)
|
else if (e1->op == TOKstring && e2->op == TOKint64)
|
||||||
{
|
{
|
||||||
// string ~ char --> string
|
// string ~ char --> string
|
||||||
void *s;
|
void *s;
|
||||||
StringExp *es1 = (StringExp *)e1;
|
StringExp *es1 = (StringExp *)e1;
|
||||||
StringExp *es;
|
StringExp *es;
|
||||||
int sz = es1->sz;
|
int sz = es1->sz;
|
||||||
dinteger_t v = e2->toInteger();
|
dinteger_t v = e2->toInteger();
|
||||||
|
|
||||||
// Is it a concatentation of homogenous types?
|
// Is it a concatentation of homogenous types?
|
||||||
// (char[] ~ char, wchar[]~wchar, or dchar[]~dchar)
|
// (char[] ~ char, wchar[]~wchar, or dchar[]~dchar)
|
||||||
bool homoConcat = (sz == t2->size());
|
bool homoConcat = (sz == t2->size());
|
||||||
size_t len = es1->len;
|
size_t len = es1->len;
|
||||||
len += homoConcat ? 1 : utf_codeLength(sz, v);
|
len += homoConcat ? 1 : utf_codeLength(sz, v);
|
||||||
|
|
||||||
s = mem.malloc((len + 1) * sz);
|
s = mem.malloc((len + 1) * sz);
|
||||||
memcpy(s, es1->string, es1->len * sz);
|
memcpy(s, es1->string, es1->len * sz);
|
||||||
if (homoConcat)
|
if (homoConcat)
|
||||||
memcpy((unsigned char *)s + (sz * es1->len), &v, sz);
|
memcpy((unsigned char *)s + (sz * es1->len), &v, sz);
|
||||||
else
|
else
|
||||||
utf_encode(sz, (unsigned char *)s + (sz * es1->len), v);
|
utf_encode(sz, (unsigned char *)s + (sz * es1->len), v);
|
||||||
|
|
||||||
// Add terminating 0
|
// Add terminating 0
|
||||||
|
|||||||
+98
-98
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -111,7 +111,7 @@ void Declaration::checkModify(Loc loc, Scope *sc, Type *t)
|
|||||||
if (fd &&
|
if (fd &&
|
||||||
((fd->isCtorDeclaration() && storage_class & STCfield) ||
|
((fd->isCtorDeclaration() && storage_class & STCfield) ||
|
||||||
(fd->isStaticCtorDeclaration() && !(storage_class & STCfield))) &&
|
(fd->isStaticCtorDeclaration() && !(storage_class & STCfield))) &&
|
||||||
fd->toParent2() == toParent()
|
fd->toParent2() == toParent()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VarDeclaration *v = isVarDeclaration();
|
VarDeclaration *v = isVarDeclaration();
|
||||||
@@ -194,7 +194,7 @@ Type *TupleDeclaration::getType()
|
|||||||
/* It's only a type tuple if all the Object's are types
|
/* It's only a type tuple if all the Object's are types
|
||||||
*/
|
*/
|
||||||
for (size_t i = 0; i < objects->dim; i++)
|
for (size_t i = 0; i < objects->dim; i++)
|
||||||
{ Object *o = (*objects)[i];
|
{ Object *o = (*objects)[i];
|
||||||
|
|
||||||
if (o->dyncast() != DYNCAST_TYPE)
|
if (o->dyncast() != DYNCAST_TYPE)
|
||||||
{
|
{
|
||||||
@@ -221,7 +221,7 @@ Type *TupleDeclaration::getType()
|
|||||||
#else
|
#else
|
||||||
Parameter *arg = new Parameter(STCin, t, NULL, NULL);
|
Parameter *arg = new Parameter(STCin, t, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
(*args)[i] = arg;
|
(*args)[i] = arg;
|
||||||
if (!t->deco)
|
if (!t->deco)
|
||||||
hasdeco = 0;
|
hasdeco = 0;
|
||||||
}
|
}
|
||||||
@@ -238,7 +238,7 @@ int TupleDeclaration::needThis()
|
|||||||
{
|
{
|
||||||
//printf("TupleDeclaration::needThis(%s)\n", toChars());
|
//printf("TupleDeclaration::needThis(%s)\n", toChars());
|
||||||
for (size_t i = 0; i < objects->dim; i++)
|
for (size_t i = 0; i < objects->dim; i++)
|
||||||
{ Object *o = (*objects)[i];
|
{ Object *o = (*objects)[i];
|
||||||
if (o->dyncast() == DYNCAST_EXPRESSION)
|
if (o->dyncast() == DYNCAST_EXPRESSION)
|
||||||
{ Expression *e = (Expression *)o;
|
{ Expression *e = (Expression *)o;
|
||||||
if (e->op == TOKdsymbol)
|
if (e->op == TOKdsymbol)
|
||||||
@@ -282,7 +282,7 @@ Dsymbol *TypedefDeclaration::syntaxCopy(Dsymbol *s)
|
|||||||
assert(!s);
|
assert(!s);
|
||||||
TypedefDeclaration *st;
|
TypedefDeclaration *st;
|
||||||
st = new TypedefDeclaration(loc, ident, basetype, init);
|
st = new TypedefDeclaration(loc, ident, basetype, init);
|
||||||
|
|
||||||
// Syntax copy for header file
|
// Syntax copy for header file
|
||||||
if (!htype) // Don't overwrite original
|
if (!htype) // Don't overwrite original
|
||||||
{ if (type) // Make copy for both old and new instances
|
{ if (type) // Make copy for both old and new instances
|
||||||
@@ -300,43 +300,43 @@ Dsymbol *TypedefDeclaration::syntaxCopy(Dsymbol *s)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
st->hbasetype = hbasetype->syntaxCopy();
|
st->hbasetype = hbasetype->syntaxCopy();
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypedefDeclaration::semantic(Scope *sc)
|
void TypedefDeclaration::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
//printf("TypedefDeclaration::semantic(%s) sem = %d\n", toChars(), sem);
|
//printf("TypedefDeclaration::semantic(%s) sem = %d\n", toChars(), sem);
|
||||||
if (sem == SemanticStart)
|
if (sem == SemanticStart)
|
||||||
{ sem = SemanticIn;
|
{ sem = SemanticIn;
|
||||||
parent = sc->parent;
|
parent = sc->parent;
|
||||||
int errors = global.errors;
|
int errors = global.errors;
|
||||||
Type *savedbasetype = basetype;
|
Type *savedbasetype = basetype;
|
||||||
basetype = basetype->semantic(loc, sc);
|
basetype = basetype->semantic(loc, sc);
|
||||||
if (errors != global.errors)
|
if (errors != global.errors)
|
||||||
{
|
{
|
||||||
basetype = savedbasetype;
|
basetype = savedbasetype;
|
||||||
sem = SemanticStart;
|
sem = SemanticStart;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sem = SemanticDone;
|
sem = SemanticDone;
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
type = type->addStorageClass(storage_class);
|
type = type->addStorageClass(storage_class);
|
||||||
#endif
|
#endif
|
||||||
Type *savedtype = type;
|
Type *savedtype = type;
|
||||||
type = type->semantic(loc, sc);
|
type = type->semantic(loc, sc);
|
||||||
if (sc->parent->isFuncDeclaration() && init)
|
if (sc->parent->isFuncDeclaration() && init)
|
||||||
semantic2(sc);
|
semantic2(sc);
|
||||||
if (errors != global.errors)
|
if (errors != global.errors)
|
||||||
{
|
{
|
||||||
basetype = savedbasetype;
|
basetype = savedbasetype;
|
||||||
type = savedtype;
|
type = savedtype;
|
||||||
sem = SemanticStart;
|
sem = SemanticStart;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
storage_class |= sc->stc & STCdeprecated;
|
storage_class |= sc->stc & STCdeprecated;
|
||||||
}
|
}
|
||||||
else if (sem == SemanticIn)
|
else if (sem == SemanticIn)
|
||||||
{
|
{
|
||||||
error("circular definition");
|
error("circular definition");
|
||||||
}
|
}
|
||||||
@@ -345,18 +345,18 @@ void TypedefDeclaration::semantic(Scope *sc)
|
|||||||
void TypedefDeclaration::semantic2(Scope *sc)
|
void TypedefDeclaration::semantic2(Scope *sc)
|
||||||
{
|
{
|
||||||
//printf("TypedefDeclaration::semantic2(%s) sem = %d\n", toChars(), sem);
|
//printf("TypedefDeclaration::semantic2(%s) sem = %d\n", toChars(), sem);
|
||||||
if (sem == SemanticDone)
|
if (sem == SemanticDone)
|
||||||
{ sem = Semantic2Done;
|
{ sem = Semantic2Done;
|
||||||
if (init)
|
if (init)
|
||||||
{
|
{
|
||||||
Initializer *savedinit = init;
|
Initializer *savedinit = init;
|
||||||
int errors = global.errors;
|
int errors = global.errors;
|
||||||
init = init->semantic(sc, basetype, WANTinterpret);
|
init = init->semantic(sc, basetype, WANTinterpret);
|
||||||
if (errors != global.errors)
|
if (errors != global.errors)
|
||||||
{
|
{
|
||||||
init = savedinit;
|
init = savedinit;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpInitializer *ie = init->isExpInitializer();
|
ExpInitializer *ie = init->isExpInitializer();
|
||||||
if (ie)
|
if (ie)
|
||||||
@@ -470,7 +470,7 @@ void AliasDeclaration::semantic(Scope *sc)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
storage_class |= sc->stc & STCdeprecated;
|
storage_class |= sc->stc & STCdeprecated;
|
||||||
protection = sc->protection;
|
protection = sc->protection;
|
||||||
|
|
||||||
// Given:
|
// Given:
|
||||||
// alias foo.bar.abc def;
|
// alias foo.bar.abc def;
|
||||||
@@ -481,9 +481,9 @@ void AliasDeclaration::semantic(Scope *sc)
|
|||||||
// type. If it is a symbol, then aliassym is set and type is NULL -
|
// type. If it is a symbol, then aliassym is set and type is NULL -
|
||||||
// toAlias() will return aliasssym.
|
// toAlias() will return aliasssym.
|
||||||
|
|
||||||
int errors = global.errors;
|
int errors = global.errors;
|
||||||
Type *savedtype = type;
|
Type *savedtype = type;
|
||||||
|
|
||||||
Dsymbol *s;
|
Dsymbol *s;
|
||||||
Type *t;
|
Type *t;
|
||||||
Expression *e;
|
Expression *e;
|
||||||
@@ -496,7 +496,7 @@ void AliasDeclaration::semantic(Scope *sc)
|
|||||||
s = type->toDsymbol(sc);
|
s = type->toDsymbol(sc);
|
||||||
if (s
|
if (s
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
&& ((s->getType() && type->equals(s->getType())) || s->isEnumMember())
|
&& ((s->getType() && type->equals(s->getType())) || s->isEnumMember())
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
goto L2; // it's a symbolic alias
|
goto L2; // it's a symbolic alias
|
||||||
@@ -536,15 +536,15 @@ void AliasDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
else if (t)
|
else if (t)
|
||||||
{
|
{
|
||||||
type = t->semantic(loc, sc);
|
type = t->semantic(loc, sc);
|
||||||
//printf("\talias resolved to type %s\n", type->toChars());
|
//printf("\talias resolved to type %s\n", type->toChars());
|
||||||
}
|
}
|
||||||
if (overnext)
|
if (overnext)
|
||||||
ScopeDsymbol::multiplyDefined(0, this, overnext);
|
ScopeDsymbol::multiplyDefined(0, this, overnext);
|
||||||
this->inSemantic = 0;
|
this->inSemantic = 0;
|
||||||
|
|
||||||
if (errors != global.errors)
|
if (errors != global.errors)
|
||||||
type = savedtype;
|
type = savedtype;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
L2:
|
L2:
|
||||||
@@ -558,7 +558,7 @@ void AliasDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Dsymbol *savedovernext = overnext;
|
Dsymbol *savedovernext = overnext;
|
||||||
FuncDeclaration *f = s->toAlias()->isFuncDeclaration();
|
FuncDeclaration *f = s->toAlias()->isFuncDeclaration();
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
@@ -574,25 +574,25 @@ void AliasDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (overnext)
|
if (overnext)
|
||||||
ScopeDsymbol::multiplyDefined(0, this, overnext);
|
ScopeDsymbol::multiplyDefined(0, this, overnext);
|
||||||
if (s == this)
|
if (s == this)
|
||||||
{
|
{
|
||||||
assert(global.errors);
|
assert(global.errors);
|
||||||
s = NULL;
|
s = NULL;
|
||||||
}
|
}
|
||||||
if (errors != global.errors)
|
if (errors != global.errors)
|
||||||
{
|
{
|
||||||
type = savedtype;
|
type = savedtype;
|
||||||
overnext = savedovernext;
|
overnext = savedovernext;
|
||||||
aliassym = NULL;
|
aliassym = NULL;
|
||||||
inSemantic = 0;
|
inSemantic = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!type || type->ty != Terror)
|
if (!type || type->ty != Terror)
|
||||||
{ //printf("setting aliassym %s to %s %s\n", toChars(), s->kind(), s->toChars());
|
{ //printf("setting aliassym %s to %s %s\n", toChars(), s->kind(), s->toChars());
|
||||||
aliassym = s;
|
aliassym = s;
|
||||||
}
|
}
|
||||||
this->inSemantic = 0;
|
this->inSemantic = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,7 +654,7 @@ Dsymbol *AliasDeclaration::toAlias()
|
|||||||
//static int count; if (++count == 75) exit(0); //*(char*)0=0;
|
//static int count; if (++count == 75) exit(0); //*(char*)0=0;
|
||||||
if (inSemantic)
|
if (inSemantic)
|
||||||
{ error("recursive alias declaration");
|
{ error("recursive alias declaration");
|
||||||
aliassym = new AliasDeclaration(loc, ident, Type::terror);
|
aliassym = new AliasDeclaration(loc, ident, Type::terror);
|
||||||
type = Type::terror;
|
type = Type::terror;
|
||||||
}
|
}
|
||||||
else if (!aliassym && scope)
|
else if (!aliassym && scope)
|
||||||
@@ -666,7 +666,7 @@ Dsymbol *AliasDeclaration::toAlias()
|
|||||||
void AliasDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void AliasDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->writestring("alias ");
|
buf->writestring("alias ");
|
||||||
#if 0
|
#if 0
|
||||||
if (hgs->hdrgen)
|
if (hgs->hdrgen)
|
||||||
{
|
{
|
||||||
if (haliassym)
|
if (haliassym)
|
||||||
@@ -724,11 +724,11 @@ VarDeclaration::VarDeclaration(Loc loc, Type *type, Identifier *id, Initializer
|
|||||||
aliassym = NULL;
|
aliassym = NULL;
|
||||||
onstack = 0;
|
onstack = 0;
|
||||||
canassign = 0;
|
canassign = 0;
|
||||||
ctfeAdrOnStack = (size_t)(-1);
|
ctfeAdrOnStack = (size_t)(-1);
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
rundtor = NULL;
|
rundtor = NULL;
|
||||||
edtor = NULL;
|
edtor = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
aggrIndex = 0;
|
aggrIndex = 0;
|
||||||
@@ -794,11 +794,11 @@ void VarDeclaration::semantic(Scope *sc)
|
|||||||
//if (strcmp(toChars(), "mul") == 0) halt();
|
//if (strcmp(toChars(), "mul") == 0) halt();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (scope)
|
if (scope)
|
||||||
{ sc = scope;
|
{ sc = scope;
|
||||||
scope = NULL;
|
scope = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
storage_class |= sc->stc;
|
storage_class |= sc->stc;
|
||||||
if (storage_class & STCextern && init)
|
if (storage_class & STCextern && init)
|
||||||
error("extern symbols cannot have initializers");
|
error("extern symbols cannot have initializers");
|
||||||
@@ -813,7 +813,7 @@ void VarDeclaration::semantic(Scope *sc)
|
|||||||
if (!type)
|
if (!type)
|
||||||
{ inuse++;
|
{ inuse++;
|
||||||
type = init->inferType(sc);
|
type = init->inferType(sc);
|
||||||
type = type->semantic(loc, sc);
|
type = type->semantic(loc, sc);
|
||||||
inuse--;
|
inuse--;
|
||||||
inferred = 1;
|
inferred = 1;
|
||||||
|
|
||||||
@@ -990,10 +990,10 @@ void VarDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If it's a member template
|
// If it's a member template
|
||||||
AggregateDeclaration *ad2 = ti->tempdecl->isMember();
|
AggregateDeclaration *ad2 = ti->tempdecl->isMember();
|
||||||
if (ad2 && storage_class != STCundefined)
|
if (ad2 && storage_class != STCundefined)
|
||||||
{
|
{
|
||||||
error("cannot use template to add field to aggregate '%s'", ad2->toChars());
|
error("cannot use template to add field to aggregate '%s'", ad2->toChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1102,7 +1102,7 @@ void VarDeclaration::semantic(Scope *sc)
|
|||||||
Expression *e = init->toExpression();
|
Expression *e = init->toExpression();
|
||||||
if (!e)
|
if (!e)
|
||||||
{
|
{
|
||||||
init = init->semantic(sc, type, 0); // Don't need to interpret
|
init = init->semantic(sc, type, 0); // Don't need to interpret
|
||||||
e = init->toExpression();
|
e = init->toExpression();
|
||||||
if (!e)
|
if (!e)
|
||||||
{ error("is not a static and cannot have static initializer");
|
{ error("is not a static and cannot have static initializer");
|
||||||
@@ -1121,7 +1121,7 @@ void VarDeclaration::semantic(Scope *sc)
|
|||||||
ei->exp = ei->exp->semantic(sc);
|
ei->exp = ei->exp->semantic(sc);
|
||||||
if (!ei->exp->implicitConvTo(type))
|
if (!ei->exp->implicitConvTo(type))
|
||||||
{
|
{
|
||||||
dinteger_t dim = ((TypeSArray *)t)->dim->toInteger();
|
dinteger_t dim = ((TypeSArray *)t)->dim->toInteger();
|
||||||
// If multidimensional static array, treat as one large array
|
// If multidimensional static array, treat as one large array
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -1203,7 +1203,7 @@ void VarDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
init = init->semantic(sc, type, WANTinterpret);
|
init = init->semantic(sc, type, WANTinterpret);
|
||||||
if (fd && isConst() && !isStatic())
|
if (fd && isConst() && !isStatic())
|
||||||
{ // Make it static
|
{ // Make it static
|
||||||
storage_class |= STCstatic;
|
storage_class |= STCstatic;
|
||||||
@@ -1221,7 +1221,7 @@ void VarDeclaration::semantic(Scope *sc)
|
|||||||
|
|
||||||
if (!global.errors && !inferred)
|
if (!global.errors && !inferred)
|
||||||
{
|
{
|
||||||
unsigned errors = global.startGagging();
|
unsigned errors = global.startGagging();
|
||||||
Expression *e;
|
Expression *e;
|
||||||
Initializer *i2 = init;
|
Initializer *i2 = init;
|
||||||
inuse++;
|
inuse++;
|
||||||
@@ -1233,10 +1233,10 @@ void VarDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
else if (si || ai)
|
else if (si || ai)
|
||||||
{ i2 = init->syntaxCopy();
|
{ i2 = init->syntaxCopy();
|
||||||
i2 = i2->semantic(sc, type, WANTinterpret);
|
i2 = i2->semantic(sc, type, WANTinterpret);
|
||||||
}
|
}
|
||||||
inuse--;
|
inuse--;
|
||||||
if (global.endGagging(errors)) // if errors happened
|
if (global.endGagging(errors)) // if errors happened
|
||||||
{
|
{
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
/* Save scope for later use, to try again
|
/* Save scope for later use, to try again
|
||||||
@@ -1311,7 +1311,7 @@ void VarDeclaration::semantic2(Scope *sc)
|
|||||||
printf("type = %p\n", ei->exp->type);
|
printf("type = %p\n", ei->exp->type);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
init = init->semantic(sc, type, WANTinterpret);
|
init = init->semantic(sc, type, WANTinterpret);
|
||||||
inuse--;
|
inuse--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1419,12 +1419,12 @@ void VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
|
|||||||
// The current function
|
// The current function
|
||||||
FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();
|
FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();
|
||||||
|
|
||||||
if (fdv && fdthis && fdv != fdthis && fdthis->ident != Id::ensure)
|
if (fdv && fdthis && fdv != fdthis && fdthis->ident != Id::ensure)
|
||||||
{
|
{
|
||||||
/* __ensure is always called directly,
|
/* __ensure is always called directly,
|
||||||
* so it never becomes closure.
|
* so it never becomes closure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (loc.filename)
|
if (loc.filename)
|
||||||
fdthis->getLevel(loc, fdv);
|
fdthis->getLevel(loc, fdv);
|
||||||
nestedref = 1;
|
nestedref = 1;
|
||||||
@@ -1535,15 +1535,15 @@ Expression *VarDeclaration::callScopeDtor(Scope *sc)
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ObjectNotFound(Identifier *id)
|
void ObjectNotFound(Identifier *id)
|
||||||
{
|
{
|
||||||
Type::error(0, "%s not found. object.d may be incorrectly installed or corrupt.", id->toChars());
|
Type::error(0, "%s not found. object.d may be incorrectly installed or corrupt.", id->toChars());
|
||||||
fatal();
|
fatal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************* ClassInfoDeclaration ****************************/
|
/********************************* ClassInfoDeclaration ****************************/
|
||||||
|
|
||||||
|
|||||||
+42
-42
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -282,22 +282,22 @@ struct VarDeclaration : Declaration
|
|||||||
// 2: on stack, run destructor anyway
|
// 2: on stack, run destructor anyway
|
||||||
int canassign; // it can be assigned to
|
int canassign; // it can be assigned to
|
||||||
Dsymbol *aliassym; // if redone as alias to another symbol
|
Dsymbol *aliassym; // if redone as alias to another symbol
|
||||||
|
|
||||||
// When interpreting, these point to the value (NULL if value not determinable)
|
// When interpreting, these point to the value (NULL if value not determinable)
|
||||||
// The index of this variable on the CTFE stack, -1 if not allocated
|
// The index of this variable on the CTFE stack, -1 if not allocated
|
||||||
size_t ctfeAdrOnStack;
|
size_t ctfeAdrOnStack;
|
||||||
// The various functions are used only to detect compiler CTFE bugs
|
// The various functions are used only to detect compiler CTFE bugs
|
||||||
Expression *getValue();
|
Expression *getValue();
|
||||||
bool hasValue();
|
bool hasValue();
|
||||||
void setValueNull();
|
void setValueNull();
|
||||||
void setValueWithoutChecking(Expression *newval);
|
void setValueWithoutChecking(Expression *newval);
|
||||||
void setValue(Expression *newval);
|
void setValue(Expression *newval);
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
VarDeclaration *rundtor; // if !NULL, rundtor is tested at runtime to see
|
VarDeclaration *rundtor; // if !NULL, rundtor is tested at runtime to see
|
||||||
// if the destructor should be run. Used to prevent
|
// if the destructor should be run. Used to prevent
|
||||||
// dtor calls on postblitted vars
|
// dtor calls on postblitted vars
|
||||||
Expression *edtor; // if !=NULL, does the destruction of the variable
|
Expression *edtor; // if !=NULL, does the destruction of the variable
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init);
|
VarDeclaration(Loc loc, Type *t, Identifier *id, Initializer *init);
|
||||||
@@ -667,18 +667,18 @@ enum BUILTIN
|
|||||||
BUILTINtan, // std.math.tan
|
BUILTINtan, // std.math.tan
|
||||||
BUILTINsqrt, // std.math.sqrt
|
BUILTINsqrt, // std.math.sqrt
|
||||||
BUILTINfabs, // std.math.fabs
|
BUILTINfabs, // std.math.fabs
|
||||||
BUILTINatan2, // std.math.atan2
|
BUILTINatan2, // std.math.atan2
|
||||||
BUILTINrndtol, // std.math.rndtol
|
BUILTINrndtol, // std.math.rndtol
|
||||||
BUILTINexpm1, // std.math.expm1
|
BUILTINexpm1, // std.math.expm1
|
||||||
BUILTINexp2, // std.math.exp2
|
BUILTINexp2, // std.math.exp2
|
||||||
BUILTINyl2x, // std.math.yl2x
|
BUILTINyl2x, // std.math.yl2x
|
||||||
BUILTINyl2xp1, // std.math.yl2xp1
|
BUILTINyl2xp1, // std.math.yl2xp1
|
||||||
BUILTINbsr, // core.bitop.bsr
|
BUILTINbsr, // core.bitop.bsr
|
||||||
BUILTINbsf, // core.bitop.bsf
|
BUILTINbsf, // core.bitop.bsf
|
||||||
BUILTINbswap, // core.bitop.bswap
|
BUILTINbswap, // core.bitop.bswap
|
||||||
};
|
};
|
||||||
|
|
||||||
Expression *eval_builtin(Loc loc, enum BUILTIN builtin, Expressions *arguments);
|
Expression *eval_builtin(Loc loc, enum BUILTIN builtin, Expressions *arguments);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
enum BUILTIN { };
|
enum BUILTIN { };
|
||||||
@@ -686,7 +686,7 @@ enum BUILTIN { };
|
|||||||
|
|
||||||
struct FuncDeclaration : Declaration
|
struct FuncDeclaration : Declaration
|
||||||
{
|
{
|
||||||
Types *fthrows; // Array of Type's of exceptions (not used)
|
Types *fthrows; // Array of Type's of exceptions (not used)
|
||||||
Statement *frequire;
|
Statement *frequire;
|
||||||
Statement *fensure;
|
Statement *fensure;
|
||||||
Statement *fbody;
|
Statement *fbody;
|
||||||
@@ -706,25 +706,25 @@ struct FuncDeclaration : Declaration
|
|||||||
#if IN_GCC
|
#if IN_GCC
|
||||||
VarDeclaration *v_argptr; // '_argptr' variable
|
VarDeclaration *v_argptr; // '_argptr' variable
|
||||||
#endif
|
#endif
|
||||||
VarDeclaration *v_argsave; // save area for args passed in registers for variadic functions
|
VarDeclaration *v_argsave; // save area for args passed in registers for variadic functions
|
||||||
VarDeclarations *parameters; // Array of VarDeclaration's for parameters
|
VarDeclarations *parameters; // Array of VarDeclaration's for parameters
|
||||||
DsymbolTable *labtab; // statement label symbol table
|
DsymbolTable *labtab; // statement label symbol table
|
||||||
Declaration *overnext; // next in overload list
|
Declaration *overnext; // next in overload list
|
||||||
Loc endloc; // location of closing curly bracket
|
Loc endloc; // location of closing curly bracket
|
||||||
int vtblIndex; // for member functions, index into vtbl[]
|
int vtblIndex; // for member functions, index into vtbl[]
|
||||||
int naked; // !=0 if naked
|
int naked; // !=0 if naked
|
||||||
int inlineAsm; // !=0 if has inline assembler
|
int inlineAsm; // !=0 if has inline assembler
|
||||||
ILS inlineStatusStmt;
|
ILS inlineStatusStmt;
|
||||||
ILS inlineStatusExp;
|
ILS inlineStatusExp;
|
||||||
int inlineNest; // !=0 if nested inline
|
int inlineNest; // !=0 if nested inline
|
||||||
int isArrayOp; // !=0 if array operation
|
int isArrayOp; // !=0 if array operation
|
||||||
int semanticRun; // 1 semantic() run
|
int semanticRun; // 1 semantic() run
|
||||||
// 2 semantic2() run
|
// 2 semantic2() run
|
||||||
// 3 semantic3() started
|
// 3 semantic3() started
|
||||||
// 4 semantic3() done
|
// 4 semantic3() done
|
||||||
// 5 toObjFile() run
|
// 5 toObjFile() run
|
||||||
// this function's frame ptr
|
// this function's frame ptr
|
||||||
int semantic3Errors; // !=0 if errors in semantic3
|
int semantic3Errors; // !=0 if errors in semantic3
|
||||||
ForeachStatement *fes; // if foreach body, this is the foreach
|
ForeachStatement *fes; // if foreach body, this is the foreach
|
||||||
int introducing; // !=0 if 'introducing' function
|
int introducing; // !=0 if 'introducing' function
|
||||||
Type *tintro; // if !=NULL, then this is the type
|
Type *tintro; // if !=NULL, then this is the type
|
||||||
@@ -752,14 +752,14 @@ struct FuncDeclaration : Declaration
|
|||||||
|
|
||||||
int tookAddressOf; // set if someone took the address of
|
int tookAddressOf; // set if someone took the address of
|
||||||
// this function
|
// this function
|
||||||
VarDeclarations closureVars; // local variables in this function
|
VarDeclarations closureVars; // local variables in this function
|
||||||
// which are referenced by nested
|
// which are referenced by nested
|
||||||
// functions
|
// functions
|
||||||
|
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
#define FUNCFLAGpurityInprocess 1 // working on determining purity
|
#define FUNCFLAGpurityInprocess 1 // working on determining purity
|
||||||
#define FUNCFLAGsafetyInprocess 2 // working on determining safety
|
#define FUNCFLAGsafetyInprocess 2 // working on determining safety
|
||||||
#define FUNCFLAGnothrowInprocess 4 // working on determining nothrow
|
#define FUNCFLAGnothrowInprocess 4 // working on determining nothrow
|
||||||
#else
|
#else
|
||||||
int nestedFrameRef; // !=0 if nested variables referenced
|
int nestedFrameRef; // !=0 if nested variables referenced
|
||||||
#endif
|
#endif
|
||||||
@@ -802,20 +802,20 @@ struct FuncDeclaration : Declaration
|
|||||||
int isTrusted();
|
int isTrusted();
|
||||||
virtual int isNested();
|
virtual int isNested();
|
||||||
int needThis();
|
int needThis();
|
||||||
int isVirtualMethod();
|
int isVirtualMethod();
|
||||||
virtual int isVirtual();
|
virtual int isVirtual();
|
||||||
virtual int isFinal();
|
virtual int isFinal();
|
||||||
virtual int addPreInvariant();
|
virtual int addPreInvariant();
|
||||||
virtual int addPostInvariant();
|
virtual int addPostInvariant();
|
||||||
Expression *interpret(InterState *istate, Expressions *arguments, Expression *thisexp = NULL);
|
Expression *interpret(InterState *istate, Expressions *arguments, Expression *thisexp = NULL);
|
||||||
void inlineScan();
|
void inlineScan();
|
||||||
int canInline(int hasthis, int hdrscan = false, int statementsToo = true);
|
int canInline(int hasthis, int hdrscan = false, int statementsToo = true);
|
||||||
Expression *expandInline(InlineScanState *iss, Expression *ethis, Expressions *arguments, Statement **ps);
|
Expression *expandInline(InlineScanState *iss, Expression *ethis, Expressions *arguments, Statement **ps);
|
||||||
const char *kind();
|
const char *kind();
|
||||||
void toDocBuffer(OutBuffer *buf);
|
void toDocBuffer(OutBuffer *buf);
|
||||||
FuncDeclaration *isUnique();
|
FuncDeclaration *isUnique();
|
||||||
int needsClosure();
|
int needsClosure();
|
||||||
int hasNestedFrameRefs();
|
int hasNestedFrameRefs();
|
||||||
Statement *mergeFrequire(Statement *);
|
Statement *mergeFrequire(Statement *);
|
||||||
Statement *mergeFensure(Statement *);
|
Statement *mergeFensure(Statement *);
|
||||||
Parameters *getParameters(int *pvarargs);
|
Parameters *getParameters(int *pvarargs);
|
||||||
@@ -966,7 +966,7 @@ struct StaticCtorDeclaration : FuncDeclaration
|
|||||||
int isVirtual();
|
int isVirtual();
|
||||||
int addPreInvariant();
|
int addPreInvariant();
|
||||||
int addPostInvariant();
|
int addPostInvariant();
|
||||||
bool hasStaticCtorOrDtor();
|
bool hasStaticCtorOrDtor();
|
||||||
void emitComment(Scope *sc);
|
void emitComment(Scope *sc);
|
||||||
void toJsonBuffer(OutBuffer *buf);
|
void toJsonBuffer(OutBuffer *buf);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -994,7 +994,7 @@ struct StaticDtorDeclaration : FuncDeclaration
|
|||||||
AggregateDeclaration *isThis();
|
AggregateDeclaration *isThis();
|
||||||
int isStaticDestructor();
|
int isStaticDestructor();
|
||||||
int isVirtual();
|
int isVirtual();
|
||||||
bool hasStaticCtorOrDtor();
|
bool hasStaticCtorOrDtor();
|
||||||
int addPreInvariant();
|
int addPreInvariant();
|
||||||
int addPostInvariant();
|
int addPostInvariant();
|
||||||
void emitComment(Scope *sc);
|
void emitComment(Scope *sc);
|
||||||
|
|||||||
+140
-140
@@ -1,140 +1,140 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "mars.h"
|
#include "mars.h"
|
||||||
#include "expression.h"
|
#include "expression.h"
|
||||||
#include "statement.h"
|
#include "statement.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "utf.h"
|
#include "utf.h"
|
||||||
#include "declaration.h"
|
#include "declaration.h"
|
||||||
#include "aggregate.h"
|
#include "aggregate.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
|
|
||||||
/********************************************
|
/********************************************
|
||||||
* Convert from expression to delegate that returns the expression,
|
* Convert from expression to delegate that returns the expression,
|
||||||
* i.e. convert:
|
* i.e. convert:
|
||||||
* expr
|
* expr
|
||||||
* to:
|
* to:
|
||||||
* t delegate() { return expr; }
|
* t delegate() { return expr; }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int lambdaSetParent(Expression *e, void *param);
|
int lambdaSetParent(Expression *e, void *param);
|
||||||
int lambdaCheckForNestedRef(Expression *e, void *param);
|
int lambdaCheckForNestedRef(Expression *e, void *param);
|
||||||
|
|
||||||
Expression *Expression::toDelegate(Scope *sc, Type *t)
|
Expression *Expression::toDelegate(Scope *sc, Type *t)
|
||||||
{
|
{
|
||||||
//printf("Expression::toDelegate(t = %s) %s\n", t->toChars(), toChars());
|
//printf("Expression::toDelegate(t = %s) %s\n", t->toChars(), toChars());
|
||||||
TypeFunction *tf = new TypeFunction(NULL, t, 0, LINKd);
|
TypeFunction *tf = new TypeFunction(NULL, t, 0, LINKd);
|
||||||
FuncLiteralDeclaration *fld =
|
FuncLiteralDeclaration *fld =
|
||||||
new FuncLiteralDeclaration(loc, loc, tf, TOKdelegate, NULL);
|
new FuncLiteralDeclaration(loc, loc, tf, TOKdelegate, NULL);
|
||||||
Expression *e;
|
Expression *e;
|
||||||
sc = sc->push();
|
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 = this;
|
||||||
e->apply(&lambdaSetParent, sc);
|
e->apply(&lambdaSetParent, sc);
|
||||||
e->apply(&lambdaCheckForNestedRef, sc);
|
e->apply(&lambdaCheckForNestedRef, sc);
|
||||||
sc = sc->pop();
|
sc = sc->pop();
|
||||||
Statement *s;
|
Statement *s;
|
||||||
if (t->ty == Tvoid)
|
if (t->ty == Tvoid)
|
||||||
s = new ExpStatement(loc, e);
|
s = new ExpStatement(loc, e);
|
||||||
else
|
else
|
||||||
s = new ReturnStatement(loc, e);
|
s = new ReturnStatement(loc, e);
|
||||||
fld->fbody = s;
|
fld->fbody = s;
|
||||||
e = new FuncExp(loc, fld);
|
e = new FuncExp(loc, fld);
|
||||||
e = e->semantic(sc);
|
e = e->semantic(sc);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
* Patch the parent of declarations to be the new function literal.
|
* Patch the parent of declarations to be the new function literal.
|
||||||
*/
|
*/
|
||||||
int lambdaSetParent(Expression *e, void *param)
|
int lambdaSetParent(Expression *e, void *param)
|
||||||
{
|
{
|
||||||
Scope *sc = (Scope *)param;
|
Scope *sc = (Scope *)param;
|
||||||
/* We could use virtual functions instead of a switch,
|
/* We could use virtual functions instead of a switch,
|
||||||
* but it doesn't seem worth the bother.
|
* but it doesn't seem worth the bother.
|
||||||
*/
|
*/
|
||||||
switch (e->op)
|
switch (e->op)
|
||||||
{
|
{
|
||||||
case TOKdeclaration:
|
case TOKdeclaration:
|
||||||
{ DeclarationExp *de = (DeclarationExp *)e;
|
{ DeclarationExp *de = (DeclarationExp *)e;
|
||||||
de->declaration->parent = sc->parent;
|
de->declaration->parent = sc->parent;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOKindex:
|
case TOKindex:
|
||||||
{ IndexExp *de = (IndexExp *)e;
|
{ IndexExp *de = (IndexExp *)e;
|
||||||
if (de->lengthVar)
|
if (de->lengthVar)
|
||||||
{ //printf("lengthVar\n");
|
{ //printf("lengthVar\n");
|
||||||
de->lengthVar->parent = sc->parent;
|
de->lengthVar->parent = sc->parent;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOKslice:
|
case TOKslice:
|
||||||
{ SliceExp *se = (SliceExp *)e;
|
{ SliceExp *se = (SliceExp *)e;
|
||||||
if (se->lengthVar)
|
if (se->lengthVar)
|
||||||
{ //printf("lengthVar\n");
|
{ //printf("lengthVar\n");
|
||||||
se->lengthVar->parent = sc->parent;
|
se->lengthVar->parent = sc->parent;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************
|
/*******************************************
|
||||||
* Look for references to variables in a scope enclosing the new function literal.
|
* Look for references to variables in a scope enclosing the new function literal.
|
||||||
*/
|
*/
|
||||||
int lambdaCheckForNestedRef(Expression *e, void *param)
|
int lambdaCheckForNestedRef(Expression *e, void *param)
|
||||||
{
|
{
|
||||||
Scope *sc = (Scope *)param;
|
Scope *sc = (Scope *)param;
|
||||||
/* We could use virtual functions instead of a switch,
|
/* We could use virtual functions instead of a switch,
|
||||||
* but it doesn't seem worth the bother.
|
* but it doesn't seem worth the bother.
|
||||||
*/
|
*/
|
||||||
switch (e->op)
|
switch (e->op)
|
||||||
{
|
{
|
||||||
case TOKsymoff:
|
case TOKsymoff:
|
||||||
{ SymOffExp *se = (SymOffExp *)e;
|
{ SymOffExp *se = (SymOffExp *)e;
|
||||||
VarDeclaration *v = se->var->isVarDeclaration();
|
VarDeclaration *v = se->var->isVarDeclaration();
|
||||||
if (v)
|
if (v)
|
||||||
v->checkNestedReference(sc, 0);
|
v->checkNestedReference(sc, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOKvar:
|
case TOKvar:
|
||||||
{ VarExp *ve = (VarExp *)e;
|
{ VarExp *ve = (VarExp *)e;
|
||||||
VarDeclaration *v = ve->var->isVarDeclaration();
|
VarDeclaration *v = ve->var->isVarDeclaration();
|
||||||
if (v)
|
if (v)
|
||||||
v->checkNestedReference(sc, 0);
|
v->checkNestedReference(sc, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOKthis:
|
case TOKthis:
|
||||||
case TOKsuper:
|
case TOKsuper:
|
||||||
{ ThisExp *te = (ThisExp *)e;
|
{ ThisExp *te = (ThisExp *)e;
|
||||||
VarDeclaration *v = te->var->isVarDeclaration();
|
VarDeclaration *v = te->var->isVarDeclaration();
|
||||||
if (v)
|
if (v)
|
||||||
v->checkNestedReference(sc, 0);
|
v->checkNestedReference(sc, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2012 by Digital Mars
|
// Copyright (c) 1999-2012 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -65,11 +65,11 @@ struct MacroSection : Section
|
|||||||
void write(DocComment *dc, Scope *sc, Dsymbol *s, OutBuffer *buf);
|
void write(DocComment *dc, Scope *sc, Dsymbol *s, OutBuffer *buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef ArrayBase<Section> Sections;
|
typedef ArrayBase<Section> Sections;
|
||||||
|
|
||||||
struct DocComment
|
struct DocComment
|
||||||
{
|
{
|
||||||
Sections sections; // Section*[]
|
Sections sections; // Section*[]
|
||||||
|
|
||||||
Section *summary;
|
Section *summary;
|
||||||
Section *copyright;
|
Section *copyright;
|
||||||
@@ -135,7 +135,7 @@ LINK = <a href=\"$0\">$0</a>\n\
|
|||||||
LINK2 = <a href=\"$1\">$+</a>\n\
|
LINK2 = <a href=\"$1\">$+</a>\n\
|
||||||
LPAREN= (\n\
|
LPAREN= (\n\
|
||||||
RPAREN= )\n\
|
RPAREN= )\n\
|
||||||
DOLLAR= $\n\
|
DOLLAR= $\n\
|
||||||
\n\
|
\n\
|
||||||
RED = <font color=red>$0</font>\n\
|
RED = <font color=red>$0</font>\n\
|
||||||
BLUE = <font color=blue>$0</font>\n\
|
BLUE = <font color=blue>$0</font>\n\
|
||||||
@@ -225,9 +225,9 @@ void Module::gendocfile()
|
|||||||
global.params.ddocfiles->shift(p);
|
global.params.ddocfiles->shift(p);
|
||||||
|
|
||||||
// Override with the ddoc macro files from the command line
|
// Override with the ddoc macro files from the command line
|
||||||
for (size_t i = 0; i < global.params.ddocfiles->dim; i++)
|
for (size_t i = 0; i < global.params.ddocfiles->dim; i++)
|
||||||
{
|
{
|
||||||
FileName f(global.params.ddocfiles->tdata()[i], 0);
|
FileName f(global.params.ddocfiles->tdata()[i], 0);
|
||||||
File file(&f);
|
File file(&f);
|
||||||
file.readv();
|
file.readv();
|
||||||
// BUG: convert file contents to UTF-8 before use
|
// BUG: convert file contents to UTF-8 before use
|
||||||
@@ -252,14 +252,14 @@ void Module::gendocfile()
|
|||||||
Macro::define(¯otable, (unsigned char *)"TITLE", 5, (unsigned char *)p, strlen(p));
|
Macro::define(¯otable, (unsigned char *)"TITLE", 5, (unsigned char *)p, strlen(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set time macros
|
// Set time macros
|
||||||
{ time_t t;
|
{ time_t t;
|
||||||
time(&t);
|
time(&t);
|
||||||
char *p = ctime(&t);
|
char *p = ctime(&t);
|
||||||
p = mem.strdup(p);
|
p = mem.strdup(p);
|
||||||
Macro::define(¯otable, (unsigned char *)"DATETIME", 8, (unsigned char *)p, strlen(p));
|
Macro::define(¯otable, (unsigned char *)"DATETIME", 8, (unsigned char *)p, strlen(p));
|
||||||
Macro::define(¯otable, (unsigned char *)"YEAR", 4, (unsigned char *)p + 20, 4);
|
Macro::define(¯otable, (unsigned char *)"YEAR", 4, (unsigned char *)p + 20, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *docfilename = docfile->toChars();
|
char *docfilename = docfile->toChars();
|
||||||
Macro::define(¯otable, (unsigned char *)"DOCFILENAME", 11, (unsigned char *)docfilename, strlen(docfilename));
|
Macro::define(¯otable, (unsigned char *)"DOCFILENAME", 11, (unsigned char *)docfilename, strlen(docfilename));
|
||||||
@@ -379,12 +379,12 @@ void escapeDdocString(OutBuffer *buf, unsigned start)
|
|||||||
unsigned char c = buf->data[u];
|
unsigned char c = buf->data[u];
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case '$':
|
case '$':
|
||||||
buf->remove(u, 1);
|
buf->remove(u, 1);
|
||||||
buf->insert(u, "$(DOLLAR)", 9);
|
buf->insert(u, "$(DOLLAR)", 9);
|
||||||
u += 8;
|
u += 8;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '(':
|
case '(':
|
||||||
buf->remove(u, 1); //remove the (
|
buf->remove(u, 1); //remove the (
|
||||||
buf->insert(u, "$(LPAREN)", 9); //insert this instead
|
buf->insert(u, "$(LPAREN)", 9); //insert this instead
|
||||||
@@ -530,9 +530,9 @@ void ScopeDsymbol::emitMemberComments(Scope *sc)
|
|||||||
buf->writestring(m);
|
buf->writestring(m);
|
||||||
unsigned offset2 = buf->offset; // to see if we write anything
|
unsigned offset2 = buf->offset; // to see if we write anything
|
||||||
sc = sc->push(this);
|
sc = sc->push(this);
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (*members)[i];
|
Dsymbol *s = (*members)[i];
|
||||||
//printf("\ts = '%s'\n", s->toChars());
|
//printf("\ts = '%s'\n", s->toChars());
|
||||||
s->emitComment(sc);
|
s->emitComment(sc);
|
||||||
}
|
}
|
||||||
@@ -702,9 +702,9 @@ void EnumDeclaration::emitComment(Scope *sc)
|
|||||||
// if (!comment)
|
// if (!comment)
|
||||||
{ if (isAnonymous() && members)
|
{ if (isAnonymous() && members)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (*members)[i];
|
Dsymbol *s = (*members)[i];
|
||||||
s->emitComment(sc);
|
s->emitComment(sc);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -803,35 +803,35 @@ void prefix(OutBuffer *buf, Dsymbol *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void declarationToDocBuffer(Declaration *decl, OutBuffer *buf, TemplateDeclaration *td)
|
void declarationToDocBuffer(Declaration *decl, OutBuffer *buf, TemplateDeclaration *td)
|
||||||
{
|
{
|
||||||
//printf("declarationToDocBuffer() %s, originalType = %s, td = %s\n", decl->toChars(), decl->originalType ? decl->originalType->toChars() : "--", td ? td->toChars() : "--");
|
//printf("declarationToDocBuffer() %s, originalType = %s, td = %s\n", decl->toChars(), decl->originalType ? decl->originalType->toChars() : "--", td ? td->toChars() : "--");
|
||||||
if (decl->ident)
|
if (decl->ident)
|
||||||
{
|
{
|
||||||
prefix(buf, decl);
|
prefix(buf, decl);
|
||||||
|
|
||||||
if (decl->type)
|
if (decl->type)
|
||||||
{ HdrGenState hgs;
|
{ HdrGenState hgs;
|
||||||
hgs.ddoc = 1;
|
hgs.ddoc = 1;
|
||||||
Type *origType = decl->originalType ? decl->originalType : decl->type;
|
Type *origType = decl->originalType ? decl->originalType : decl->type;
|
||||||
if (origType->ty == Tfunction)
|
if (origType->ty == Tfunction)
|
||||||
{
|
{
|
||||||
TypeFunction *attrType = (TypeFunction*)(decl->ident == Id::ctor ? origType : decl->type);
|
TypeFunction *attrType = (TypeFunction*)(decl->ident == Id::ctor ? origType : decl->type);
|
||||||
((TypeFunction*)origType)->toCBufferWithAttributes(buf, decl->ident, &hgs, attrType, td);
|
((TypeFunction*)origType)->toCBufferWithAttributes(buf, decl->ident, &hgs, attrType, td);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
origType->toCBuffer(buf, decl->ident, &hgs);
|
origType->toCBuffer(buf, decl->ident, &hgs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
buf->writestring(decl->ident->toChars());
|
buf->writestring(decl->ident->toChars());
|
||||||
buf->writestring(";\n");
|
buf->writestring(";\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Declaration::toDocBuffer(OutBuffer *buf)
|
void Declaration::toDocBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
declarationToDocBuffer(this, buf, NULL);
|
declarationToDocBuffer(this, buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AliasDeclaration::toDocBuffer(OutBuffer *buf)
|
void AliasDeclaration::toDocBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
@@ -878,7 +878,7 @@ void FuncDeclaration::toDocBuffer(OutBuffer *buf)
|
|||||||
*/
|
*/
|
||||||
unsigned o = buf->offset;
|
unsigned o = buf->offset;
|
||||||
|
|
||||||
declarationToDocBuffer(this, buf, td);
|
declarationToDocBuffer(this, buf, td);
|
||||||
|
|
||||||
highlightCode(NULL, this, buf, o);
|
highlightCode(NULL, this, buf, o);
|
||||||
}
|
}
|
||||||
@@ -889,7 +889,7 @@ void FuncDeclaration::toDocBuffer(OutBuffer *buf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DMDV1
|
#if DMDV1
|
||||||
void CtorDeclaration::toDocBuffer(OutBuffer *buf)
|
void CtorDeclaration::toDocBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
HdrGenState hgs;
|
HdrGenState hgs;
|
||||||
@@ -898,7 +898,7 @@ void CtorDeclaration::toDocBuffer(OutBuffer *buf)
|
|||||||
Parameter::argsToCBuffer(buf, &hgs, arguments, varargs);
|
Parameter::argsToCBuffer(buf, &hgs, arguments, varargs);
|
||||||
buf->writestring(";\n");
|
buf->writestring(";\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void AggregateDeclaration::toDocBuffer(OutBuffer *buf)
|
void AggregateDeclaration::toDocBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
@@ -961,8 +961,8 @@ void ClassDeclaration::toDocBuffer(OutBuffer *buf)
|
|||||||
buf->printf("%s $(DDOC_PSYMBOL %s)", kind(), toChars());
|
buf->printf("%s $(DDOC_PSYMBOL %s)", kind(), toChars());
|
||||||
}
|
}
|
||||||
int any = 0;
|
int any = 0;
|
||||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||||
{ BaseClass *bc = (*baseclasses)[i];
|
{ BaseClass *bc = (*baseclasses)[i];
|
||||||
|
|
||||||
if (bc->protection == PROTprivate)
|
if (bc->protection == PROTprivate)
|
||||||
continue;
|
continue;
|
||||||
@@ -1017,7 +1017,7 @@ DocComment::DocComment()
|
|||||||
}
|
}
|
||||||
|
|
||||||
DocComment *DocComment::parse(Scope *sc, Dsymbol *s, unsigned char *comment)
|
DocComment *DocComment::parse(Scope *sc, Dsymbol *s, unsigned char *comment)
|
||||||
{
|
{
|
||||||
//printf("parse(%s): '%s'\n", s->toChars(), comment);
|
//printf("parse(%s): '%s'\n", s->toChars(), comment);
|
||||||
if (sc->lastdc && isDitto(comment))
|
if (sc->lastdc && isDitto(comment))
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1028,16 +1028,16 @@ DocComment *DocComment::parse(Scope *sc, Dsymbol *s, unsigned char *comment)
|
|||||||
|
|
||||||
dc->parseSections(comment);
|
dc->parseSections(comment);
|
||||||
|
|
||||||
for (size_t i = 0; i < dc->sections.dim; i++)
|
for (size_t i = 0; i < dc->sections.dim; i++)
|
||||||
{ Section *sec = dc->sections[i];
|
{ Section *sec = dc->sections[i];
|
||||||
|
|
||||||
if (icmp("copyright", sec->name, sec->namelen) == 0)
|
if (icmp("copyright", sec->name, sec->namelen) == 0)
|
||||||
{
|
{
|
||||||
dc->copyright = sec;
|
dc->copyright = sec;
|
||||||
}
|
}
|
||||||
if (icmp("macros", sec->name, sec->namelen) == 0)
|
if (icmp("macros", sec->name, sec->namelen) == 0)
|
||||||
{
|
{
|
||||||
dc->macros = sec;
|
dc->macros = sec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1116,7 +1116,7 @@ void DocComment::parseSections(unsigned char *comment)
|
|||||||
goto L1;
|
goto L1;
|
||||||
if (*p == '\n')
|
if (*p == '\n')
|
||||||
{ p++;
|
{ p++;
|
||||||
if (*p == '\n' && !summary && !namelen && !inCode)
|
if (*p == '\n' && !summary && !namelen && !inCode)
|
||||||
{
|
{
|
||||||
pend = p;
|
pend = p;
|
||||||
p++;
|
p++;
|
||||||
@@ -1173,8 +1173,8 @@ void DocComment::writeSections(Scope *sc, Dsymbol *s, OutBuffer *buf)
|
|||||||
if (sections.dim)
|
if (sections.dim)
|
||||||
{
|
{
|
||||||
buf->writestring("$(DDOC_SECTIONS \n");
|
buf->writestring("$(DDOC_SECTIONS \n");
|
||||||
for (size_t i = 0; i < sections.dim; i++)
|
for (size_t i = 0; i < sections.dim; i++)
|
||||||
{ Section *sec = sections[i];
|
{ Section *sec = sections[i];
|
||||||
|
|
||||||
if (sec->nooutput)
|
if (sec->nooutput)
|
||||||
continue;
|
continue;
|
||||||
@@ -1751,7 +1751,7 @@ Parameter *isFunctionParameter(Dsymbol *s, unsigned char *p, unsigned len)
|
|||||||
if (tf->parameters)
|
if (tf->parameters)
|
||||||
{
|
{
|
||||||
for (size_t k = 0; k < tf->parameters->dim; k++)
|
for (size_t k = 0; k < tf->parameters->dim; k++)
|
||||||
{ Parameter *arg = (*tf->parameters)[k];
|
{ Parameter *arg = (*tf->parameters)[k];
|
||||||
|
|
||||||
if (arg->ident && cmp(arg->ident->toChars(), p, len) == 0)
|
if (arg->ident && cmp(arg->ident->toChars(), p, len) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_DOC_H
|
#ifndef DMD_DOC_H
|
||||||
#define DMD_DOC_H
|
#define DMD_DOC_H
|
||||||
|
|
||||||
#ifdef __DMC__
|
#ifdef __DMC__
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif /* __DMC__ */
|
#endif /* __DMC__ */
|
||||||
|
|
||||||
void escapeDdocString(OutBuffer *buf, unsigned start);
|
void escapeDdocString(OutBuffer *buf, unsigned start);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+153
-153
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -119,15 +119,15 @@ int Dsymbol::oneMember(Dsymbol **ps)
|
|||||||
* Same as Dsymbol::oneMember(), but look at an array of Dsymbols.
|
* Same as Dsymbol::oneMember(), but look at an array of Dsymbols.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int Dsymbol::oneMembers(Dsymbols *members, Dsymbol **ps)
|
int Dsymbol::oneMembers(Dsymbols *members, Dsymbol **ps)
|
||||||
{
|
{
|
||||||
//printf("Dsymbol::oneMembers() %d\n", members ? members->dim : 0);
|
//printf("Dsymbol::oneMembers() %d\n", members ? members->dim : 0);
|
||||||
Dsymbol *s = NULL;
|
Dsymbol *s = NULL;
|
||||||
|
|
||||||
if (members)
|
if (members)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *sx = (*members)[i];
|
{ Dsymbol *sx = (*members)[i];
|
||||||
|
|
||||||
int x = sx->oneMember(ps);
|
int x = sx->oneMember(ps);
|
||||||
//printf("\t[%d] kind %s = %d, s = %p\n", i, sx->kind(), x, *ps);
|
//printf("\t[%d] kind %s = %d, s = %p\n", i, sx->kind(), x, *ps);
|
||||||
@@ -163,12 +163,12 @@ int Dsymbol::hasPointers()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Dsymbol::hasStaticCtorOrDtor()
|
bool Dsymbol::hasStaticCtorOrDtor()
|
||||||
{
|
{
|
||||||
//printf("Dsymbol::hasStaticCtorOrDtor() %s\n", toChars());
|
//printf("Dsymbol::hasStaticCtorOrDtor() %s\n", toChars());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Dsymbol::toChars()
|
char *Dsymbol::toChars()
|
||||||
{
|
{
|
||||||
return ident ? ident->toChars() : (char *)"__anonymous";
|
return ident ? ident->toChars() : (char *)"__anonymous";
|
||||||
@@ -219,13 +219,13 @@ char *Dsymbol::locToChars()
|
|||||||
{
|
{
|
||||||
OutBuffer buf;
|
OutBuffer buf;
|
||||||
|
|
||||||
if (!loc.filename) // avoid bug 5861.
|
if (!loc.filename) // avoid bug 5861.
|
||||||
{
|
{
|
||||||
Module *m = getModule();
|
Module *m = getModule();
|
||||||
|
|
||||||
if (m && m->srcfile)
|
if (m && m->srcfile)
|
||||||
loc.filename = m->srcfile->toChars();
|
loc.filename = m->srcfile->toChars();
|
||||||
}
|
}
|
||||||
return loc.toChars();
|
return loc.toChars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,29 +549,29 @@ int Dsymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
|||||||
void Dsymbol::error(const char *format, ...)
|
void Dsymbol::error(const char *format, ...)
|
||||||
{
|
{
|
||||||
//printf("Dsymbol::error()\n");
|
//printf("Dsymbol::error()\n");
|
||||||
if (!loc.filename) // avoid bug 5861.
|
if (!loc.filename) // avoid bug 5861.
|
||||||
{
|
{
|
||||||
Module *m = getModule();
|
Module *m = getModule();
|
||||||
|
|
||||||
if (m && m->srcfile)
|
if (m && m->srcfile)
|
||||||
loc.filename = m->srcfile->toChars();
|
loc.filename = m->srcfile->toChars();
|
||||||
}
|
}
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
verror(loc, format, ap);
|
verror(loc, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dsymbol::error(Loc loc, const char *format, ...)
|
void Dsymbol::error(Loc loc, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
verror(loc, format, ap);
|
verror(loc, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dsymbol::verror(Loc loc, const char *format, va_list ap)
|
void Dsymbol::verror(Loc loc, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
if (!global.gag)
|
if (!global.gag)
|
||||||
{
|
{
|
||||||
char *p = loc.toChars();
|
char *p = loc.toChars();
|
||||||
@@ -589,11 +589,11 @@ void Dsymbol::verror(Loc loc, const char *format, va_list ap)
|
|||||||
|
|
||||||
fprintf(stdmsg, "\n");
|
fprintf(stdmsg, "\n");
|
||||||
fflush(stdmsg);
|
fflush(stdmsg);
|
||||||
//halt();
|
//halt();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
global.gaggedErrors++;
|
global.gaggedErrors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
global.errors++;
|
global.errors++;
|
||||||
@@ -608,24 +608,24 @@ void Dsymbol::checkDeprecated(Loc loc, Scope *sc)
|
|||||||
// Don't complain if we're inside a deprecated symbol's scope
|
// Don't complain if we're inside a deprecated symbol's scope
|
||||||
for (Dsymbol *sp = sc->parent; sp; sp = sp->parent)
|
for (Dsymbol *sp = sc->parent; sp; sp = sp->parent)
|
||||||
{ if (sp->isDeprecated())
|
{ if (sp->isDeprecated())
|
||||||
goto L1;
|
goto L1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Scope *sc2 = sc; sc2; sc2 = sc2->enclosing)
|
for (Scope *sc2 = sc; sc2; sc2 = sc2->enclosing)
|
||||||
{
|
{
|
||||||
if (sc2->scopesym && sc2->scopesym->isDeprecated())
|
if (sc2->scopesym && sc2->scopesym->isDeprecated())
|
||||||
goto L1;
|
goto L1;
|
||||||
|
|
||||||
// If inside a StorageClassDeclaration that is deprecated
|
// If inside a StorageClassDeclaration that is deprecated
|
||||||
if (sc2->stc & STCdeprecated)
|
if (sc2->stc & STCdeprecated)
|
||||||
goto L1;
|
goto L1;
|
||||||
}
|
}
|
||||||
|
|
||||||
error(loc, "is deprecated");
|
error(loc, "is deprecated");
|
||||||
}
|
}
|
||||||
|
|
||||||
L1:
|
L1:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************
|
/**********************************
|
||||||
@@ -638,10 +638,10 @@ Module *Dsymbol::getModule()
|
|||||||
Dsymbol *s;
|
Dsymbol *s;
|
||||||
|
|
||||||
//printf("Dsymbol::getModule()\n");
|
//printf("Dsymbol::getModule()\n");
|
||||||
TemplateDeclaration *td = getFuncTemplateDecl(this);
|
TemplateDeclaration *td = getFuncTemplateDecl(this);
|
||||||
if (td)
|
if (td)
|
||||||
return td->getModule();
|
return td->getModule();
|
||||||
|
|
||||||
s = this;
|
s = this;
|
||||||
while (s)
|
while (s)
|
||||||
{
|
{
|
||||||
@@ -695,19 +695,19 @@ enum PROT Dsymbol::prot()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
Dsymbols *Dsymbol::arraySyntaxCopy(Dsymbols *a)
|
Dsymbols *Dsymbol::arraySyntaxCopy(Dsymbols *a)
|
||||||
{
|
{
|
||||||
|
|
||||||
Dsymbols *b = NULL;
|
Dsymbols *b = NULL;
|
||||||
if (a)
|
if (a)
|
||||||
{
|
{
|
||||||
b = a->copy();
|
b = a->copy();
|
||||||
for (size_t i = 0; i < b->dim; i++)
|
for (size_t i = 0; i < b->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (*b)[i];
|
Dsymbol *s = (*b)[i];
|
||||||
|
|
||||||
s = s->syntaxCopy(NULL);
|
s = s->syntaxCopy(NULL);
|
||||||
(*b)[i] = s;
|
(*b)[i] = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
@@ -794,7 +794,7 @@ Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags)
|
|||||||
|
|
||||||
// Look in symbols declared in this module
|
// Look in symbols declared in this module
|
||||||
Dsymbol *s = symtab ? symtab->lookup(ident) : NULL;
|
Dsymbol *s = symtab ? symtab->lookup(ident) : NULL;
|
||||||
//printf("\ts = %p, imports = %p, %d\n", s, imports, imports ? imports->dim : 0);
|
//printf("\ts = %p, imports = %p, %d\n", s, imports, imports ? imports->dim : 0);
|
||||||
|
|
||||||
// hide the aliases generated by selective or renamed private imports
|
// hide the aliases generated by selective or renamed private imports
|
||||||
if (s && flags & 1)
|
if (s && flags & 1)
|
||||||
@@ -811,8 +811,8 @@ Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags)
|
|||||||
else if (imports)
|
else if (imports)
|
||||||
{
|
{
|
||||||
// Look in imported modules
|
// Look in imported modules
|
||||||
for (size_t i = 0; i < imports->dim; i++)
|
for (size_t i = 0; i < imports->dim; i++)
|
||||||
{ Dsymbol *ss = (*imports)[i];
|
{ Dsymbol *ss = (*imports)[i];
|
||||||
Dsymbol *s2;
|
Dsymbol *s2;
|
||||||
|
|
||||||
// If private import, don't search it
|
// If private import, don't search it
|
||||||
@@ -822,7 +822,7 @@ Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags)
|
|||||||
//printf("\tscanning import '%s', prots = %d, isModule = %p, isImport = %p\n", ss->toChars(), prots[i], ss->isModule(), ss->isImport());
|
//printf("\tscanning import '%s', prots = %d, isModule = %p, isImport = %p\n", ss->toChars(), prots[i], ss->isModule(), ss->isImport());
|
||||||
/* Don't find private members if ss is a module
|
/* Don't find private members if ss is a module
|
||||||
*/
|
*/
|
||||||
s2 = ss->search(loc, ident, ss->isImport() ? 1 : 0);
|
s2 = ss->search(loc, ident, ss->isImport() ? 1 : 0);
|
||||||
if (!s)
|
if (!s)
|
||||||
s = s2;
|
s = s2;
|
||||||
else if (s2 && s != s2)
|
else if (s2 && s != s2)
|
||||||
@@ -851,7 +851,7 @@ Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags)
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ScopeDsymbol::multiplyDefined(loc, s, s2);
|
ScopeDsymbol::multiplyDefined(loc, s, s2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -860,15 +860,15 @@ Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags)
|
|||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
Declaration *d = s->isDeclaration();
|
Declaration *d = s->isDeclaration();
|
||||||
if (d && d->protection == PROTprivate &&
|
if (d && d->protection == PROTprivate &&
|
||||||
!d->parent->isTemplateMixin())
|
!d->parent->isTemplateMixin())
|
||||||
error(loc, "%s is private", d->toPrettyChars());
|
error(loc, "%s is private", d->toPrettyChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeDsymbol::importScope(Dsymbol *s, enum PROT protection)
|
void ScopeDsymbol::importScope(Dsymbol *s, enum PROT protection)
|
||||||
{
|
{
|
||||||
//printf("%s->ScopeDsymbol::importScope(%s, %d)\n", toChars(), s->toChars(), protection);
|
//printf("%s->ScopeDsymbol::importScope(%s, %d)\n", toChars(), s->toChars(), protection);
|
||||||
|
|
||||||
@@ -876,11 +876,11 @@ void ScopeDsymbol::importScope(Dsymbol *s, enum PROT protection)
|
|||||||
if (s != this)
|
if (s != this)
|
||||||
{
|
{
|
||||||
if (!imports)
|
if (!imports)
|
||||||
imports = new Dsymbols();
|
imports = new Dsymbols();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < imports->dim; i++)
|
for (size_t i = 0; i < imports->dim; i++)
|
||||||
{ Dsymbol *ss = (*imports)[i];
|
{ Dsymbol *ss = (*imports)[i];
|
||||||
if (ss == s) // if already imported
|
if (ss == s) // if already imported
|
||||||
{
|
{
|
||||||
if (protection > prots[i])
|
if (protection > prots[i])
|
||||||
@@ -964,40 +964,40 @@ Dsymbol *ScopeDsymbol::symtabInsert(Dsymbol *s)
|
|||||||
return symtab->insert(s);
|
return symtab->insert(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
* Return true if any of the members are static ctors or static dtors, or if
|
* Return true if any of the members are static ctors or static dtors, or if
|
||||||
* any members have members that are.
|
* any members have members that are.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool ScopeDsymbol::hasStaticCtorOrDtor()
|
bool ScopeDsymbol::hasStaticCtorOrDtor()
|
||||||
{
|
{
|
||||||
if (members)
|
if (members)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *member = (*members)[i];
|
{ Dsymbol *member = (*members)[i];
|
||||||
|
|
||||||
if (member->hasStaticCtorOrDtor())
|
if (member->hasStaticCtorOrDtor())
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************
|
/***************************************
|
||||||
* Determine number of Dsymbols, folding in AttribDeclaration members.
|
* Determine number of Dsymbols, folding in AttribDeclaration members.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
static int dimDg(void *ctx, size_t n, Dsymbol *)
|
static int dimDg(void *ctx, size_t n, Dsymbol *)
|
||||||
{
|
{
|
||||||
++*(size_t *)ctx;
|
++*(size_t *)ctx;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ScopeDsymbol::dim(Dsymbols *members)
|
size_t ScopeDsymbol::dim(Dsymbols *members)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
foreach(members, &dimDg, &n);
|
foreach(members, &dimDg, &n);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1011,67 +1011,67 @@ size_t ScopeDsymbol::dim(Dsymbols *members)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
struct GetNthSymbolCtx
|
struct GetNthSymbolCtx
|
||||||
{
|
{
|
||||||
size_t nth;
|
size_t nth;
|
||||||
Dsymbol *sym;
|
Dsymbol *sym;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int getNthSymbolDg(void *ctx, size_t n, Dsymbol *sym)
|
static int getNthSymbolDg(void *ctx, size_t n, Dsymbol *sym)
|
||||||
{
|
{
|
||||||
GetNthSymbolCtx *p = (GetNthSymbolCtx *)ctx;
|
GetNthSymbolCtx *p = (GetNthSymbolCtx *)ctx;
|
||||||
if (n == p->nth)
|
if (n == p->nth)
|
||||||
{ p->sym = sym;
|
{ p->sym = sym;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn)
|
Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn)
|
||||||
{
|
{
|
||||||
GetNthSymbolCtx ctx = { nth, NULL };
|
GetNthSymbolCtx ctx = { nth, NULL };
|
||||||
int res = foreach(members, &getNthSymbolDg, &ctx);
|
int res = foreach(members, &getNthSymbolDg, &ctx);
|
||||||
return res ? ctx.sym : NULL;
|
return res ? ctx.sym : NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/***************************************
|
/***************************************
|
||||||
* Expands attribute declarations in members in depth first
|
* Expands attribute declarations in members in depth first
|
||||||
* order. Calls dg(void *ctx, size_t symidx, Dsymbol *sym) for each
|
* order. Calls dg(void *ctx, size_t symidx, Dsymbol *sym) for each
|
||||||
* member.
|
* member.
|
||||||
* If dg returns !=0, stops and returns that value else returns 0.
|
* If dg returns !=0, stops and returns that value else returns 0.
|
||||||
* Use this function to avoid the O(N + N^2/2) complexity of
|
* Use this function to avoid the O(N + N^2/2) complexity of
|
||||||
* calculating dim and calling N times getNth.
|
* calculating dim and calling N times getNth.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
int ScopeDsymbol::foreach(Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *ctx, size_t *pn)
|
int ScopeDsymbol::foreach(Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *ctx, size_t *pn)
|
||||||
{
|
{
|
||||||
assert(dg);
|
assert(dg);
|
||||||
if (!members)
|
if (!members)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size_t n = pn ? *pn : 0; // take over index
|
size_t n = pn ? *pn : 0; // take over index
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *s = (*members)[i];
|
{ Dsymbol *s = (*members)[i];
|
||||||
|
|
||||||
if (AttribDeclaration *a = s->isAttribDeclaration())
|
if (AttribDeclaration *a = s->isAttribDeclaration())
|
||||||
result = foreach(a->decl, dg, ctx, &n);
|
result = foreach(a->decl, dg, ctx, &n);
|
||||||
else if (TemplateMixin *tm = s->isTemplateMixin())
|
else if (TemplateMixin *tm = s->isTemplateMixin())
|
||||||
result = foreach(tm->members, dg, ctx, &n);
|
result = foreach(tm->members, dg, ctx, &n);
|
||||||
else if (s->isTemplateInstance())
|
else if (s->isTemplateInstance())
|
||||||
;
|
;
|
||||||
else
|
else
|
||||||
result = dg(ctx, n++, s);
|
result = dg(ctx, n++, s);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pn)
|
if (pn)
|
||||||
*pn = n; // update index
|
*pn = n; // update index
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1220,27 +1220,27 @@ Dsymbol *ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags)
|
|||||||
* multiple times, it gets set only once.
|
* multiple times, it gets set only once.
|
||||||
*/
|
*/
|
||||||
if (!*pvar) // if not already initialized
|
if (!*pvar) // if not already initialized
|
||||||
{ /* Create variable v and set it to the value of $
|
{ /* Create variable v and set it to the value of $
|
||||||
*/
|
*/
|
||||||
VarDeclaration *v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, NULL);
|
VarDeclaration *v = new VarDeclaration(loc, Type::tsize_t, Id::dollar, NULL);
|
||||||
if (ce->op == TOKtuple)
|
if (ce->op == TOKtuple)
|
||||||
{ /* It is for an expression tuple, so the
|
{ /* It is for an expression tuple, so the
|
||||||
* length will be a compile-time constant.
|
* length will be a compile-time constant.
|
||||||
*/
|
*/
|
||||||
Expression *e = new IntegerExp(0, ((TupleExp *)ce)->exps->dim, Type::tsize_t);
|
Expression *e = new IntegerExp(0, ((TupleExp *)ce)->exps->dim, Type::tsize_t);
|
||||||
v->init = new ExpInitializer(0, e);
|
v->init = new ExpInitializer(0, e);
|
||||||
v->storage_class |= STCconst;
|
v->storage_class |= STCconst;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* For arrays, $ will either be a compile-time constant
|
{ /* For arrays, $ will either be a compile-time constant
|
||||||
* (in which case its value in set during constant-folding),
|
* (in which case its value in set during constant-folding),
|
||||||
* or a variable (in which case an expression is created in
|
* or a variable (in which case an expression is created in
|
||||||
* toir.c).
|
* toir.c).
|
||||||
*/
|
*/
|
||||||
VoidInitializer *e = new VoidInitializer(0);
|
VoidInitializer *e = new VoidInitializer(0);
|
||||||
e->type = Type::tsize_t;
|
e->type = Type::tsize_t;
|
||||||
v->init = e;
|
v->init = e;
|
||||||
}
|
}
|
||||||
*pvar = v;
|
*pvar = v;
|
||||||
}
|
}
|
||||||
return (*pvar);
|
return (*pvar);
|
||||||
|
|||||||
+15
-15
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -145,7 +145,7 @@ struct Dsymbol : Object
|
|||||||
int isAnonymous();
|
int isAnonymous();
|
||||||
void error(Loc loc, const char *format, ...) IS_PRINTF(3);
|
void error(Loc loc, const char *format, ...) IS_PRINTF(3);
|
||||||
void error(const char *format, ...) IS_PRINTF(2);
|
void error(const char *format, ...) IS_PRINTF(2);
|
||||||
void verror(Loc loc, const char *format, va_list ap);
|
void verror(Loc loc, const char *format, va_list ap);
|
||||||
void checkDeprecated(Loc loc, Scope *sc);
|
void checkDeprecated(Loc loc, Scope *sc);
|
||||||
Module *getModule(); // module where declared
|
Module *getModule(); // module where declared
|
||||||
Module *getCompilationModule(); // possibly different for templates
|
Module *getCompilationModule(); // possibly different for templates
|
||||||
@@ -156,7 +156,7 @@ struct Dsymbol : Object
|
|||||||
|
|
||||||
int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol()
|
int dyncast() { return DYNCAST_DSYMBOL; } // kludge for template.isSymbol()
|
||||||
|
|
||||||
static Dsymbols *arraySyntaxCopy(Dsymbols *a);
|
static Dsymbols *arraySyntaxCopy(Dsymbols *a);
|
||||||
|
|
||||||
virtual const char *toPrettyChars();
|
virtual const char *toPrettyChars();
|
||||||
virtual const char *kind();
|
virtual const char *kind();
|
||||||
@@ -197,9 +197,9 @@ struct Dsymbol : Object
|
|||||||
virtual enum PROT prot();
|
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);
|
virtual int oneMember(Dsymbol **ps);
|
||||||
static int oneMembers(Dsymbols *members, Dsymbol **ps);
|
static int oneMembers(Dsymbols *members, Dsymbol **ps);
|
||||||
virtual int hasPointers();
|
virtual int hasPointers();
|
||||||
virtual bool hasStaticCtorOrDtor();
|
virtual bool hasStaticCtorOrDtor();
|
||||||
virtual void addLocalClass(ClassDeclarations *) { }
|
virtual void addLocalClass(ClassDeclarations *) { }
|
||||||
virtual void checkCtorConstInit() { }
|
virtual void checkCtorConstInit() { }
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ struct Dsymbol : Object
|
|||||||
virtual Import *isImport() { return NULL; }
|
virtual Import *isImport() { return NULL; }
|
||||||
virtual EnumDeclaration *isEnumDeclaration() { return NULL; }
|
virtual EnumDeclaration *isEnumDeclaration() { return NULL; }
|
||||||
virtual DeleteDeclaration *isDeleteDeclaration() { return NULL; }
|
virtual DeleteDeclaration *isDeleteDeclaration() { return NULL; }
|
||||||
//virtual SymbolDeclaration *isSymbolDeclaration() { return NULL; }
|
//virtual SymbolDeclaration *isSymbolDeclaration() { return NULL; }
|
||||||
virtual StaticStructInitDeclaration *isStaticStructInitDeclaration() { return NULL; }
|
virtual StaticStructInitDeclaration *isStaticStructInitDeclaration() { return NULL; }
|
||||||
virtual AttribDeclaration *isAttribDeclaration() { return NULL; }
|
virtual AttribDeclaration *isAttribDeclaration() { return NULL; }
|
||||||
virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return NULL; }
|
virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return NULL; }
|
||||||
@@ -282,17 +282,17 @@ struct Dsymbol : Object
|
|||||||
|
|
||||||
struct ScopeDsymbol : Dsymbol
|
struct ScopeDsymbol : Dsymbol
|
||||||
{
|
{
|
||||||
Dsymbols *members; // all Dsymbol's in this scope
|
Dsymbols *members; // all Dsymbol's in this scope
|
||||||
DsymbolTable *symtab; // members[] sorted into table
|
DsymbolTable *symtab; // members[] sorted into table
|
||||||
|
|
||||||
Dsymbols *imports; // imported Dsymbol's
|
Dsymbols *imports; // imported Dsymbol's
|
||||||
unsigned char *prots; // array of PROT, one for each import
|
unsigned char *prots; // array of PROT, one for each import
|
||||||
|
|
||||||
ScopeDsymbol();
|
ScopeDsymbol();
|
||||||
ScopeDsymbol(Identifier *id);
|
ScopeDsymbol(Identifier *id);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
Dsymbol *search(Loc loc, Identifier *ident, int flags);
|
Dsymbol *search(Loc loc, Identifier *ident, int flags);
|
||||||
void importScope(Dsymbol *s, enum PROT protection);
|
void importScope(Dsymbol *s, enum PROT protection);
|
||||||
int isforwardRef();
|
int isforwardRef();
|
||||||
void defineRef(Dsymbol *s);
|
void defineRef(Dsymbol *s);
|
||||||
static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2);
|
static void multiplyDefined(Loc loc, Dsymbol *s1, Dsymbol *s2);
|
||||||
@@ -300,15 +300,15 @@ struct ScopeDsymbol : Dsymbol
|
|||||||
const char *kind();
|
const char *kind();
|
||||||
FuncDeclaration *findGetMembers();
|
FuncDeclaration *findGetMembers();
|
||||||
virtual Dsymbol *symtabInsert(Dsymbol *s);
|
virtual Dsymbol *symtabInsert(Dsymbol *s);
|
||||||
bool hasStaticCtorOrDtor();
|
bool hasStaticCtorOrDtor();
|
||||||
|
|
||||||
void emitMemberComments(Scope *sc);
|
void emitMemberComments(Scope *sc);
|
||||||
|
|
||||||
static size_t dim(Dsymbols *members);
|
static size_t dim(Dsymbols *members);
|
||||||
static Dsymbol *getNth(Dsymbols *members, size_t nth, size_t *pn = NULL);
|
static Dsymbol *getNth(Dsymbols *members, size_t nth, size_t *pn = NULL);
|
||||||
|
|
||||||
typedef int (*ForeachDg)(void *ctx, size_t idx, Dsymbol *s);
|
typedef int (*ForeachDg)(void *ctx, size_t idx, Dsymbol *s);
|
||||||
static int foreach(Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn=NULL);
|
static int foreach(Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn=NULL);
|
||||||
|
|
||||||
ScopeDsymbol *isScopeDsymbol() { return this; }
|
ScopeDsymbol *isScopeDsymbol() { return this; }
|
||||||
};
|
};
|
||||||
|
|||||||
+144
-144
@@ -1,144 +1,144 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "mars.h"
|
#include "mars.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "declaration.h"
|
#include "declaration.h"
|
||||||
#include "expression.h"
|
#include "expression.h"
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
|
|
||||||
static void indent(int indent)
|
static void indent(int indent)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < indent; i++)
|
for (i = 0; i < indent; i++)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *type_print(Type *type)
|
static char *type_print(Type *type)
|
||||||
{
|
{
|
||||||
return type ? type->toChars() : (char *) "null";
|
return type ? type->toChars() : (char *) "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
void dumpExpressions(int i, Expressions *exps)
|
void dumpExpressions(int i, Expressions *exps)
|
||||||
{
|
{
|
||||||
for (size_t j = 0; j < exps->dim; j++)
|
for (size_t j = 0; j < exps->dim; j++)
|
||||||
{ Expression *e = (Expression *)exps->data[j];
|
{ Expression *e = (Expression *)exps->data[j];
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("(\n");
|
printf("(\n");
|
||||||
e->dump(i + 2);
|
e->dump(i + 2);
|
||||||
indent(i);
|
indent(i);
|
||||||
printf(")\n");
|
printf(")\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Expression::dump(int i)
|
void Expression::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s type=%s\n", this, Token::toChars(op), type_print(type));
|
printf("%p %s type=%s\n", this, Token::toChars(op), type_print(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegerExp::dump(int i)
|
void IntegerExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %jd type=%s\n", this, (intmax_t)value, type_print(type));
|
printf("%p %jd type=%s\n", this, (intmax_t)value, type_print(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdentifierExp::dump(int i)
|
void IdentifierExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p ident '%s' type=%s\n", this, ident->toChars(), type_print(type));
|
printf("%p ident '%s' type=%s\n", this, ident->toChars(), type_print(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DsymbolExp::dump(int i)
|
void DsymbolExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s type=%s\n", this, s->toChars(), type_print(type));
|
printf("%p %s type=%s\n", this, s->toChars(), type_print(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VarExp::dump(int i)
|
void VarExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s var=%s type=%s\n", this, Token::toChars(op), var->toChars(), type_print(type));
|
printf("%p %s var=%s type=%s\n", this, Token::toChars(op), var->toChars(), type_print(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnaExp::dump(int i)
|
void UnaExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1);
|
printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1);
|
||||||
if (e1)
|
if (e1)
|
||||||
e1->dump(i + 2);
|
e1->dump(i + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallExp::dump(int i)
|
void CallExp::dump(int i)
|
||||||
{
|
{
|
||||||
UnaExp::dump(i);
|
UnaExp::dump(i);
|
||||||
dumpExpressions(i, arguments);
|
dumpExpressions(i, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliceExp::dump(int i)
|
void SliceExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1);
|
printf("%p %s type=%s e1=%p\n", this, Token::toChars(op), type_print(type), e1);
|
||||||
if (e1)
|
if (e1)
|
||||||
e1->dump(i + 2);
|
e1->dump(i + 2);
|
||||||
if (lwr)
|
if (lwr)
|
||||||
lwr->dump(i + 2);
|
lwr->dump(i + 2);
|
||||||
if (upr)
|
if (upr)
|
||||||
upr->dump(i + 2);
|
upr->dump(i + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DotIdExp::dump(int i)
|
void DotIdExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s type=%s ident=%s e1=%p\n", this, Token::toChars(op), type_print(type), ident->toChars(), e1);
|
printf("%p %s type=%s ident=%s e1=%p\n", this, Token::toChars(op), type_print(type), ident->toChars(), e1);
|
||||||
if (e1)
|
if (e1)
|
||||||
e1->dump(i + 2);
|
e1->dump(i + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DotVarExp::dump(int i)
|
void DotVarExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s type=%s var='%s' e1=%p\n", this, Token::toChars(op), type_print(type), var->toChars(), e1);
|
printf("%p %s type=%s var='%s' e1=%p\n", this, Token::toChars(op), type_print(type), var->toChars(), e1);
|
||||||
if (e1)
|
if (e1)
|
||||||
e1->dump(i + 2);
|
e1->dump(i + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DotTemplateInstanceExp::dump(int i)
|
void DotTemplateInstanceExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s type=%s ti='%s' e1=%p\n", this, Token::toChars(op), type_print(type), ti->toChars(), e1);
|
printf("%p %s type=%s ti='%s' e1=%p\n", this, Token::toChars(op), type_print(type), ti->toChars(), e1);
|
||||||
if (e1)
|
if (e1)
|
||||||
e1->dump(i + 2);
|
e1->dump(i + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DelegateExp::dump(int i)
|
void DelegateExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s func=%s type=%s e1=%p\n", this, Token::toChars(op), func->toChars(), type_print(type), e1);
|
printf("%p %s func=%s type=%s e1=%p\n", this, Token::toChars(op), func->toChars(), type_print(type), e1);
|
||||||
if (e1)
|
if (e1)
|
||||||
e1->dump(i + 2);
|
e1->dump(i + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinExp::dump(int i)
|
void BinExp::dump(int i)
|
||||||
{
|
{
|
||||||
indent(i);
|
indent(i);
|
||||||
printf("%p %s type=%s e1=%p e2=%p\n", this, Token::toChars(op), type_print(type), e1, e2);
|
printf("%p %s type=%s e1=%p e2=%p\n", this, Token::toChars(op), type_print(type), e1, e2);
|
||||||
if (e1)
|
if (e1)
|
||||||
e1->dump(i + 2);
|
e1->dump(i + 2);
|
||||||
if (e2)
|
if (e2)
|
||||||
e2->dump(i + 2);
|
e2->dump(i + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -68,7 +68,7 @@ void EnumDeclaration::semantic0(Scope *sc)
|
|||||||
return;
|
return;
|
||||||
if (!isAnonymous() || memtype)
|
if (!isAnonymous() || memtype)
|
||||||
return;
|
return;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
||||||
if (em && em->value)
|
if (em && em->value)
|
||||||
@@ -80,7 +80,7 @@ void EnumDeclaration::semantic0(Scope *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EnumDeclaration::semantic(Scope *sc)
|
void EnumDeclaration::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
uinteger_t number;
|
uinteger_t number;
|
||||||
Type *t;
|
Type *t;
|
||||||
Scope *sce;
|
Scope *sce;
|
||||||
@@ -140,7 +140,7 @@ void EnumDeclaration::semantic(Scope *sc)
|
|||||||
if (members->dim == 0)
|
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;
|
int first = 1;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
||||||
Expression *e;
|
Expression *e;
|
||||||
@@ -228,13 +228,13 @@ void EnumDeclaration::semantic(Scope *sc)
|
|||||||
if (isAnonymous())
|
if (isAnonymous())
|
||||||
{
|
{
|
||||||
//sce->enclosing->insert(em);
|
//sce->enclosing->insert(em);
|
||||||
for (Scope *sct = sce->enclosing; sct; sct = sct->enclosing)
|
for (Scope *sct = sce->enclosing; sct; sct = sct->enclosing)
|
||||||
{
|
{
|
||||||
if (sct->scopesym)
|
if (sct->scopesym)
|
||||||
{
|
{
|
||||||
if (!sct->scopesym->symtab)
|
if (!sct->scopesym->symtab)
|
||||||
sct->scopesym->symtab = new DsymbolTable();
|
sct->scopesym->symtab = new DsymbolTable();
|
||||||
em->addMember(sce, sct->scopesym, 1);
|
em->addMember(sce, sct->scopesym, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ int EnumDeclaration::oneMember(Dsymbol **ps)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EnumDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void EnumDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->writestring("enum ");
|
buf->writestring("enum ");
|
||||||
if (ident)
|
if (ident)
|
||||||
{ buf->writestring(ident->toChars());
|
{ buf->writestring(ident->toChars());
|
||||||
@@ -299,7 +299,7 @@ void EnumDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
|||||||
buf->writenl();
|
buf->writenl();
|
||||||
buf->writeByte('{');
|
buf->writeByte('{');
|
||||||
buf->writenl();
|
buf->writenl();
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember();
|
||||||
if (!em)
|
if (!em)
|
||||||
|
|||||||
+697
-697
File diff suppressed because it is too large
Load Diff
+128
-128
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -44,8 +44,8 @@ struct BinExp;
|
|||||||
struct AssignExp;
|
struct AssignExp;
|
||||||
struct InterState;
|
struct InterState;
|
||||||
struct OverloadSet;
|
struct OverloadSet;
|
||||||
struct Initializer;
|
struct Initializer;
|
||||||
struct StringExp;
|
struct StringExp;
|
||||||
|
|
||||||
enum TOK;
|
enum TOK;
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@ namespace llvm {
|
|||||||
|
|
||||||
void initPrecedence();
|
void initPrecedence();
|
||||||
|
|
||||||
typedef int (*apply_fp_t)(Expression *, void *);
|
typedef int (*apply_fp_t)(Expression *, void *);
|
||||||
|
|
||||||
Expression *resolveProperties(Scope *sc, Expression *e);
|
Expression *resolveProperties(Scope *sc, Expression *e);
|
||||||
void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d);
|
void accessCheck(Loc loc, Scope *sc, Expression *e, Declaration *d);
|
||||||
Dsymbol *search_function(AggregateDeclaration *ad, Identifier *funcid);
|
Dsymbol *search_function(AggregateDeclaration *ad, Identifier *funcid);
|
||||||
@@ -86,17 +86,17 @@ void expandTuples(Expressions *exps);
|
|||||||
FuncDeclaration *hasThis(Scope *sc);
|
FuncDeclaration *hasThis(Scope *sc);
|
||||||
Expression *fromConstInitializer(int result, Expression *e);
|
Expression *fromConstInitializer(int result, Expression *e);
|
||||||
int arrayExpressionCanThrow(Expressions *exps);
|
int arrayExpressionCanThrow(Expressions *exps);
|
||||||
TemplateDeclaration *getFuncTemplateDecl(Dsymbol *s);
|
TemplateDeclaration *getFuncTemplateDecl(Dsymbol *s);
|
||||||
|
|
||||||
/* Interpreter: what form of return value expression is required?
|
/* Interpreter: what form of return value expression is required?
|
||||||
*/
|
*/
|
||||||
enum CtfeGoal
|
enum CtfeGoal
|
||||||
{ ctfeNeedRvalue, // Must return an Rvalue
|
{ ctfeNeedRvalue, // Must return an Rvalue
|
||||||
ctfeNeedLvalue, // Must return an Lvalue
|
ctfeNeedLvalue, // Must return an Lvalue
|
||||||
ctfeNeedAnyValue, // Can return either an Rvalue or an Lvalue
|
ctfeNeedAnyValue, // Can return either an Rvalue or an Lvalue
|
||||||
ctfeNeedLvalueRef,// Must return a reference to an Lvalue (for ref types)
|
ctfeNeedLvalueRef,// Must return a reference to an Lvalue (for ref types)
|
||||||
ctfeNeedNothing // The return value is not required
|
ctfeNeedNothing // The return value is not required
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IntRange
|
struct IntRange
|
||||||
{ uinteger_t imin;
|
{ uinteger_t imin;
|
||||||
@@ -113,9 +113,9 @@ struct Expression : Object
|
|||||||
Expression(Loc loc, enum TOK op, int size);
|
Expression(Loc loc, enum TOK op, int size);
|
||||||
Expression *copy();
|
Expression *copy();
|
||||||
virtual Expression *syntaxCopy();
|
virtual Expression *syntaxCopy();
|
||||||
virtual int apply(apply_fp_t fp, void *param);
|
virtual int apply(apply_fp_t fp, void *param);
|
||||||
virtual Expression *semantic(Scope *sc);
|
virtual Expression *semantic(Scope *sc);
|
||||||
Expression *trySemantic(Scope *sc);
|
Expression *trySemantic(Scope *sc);
|
||||||
|
|
||||||
int dyncast() { return DYNCAST_EXPRESSION; } // kludge for template.isExpression()
|
int dyncast() { return DYNCAST_EXPRESSION; } // kludge for template.isExpression()
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ struct Expression : Object
|
|||||||
virtual void dump(int indent);
|
virtual void dump(int indent);
|
||||||
void error(const char *format, ...) IS_PRINTF(2);
|
void error(const char *format, ...) IS_PRINTF(2);
|
||||||
void warning(const char *format, ...) IS_PRINTF(2);
|
void warning(const char *format, ...) IS_PRINTF(2);
|
||||||
virtual int rvalue();
|
virtual int rvalue();
|
||||||
|
|
||||||
static Expression *combine(Expression *e1, Expression *e2);
|
static Expression *combine(Expression *e1, Expression *e2);
|
||||||
static Expressions *arraySyntaxCopy(Expressions *exps);
|
static Expressions *arraySyntaxCopy(Expressions *exps);
|
||||||
@@ -134,7 +134,7 @@ struct Expression : Object
|
|||||||
virtual real_t toReal();
|
virtual real_t toReal();
|
||||||
virtual real_t toImaginary();
|
virtual real_t toImaginary();
|
||||||
virtual complex_t toComplex();
|
virtual complex_t toComplex();
|
||||||
virtual StringExp *toString();
|
virtual StringExp *toString();
|
||||||
virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
virtual void toMangleBuffer(OutBuffer *buf);
|
virtual void toMangleBuffer(OutBuffer *buf);
|
||||||
virtual Expression *toLvalue(Scope *sc, Expression *e);
|
virtual Expression *toLvalue(Scope *sc, Expression *e);
|
||||||
@@ -160,21 +160,21 @@ struct Expression : Object
|
|||||||
virtual Expression *optimize(int result);
|
virtual Expression *optimize(int result);
|
||||||
#define WANTflags 1
|
#define WANTflags 1
|
||||||
#define WANTvalue 2
|
#define WANTvalue 2
|
||||||
// A compile-time result is required. Give an error if not possible
|
// A compile-time result is required. Give an error if not possible
|
||||||
#define WANTinterpret 4
|
#define WANTinterpret 4
|
||||||
// Same as WANTvalue, but also expand variables as far as possible
|
// Same as WANTvalue, but also expand variables as far as possible
|
||||||
#define WANTexpand 8
|
#define WANTexpand 8
|
||||||
|
|
||||||
virtual Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
virtual Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
|
|
||||||
virtual int isConst();
|
virtual int isConst();
|
||||||
virtual int isBool(int result);
|
virtual int isBool(int result);
|
||||||
virtual int isBit();
|
virtual int isBit();
|
||||||
bool hasSideEffect();
|
bool hasSideEffect();
|
||||||
virtual int checkSideEffect(int flag);
|
virtual int checkSideEffect(int flag);
|
||||||
virtual int canThrow();
|
virtual int canThrow();
|
||||||
|
|
||||||
virtual int inlineCost3(InlineCostState *ics);
|
virtual int inlineCost3(InlineCostState *ics);
|
||||||
virtual Expression *doInline(InlineDoState *ids);
|
virtual Expression *doInline(InlineDoState *ids);
|
||||||
virtual Expression *inlineScan(InlineScanState *iss);
|
virtual Expression *inlineScan(InlineScanState *iss);
|
||||||
Expression *inlineCopy(Scope *sc);
|
Expression *inlineCopy(Scope *sc);
|
||||||
@@ -215,7 +215,7 @@ struct IntegerExp : Expression
|
|||||||
IntegerExp(dinteger_t value);
|
IntegerExp(dinteger_t value);
|
||||||
int equals(Object *o);
|
int equals(Object *o);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
char *toChars();
|
char *toChars();
|
||||||
void dump(int indent);
|
void dump(int indent);
|
||||||
dinteger_t toInteger();
|
dinteger_t toInteger();
|
||||||
@@ -242,7 +242,7 @@ struct ErrorExp : IntegerExp
|
|||||||
ErrorExp();
|
ErrorExp();
|
||||||
|
|
||||||
Expression *implicitCastTo(Scope *sc, Type *t);
|
Expression *implicitCastTo(Scope *sc, Type *t);
|
||||||
Expression *castTo(Scope *sc, Type *t);
|
Expression *castTo(Scope *sc, Type *t);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ struct RealExp : Expression
|
|||||||
RealExp(Loc loc, real_t value, Type *type);
|
RealExp(Loc loc, real_t value, Type *type);
|
||||||
int equals(Object *o);
|
int equals(Object *o);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
char *toChars();
|
char *toChars();
|
||||||
dinteger_t toInteger();
|
dinteger_t toInteger();
|
||||||
uinteger_t toUInteger();
|
uinteger_t toUInteger();
|
||||||
@@ -281,7 +281,7 @@ struct ComplexExp : Expression
|
|||||||
ComplexExp(Loc loc, complex_t value, Type *type);
|
ComplexExp(Loc loc, complex_t value, Type *type);
|
||||||
int equals(Object *o);
|
int equals(Object *o);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
char *toChars();
|
char *toChars();
|
||||||
dinteger_t toInteger();
|
dinteger_t toInteger();
|
||||||
uinteger_t toUInteger();
|
uinteger_t toUInteger();
|
||||||
@@ -341,12 +341,12 @@ struct ThisExp : Expression
|
|||||||
|
|
||||||
ThisExp(Loc loc);
|
ThisExp(Loc loc);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int isBool(int result);
|
int isBool(int result);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Expression *toLvalue(Scope *sc, Expression *e);
|
Expression *toLvalue(Scope *sc, Expression *e);
|
||||||
|
|
||||||
int inlineCost3(InlineCostState *ics);
|
int inlineCost3(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
//Expression *inlineScan(InlineScanState *iss);
|
//Expression *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
@@ -377,12 +377,12 @@ struct NullExp : Expression
|
|||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
int isBool(int result);
|
int isBool(int result);
|
||||||
int isConst();
|
int isConst();
|
||||||
StringExp *toString();
|
StringExp *toString();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void toMangleBuffer(OutBuffer *buf);
|
void toMangleBuffer(OutBuffer *buf);
|
||||||
MATCH implicitConvTo(Type *t);
|
MATCH implicitConvTo(Type *t);
|
||||||
Expression *castTo(Scope *sc, Type *t);
|
Expression *castTo(Scope *sc, Type *t);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
dt_t **toDt(dt_t **pdt);
|
dt_t **toDt(dt_t **pdt);
|
||||||
@@ -399,7 +399,7 @@ struct StringExp : Expression
|
|||||||
unsigned char sz; // 1: char, 2: wchar, 4: dchar
|
unsigned char sz; // 1: char, 2: wchar, 4: dchar
|
||||||
unsigned char committed; // !=0 if type is committed
|
unsigned char committed; // !=0 if type is committed
|
||||||
unsigned char postfix; // 'c', 'w', 'd'
|
unsigned char postfix; // 'c', 'w', 'd'
|
||||||
bool ownedByCtfe; // true = created in CTFE
|
bool ownedByCtfe; // true = created in CTFE
|
||||||
|
|
||||||
StringExp(Loc loc, char *s);
|
StringExp(Loc loc, char *s);
|
||||||
StringExp(Loc loc, void *s, size_t len);
|
StringExp(Loc loc, void *s, size_t len);
|
||||||
@@ -408,9 +408,9 @@ struct StringExp : Expression
|
|||||||
int equals(Object *o);
|
int equals(Object *o);
|
||||||
char *toChars();
|
char *toChars();
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
size_t length();
|
size_t length();
|
||||||
StringExp *toString();
|
StringExp *toString();
|
||||||
StringExp *toUTF8(Scope *sc);
|
StringExp *toUTF8(Scope *sc);
|
||||||
MATCH implicitConvTo(Type *t);
|
MATCH implicitConvTo(Type *t);
|
||||||
Expression *castTo(Scope *sc, Type *t);
|
Expression *castTo(Scope *sc, Type *t);
|
||||||
@@ -437,14 +437,14 @@ struct TupleExp : Expression
|
|||||||
TupleExp(Loc loc, Expressions *exps);
|
TupleExp(Loc loc, Expressions *exps);
|
||||||
TupleExp(Loc loc, TupleDeclaration *tup);
|
TupleExp(Loc loc, TupleDeclaration *tup);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
int equals(Object *o);
|
int equals(Object *o);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void checkEscape();
|
void checkEscape();
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
Expression *castTo(Scope *sc, Type *t);
|
Expression *castTo(Scope *sc, Type *t);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
@@ -461,21 +461,21 @@ struct TupleExp : Expression
|
|||||||
struct ArrayLiteralExp : Expression
|
struct ArrayLiteralExp : Expression
|
||||||
{
|
{
|
||||||
Expressions *elements;
|
Expressions *elements;
|
||||||
bool ownedByCtfe; // true = created in CTFE
|
bool ownedByCtfe; // true = created in CTFE
|
||||||
|
|
||||||
ArrayLiteralExp(Loc loc, Expressions *elements);
|
ArrayLiteralExp(Loc loc, Expressions *elements);
|
||||||
ArrayLiteralExp(Loc loc, Expression *e);
|
ArrayLiteralExp(Loc loc, Expression *e);
|
||||||
|
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
int isBool(int result);
|
int isBool(int result);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
StringExp *toString();
|
StringExp *toString();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void toMangleBuffer(OutBuffer *buf);
|
void toMangleBuffer(OutBuffer *buf);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
MATCH implicitConvTo(Type *t);
|
MATCH implicitConvTo(Type *t);
|
||||||
Expression *castTo(Scope *sc, Type *t);
|
Expression *castTo(Scope *sc, Type *t);
|
||||||
|
|
||||||
@@ -495,12 +495,12 @@ struct AssocArrayLiteralExp : Expression
|
|||||||
{
|
{
|
||||||
Expressions *keys;
|
Expressions *keys;
|
||||||
Expressions *values;
|
Expressions *values;
|
||||||
bool ownedByCtfe; // true = created in CTFE
|
bool ownedByCtfe; // true = created in CTFE
|
||||||
|
|
||||||
AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values);
|
AssocArrayLiteralExp(Loc loc, Expressions *keys, Expressions *values);
|
||||||
|
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
int isBool(int result);
|
int isBool(int result);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
@@ -510,7 +510,7 @@ struct AssocArrayLiteralExp : Expression
|
|||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void toMangleBuffer(OutBuffer *buf);
|
void toMangleBuffer(OutBuffer *buf);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
MATCH implicitConvTo(Type *t);
|
MATCH implicitConvTo(Type *t);
|
||||||
Expression *castTo(Scope *sc, Type *t);
|
Expression *castTo(Scope *sc, Type *t);
|
||||||
|
|
||||||
@@ -528,19 +528,19 @@ struct StructLiteralExp : Expression
|
|||||||
StructDeclaration *sd; // which aggregate this is for
|
StructDeclaration *sd; // which aggregate this is for
|
||||||
Expressions *elements; // parallels sd->fields[] with
|
Expressions *elements; // parallels sd->fields[] with
|
||||||
// NULL entries for fields to skip
|
// NULL entries for fields to skip
|
||||||
Type *stype; // final type of result (can be different from sd's type)
|
Type *stype; // final type of result (can be different from sd's type)
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
Symbol *sym; // back end symbol to initialize with literal
|
Symbol *sym; // back end symbol to initialize with literal
|
||||||
#endif
|
#endif
|
||||||
size_t soffset; // offset from start of s
|
size_t soffset; // offset from start of s
|
||||||
int fillHoles; // fill alignment 'holes' with zero
|
int fillHoles; // fill alignment 'holes' with zero
|
||||||
bool ownedByCtfe; // true = created in CTFE
|
bool ownedByCtfe; // true = created in CTFE
|
||||||
|
|
||||||
StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements, Type *stype = NULL);
|
StructLiteralExp(Loc loc, StructDeclaration *sd, Expressions *elements, Type *stype = NULL);
|
||||||
|
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *getField(Type *type, unsigned offset);
|
Expression *getField(Type *type, unsigned offset);
|
||||||
int getFieldIndex(Type *type, unsigned offset);
|
int getFieldIndex(Type *type, unsigned offset);
|
||||||
@@ -548,10 +548,10 @@ struct StructLiteralExp : Expression
|
|||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void toMangleBuffer(OutBuffer *buf);
|
void toMangleBuffer(OutBuffer *buf);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
Expression *toLvalue(Scope *sc, Expression *e);
|
Expression *toLvalue(Scope *sc, Expression *e);
|
||||||
|
|
||||||
int inlineCost3(InlineCostState *ics);
|
int inlineCost3(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Expression *inlineScan(InlineScanState *iss);
|
Expression *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
@@ -611,7 +611,7 @@ struct TemplateExp : Expression
|
|||||||
TemplateDeclaration *td;
|
TemplateDeclaration *td;
|
||||||
|
|
||||||
TemplateExp(Loc loc, TemplateDeclaration *td);
|
TemplateExp(Loc loc, TemplateDeclaration *td);
|
||||||
int rvalue();
|
int rvalue();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -631,9 +631,9 @@ struct NewExp : Expression
|
|||||||
NewExp(Loc loc, Expression *thisexp, Expressions *newargs,
|
NewExp(Loc loc, Expression *thisexp, Expressions *newargs,
|
||||||
Type *newtype, Expressions *arguments);
|
Type *newtype, Expressions *arguments);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
@@ -641,7 +641,7 @@ struct NewExp : Expression
|
|||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
//int inlineCost3(InlineCostState *ics);
|
//int inlineCost3(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
//Expression *inlineScan(InlineScanState *iss);
|
//Expression *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
@@ -662,7 +662,7 @@ struct NewAnonClassExp : Expression
|
|||||||
NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs,
|
NewAnonClassExp(Loc loc, Expression *thisexp, Expressions *newargs,
|
||||||
ClassDeclaration *cd, Expressions *arguments);
|
ClassDeclaration *cd, Expressions *arguments);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -690,7 +690,7 @@ struct SymOffExp : Expression
|
|||||||
|
|
||||||
SymOffExp(Loc loc, Declaration *var, unsigned offset);
|
SymOffExp(Loc loc, Declaration *var, unsigned offset);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void checkEscape();
|
void checkEscape();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
int isConst();
|
int isConst();
|
||||||
@@ -719,7 +719,7 @@ struct VarExp : Expression
|
|||||||
int equals(Object *o);
|
int equals(Object *o);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void dump(int indent);
|
void dump(int indent);
|
||||||
char *toChars();
|
char *toChars();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -765,15 +765,15 @@ struct FuncExp : Expression
|
|||||||
FuncExp(Loc loc, FuncLiteralDeclaration *fd);
|
FuncExp(Loc loc, FuncLiteralDeclaration *fd);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
char *toChars();
|
char *toChars();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
dt_t **toDt(dt_t **pdt);
|
dt_t **toDt(dt_t **pdt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int inlineCost3(InlineCostState *ics);
|
int inlineCost3(InlineCostState *ics);
|
||||||
//Expression *doInline(InlineDoState *ids);
|
//Expression *doInline(InlineDoState *ids);
|
||||||
//Expression *inlineScan(InlineScanState *iss);
|
//Expression *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
@@ -792,14 +792,14 @@ struct DeclarationExp : Expression
|
|||||||
DeclarationExp(Loc loc, Dsymbol *declaration);
|
DeclarationExp(Loc loc, Dsymbol *declaration);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int inlineCost3(InlineCostState *ics);
|
int inlineCost3(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Expression *inlineScan(InlineScanState *iss);
|
Expression *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
@@ -872,12 +872,12 @@ struct UnaExp : Expression
|
|||||||
|
|
||||||
UnaExp(Loc loc, enum TOK op, int size, Expression *e1);
|
UnaExp(Loc loc, enum TOK op, int size, Expression *e1);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
void dump(int indent);
|
void dump(int indent);
|
||||||
Expression *interpretCommon(InterState *istate, CtfeGoal goal, Expression *(*fp)(Type *, Expression *));
|
Expression *interpretCommon(InterState *istate, CtfeGoal goal, Expression *(*fp)(Type *, Expression *));
|
||||||
|
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Expression *inlineScan(InlineScanState *iss);
|
Expression *inlineScan(InlineScanState *iss);
|
||||||
@@ -892,7 +892,7 @@ struct BinExp : Expression
|
|||||||
|
|
||||||
BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2);
|
BinExp(Loc loc, enum TOK op, int size, Expression *e1, Expression *e2);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *semanticp(Scope *sc);
|
Expression *semanticp(Scope *sc);
|
||||||
Expression *commonSemanticAssign(Scope *sc);
|
Expression *commonSemanticAssign(Scope *sc);
|
||||||
@@ -907,12 +907,12 @@ struct BinExp : Expression
|
|||||||
int isunsigned();
|
int isunsigned();
|
||||||
void incompatibleTypes();
|
void incompatibleTypes();
|
||||||
void dump(int indent);
|
void dump(int indent);
|
||||||
Expression *interpretCommon(InterState *istate, CtfeGoal goal,
|
Expression *interpretCommon(InterState *istate, CtfeGoal goal,
|
||||||
Expression *(*fp)(Type *, Expression *, Expression *));
|
Expression *(*fp)(Type *, Expression *, Expression *));
|
||||||
Expression *interpretCommon2(InterState *istate, CtfeGoal goal,
|
Expression *interpretCommon2(InterState *istate, CtfeGoal goal,
|
||||||
Expression *(*fp)(TOK, Type *, Expression *, Expression *));
|
Expression *(*fp)(TOK, Type *, Expression *, Expression *));
|
||||||
Expression *interpretAssignCommon(InterState *istate, CtfeGoal goal,
|
Expression *interpretAssignCommon(InterState *istate, CtfeGoal goal,
|
||||||
Expression *(*fp)(Type *, Expression *, Expression *), int post = 0);
|
Expression *(*fp)(Type *, Expression *, Expression *), int post = 0);
|
||||||
Expression *arrayOp(Scope *sc);
|
Expression *arrayOp(Scope *sc);
|
||||||
|
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
@@ -953,9 +953,9 @@ struct AssertExp : UnaExp
|
|||||||
|
|
||||||
AssertExp(Loc loc, Expression *e, Expression *msg = NULL);
|
AssertExp(Loc loc, Expression *e, Expression *msg = NULL);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
@@ -998,7 +998,7 @@ struct DotVarExp : UnaExp
|
|||||||
Expression *toLvalue(Scope *sc, Expression *e);
|
Expression *toLvalue(Scope *sc, Expression *e);
|
||||||
Expression *modifiableLvalue(Scope *sc, Expression *e);
|
Expression *modifiableLvalue(Scope *sc, Expression *e);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void dump(int indent);
|
void dump(int indent);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
@@ -1029,13 +1029,13 @@ struct DelegateExp : UnaExp
|
|||||||
|
|
||||||
DelegateExp(Loc loc, Expression *e, FuncDeclaration *func);
|
DelegateExp(Loc loc, Expression *e, FuncDeclaration *func);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
MATCH implicitConvTo(Type *t);
|
MATCH implicitConvTo(Type *t);
|
||||||
Expression *castTo(Scope *sc, Type *t);
|
Expression *castTo(Scope *sc, Type *t);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void dump(int indent);
|
void dump(int indent);
|
||||||
|
|
||||||
int inlineCost3(InlineCostState *ics);
|
int inlineCost3(InlineCostState *ics);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
@@ -1071,10 +1071,10 @@ struct CallExp : UnaExp
|
|||||||
CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2);
|
CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2);
|
||||||
|
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void dump(int indent);
|
void dump(int indent);
|
||||||
@@ -1084,7 +1084,7 @@ struct CallExp : UnaExp
|
|||||||
Expression *toLvalue(Scope *sc, Expression *e);
|
Expression *toLvalue(Scope *sc, Expression *e);
|
||||||
Expression *modifiableLvalue(Scope *sc, Expression *e);
|
Expression *modifiableLvalue(Scope *sc, Expression *e);
|
||||||
|
|
||||||
int inlineCost3(InlineCostState *ics);
|
int inlineCost3(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Expression *inlineScan(InlineScanState *iss);
|
Expression *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
@@ -1107,7 +1107,7 @@ struct AddrExp : UnaExp
|
|||||||
MATCH implicitConvTo(Type *t);
|
MATCH implicitConvTo(Type *t);
|
||||||
Expression *castTo(Scope *sc, Type *t);
|
Expression *castTo(Scope *sc, Type *t);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
DValue* toElem(IRState* irs);
|
DValue* toElem(IRState* irs);
|
||||||
@@ -1127,7 +1127,7 @@ struct PtrExp : UnaExp
|
|||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
DValue* toElem(IRState* irs);
|
DValue* toElem(IRState* irs);
|
||||||
@@ -1140,7 +1140,7 @@ struct NegExp : UnaExp
|
|||||||
NegExp(Loc loc, Expression *e);
|
NegExp(Loc loc, Expression *e);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1170,7 +1170,7 @@ struct ComExp : UnaExp
|
|||||||
ComExp(Loc loc, Expression *e);
|
ComExp(Loc loc, Expression *e);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1191,7 +1191,7 @@ struct NotExp : UnaExp
|
|||||||
NotExp(Loc loc, Expression *e);
|
NotExp(Loc loc, Expression *e);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int isBit();
|
int isBit();
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
@@ -1207,7 +1207,7 @@ struct BoolExp : UnaExp
|
|||||||
BoolExp(Loc loc, Expression *e, Type *type);
|
BoolExp(Loc loc, Expression *e, Type *type);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int isBit();
|
int isBit();
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
@@ -1243,7 +1243,7 @@ struct CastExp : UnaExp
|
|||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
void checkEscape();
|
void checkEscape();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -1271,23 +1271,23 @@ struct SliceExp : UnaExp
|
|||||||
|
|
||||||
SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr);
|
SliceExp(Loc loc, Expression *e1, Expression *lwr, Expression *upr);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
void checkEscape();
|
void checkEscape();
|
||||||
void checkEscapeRef();
|
void checkEscapeRef();
|
||||||
Expression *toLvalue(Scope *sc, Expression *e);
|
Expression *toLvalue(Scope *sc, Expression *e);
|
||||||
Expression *modifiableLvalue(Scope *sc, Expression *e);
|
Expression *modifiableLvalue(Scope *sc, Expression *e);
|
||||||
int isBool(int result);
|
int isBool(int result);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void dump(int indent);
|
void dump(int indent);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
int canThrow();
|
int canThrow();
|
||||||
|
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Expression *inlineScan(InlineScanState *iss);
|
Expression *inlineScan(InlineScanState *iss);
|
||||||
@@ -1303,7 +1303,7 @@ struct ArrayLengthExp : UnaExp
|
|||||||
ArrayLengthExp(Loc loc, Expression *e1);
|
ArrayLengthExp(Loc loc, Expression *e1);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
@@ -1322,7 +1322,7 @@ struct ArrayExp : UnaExp
|
|||||||
|
|
||||||
ArrayExp(Loc loc, Expression *e1, Expressions *arguments);
|
ArrayExp(Loc loc, Expression *e1, Expressions *arguments);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *toLvalue(Scope *sc, Expression *e);
|
Expression *toLvalue(Scope *sc, Expression *e);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -1354,7 +1354,7 @@ struct CommaExp : BinExp
|
|||||||
int isBool(int result);
|
int isBool(int result);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
@@ -1376,7 +1376,7 @@ struct IndexExp : BinExp
|
|||||||
Expression *modifiableLvalue(Scope *sc, Expression *e);
|
Expression *modifiableLvalue(Scope *sc, Expression *e);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
@@ -1394,7 +1394,7 @@ struct PostExp : BinExp
|
|||||||
{
|
{
|
||||||
PostExp(enum TOK op, Loc loc, Expression *e);
|
PostExp(enum TOK op, Loc loc, Expression *e);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Identifier *opId(); // For operator overloading
|
Identifier *opId(); // For operator overloading
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
@@ -1412,7 +1412,7 @@ struct AssignExp : BinExp
|
|||||||
AssignExp(Loc loc, Expression *e1, Expression *e2);
|
AssignExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *checkToBoolean();
|
Expression *checkToBoolean();
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
Identifier *opId(); // For operator overloading
|
Identifier *opId(); // For operator overloading
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
@@ -1445,7 +1445,7 @@ struct op##AssignExp : BinExp \
|
|||||||
{ \
|
{ \
|
||||||
op##AssignExp(Loc loc, Expression *e1, Expression *e2); \
|
op##AssignExp(Loc loc, Expression *e1, Expression *e2); \
|
||||||
Expression *semantic(Scope *sc); \
|
Expression *semantic(Scope *sc); \
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue); \
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue); \
|
||||||
X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \
|
X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \
|
||||||
X(Expression *buildArrayLoop(Parameters *fparams);) \
|
X(Expression *buildArrayLoop(Parameters *fparams);) \
|
||||||
\
|
\
|
||||||
@@ -1481,7 +1481,7 @@ struct AddExp : BinExp
|
|||||||
AddExp(Loc loc, Expression *e1, Expression *e2);
|
AddExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1505,7 +1505,7 @@ struct MinExp : BinExp
|
|||||||
MinExp(Loc loc, Expression *e1, Expression *e2);
|
MinExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1528,7 +1528,7 @@ struct CatExp : BinExp
|
|||||||
CatExp(Loc loc, Expression *e1, Expression *e2);
|
CatExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
@@ -1548,7 +1548,7 @@ struct MulExp : BinExp
|
|||||||
MulExp(Loc loc, Expression *e1, Expression *e2);
|
MulExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1571,7 +1571,7 @@ struct DivExp : BinExp
|
|||||||
DivExp(Loc loc, Expression *e1, Expression *e2);
|
DivExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1593,7 +1593,7 @@ struct ModExp : BinExp
|
|||||||
ModExp(Loc loc, Expression *e1, Expression *e2);
|
ModExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1627,7 +1627,7 @@ struct ShlExp : BinExp
|
|||||||
ShlExp(Loc loc, Expression *e1, Expression *e2);
|
ShlExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
@@ -1647,7 +1647,7 @@ struct ShrExp : BinExp
|
|||||||
ShrExp(Loc loc, Expression *e1, Expression *e2);
|
ShrExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
@@ -1667,7 +1667,7 @@ struct UshrExp : BinExp
|
|||||||
UshrExp(Loc loc, Expression *e1, Expression *e2);
|
UshrExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
@@ -1687,7 +1687,7 @@ struct AndExp : BinExp
|
|||||||
AndExp(Loc loc, Expression *e1, Expression *e2);
|
AndExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1710,7 +1710,7 @@ struct OrExp : BinExp
|
|||||||
OrExp(Loc loc, Expression *e1, Expression *e2);
|
OrExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1733,7 +1733,7 @@ struct XorExp : BinExp
|
|||||||
XorExp(Loc loc, Expression *e1, Expression *e2);
|
XorExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Parameters *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
@@ -1758,7 +1758,7 @@ struct OrOrExp : BinExp
|
|||||||
Expression *checkToBoolean();
|
Expression *checkToBoolean();
|
||||||
int isBit();
|
int isBit();
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
@@ -1776,7 +1776,7 @@ struct AndAndExp : BinExp
|
|||||||
Expression *checkToBoolean();
|
Expression *checkToBoolean();
|
||||||
int isBit();
|
int isBit();
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int checkSideEffect(int flag);
|
int checkSideEffect(int flag);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
@@ -1792,7 +1792,7 @@ struct CmpExp : BinExp
|
|||||||
CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
|
CmpExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int isBit();
|
int isBit();
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
@@ -1812,7 +1812,7 @@ struct InExp : BinExp
|
|||||||
{
|
{
|
||||||
InExp(Loc loc, Expression *e1, Expression *e2);
|
InExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int isBit();
|
int isBit();
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
@@ -1831,7 +1831,7 @@ struct InExp : BinExp
|
|||||||
struct RemoveExp : BinExp
|
struct RemoveExp : BinExp
|
||||||
{
|
{
|
||||||
RemoveExp(Loc loc, Expression *e1, Expression *e2);
|
RemoveExp(Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
@@ -1849,7 +1849,7 @@ struct EqualExp : BinExp
|
|||||||
EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
|
EqualExp(enum TOK op, Loc loc, Expression *e1, Expression *e2);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
int isBit();
|
int isBit();
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
@@ -1873,7 +1873,7 @@ struct IdentityExp : BinExp
|
|||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
int isBit();
|
int isBit();
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
@@ -1891,10 +1891,10 @@ struct CondExp : BinExp
|
|||||||
|
|
||||||
CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2);
|
CondExp(Loc loc, Expression *econd, Expression *e1, Expression *e2);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
int apply(apply_fp_t fp, void *param);
|
int apply(apply_fp_t fp, void *param);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
void checkEscape();
|
void checkEscape();
|
||||||
void checkEscapeRef();
|
void checkEscapeRef();
|
||||||
Expression *toLvalue(Scope *sc, Expression *e);
|
Expression *toLvalue(Scope *sc, Expression *e);
|
||||||
@@ -2006,11 +2006,11 @@ Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2);
|
|||||||
|
|
||||||
Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr);
|
Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr);
|
||||||
|
|
||||||
// Const-folding functions used by CTFE
|
// Const-folding functions used by CTFE
|
||||||
|
|
||||||
void sliceAssignArrayLiteralFromString(ArrayLiteralExp *existingAE, StringExp *newval, int firstIndex);
|
void sliceAssignArrayLiteralFromString(ArrayLiteralExp *existingAE, StringExp *newval, int firstIndex);
|
||||||
void sliceAssignStringFromArrayLiteral(StringExp *existingSE, ArrayLiteralExp *newae, int firstIndex);
|
void sliceAssignStringFromArrayLiteral(StringExp *existingSE, ArrayLiteralExp *newae, int firstIndex);
|
||||||
void sliceAssignStringFromString(StringExp *existingSE, StringExp *newstr, int firstIndex);
|
void sliceAssignStringFromString(StringExp *existingSE, StringExp *newstr, int firstIndex);
|
||||||
|
|
||||||
|
|
||||||
#endif /* DMD_EXPRESSION_H */
|
#endif /* DMD_EXPRESSION_H */
|
||||||
|
|||||||
+160
-160
@@ -61,13 +61,13 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla
|
|||||||
vtblIndex = -1;
|
vtblIndex = -1;
|
||||||
hasReturnExp = 0;
|
hasReturnExp = 0;
|
||||||
naked = 0;
|
naked = 0;
|
||||||
inlineStatusExp = ILSuninitialized;
|
inlineStatusExp = ILSuninitialized;
|
||||||
inlineStatusStmt = ILSuninitialized;
|
inlineStatusStmt = ILSuninitialized;
|
||||||
inlineNest = 0;
|
inlineNest = 0;
|
||||||
inlineAsm = 0;
|
inlineAsm = 0;
|
||||||
isArrayOp = 0;
|
isArrayOp = 0;
|
||||||
semanticRun = PASSinit;
|
semanticRun = PASSinit;
|
||||||
semantic3Errors = 0;
|
semantic3Errors = 0;
|
||||||
#if DMDV1
|
#if DMDV1
|
||||||
nestedFrameRef = 0;
|
nestedFrameRef = 0;
|
||||||
#endif
|
#endif
|
||||||
@@ -88,7 +88,7 @@ FuncDeclaration::FuncDeclaration(Loc loc, Loc endloc, Identifier *id, StorageCla
|
|||||||
#if DMDV2
|
#if DMDV2
|
||||||
builtin = BUILTINunknown;
|
builtin = BUILTINunknown;
|
||||||
tookAddressOf = 0;
|
tookAddressOf = 0;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
@@ -221,10 +221,10 @@ void FuncDeclaration::semantic(Scope *sc)
|
|||||||
if (isAbstract() && !isVirtual())
|
if (isAbstract() && !isVirtual())
|
||||||
error("non-virtual functions cannot be abstract");
|
error("non-virtual functions cannot be abstract");
|
||||||
|
|
||||||
// https://github.com/donc/dmd/commit/9f7b2f8cfe5d7482f2de7f9678c176d54abe237f#commitcomment-321724
|
// https://github.com/donc/dmd/commit/9f7b2f8cfe5d7482f2de7f9678c176d54abe237f#commitcomment-321724
|
||||||
//if (isOverride() && !isVirtual())
|
//if (isOverride() && !isVirtual())
|
||||||
//error("cannot override a non-virtual function");
|
//error("cannot override a non-virtual function");
|
||||||
|
|
||||||
if (isAbstract() && isFinal())
|
if (isAbstract() && isFinal())
|
||||||
error("cannot be both final and abstract");
|
error("cannot be both final and abstract");
|
||||||
#if 0
|
#if 0
|
||||||
@@ -320,7 +320,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
|||||||
// ctor = (CtorDeclaration *)this;
|
// ctor = (CtorDeclaration *)this;
|
||||||
// if (!cd->ctor)
|
// if (!cd->ctor)
|
||||||
// cd->ctor = ctor;
|
// cd->ctor = ctor;
|
||||||
goto Ldone;
|
goto Ldone;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -411,7 +411,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{ FuncDeclaration *fdv = (FuncDeclaration *)cd->baseClass->vtbl[vi];
|
{ FuncDeclaration *fdv = (FuncDeclaration *)cd->baseClass->vtbl[vi];
|
||||||
// This function is covariant with fdv
|
// This function is covariant with fdv
|
||||||
if (fdv->isFinal())
|
if (fdv->isFinal())
|
||||||
error("cannot override final function %s", fdv->toPrettyChars());
|
error("cannot override final function %s", fdv->toPrettyChars());
|
||||||
@@ -421,17 +421,17 @@ void FuncDeclaration::semantic(Scope *sc)
|
|||||||
warning(loc, "overrides base class function %s, but is not marked with 'override'", fdv->toPrettyChars());
|
warning(loc, "overrides base class function %s, but is not marked with 'override'", fdv->toPrettyChars());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FuncDeclaration *fdc = ((Dsymbol *)cd->vtbl.data[vi])->isFuncDeclaration();
|
FuncDeclaration *fdc = ((Dsymbol *)cd->vtbl.data[vi])->isFuncDeclaration();
|
||||||
if (fdc->toParent() == parent)
|
if (fdc->toParent() == parent)
|
||||||
{
|
{
|
||||||
// If both are mixins, then error.
|
// If both are mixins, then error.
|
||||||
// If either is not, the one that is not overrides the other.
|
// If either is not, the one that is not overrides the other.
|
||||||
|
|
||||||
// if (this is mixin) && (fdc is not mixin) then fdc overrides
|
// if (this is mixin) && (fdc is not mixin) then fdc overrides
|
||||||
if (!this->parent->isClassDeclaration() && fdc->parent->isClassDeclaration())
|
if (!this->parent->isClassDeclaration() && fdc->parent->isClassDeclaration())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!this->parent->isClassDeclaration() // if both are mixins then error
|
if (!this->parent->isClassDeclaration() // if both are mixins then error
|
||||||
#if !BREAKABI
|
#if !BREAKABI
|
||||||
&& !isDtorDeclaration()
|
&& !isDtorDeclaration()
|
||||||
#endif
|
#endif
|
||||||
@@ -441,7 +441,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
|||||||
)
|
)
|
||||||
error("multiple overrides of same function");
|
error("multiple overrides of same function");
|
||||||
}
|
}
|
||||||
cd->vtbl[vi] = this;
|
cd->vtbl[vi] = this;
|
||||||
vtblIndex = vi;
|
vtblIndex = vi;
|
||||||
|
|
||||||
/* Remember which functions this overrides
|
/* Remember which functions this overrides
|
||||||
@@ -506,10 +506,10 @@ void FuncDeclaration::semantic(Scope *sc)
|
|||||||
/* Only need to have a tintro if the vptr
|
/* Only need to have a tintro if the vptr
|
||||||
* offsets differ
|
* offsets differ
|
||||||
*/
|
*/
|
||||||
unsigned errors = global.startGagging(); // suppress printing of error messages
|
unsigned errors = global.startGagging(); // suppress printing of error messages
|
||||||
int offset;
|
int offset;
|
||||||
int baseOf = fdv->type->nextOf()->isBaseOf(type->nextOf(), &offset);
|
int baseOf = fdv->type->nextOf()->isBaseOf(type->nextOf(), &offset);
|
||||||
if (global.endGagging(errors))
|
if (global.endGagging(errors))
|
||||||
{
|
{
|
||||||
// any error in isBaseOf() is a forward reference error, so we bail out
|
// any error in isBaseOf() is a forward reference error, so we bail out
|
||||||
cd->sizeok = 2; // can't finish due to forward reference
|
cd->sizeok = 2; // can't finish due to forward reference
|
||||||
@@ -647,7 +647,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
|||||||
FuncDeclaration *fd = new FuncDeclaration(loc, loc,
|
FuncDeclaration *fd = new FuncDeclaration(loc, loc,
|
||||||
Id::require, STCundefined, tf);
|
Id::require, STCundefined, tf);
|
||||||
fd->fbody = frequire;
|
fd->fbody = frequire;
|
||||||
Statement *s1 = new ExpStatement(loc, fd);
|
Statement *s1 = new ExpStatement(loc, fd);
|
||||||
Expression *e = new CallExp(loc, new VarExp(loc, fd), (Expressions *)NULL);
|
Expression *e = new CallExp(loc, new VarExp(loc, fd), (Expressions *)NULL);
|
||||||
Statement *s2 = new ExpStatement(loc, e);
|
Statement *s2 = new ExpStatement(loc, e);
|
||||||
frequire = new CompoundStatement(loc, s1, s2);
|
frequire = new CompoundStatement(loc, s1, s2);
|
||||||
@@ -674,7 +674,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
|||||||
FuncDeclaration *fd = new FuncDeclaration(loc, loc,
|
FuncDeclaration *fd = new FuncDeclaration(loc, loc,
|
||||||
Id::ensure, STCundefined, tf);
|
Id::ensure, STCundefined, tf);
|
||||||
fd->fbody = fensure;
|
fd->fbody = fensure;
|
||||||
Statement *s1 = new ExpStatement(loc, fd);
|
Statement *s1 = new ExpStatement(loc, fd);
|
||||||
Expression *eresult = NULL;
|
Expression *eresult = NULL;
|
||||||
if (outId)
|
if (outId)
|
||||||
eresult = new IdentifierExp(loc, outId);
|
eresult = new IdentifierExp(loc, outId);
|
||||||
@@ -689,7 +689,7 @@ Ldone:
|
|||||||
Module::dprogress++;
|
Module::dprogress++;
|
||||||
//LDC relies on semanticRun variable not being reset here
|
//LDC relies on semanticRun variable not being reset here
|
||||||
if(semanticRun < PASSsemanticdone)
|
if(semanticRun < PASSsemanticdone)
|
||||||
semanticRun = PASSsemanticdone;
|
semanticRun = PASSsemanticdone;
|
||||||
|
|
||||||
/* Save scope for possible later use (if we need the
|
/* Save scope for possible later use (if we need the
|
||||||
* function internals)
|
* function internals)
|
||||||
@@ -731,7 +731,7 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
if (semanticRun >= PASSsemantic3)
|
if (semanticRun >= PASSsemantic3)
|
||||||
return;
|
return;
|
||||||
semanticRun = PASSsemantic3;
|
semanticRun = PASSsemantic3;
|
||||||
semantic3Errors = 0;
|
semantic3Errors = 0;
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
if (!global.params.useAvailableExternally)
|
if (!global.params.useAvailableExternally)
|
||||||
@@ -754,20 +754,20 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frequire)
|
if (frequire)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < foverrides.dim; i++)
|
for (int i = 0; i < foverrides.dim; i++)
|
||||||
{
|
{
|
||||||
FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i];
|
FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i];
|
||||||
|
|
||||||
if (fdv->fbody && !fdv->frequire)
|
if (fdv->fbody && !fdv->frequire)
|
||||||
{
|
{
|
||||||
error("cannot have an in contract when overriden function %s does not have an in contract", fdv->toPrettyChars());
|
error("cannot have an in contract when overriden function %s does not have an in contract", fdv->toPrettyChars());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frequire = mergeFrequire(frequire);
|
frequire = mergeFrequire(frequire);
|
||||||
fensure = mergeFensure(fensure);
|
fensure = mergeFensure(fensure);
|
||||||
|
|
||||||
@@ -790,10 +790,10 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
sc2->sw = NULL;
|
sc2->sw = NULL;
|
||||||
sc2->fes = fes;
|
sc2->fes = fes;
|
||||||
sc2->linkage = LINKd;
|
sc2->linkage = LINKd;
|
||||||
sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract |
|
sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract |
|
||||||
STCdeprecated | STCoverride |
|
STCdeprecated | STCoverride |
|
||||||
STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref |
|
STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref |
|
||||||
STCproperty | STCsafe | STCtrusted | STCsystem);
|
STCproperty | STCsafe | STCtrusted | STCsystem);
|
||||||
sc2->protection = PROTpublic;
|
sc2->protection = PROTpublic;
|
||||||
sc2->explicitProtection = 0;
|
sc2->explicitProtection = 0;
|
||||||
sc2->structalign = 8;
|
sc2->structalign = 8;
|
||||||
@@ -848,24 +848,24 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
#else
|
#else
|
||||||
Type *t;
|
Type *t;
|
||||||
|
|
||||||
if (global.params.is64bit)
|
if (global.params.is64bit)
|
||||||
{ // Declare save area for varargs registers
|
{ // Declare save area for varargs registers
|
||||||
Type *t = new TypeIdentifier(loc, Id::va_argsave_t);
|
Type *t = new TypeIdentifier(loc, Id::va_argsave_t);
|
||||||
t = t->semantic(loc, sc);
|
t = t->semantic(loc, sc);
|
||||||
if (t == Type::terror)
|
if (t == Type::terror)
|
||||||
{
|
{
|
||||||
error("must import std.c.stdarg to use variadic functions");
|
error("must import std.c.stdarg to use variadic functions");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
v_argsave = new VarDeclaration(loc, t, Id::va_argsave, NULL);
|
v_argsave = new VarDeclaration(loc, t, Id::va_argsave, NULL);
|
||||||
v_argsave->semantic(sc2);
|
v_argsave->semantic(sc2);
|
||||||
sc2->insert(v_argsave);
|
sc2->insert(v_argsave);
|
||||||
v_argsave->parent = this;
|
v_argsave->parent = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f->linkage == LINKd)
|
if (f->linkage == LINKd)
|
||||||
{ // Declare _arguments[]
|
{ // Declare _arguments[]
|
||||||
#if BREAKABI
|
#if BREAKABI
|
||||||
@@ -889,7 +889,7 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
v_arguments->parent = this;
|
v_arguments->parent = this;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (f->linkage == LINKd || (f->parameters && Parameter::dim(f->parameters)))
|
if (f->linkage == LINKd || (f->parameters && Parameter::dim(f->parameters)))
|
||||||
{ // Declare _argptr
|
{ // Declare _argptr
|
||||||
#if IN_GCC
|
#if IN_GCC
|
||||||
t = d_gcc_builtin_va_list_d_type;
|
t = d_gcc_builtin_va_list_d_type;
|
||||||
@@ -954,7 +954,7 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
{ /* parameters[] has all the tuples removed, as the back end
|
{ /* parameters[] has all the tuples removed, as the back end
|
||||||
* doesn't know about tuples
|
* doesn't know about tuples
|
||||||
*/
|
*/
|
||||||
parameters = new VarDeclarations();
|
parameters = new VarDeclarations();
|
||||||
parameters->reserve(nparams);
|
parameters->reserve(nparams);
|
||||||
for (size_t i = 0; i < nparams; i++)
|
for (size_t i = 0; i < nparams; i++)
|
||||||
{
|
{
|
||||||
@@ -1186,7 +1186,7 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
f = (TypeFunction *)type;
|
f = (TypeFunction *)type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int offend = fbody ? fbody->blockExit(FALSE) & BEfallthru : TRUE;
|
int offend = fbody ? fbody->blockExit(FALSE) & BEfallthru : TRUE;
|
||||||
|
|
||||||
if (isStaticCtorDeclaration())
|
if (isStaticCtorDeclaration())
|
||||||
{ /* It's a static constructor. Ensure that all
|
{ /* It's a static constructor. Ensure that all
|
||||||
@@ -1233,16 +1233,16 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
Expression *e1 = new SuperExp(0);
|
Expression *e1 = new SuperExp(0);
|
||||||
Expression *e = new CallExp(0, e1);
|
Expression *e = new CallExp(0, e1);
|
||||||
|
|
||||||
e = e->trySemantic(sc2);
|
e = e->trySemantic(sc2);
|
||||||
if (!e)
|
if (!e)
|
||||||
error("no match for implicit super() call in constructor");
|
error("no match for implicit super() call in constructor");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Statement *s = new ExpStatement(0, e);
|
Statement *s = new ExpStatement(0, e);
|
||||||
fbody = new CompoundStatement(0, s, fbody);
|
fbody = new CompoundStatement(0, s, fbody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fes)
|
else if (fes)
|
||||||
{ // For foreach(){} body, append a return 0;
|
{ // For foreach(){} body, append a return 0;
|
||||||
Expression *e = new IntegerExp(0);
|
Expression *e = new IntegerExp(0);
|
||||||
@@ -1329,17 +1329,17 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
v_argptr->init = new VoidInitializer(loc);
|
v_argptr->init = new VoidInitializer(loc);
|
||||||
#else
|
#else
|
||||||
Type *t = argptr->type;
|
Type *t = argptr->type;
|
||||||
if (global.params.is64bit)
|
if (global.params.is64bit)
|
||||||
{ // Initialize _argptr to point to v_argsave
|
{ // Initialize _argptr to point to v_argsave
|
||||||
Expression *e1 = new VarExp(0, argptr);
|
Expression *e1 = new VarExp(0, argptr);
|
||||||
Expression *e = new SymOffExp(0, v_argsave, 6*8 + 8*16);
|
Expression *e = new SymOffExp(0, v_argsave, 6*8 + 8*16);
|
||||||
e->type = argptr->type;
|
e->type = argptr->type;
|
||||||
e = new AssignExp(0, e1, e);
|
e = new AssignExp(0, e1, e);
|
||||||
e = e->semantic(sc);
|
e = e->semantic(sc);
|
||||||
a->push(new ExpStatement(0, e));
|
a->push(new ExpStatement(0, e));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Initialize _argptr to point past non-variadic arg
|
{ // Initialize _argptr to point past non-variadic arg
|
||||||
VarDeclaration *p;
|
VarDeclaration *p;
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
|
|
||||||
@@ -1531,7 +1531,7 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
if (isSynchronized())
|
if (isSynchronized())
|
||||||
{
|
{
|
||||||
AggregateDeclaration *ad = isThis();
|
AggregateDeclaration *ad = isThis();
|
||||||
ClassDeclaration *cd = ad ? ad->isClassDeclaration() : parent->isClassDeclaration();
|
ClassDeclaration *cd = ad ? ad->isClassDeclaration() : parent->isClassDeclaration();
|
||||||
|
|
||||||
Expression *sync;
|
Expression *sync;
|
||||||
if (isStatic())
|
if (isStatic())
|
||||||
@@ -1569,12 +1569,12 @@ void FuncDeclaration::semantic3(Scope *sc)
|
|||||||
if (global.gag && global.errors != nerrors)
|
if (global.gag && global.errors != nerrors)
|
||||||
semanticRun = PASSsemanticdone; // Ensure errors get reported again
|
semanticRun = PASSsemanticdone; // Ensure errors get reported again
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
semanticRun = PASSsemantic3done;
|
semanticRun = PASSsemantic3done;
|
||||||
semantic3Errors = global.errors - nerrors;
|
semantic3Errors = global.errors - nerrors;
|
||||||
}
|
}
|
||||||
//printf("-FuncDeclaration::semantic3('%s.%s', sc = %p, loc = %s)\n", parent->toChars(), toChars(), sc, loc.toChars());
|
//printf("-FuncDeclaration::semantic3('%s.%s', sc = %p, loc = %s)\n", parent->toChars(), toChars(), sc, loc.toChars());
|
||||||
//fflush(stdout);
|
//fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FuncDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void FuncDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
@@ -1589,7 +1589,7 @@ void FuncDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
|||||||
void FuncDeclaration::bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void FuncDeclaration::bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
if (fbody &&
|
if (fbody &&
|
||||||
(!hgs->hdrgen || hgs->tpltMember || canInline(1,1,1))
|
(!hgs->hdrgen || hgs->tpltMember || canInline(1,1,1))
|
||||||
)
|
)
|
||||||
{ buf->writenl();
|
{ buf->writenl();
|
||||||
|
|
||||||
@@ -1669,7 +1669,7 @@ Statement *FuncDeclaration::mergeFrequire(Statement *sf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sf = fdv->mergeFrequire(sf);
|
sf = fdv->mergeFrequire(sf);
|
||||||
if (sf && fdv->fdrequire)
|
if (sf && fdv->fdrequire)
|
||||||
{
|
{
|
||||||
//printf("fdv->frequire: %s\n", fdv->frequire->toChars());
|
//printf("fdv->frequire: %s\n", fdv->frequire->toChars());
|
||||||
/* Make the call:
|
/* Make the call:
|
||||||
@@ -1680,13 +1680,13 @@ Statement *FuncDeclaration::mergeFrequire(Statement *sf)
|
|||||||
Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdrequire), eresult);
|
Expression *e = new CallExp(loc, new VarExp(loc, fdv->fdrequire), eresult);
|
||||||
Statement *s2 = new ExpStatement(loc, e);
|
Statement *s2 = new ExpStatement(loc, e);
|
||||||
|
|
||||||
Catch *c = new Catch(loc, NULL, NULL, sf);
|
Catch *c = new Catch(loc, NULL, NULL, sf);
|
||||||
Catches *catches = new Catches();
|
Catches *catches = new Catches();
|
||||||
catches->push(c);
|
catches->push(c);
|
||||||
sf = new TryCatchStatement(loc, s2, catches);
|
sf = new TryCatchStatement(loc, s2, catches);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return sf;
|
return sf;
|
||||||
}
|
}
|
||||||
@@ -2462,21 +2462,21 @@ int FuncDeclaration::isVirtual()
|
|||||||
toParent()->isClassDeclaration();
|
toParent()->isClassDeclaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine if a function is pedantically virtual
|
// Determine if a function is pedantically virtual
|
||||||
|
|
||||||
int FuncDeclaration::isVirtualMethod()
|
int FuncDeclaration::isVirtualMethod()
|
||||||
{
|
{
|
||||||
//printf("FuncDeclaration::isVirtualMethod() %s\n", toChars());
|
//printf("FuncDeclaration::isVirtualMethod() %s\n", toChars());
|
||||||
if (!isVirtual())
|
if (!isVirtual())
|
||||||
return 0;
|
return 0;
|
||||||
// If it's a final method, and does not override anything, then it is not virtual
|
// If it's a final method, and does not override anything, then it is not virtual
|
||||||
if (isFinal() && foverrides.dim == 0)
|
if (isFinal() && foverrides.dim == 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FuncDeclaration::isFinal()
|
int FuncDeclaration::isFinal()
|
||||||
{
|
{
|
||||||
ClassDeclaration *cd;
|
ClassDeclaration *cd;
|
||||||
@@ -2651,43 +2651,43 @@ Lyes:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/***********************************************
|
/***********************************************
|
||||||
* Determine if function's variables are referenced by a function
|
* Determine if function's variables are referenced by a function
|
||||||
* nested within it.
|
* nested within it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int FuncDeclaration::hasNestedFrameRefs()
|
int FuncDeclaration::hasNestedFrameRefs()
|
||||||
{
|
{
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
if (closureVars.dim)
|
if (closureVars.dim)
|
||||||
#else
|
#else
|
||||||
if (nestedFrameRef)
|
if (nestedFrameRef)
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* If a virtual method has contracts, assume its variables are referenced
|
/* If a virtual method has contracts, assume its variables are referenced
|
||||||
* by those contracts, even if they aren't. Because they might be referenced
|
* by those contracts, even if they aren't. Because they might be referenced
|
||||||
* by the overridden or overriding function's contracts.
|
* by the overridden or overriding function's contracts.
|
||||||
* This can happen because frequire and fensure are implemented as nested functions,
|
* This can happen because frequire and fensure are implemented as nested functions,
|
||||||
* and they can be called directly by an overriding function and the overriding function's
|
* and they can be called directly by an overriding function and the overriding function's
|
||||||
* context had better match, or Bugzilla 7337 will bite.
|
* context had better match, or Bugzilla 7337 will bite.
|
||||||
*/
|
*/
|
||||||
if ((fdrequire || fdensure) && isVirtualMethod())
|
if ((fdrequire || fdensure) && isVirtualMethod())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (foverrides.dim && isVirtualMethod())
|
if (foverrides.dim && isVirtualMethod())
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < foverrides.dim; i++)
|
for (size_t i = 0; i < foverrides.dim; i++)
|
||||||
{
|
{
|
||||||
FuncDeclaration *fdv = foverrides.tdata()[i];
|
FuncDeclaration *fdv = foverrides.tdata()[i];
|
||||||
if (fdv->hasNestedFrameRefs())
|
if (fdv->hasNestedFrameRefs())
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************
|
/*********************************************
|
||||||
* Return the function's parameter list, and whether
|
* Return the function's parameter list, and whether
|
||||||
* it is variadic or not.
|
* it is variadic or not.
|
||||||
@@ -3112,7 +3112,7 @@ void StaticCtorDeclaration::semantic(Scope *sc)
|
|||||||
VarDeclaration *v = new VarDeclaration(0, Type::tint32, id, NULL);
|
VarDeclaration *v = new VarDeclaration(0, Type::tint32, id, NULL);
|
||||||
v->storage_class = STCstatic;
|
v->storage_class = STCstatic;
|
||||||
Statements *sa = new Statements();
|
Statements *sa = new Statements();
|
||||||
Statement *s = new ExpStatement(0, v);
|
Statement *s = new ExpStatement(0, v);
|
||||||
sa->push(s);
|
sa->push(s);
|
||||||
Expression *e = new IdentifierExp(0, id);
|
Expression *e = new IdentifierExp(0, id);
|
||||||
e = new AddAssignExp(0, e, new IntegerExp(1));
|
e = new AddAssignExp(0, e, new IntegerExp(1));
|
||||||
@@ -3154,11 +3154,11 @@ int StaticCtorDeclaration::isVirtual()
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StaticCtorDeclaration::hasStaticCtorOrDtor()
|
bool StaticCtorDeclaration::hasStaticCtorOrDtor()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StaticCtorDeclaration::addPreInvariant()
|
int StaticCtorDeclaration::addPreInvariant()
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -3223,7 +3223,7 @@ void StaticDtorDeclaration::semantic(Scope *sc)
|
|||||||
VarDeclaration *v = new VarDeclaration(0, Type::tint32, id, NULL);
|
VarDeclaration *v = new VarDeclaration(0, Type::tint32, id, NULL);
|
||||||
v->storage_class = STCstatic;
|
v->storage_class = STCstatic;
|
||||||
Statements *sa = new Statements();
|
Statements *sa = new Statements();
|
||||||
Statement *s = new ExpStatement(0, v);
|
Statement *s = new ExpStatement(0, v);
|
||||||
sa->push(s);
|
sa->push(s);
|
||||||
Expression *e = new IdentifierExp(0, id);
|
Expression *e = new IdentifierExp(0, id);
|
||||||
e = new AddAssignExp(0, e, new IntegerExp((uint64_t)-1));
|
e = new AddAssignExp(0, e, new IntegerExp((uint64_t)-1));
|
||||||
@@ -3266,11 +3266,11 @@ int StaticDtorDeclaration::isVirtual()
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StaticDtorDeclaration::hasStaticCtorOrDtor()
|
bool StaticDtorDeclaration::hasStaticCtorOrDtor()
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int StaticDtorDeclaration::addPreInvariant()
|
int StaticDtorDeclaration::addPreInvariant()
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
+100
-100
@@ -1,100 +1,100 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// Initial header generation implementation by Dave Fladebo
|
// Initial header generation implementation by Dave Fladebo
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
// Routines to emit header files
|
// Routines to emit header files
|
||||||
|
|
||||||
#define PRETTY_PRINT
|
#define PRETTY_PRINT
|
||||||
#define TEST_EMIT_ALL 0 // For Testing
|
#define TEST_EMIT_ALL 0 // For Testing
|
||||||
|
|
||||||
#define LOG 0
|
#define LOG 0
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#if __DMC__
|
#if __DMC__
|
||||||
#include <complex.h>
|
#include <complex.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "rmem.h"
|
#include "rmem.h"
|
||||||
|
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
|
||||||
#include "attrib.h"
|
#include "attrib.h"
|
||||||
#include "cond.h"
|
#include "cond.h"
|
||||||
#include "enum.h"
|
#include "enum.h"
|
||||||
#include "import.h"
|
#include "import.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "staticassert.h"
|
#include "staticassert.h"
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
#include "utf.h"
|
#include "utf.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#include "declaration.h"
|
#include "declaration.h"
|
||||||
#include "aggregate.h"
|
#include "aggregate.h"
|
||||||
#include "expression.h"
|
#include "expression.h"
|
||||||
#include "statement.h"
|
#include "statement.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "hdrgen.h"
|
#include "hdrgen.h"
|
||||||
|
|
||||||
void argsToCBuffer(OutBuffer *buf, Array *arguments, HdrGenState *hgs);
|
void argsToCBuffer(OutBuffer *buf, Array *arguments, HdrGenState *hgs);
|
||||||
|
|
||||||
void Module::genhdrfile()
|
void Module::genhdrfile()
|
||||||
{
|
{
|
||||||
OutBuffer hdrbufr;
|
OutBuffer hdrbufr;
|
||||||
|
|
||||||
hdrbufr.printf("// D import file generated from '%s'", srcfile->toChars());
|
hdrbufr.printf("// D import file generated from '%s'", srcfile->toChars());
|
||||||
hdrbufr.writenl();
|
hdrbufr.writenl();
|
||||||
|
|
||||||
HdrGenState hgs;
|
HdrGenState hgs;
|
||||||
memset(&hgs, 0, sizeof(hgs));
|
memset(&hgs, 0, sizeof(hgs));
|
||||||
hgs.hdrgen = 1;
|
hgs.hdrgen = 1;
|
||||||
|
|
||||||
toCBuffer(&hdrbufr, &hgs);
|
toCBuffer(&hdrbufr, &hgs);
|
||||||
|
|
||||||
// Transfer image to file
|
// Transfer image to file
|
||||||
hdrfile->setbuffer(hdrbufr.data, hdrbufr.offset);
|
hdrfile->setbuffer(hdrbufr.data, hdrbufr.offset);
|
||||||
hdrbufr.data = NULL;
|
hdrbufr.data = NULL;
|
||||||
|
|
||||||
char *pt = FileName::path(hdrfile->toChars());
|
char *pt = FileName::path(hdrfile->toChars());
|
||||||
if (*pt)
|
if (*pt)
|
||||||
FileName::ensurePathExists(pt);
|
FileName::ensurePathExists(pt);
|
||||||
mem.free(pt);
|
mem.free(pt);
|
||||||
hdrfile->writev();
|
hdrfile->writev();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Module::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void Module::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
if (md)
|
if (md)
|
||||||
{
|
{
|
||||||
buf->writestring("module ");
|
buf->writestring("module ");
|
||||||
buf->writestring(md->toChars());
|
buf->writestring(md->toChars());
|
||||||
buf->writebyte(';');
|
buf->writebyte(';');
|
||||||
buf->writenl();
|
buf->writenl();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||||
|
|
||||||
s->toHBuffer(buf, hgs);
|
s->toHBuffer(buf, hgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Dsymbol::toHBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void Dsymbol::toHBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
toCBuffer(buf, hgs);
|
toCBuffer(buf, hgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************/
|
/*************************************/
|
||||||
|
|||||||
+34
-34
@@ -1,34 +1,34 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// initial header generation implementation by Dave Fladebo
|
// initial header generation implementation by Dave Fladebo
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
|
|
||||||
struct HdrGenState
|
struct HdrGenState
|
||||||
{
|
{
|
||||||
int hdrgen; // 1 if generating header file
|
int hdrgen; // 1 if generating header file
|
||||||
int ddoc; // 1 if generating Ddoc file
|
int ddoc; // 1 if generating Ddoc file
|
||||||
int console; // 1 if writing to console
|
int console; // 1 if writing to console
|
||||||
int tpltMember;
|
int tpltMember;
|
||||||
int inCallExp;
|
int inCallExp;
|
||||||
int inPtrExp;
|
int inPtrExp;
|
||||||
int inSlcExp;
|
int inSlcExp;
|
||||||
int inDotExp;
|
int inDotExp;
|
||||||
int inBinExp;
|
int inBinExp;
|
||||||
int inArrExp;
|
int inArrExp;
|
||||||
int emitInst;
|
int emitInst;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
int init;
|
int init;
|
||||||
int decl;
|
int decl;
|
||||||
} FLinit;
|
} FLinit;
|
||||||
|
|
||||||
HdrGenState() { memset(this, 0, sizeof(HdrGenState)); }
|
HdrGenState() { memset(this, 0, sizeof(HdrGenState)); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+718
-718
File diff suppressed because it is too large
Load Diff
+43
-43
@@ -1,43 +1,43 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_HTML_H
|
#ifndef DMD_HTML_H
|
||||||
#define DMD_HTML_H 1
|
#define DMD_HTML_H 1
|
||||||
|
|
||||||
struct OutBuffer;
|
struct OutBuffer;
|
||||||
|
|
||||||
struct Html
|
struct Html
|
||||||
{
|
{
|
||||||
const char *sourcename;
|
const char *sourcename;
|
||||||
|
|
||||||
unsigned char *base; // pointer to start of buffer
|
unsigned char *base; // pointer to start of buffer
|
||||||
unsigned char *end; // past end of buffer
|
unsigned char *end; // past end of buffer
|
||||||
unsigned char *p; // current character
|
unsigned char *p; // current character
|
||||||
unsigned linnum; // current line number
|
unsigned linnum; // current line number
|
||||||
OutBuffer *dbuf; // code source buffer
|
OutBuffer *dbuf; // code source buffer
|
||||||
int inCode; // !=0 if in code
|
int inCode; // !=0 if in code
|
||||||
|
|
||||||
|
|
||||||
Html(const char *sourcename, unsigned char *base, unsigned length);
|
Html(const char *sourcename, unsigned char *base, unsigned length);
|
||||||
|
|
||||||
void error(const char *format, ...) IS_PRINTF(2);
|
void error(const char *format, ...) IS_PRINTF(2);
|
||||||
void extractCode(OutBuffer *buf);
|
void extractCode(OutBuffer *buf);
|
||||||
void skipTag();
|
void skipTag();
|
||||||
void skipString();
|
void skipString();
|
||||||
unsigned char *skipWhite(unsigned char *q);
|
unsigned char *skipWhite(unsigned char *q);
|
||||||
void scanComment();
|
void scanComment();
|
||||||
int isCommentStart();
|
int isCommentStart();
|
||||||
void scanCDATA();
|
void scanCDATA();
|
||||||
int isCDATAStart();
|
int isCDATAStart();
|
||||||
int charEntity();
|
int charEntity();
|
||||||
static int namedEntity(unsigned char *p, int length);
|
static int namedEntity(unsigned char *p, int length);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+101
-101
@@ -1,101 +1,101 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "root.h"
|
#include "root.h"
|
||||||
#include "identifier.h"
|
#include "identifier.h"
|
||||||
#include "mars.h"
|
#include "mars.h"
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
|
|
||||||
Identifier::Identifier(const char *string, int value)
|
Identifier::Identifier(const char *string, int value)
|
||||||
{
|
{
|
||||||
//printf("Identifier('%s', %d)\n", string, value);
|
//printf("Identifier('%s', %d)\n", string, value);
|
||||||
this->string = string;
|
this->string = string;
|
||||||
this->value = value;
|
this->value = value;
|
||||||
this->len = strlen(string);
|
this->len = strlen(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_t Identifier::hashCode()
|
hash_t Identifier::hashCode()
|
||||||
{
|
{
|
||||||
return String::calcHash(string);
|
return String::calcHash(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Identifier::equals(Object *o)
|
int Identifier::equals(Object *o)
|
||||||
{
|
{
|
||||||
return this == o || memcmp(string,o->toChars(),len+1) == 0;
|
return this == o || memcmp(string,o->toChars(),len+1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Identifier::compare(Object *o)
|
int Identifier::compare(Object *o)
|
||||||
{
|
{
|
||||||
return memcmp(string, o->toChars(), len + 1);
|
return memcmp(string, o->toChars(), len + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Identifier::toChars()
|
char *Identifier::toChars()
|
||||||
{
|
{
|
||||||
return (char *)string;
|
return (char *)string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Identifier::toHChars2()
|
const char *Identifier::toHChars2()
|
||||||
{
|
{
|
||||||
const char *p = NULL;
|
const char *p = NULL;
|
||||||
|
|
||||||
if (this == Id::ctor) p = "this";
|
if (this == Id::ctor) p = "this";
|
||||||
else if (this == Id::dtor) p = "~this";
|
else if (this == Id::dtor) p = "~this";
|
||||||
else if (this == Id::classInvariant) p = "invariant";
|
else if (this == Id::classInvariant) p = "invariant";
|
||||||
else if (this == Id::unitTest) p = "unittest";
|
else if (this == Id::unitTest) p = "unittest";
|
||||||
else if (this == Id::dollar) p = "$";
|
else if (this == Id::dollar) p = "$";
|
||||||
else if (this == Id::withSym) p = "with";
|
else if (this == Id::withSym) p = "with";
|
||||||
else if (this == Id::result) p = "result";
|
else if (this == Id::result) p = "result";
|
||||||
else if (this == Id::returnLabel) p = "return";
|
else if (this == Id::returnLabel) p = "return";
|
||||||
else
|
else
|
||||||
{ p = toChars();
|
{ p = toChars();
|
||||||
if (*p == '_')
|
if (*p == '_')
|
||||||
{
|
{
|
||||||
if (memcmp(p, "_staticCtor", 11) == 0)
|
if (memcmp(p, "_staticCtor", 11) == 0)
|
||||||
p = "static this";
|
p = "static this";
|
||||||
else if (memcmp(p, "_staticDtor", 11) == 0)
|
else if (memcmp(p, "_staticDtor", 11) == 0)
|
||||||
p = "static ~this";
|
p = "static ~this";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Identifier::print()
|
void Identifier::print()
|
||||||
{
|
{
|
||||||
fprintf(stdmsg, "%s",string);
|
fprintf(stdmsg, "%s",string);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Identifier::dyncast()
|
int Identifier::dyncast()
|
||||||
{
|
{
|
||||||
return DYNCAST_IDENTIFIER;
|
return DYNCAST_IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Identifier *Identifier::generateId(const char *prefix)
|
Identifier *Identifier::generateId(const char *prefix)
|
||||||
{
|
{
|
||||||
static size_t i;
|
static size_t i;
|
||||||
|
|
||||||
return generateId(prefix, ++i);
|
return generateId(prefix, ++i);
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier *Identifier::generateId(const char *prefix, size_t i)
|
Identifier *Identifier::generateId(const char *prefix, size_t i)
|
||||||
{ OutBuffer buf;
|
{ OutBuffer buf;
|
||||||
|
|
||||||
buf.writestring(prefix);
|
buf.writestring(prefix);
|
||||||
buf.printf("%zu", i);
|
buf.printf("%zu", i);
|
||||||
|
|
||||||
char *id = buf.toChars();
|
char *id = buf.toChars();
|
||||||
buf.data = NULL;
|
buf.data = NULL;
|
||||||
return Lexer::idPool(id);
|
return Lexer::idPool(id);
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-27
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -60,7 +60,7 @@ Msgtable msgtable[] =
|
|||||||
{ "typeinfo" },
|
{ "typeinfo" },
|
||||||
{ "outer" },
|
{ "outer" },
|
||||||
{ "Exception" },
|
{ "Exception" },
|
||||||
{ "Error" },
|
{ "Error" },
|
||||||
{ "withSym", "__withSym" },
|
{ "withSym", "__withSym" },
|
||||||
{ "result", "__result" },
|
{ "result", "__result" },
|
||||||
{ "returnLabel", "__returnLabel" },
|
{ "returnLabel", "__returnLabel" },
|
||||||
@@ -250,31 +250,31 @@ Msgtable msgtable[] =
|
|||||||
{ "main" },
|
{ "main" },
|
||||||
{ "WinMain" },
|
{ "WinMain" },
|
||||||
{ "DllMain" },
|
{ "DllMain" },
|
||||||
|
|
||||||
// varargs implementation
|
// varargs implementation
|
||||||
{ "va_argsave_t", "__va_argsave_t" },
|
{ "va_argsave_t", "__va_argsave_t" },
|
||||||
{ "va_argsave", "__va_argsave" },
|
{ "va_argsave", "__va_argsave" },
|
||||||
|
|
||||||
// Builtin functions
|
// Builtin functions
|
||||||
{ "std" },
|
{ "std" },
|
||||||
{ "core" },
|
{ "core" },
|
||||||
{ "math" },
|
{ "math" },
|
||||||
{ "sin" },
|
{ "sin" },
|
||||||
{ "cos" },
|
{ "cos" },
|
||||||
{ "tan" },
|
{ "tan" },
|
||||||
{ "_sqrt", "sqrt" },
|
{ "_sqrt", "sqrt" },
|
||||||
{ "_pow", "pow" },
|
{ "_pow", "pow" },
|
||||||
{ "atan2" },
|
{ "atan2" },
|
||||||
{ "rndtol" },
|
{ "rndtol" },
|
||||||
{ "expm1" },
|
{ "expm1" },
|
||||||
{ "exp2" },
|
{ "exp2" },
|
||||||
{ "yl2x" },
|
{ "yl2x" },
|
||||||
{ "yl2xp1" },
|
{ "yl2xp1" },
|
||||||
{ "fabs" },
|
{ "fabs" },
|
||||||
{ "bitop" },
|
{ "bitop" },
|
||||||
{ "bsf" },
|
{ "bsf" },
|
||||||
{ "bsr" },
|
{ "bsr" },
|
||||||
{ "bswap" },
|
{ "bswap" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+457
-457
@@ -1,457 +1,457 @@
|
|||||||
|
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
|
|
||||||
enum TY impcnvResult[TMAX][TMAX];
|
enum TY impcnvResult[TMAX][TMAX];
|
||||||
enum TY impcnvType1[TMAX][TMAX];
|
enum TY impcnvType1[TMAX][TMAX];
|
||||||
enum TY impcnvType2[TMAX][TMAX];
|
enum TY impcnvType2[TMAX][TMAX];
|
||||||
int impcnvWarn[TMAX][TMAX];
|
int impcnvWarn[TMAX][TMAX];
|
||||||
|
|
||||||
int integral_promotion(int t)
|
int integral_promotion(int t)
|
||||||
{
|
{
|
||||||
switch (t)
|
switch (t)
|
||||||
{
|
{
|
||||||
case Tchar:
|
case Tchar:
|
||||||
case Twchar:
|
case Twchar:
|
||||||
case Tbit:
|
case Tbit:
|
||||||
case Tbool:
|
case Tbool:
|
||||||
case Tint8:
|
case Tint8:
|
||||||
case Tuns8:
|
case Tuns8:
|
||||||
case Tint16:
|
case Tint16:
|
||||||
case Tuns16: return Tint32;
|
case Tuns16: return Tint32;
|
||||||
case Tdchar: return Tuns32;
|
case Tdchar: return Tuns32;
|
||||||
default: return t;
|
default: return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{ int i, j;
|
{ int i, j;
|
||||||
|
|
||||||
// Set conversion tables
|
// Set conversion tables
|
||||||
for (i = 0; i < TMAX; i++)
|
for (i = 0; i < TMAX; i++)
|
||||||
for (j = 0; j < TMAX; j++)
|
for (j = 0; j < TMAX; j++)
|
||||||
{ impcnvResult[i][j] = Terror;
|
{ impcnvResult[i][j] = Terror;
|
||||||
impcnvType1[i][j] = Terror;
|
impcnvType1[i][j] = Terror;
|
||||||
impcnvType2[i][j] = Terror;
|
impcnvType2[i][j] = Terror;
|
||||||
impcnvWarn[i][j] = 0;
|
impcnvWarn[i][j] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define X(t1,t2, nt1,nt2, rt) \
|
#define X(t1,t2, nt1,nt2, rt) \
|
||||||
impcnvResult[t1][t2] = rt; \
|
impcnvResult[t1][t2] = rt; \
|
||||||
impcnvType1[t1][t2] = nt1; \
|
impcnvType1[t1][t2] = nt1; \
|
||||||
impcnvType2[t1][t2] = nt2;
|
impcnvType2[t1][t2] = nt2;
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tbit,Tbit, Tint32,Tint32, Tint32)
|
X(Tbit,Tbit, Tint32,Tint32, Tint32)
|
||||||
X(Tbit,Tint8, Tint32,Tint32, Tint32)
|
X(Tbit,Tint8, Tint32,Tint32, Tint32)
|
||||||
X(Tbit,Tuns8, Tint32,Tint32, Tint32)
|
X(Tbit,Tuns8, Tint32,Tint32, Tint32)
|
||||||
X(Tbit,Tint16, Tint32,Tint32, Tint32)
|
X(Tbit,Tint16, Tint32,Tint32, Tint32)
|
||||||
X(Tbit,Tuns16, Tint32,Tint32, Tint32)
|
X(Tbit,Tuns16, Tint32,Tint32, Tint32)
|
||||||
X(Tbit,Tint32, Tint32,Tint32, Tint32)
|
X(Tbit,Tint32, Tint32,Tint32, Tint32)
|
||||||
X(Tbit,Tuns32, Tuns32,Tuns32, Tuns32)
|
X(Tbit,Tuns32, Tuns32,Tuns32, Tuns32)
|
||||||
X(Tbit,Tint64, Tint64,Tint64, Tint64)
|
X(Tbit,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tbit,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tbit,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tbit,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tbit,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tbit,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tbit,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tbit,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tbit,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tbit,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tbit,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tbit,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tbit,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tbit,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tbit,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tbit,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tbit,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tbit,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tbit,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tbit,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tbit,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tbool,Tbool, Tbool,Tbool, Tbool)
|
X(Tbool,Tbool, Tbool,Tbool, Tbool)
|
||||||
X(Tbool,Tint8, Tint32,Tint32, Tint32)
|
X(Tbool,Tint8, Tint32,Tint32, Tint32)
|
||||||
X(Tbool,Tuns8, Tint32,Tint32, Tint32)
|
X(Tbool,Tuns8, Tint32,Tint32, Tint32)
|
||||||
X(Tbool,Tint16, Tint32,Tint32, Tint32)
|
X(Tbool,Tint16, Tint32,Tint32, Tint32)
|
||||||
X(Tbool,Tuns16, Tint32,Tint32, Tint32)
|
X(Tbool,Tuns16, Tint32,Tint32, Tint32)
|
||||||
X(Tbool,Tint32, Tint32,Tint32, Tint32)
|
X(Tbool,Tint32, Tint32,Tint32, Tint32)
|
||||||
X(Tbool,Tuns32, Tuns32,Tuns32, Tuns32)
|
X(Tbool,Tuns32, Tuns32,Tuns32, Tuns32)
|
||||||
X(Tbool,Tint64, Tint64,Tint64, Tint64)
|
X(Tbool,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tbool,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tbool,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tbool,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tbool,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tbool,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tbool,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tbool,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tbool,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tbool,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tbool,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tbool,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tbool,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tbool,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tbool,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tbool,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tbool,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tbool,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tbool,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tbool,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tbool,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tint8,Tint8, Tint32,Tint32, Tint32)
|
X(Tint8,Tint8, Tint32,Tint32, Tint32)
|
||||||
X(Tint8,Tuns8, Tint32,Tint32, Tint32)
|
X(Tint8,Tuns8, Tint32,Tint32, Tint32)
|
||||||
X(Tint8,Tint16, Tint32,Tint32, Tint32)
|
X(Tint8,Tint16, Tint32,Tint32, Tint32)
|
||||||
X(Tint8,Tuns16, Tint32,Tint32, Tint32)
|
X(Tint8,Tuns16, Tint32,Tint32, Tint32)
|
||||||
X(Tint8,Tint32, Tint32,Tint32, Tint32)
|
X(Tint8,Tint32, Tint32,Tint32, Tint32)
|
||||||
X(Tint8,Tuns32, Tuns32,Tuns32, Tuns32)
|
X(Tint8,Tuns32, Tuns32,Tuns32, Tuns32)
|
||||||
X(Tint8,Tint64, Tint64,Tint64, Tint64)
|
X(Tint8,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tint8,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tint8,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tint8,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tint8,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tint8,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tint8,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tint8,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tint8,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tint8,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tint8,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tint8,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tint8,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tint8,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tint8,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tint8,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tint8,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tint8,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tint8,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tint8,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tint8,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tuns8,Tuns8, Tint32,Tint32, Tint32)
|
X(Tuns8,Tuns8, Tint32,Tint32, Tint32)
|
||||||
X(Tuns8,Tint16, Tint32,Tint32, Tint32)
|
X(Tuns8,Tint16, Tint32,Tint32, Tint32)
|
||||||
X(Tuns8,Tuns16, Tint32,Tint32, Tint32)
|
X(Tuns8,Tuns16, Tint32,Tint32, Tint32)
|
||||||
X(Tuns8,Tint32, Tint32,Tint32, Tint32)
|
X(Tuns8,Tint32, Tint32,Tint32, Tint32)
|
||||||
X(Tuns8,Tuns32, Tuns32,Tuns32, Tuns32)
|
X(Tuns8,Tuns32, Tuns32,Tuns32, Tuns32)
|
||||||
X(Tuns8,Tint64, Tint64,Tint64, Tint64)
|
X(Tuns8,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tuns8,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tuns8,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tuns8,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tuns8,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tuns8,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tuns8,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tuns8,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tuns8,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tuns8,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tuns8,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tuns8,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tuns8,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tuns8,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tuns8,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tuns8,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tuns8,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tuns8,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tuns8,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tuns8,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tuns8,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tint16,Tint16, Tint32,Tint32, Tint32)
|
X(Tint16,Tint16, Tint32,Tint32, Tint32)
|
||||||
X(Tint16,Tuns16, Tint32,Tint32, Tint32)
|
X(Tint16,Tuns16, Tint32,Tint32, Tint32)
|
||||||
X(Tint16,Tint32, Tint32,Tint32, Tint32)
|
X(Tint16,Tint32, Tint32,Tint32, Tint32)
|
||||||
X(Tint16,Tuns32, Tuns32,Tuns32, Tuns32)
|
X(Tint16,Tuns32, Tuns32,Tuns32, Tuns32)
|
||||||
X(Tint16,Tint64, Tint64,Tint64, Tint64)
|
X(Tint16,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tint16,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tint16,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tint16,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tint16,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tint16,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tint16,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tint16,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tint16,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tint16,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tint16,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tint16,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tint16,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tint16,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tint16,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tint16,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tint16,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tint16,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tint16,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tint16,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tint16,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tuns16,Tuns16, Tint32,Tint32, Tint32)
|
X(Tuns16,Tuns16, Tint32,Tint32, Tint32)
|
||||||
X(Tuns16,Tint32, Tint32,Tint32, Tint32)
|
X(Tuns16,Tint32, Tint32,Tint32, Tint32)
|
||||||
X(Tuns16,Tuns32, Tuns32,Tuns32, Tuns32)
|
X(Tuns16,Tuns32, Tuns32,Tuns32, Tuns32)
|
||||||
X(Tuns16,Tint64, Tint64,Tint64, Tint64)
|
X(Tuns16,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tuns16,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tuns16,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tuns16,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tuns16,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tuns16,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tuns16,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tuns16,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tuns16,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tuns16,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tuns16,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tuns16,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tuns16,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tuns16,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tuns16,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tuns16,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tuns16,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tuns16,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tuns16,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tuns16,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tuns16,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tint32,Tint32, Tint32,Tint32, Tint32)
|
X(Tint32,Tint32, Tint32,Tint32, Tint32)
|
||||||
X(Tint32,Tuns32, Tuns32,Tuns32, Tuns32)
|
X(Tint32,Tuns32, Tuns32,Tuns32, Tuns32)
|
||||||
X(Tint32,Tint64, Tint64,Tint64, Tint64)
|
X(Tint32,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tint32,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tint32,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tint32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tint32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tint32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tint32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tint32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tint32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tint32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tint32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tint32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tint32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tint32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tint32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tint32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tint32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tint32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tint32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tint32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tint32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tuns32,Tuns32, Tuns32,Tuns32, Tuns32)
|
X(Tuns32,Tuns32, Tuns32,Tuns32, Tuns32)
|
||||||
X(Tuns32,Tint64, Tint64,Tint64, Tint64)
|
X(Tuns32,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tuns32,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tuns32,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tuns32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tuns32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tuns32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tuns32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tuns32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tuns32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tuns32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tuns32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tuns32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tuns32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tuns32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tuns32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tuns32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tuns32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tuns32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tuns32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tuns32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tuns32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tint64,Tint64, Tint64,Tint64, Tint64)
|
X(Tint64,Tint64, Tint64,Tint64, Tint64)
|
||||||
X(Tint64,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tint64,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tint64,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tint64,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tint64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tint64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tint64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tint64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tint64,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tint64,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tint64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tint64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tint64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tint64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tint64,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tint64,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tint64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tint64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tint64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tint64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tuns64,Tuns64, Tuns64,Tuns64, Tuns64)
|
X(Tuns64,Tuns64, Tuns64,Tuns64, Tuns64)
|
||||||
|
|
||||||
X(Tuns64,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tuns64,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tuns64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tuns64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tuns64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tuns64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
X(Tuns64,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tuns64,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tuns64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tuns64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tuns64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tuns64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tuns64,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tuns64,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tuns64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tuns64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tuns64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tuns64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tfloat32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
X(Tfloat32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
|
||||||
X(Tfloat32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tfloat32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tfloat32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tfloat32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
|
|
||||||
X(Tfloat32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
X(Tfloat32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
|
||||||
X(Tfloat32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tfloat32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tfloat32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tfloat32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
|
|
||||||
X(Tfloat32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
X(Tfloat32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
|
||||||
X(Tfloat32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tfloat32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tfloat32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tfloat32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tfloat64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
X(Tfloat64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
|
||||||
X(Tfloat64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tfloat64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
|
|
||||||
X(Tfloat64,Timaginary32, Tfloat64,Timaginary64, Tfloat64)
|
X(Tfloat64,Timaginary32, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tfloat64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
X(Tfloat64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
|
||||||
X(Tfloat64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tfloat64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
|
|
||||||
X(Tfloat64,Tcomplex32, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tfloat64,Tcomplex32, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tfloat64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
X(Tfloat64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
|
||||||
X(Tfloat64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tfloat64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tfloat80,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
X(Tfloat80,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
|
||||||
|
|
||||||
X(Tfloat80,Timaginary32, Tfloat80,Timaginary80, Tfloat80)
|
X(Tfloat80,Timaginary32, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tfloat80,Timaginary64, Tfloat80,Timaginary80, Tfloat80)
|
X(Tfloat80,Timaginary64, Tfloat80,Timaginary80, Tfloat80)
|
||||||
X(Tfloat80,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
X(Tfloat80,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
|
||||||
|
|
||||||
X(Tfloat80,Tcomplex32, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tfloat80,Tcomplex32, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
X(Tfloat80,Tcomplex64, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tfloat80,Tcomplex64, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
X(Tfloat80,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
X(Tfloat80,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Timaginary32,Timaginary32, Timaginary32,Timaginary32, Timaginary32)
|
X(Timaginary32,Timaginary32, Timaginary32,Timaginary32, Timaginary32)
|
||||||
X(Timaginary32,Timaginary64, Timaginary64,Timaginary64, Timaginary64)
|
X(Timaginary32,Timaginary64, Timaginary64,Timaginary64, Timaginary64)
|
||||||
X(Timaginary32,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
|
X(Timaginary32,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
|
||||||
|
|
||||||
X(Timaginary32,Tcomplex32, Timaginary32,Tcomplex32, Tcomplex32)
|
X(Timaginary32,Tcomplex32, Timaginary32,Tcomplex32, Tcomplex32)
|
||||||
X(Timaginary32,Tcomplex64, Timaginary64,Tcomplex64, Tcomplex64)
|
X(Timaginary32,Tcomplex64, Timaginary64,Tcomplex64, Tcomplex64)
|
||||||
X(Timaginary32,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
|
X(Timaginary32,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Timaginary64,Timaginary64, Timaginary64,Timaginary64, Timaginary64)
|
X(Timaginary64,Timaginary64, Timaginary64,Timaginary64, Timaginary64)
|
||||||
X(Timaginary64,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
|
X(Timaginary64,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
|
||||||
|
|
||||||
X(Timaginary64,Tcomplex32, Timaginary64,Tcomplex64, Tcomplex64)
|
X(Timaginary64,Tcomplex32, Timaginary64,Tcomplex64, Tcomplex64)
|
||||||
X(Timaginary64,Tcomplex64, Timaginary64,Tcomplex64, Tcomplex64)
|
X(Timaginary64,Tcomplex64, Timaginary64,Tcomplex64, Tcomplex64)
|
||||||
X(Timaginary64,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
|
X(Timaginary64,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Timaginary80,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
|
X(Timaginary80,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
|
||||||
|
|
||||||
X(Timaginary80,Tcomplex32, Timaginary80,Tcomplex80, Tcomplex80)
|
X(Timaginary80,Tcomplex32, Timaginary80,Tcomplex80, Tcomplex80)
|
||||||
X(Timaginary80,Tcomplex64, Timaginary80,Tcomplex80, Tcomplex80)
|
X(Timaginary80,Tcomplex64, Timaginary80,Tcomplex80, Tcomplex80)
|
||||||
X(Timaginary80,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
|
X(Timaginary80,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tcomplex32,Tcomplex32, Tcomplex32,Tcomplex32, Tcomplex32)
|
X(Tcomplex32,Tcomplex32, Tcomplex32,Tcomplex32, Tcomplex32)
|
||||||
X(Tcomplex32,Tcomplex64, Tcomplex64,Tcomplex64, Tcomplex64)
|
X(Tcomplex32,Tcomplex64, Tcomplex64,Tcomplex64, Tcomplex64)
|
||||||
X(Tcomplex32,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
|
X(Tcomplex32,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tcomplex64,Tcomplex64, Tcomplex64,Tcomplex64, Tcomplex64)
|
X(Tcomplex64,Tcomplex64, Tcomplex64,Tcomplex64, Tcomplex64)
|
||||||
X(Tcomplex64,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
|
X(Tcomplex64,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
/* ======================= */
|
/* ======================= */
|
||||||
|
|
||||||
X(Tcomplex80,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
|
X(Tcomplex80,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
|
||||||
|
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
#define Y(t1,t2) impcnvWarn[t1][t2] = 1;
|
#define Y(t1,t2) impcnvWarn[t1][t2] = 1;
|
||||||
Y(Tint8, Tbit)
|
Y(Tint8, Tbit)
|
||||||
Y(Tuns8, Tbit)
|
Y(Tuns8, Tbit)
|
||||||
Y(Tint16, Tbit)
|
Y(Tint16, Tbit)
|
||||||
Y(Tuns16, Tbit)
|
Y(Tuns16, Tbit)
|
||||||
Y(Tint32, Tbit)
|
Y(Tint32, Tbit)
|
||||||
Y(Tuns32, Tbit)
|
Y(Tuns32, Tbit)
|
||||||
Y(Tint64, Tbit)
|
Y(Tint64, Tbit)
|
||||||
Y(Tuns64, Tbit)
|
Y(Tuns64, Tbit)
|
||||||
|
|
||||||
Y(Tuns8, Tint8)
|
Y(Tuns8, Tint8)
|
||||||
Y(Tint16, Tint8)
|
Y(Tint16, Tint8)
|
||||||
Y(Tuns16, Tint8)
|
Y(Tuns16, Tint8)
|
||||||
Y(Tint32, Tint8)
|
Y(Tint32, Tint8)
|
||||||
Y(Tuns32, Tint8)
|
Y(Tuns32, Tint8)
|
||||||
Y(Tint64, Tint8)
|
Y(Tint64, Tint8)
|
||||||
Y(Tuns64, Tint8)
|
Y(Tuns64, Tint8)
|
||||||
|
|
||||||
Y(Tint8, Tuns8)
|
Y(Tint8, Tuns8)
|
||||||
Y(Tint16, Tuns8)
|
Y(Tint16, Tuns8)
|
||||||
Y(Tuns16, Tuns8)
|
Y(Tuns16, Tuns8)
|
||||||
Y(Tint32, Tuns8)
|
Y(Tint32, Tuns8)
|
||||||
Y(Tuns32, Tuns8)
|
Y(Tuns32, Tuns8)
|
||||||
Y(Tint64, Tuns8)
|
Y(Tint64, Tuns8)
|
||||||
Y(Tuns64, Tuns8)
|
Y(Tuns64, Tuns8)
|
||||||
|
|
||||||
Y(Tint8, Tchar)
|
Y(Tint8, Tchar)
|
||||||
Y(Tint16, Tchar)
|
Y(Tint16, Tchar)
|
||||||
Y(Tuns16, Tchar)
|
Y(Tuns16, Tchar)
|
||||||
Y(Tint32, Tchar)
|
Y(Tint32, Tchar)
|
||||||
Y(Tuns32, Tchar)
|
Y(Tuns32, Tchar)
|
||||||
Y(Tint64, Tchar)
|
Y(Tint64, Tchar)
|
||||||
Y(Tuns64, Tchar)
|
Y(Tuns64, Tchar)
|
||||||
|
|
||||||
Y(Tuns16, Tint16)
|
Y(Tuns16, Tint16)
|
||||||
Y(Tint32, Tint16)
|
Y(Tint32, Tint16)
|
||||||
Y(Tuns32, Tint16)
|
Y(Tuns32, Tint16)
|
||||||
Y(Tint64, Tint16)
|
Y(Tint64, Tint16)
|
||||||
Y(Tuns64, Tint16)
|
Y(Tuns64, Tint16)
|
||||||
|
|
||||||
Y(Tint16, Tuns16)
|
Y(Tint16, Tuns16)
|
||||||
Y(Tint32, Tuns16)
|
Y(Tint32, Tuns16)
|
||||||
Y(Tuns32, Tuns16)
|
Y(Tuns32, Tuns16)
|
||||||
Y(Tint64, Tuns16)
|
Y(Tint64, Tuns16)
|
||||||
Y(Tuns64, Tuns16)
|
Y(Tuns64, Tuns16)
|
||||||
|
|
||||||
Y(Tint16, Twchar)
|
Y(Tint16, Twchar)
|
||||||
Y(Tint32, Twchar)
|
Y(Tint32, Twchar)
|
||||||
Y(Tuns32, Twchar)
|
Y(Tuns32, Twchar)
|
||||||
Y(Tint64, Twchar)
|
Y(Tint64, Twchar)
|
||||||
Y(Tuns64, Twchar)
|
Y(Tuns64, Twchar)
|
||||||
|
|
||||||
// Y(Tuns32, Tint32)
|
// Y(Tuns32, Tint32)
|
||||||
Y(Tint64, Tint32)
|
Y(Tint64, Tint32)
|
||||||
Y(Tuns64, Tint32)
|
Y(Tuns64, Tint32)
|
||||||
|
|
||||||
// Y(Tint32, Tuns32)
|
// Y(Tint32, Tuns32)
|
||||||
Y(Tint64, Tuns32)
|
Y(Tint64, Tuns32)
|
||||||
Y(Tuns64, Tuns32)
|
Y(Tuns64, Tuns32)
|
||||||
|
|
||||||
Y(Tint64, Tdchar)
|
Y(Tint64, Tdchar)
|
||||||
Y(Tuns64, Tdchar)
|
Y(Tuns64, Tdchar)
|
||||||
|
|
||||||
// Y(Tint64, Tuns64)
|
// Y(Tint64, Tuns64)
|
||||||
// Y(Tuns64, Tint64)
|
// Y(Tuns64, Tint64)
|
||||||
|
|
||||||
for (i = 0; i < TMAX; i++)
|
for (i = 0; i < TMAX; i++)
|
||||||
for (j = 0; j < TMAX; j++)
|
for (j = 0; j < TMAX; j++)
|
||||||
{
|
{
|
||||||
if (impcnvResult[i][j] == Terror)
|
if (impcnvResult[i][j] == Terror)
|
||||||
{
|
{
|
||||||
impcnvResult[i][j] = impcnvResult[j][i];
|
impcnvResult[i][j] = impcnvResult[j][i];
|
||||||
impcnvType1[i][j] = impcnvType2[j][i];
|
impcnvType1[i][j] = impcnvType2[j][i];
|
||||||
impcnvType2[i][j] = impcnvType1[j][i];
|
impcnvType2[i][j] = impcnvType1[j][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{ FILE *fp;
|
{ FILE *fp;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
fp = fopen("impcnvtab.c","w");
|
fp = fopen("impcnvtab.c","w");
|
||||||
|
|
||||||
fprintf(fp,"// This file is generated by impcnvgen.c\n");
|
fprintf(fp,"// This file is generated by impcnvgen.c\n");
|
||||||
fprintf(fp,"#include \"mtype.h\"\n");
|
fprintf(fp,"#include \"mtype.h\"\n");
|
||||||
|
|
||||||
fprintf(fp,"unsigned char Type::impcnvResult[TMAX][TMAX] =\n{\n");
|
fprintf(fp,"unsigned char Type::impcnvResult[TMAX][TMAX] =\n{\n");
|
||||||
for (i = 0; i < TMAX; i++)
|
for (i = 0; i < TMAX; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < TMAX; j++)
|
for (j = 0; j < TMAX; j++)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d,",impcnvResult[i][j]);
|
fprintf(fp, "%d,",impcnvResult[i][j]);
|
||||||
}
|
}
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
fprintf(fp,"};\n");
|
fprintf(fp,"};\n");
|
||||||
|
|
||||||
fprintf(fp,"unsigned char Type::impcnvType1[TMAX][TMAX] =\n{\n");
|
fprintf(fp,"unsigned char Type::impcnvType1[TMAX][TMAX] =\n{\n");
|
||||||
for (i = 0; i < TMAX; i++)
|
for (i = 0; i < TMAX; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < TMAX; j++)
|
for (j = 0; j < TMAX; j++)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d,",impcnvType1[i][j]);
|
fprintf(fp, "%d,",impcnvType1[i][j]);
|
||||||
}
|
}
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
fprintf(fp,"};\n");
|
fprintf(fp,"};\n");
|
||||||
|
|
||||||
fprintf(fp,"unsigned char Type::impcnvType2[TMAX][TMAX] =\n{\n");
|
fprintf(fp,"unsigned char Type::impcnvType2[TMAX][TMAX] =\n{\n");
|
||||||
for (i = 0; i < TMAX; i++)
|
for (i = 0; i < TMAX; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < TMAX; j++)
|
for (j = 0; j < TMAX; j++)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d,",impcnvType2[i][j]);
|
fprintf(fp, "%d,",impcnvType2[i][j]);
|
||||||
}
|
}
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
fprintf(fp,"};\n");
|
fprintf(fp,"};\n");
|
||||||
|
|
||||||
fprintf(fp,"unsigned char Type::impcnvWarn[TMAX][TMAX] =\n{\n");
|
fprintf(fp,"unsigned char Type::impcnvWarn[TMAX][TMAX] =\n{\n");
|
||||||
for (i = 0; i < TMAX; i++)
|
for (i = 0; i < TMAX; i++)
|
||||||
{
|
{
|
||||||
for (j = 0; j < TMAX; j++)
|
for (j = 0; j < TMAX; j++)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d,",impcnvWarn[i][j]);
|
fprintf(fp, "%d,",impcnvWarn[i][j]);
|
||||||
}
|
}
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
fprintf(fp,"};\n");
|
fprintf(fp,"};\n");
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
+82
-82
@@ -1,82 +1,82 @@
|
|||||||
|
|
||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 2010 by Digital Mars
|
// Copyright (c) 2010 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
* Looks for undefined identifier s to see
|
* Looks for undefined identifier s to see
|
||||||
* if it might be undefined because an import
|
* if it might be undefined because an import
|
||||||
* was not specified.
|
* was not specified.
|
||||||
* Not meant to be a comprehensive list of names in each module,
|
* Not meant to be a comprehensive list of names in each module,
|
||||||
* just the most common ones.
|
* just the most common ones.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *importHint(const char *s)
|
const char *importHint(const char *s)
|
||||||
{
|
{
|
||||||
#if DMDV1
|
#if DMDV1
|
||||||
static const char *modules[] =
|
static const char *modules[] =
|
||||||
{ "tango.stdc.stdio",
|
{ "tango.stdc.stdio",
|
||||||
"tango.io.Stdout",
|
"tango.io.Stdout",
|
||||||
"tango.math.Math",
|
"tango.math.Math",
|
||||||
};
|
};
|
||||||
static const char *names[] =
|
static const char *names[] =
|
||||||
{
|
{
|
||||||
"printf", NULL,
|
"printf", NULL,
|
||||||
"Stdout", NULL,
|
"Stdout", NULL,
|
||||||
"sin", "cos", "sqrt", "abs", NULL,
|
"sin", "cos", "sqrt", "abs", NULL,
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
static const char *modules[] =
|
static const char *modules[] =
|
||||||
{ "core.stdc.stdio",
|
{ "core.stdc.stdio",
|
||||||
"std.stdio",
|
"std.stdio",
|
||||||
"std.math",
|
"std.math",
|
||||||
};
|
};
|
||||||
static const char *names[] =
|
static const char *names[] =
|
||||||
{
|
{
|
||||||
"printf", NULL,
|
"printf", NULL,
|
||||||
"writeln", NULL,
|
"writeln", NULL,
|
||||||
"sin", "cos", "sqrt", "fabs", NULL,
|
"sin", "cos", "sqrt", "fabs", NULL,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
int m = 0;
|
int m = 0;
|
||||||
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++)
|
for (int n = 0; n < sizeof(names)/sizeof(names[0]); n++)
|
||||||
{
|
{
|
||||||
const char *p = names[n];
|
const char *p = names[n];
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
{ m++;
|
{ m++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
assert(m < sizeof(modules)/sizeof(modules[0]));
|
assert(m < sizeof(modules)/sizeof(modules[0]));
|
||||||
if (strcmp(s, p) == 0)
|
if (strcmp(s, p) == 0)
|
||||||
return modules[m];
|
return modules[m];
|
||||||
}
|
}
|
||||||
return NULL; // didn't find it
|
return NULL; // didn't find it
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITTEST
|
#if UNITTEST
|
||||||
|
|
||||||
void unittest_importHint()
|
void unittest_importHint()
|
||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
p = importHint("printf");
|
p = importHint("printf");
|
||||||
assert(p);
|
assert(p);
|
||||||
p = importHint("fabs");
|
p = importHint("fabs");
|
||||||
assert(p);
|
assert(p);
|
||||||
p = importHint("xxxxx");
|
p = importHint("xxxxx");
|
||||||
assert(!p);
|
assert(!p);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+76
-76
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
/********************************* Import ****************************/
|
/********************************* Import ****************************/
|
||||||
|
|
||||||
Import::Import(Loc loc, Identifiers *packages, Identifier *id, Identifier *aliasId,
|
Import::Import(Loc loc, Identifiers *packages, Identifier *id, Identifier *aliasId,
|
||||||
int isstatic)
|
int isstatic)
|
||||||
: Dsymbol()
|
: Dsymbol()
|
||||||
{
|
{
|
||||||
assert(id);
|
assert(id);
|
||||||
this->loc = loc;
|
this->loc = loc;
|
||||||
@@ -63,11 +63,11 @@ Dsymbol *Import::syntaxCopy(Dsymbol *s)
|
|||||||
{
|
{
|
||||||
assert(!s);
|
assert(!s);
|
||||||
|
|
||||||
Import *si = new Import(loc, packages, id, aliasId, isstatic);
|
Import *si = new Import(loc, packages, id, aliasId, isstatic);
|
||||||
|
|
||||||
for (size_t i = 0; i < names.dim; i++)
|
for (size_t i = 0; i < names.dim; i++)
|
||||||
{
|
{
|
||||||
si->addAlias(names[i], aliases[i]);
|
si->addAlias(names[i], aliases[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return si;
|
return si;
|
||||||
@@ -135,12 +135,12 @@ void Import::importAll(Scope *sc)
|
|||||||
load(sc);
|
load(sc);
|
||||||
mod->importAll(0);
|
mod->importAll(0);
|
||||||
|
|
||||||
/* Default to private importing
|
/* Default to private importing
|
||||||
*/
|
*/
|
||||||
enum PROT prot = sc->protection;
|
enum PROT prot = sc->protection;
|
||||||
if (!sc->explicitProtection)
|
if (!sc->explicitProtection)
|
||||||
prot = PROTprivate;
|
prot = PROTprivate;
|
||||||
sc->scopesym->importScope(this, prot);
|
sc->scopesym->importScope(this, prot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,29 +172,29 @@ void Import::semantic(Scope *sc)
|
|||||||
|
|
||||||
/* Default to private importing
|
/* Default to private importing
|
||||||
*/
|
*/
|
||||||
enum PROT prot = sc->protection;
|
enum PROT prot = sc->protection;
|
||||||
if (!sc->explicitProtection)
|
if (!sc->explicitProtection)
|
||||||
prot = PROTprivate;
|
prot = PROTprivate;
|
||||||
for (Scope *scd = sc; scd; scd = scd->enclosing)
|
for (Scope *scd = sc; scd; scd = scd->enclosing)
|
||||||
{
|
{
|
||||||
if (scd->scopesym)
|
if (scd->scopesym)
|
||||||
{
|
{
|
||||||
scd->scopesym->importScope(this, prot);
|
scd->scopesym->importScope(this, prot);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod->semantic();
|
mod->semantic();
|
||||||
|
|
||||||
if (mod->needmoduleinfo)
|
if (mod->needmoduleinfo)
|
||||||
{ //printf("module4 %s because of %s\n", sc->module->toChars(), mod->toChars());
|
{ //printf("module4 %s because of %s\n", sc->module->toChars(), mod->toChars());
|
||||||
sc->module->needmoduleinfo = 1;
|
sc->module->needmoduleinfo = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aliasId)
|
if (aliasId)
|
||||||
{
|
{
|
||||||
AliasDeclaration *ad = new AliasDeclaration(loc, aliasId, mod);
|
AliasDeclaration *ad = new AliasDeclaration(loc, aliasId, mod);
|
||||||
sc->insert(ad);
|
sc->insert(ad);
|
||||||
ad->semantic(sc);
|
ad->semantic(sc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ void Import::semantic(Scope *sc)
|
|||||||
{
|
{
|
||||||
for (size_t i = 0; i < packages->dim; i++)
|
for (size_t i = 0; i < packages->dim; i++)
|
||||||
{
|
{
|
||||||
Identifier *pid = (*packages)[i];
|
Identifier *pid = (*packages)[i];
|
||||||
ob->printf("%s.", pid->toChars());
|
ob->printf("%s.", pid->toChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,8 +251,8 @@ void Import::semantic(Scope *sc)
|
|||||||
else
|
else
|
||||||
ob->writebyte(',');
|
ob->writebyte(',');
|
||||||
|
|
||||||
Identifier *name = names[i];
|
Identifier *name = names[i];
|
||||||
Identifier *alias = aliases[i];
|
Identifier *alias = aliases[i];
|
||||||
|
|
||||||
if (!alias)
|
if (!alias)
|
||||||
{
|
{
|
||||||
@@ -277,7 +277,7 @@ void Import::semantic2(Scope *sc)
|
|||||||
//printf("Import::semantic2('%s')\n", toChars());
|
//printf("Import::semantic2('%s')\n", toChars());
|
||||||
mod->semantic2();
|
mod->semantic2();
|
||||||
if (mod->needmoduleinfo)
|
if (mod->needmoduleinfo)
|
||||||
{ //printf("module5 %s because of %s\n", sc->module->toChars(), mod->toChars());
|
{ //printf("module5 %s because of %s\n", sc->module->toChars(), mod->toChars());
|
||||||
sc->module->needmoduleinfo = 1;
|
sc->module->needmoduleinfo = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,50 +291,50 @@ Dsymbol *Import::search(Loc loc, Identifier *ident, int flags)
|
|||||||
mod->semantic();
|
mod->semantic();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (names.dim) // selective import
|
if (names.dim) // selective import
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < names.dim; i++)
|
for (size_t i = 0; i < names.dim; i++)
|
||||||
{
|
{
|
||||||
Identifier *name = (Identifier *)names[i];
|
Identifier *name = (Identifier *)names[i];
|
||||||
Identifier *alias = (Identifier *)aliases[i];
|
Identifier *alias = (Identifier *)aliases[i];
|
||||||
|
|
||||||
if (!alias)
|
if (!alias)
|
||||||
alias = name;
|
alias = name;
|
||||||
|
|
||||||
if (alias->equals(ident))
|
if (alias->equals(ident))
|
||||||
return mod->search(loc, name, flags);
|
return mod->search(loc, name, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// What should happen when renamed and selective imports are mixed?
|
// What should happen when renamed and selective imports are mixed?
|
||||||
// This makes the whole module available with the renamed id.
|
// This makes the whole module available with the renamed id.
|
||||||
if (aliasId && aliasId->equals(ident))
|
if (aliasId && aliasId->equals(ident))
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
else // non-selective import
|
else // non-selective import
|
||||||
{
|
{
|
||||||
// For renamed imports, only the alias name is visible.
|
// For renamed imports, only the alias name is visible.
|
||||||
if (aliasId)
|
if (aliasId)
|
||||||
{
|
{
|
||||||
if (aliasId->equals(ident))
|
if (aliasId->equals(ident))
|
||||||
return mod;
|
return mod;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For non-static imports, prefer symbols in the module over the module name.
|
// For non-static imports, prefer symbols in the module over the module name.
|
||||||
if (!isstatic)
|
if (!isstatic)
|
||||||
{
|
{
|
||||||
Dsymbol *s = mod->search(loc, ident, flags);
|
Dsymbol *s = mod->search(loc, ident, flags);
|
||||||
if (s)
|
if (s)
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make the start of the package name available.
|
// Make the start of the package name available.
|
||||||
if (pkg->ident->equals(ident))
|
if (pkg->ident->equals(ident))
|
||||||
{
|
{
|
||||||
return pkg;
|
return pkg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Import::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void Import::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
@@ -352,7 +352,7 @@ void Import::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
|||||||
if (packages && packages->dim)
|
if (packages && packages->dim)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < packages->dim; i++)
|
for (size_t i = 0; i < packages->dim; i++)
|
||||||
{ Identifier *pid = (*packages)[i];
|
{ Identifier *pid = (*packages)[i];
|
||||||
|
|
||||||
buf->printf("%s.", pid->toChars());
|
buf->printf("%s.", pid->toChars());
|
||||||
}
|
}
|
||||||
@@ -381,7 +381,7 @@ void Import::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
|||||||
buf->writenl();
|
buf->writenl();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Import::toChars()
|
char *Import::toChars()
|
||||||
{
|
{
|
||||||
return id->toChars();
|
return id->toChars();
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2012 by Digital Mars
|
// Copyright (c) 1999-2012 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -28,21 +28,21 @@ struct HdrGenState;
|
|||||||
|
|
||||||
struct Import : Dsymbol
|
struct Import : Dsymbol
|
||||||
{
|
{
|
||||||
// isstatic import aliasId = packages.id;
|
// isstatic import aliasId = packages.id;
|
||||||
Identifiers *packages; // array of Identifier's representing packages
|
Identifiers *packages; // array of Identifier's representing packages
|
||||||
Identifier *id; // module Identifier
|
Identifier *id; // module Identifier
|
||||||
Identifier *aliasId;
|
Identifier *aliasId;
|
||||||
int isstatic; // !=0 if static import
|
int isstatic; // !=0 if static import
|
||||||
enum PROT protection;
|
enum PROT protection;
|
||||||
|
|
||||||
// Pairs of alias=name to bind into current namespace
|
// Pairs of alias=name to bind into current namespace
|
||||||
Identifiers names;
|
Identifiers names;
|
||||||
Identifiers aliases;
|
Identifiers aliases;
|
||||||
|
|
||||||
Module *mod;
|
Module *mod;
|
||||||
Package *pkg; // leftmost package/module
|
Package *pkg; // leftmost package/module
|
||||||
|
|
||||||
Import(Loc loc, Identifiers *packages, Identifier *id, Identifier *aliasId,
|
Import(Loc loc, Identifiers *packages, Identifier *id, Identifier *aliasId,
|
||||||
int isstatic);
|
int isstatic);
|
||||||
void addAlias(Identifier *name, Identifier *alias);
|
void addAlias(Identifier *name, Identifier *alias);
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ struct Import : Dsymbol
|
|||||||
void semantic2(Scope *sc);
|
void semantic2(Scope *sc);
|
||||||
Dsymbol *search(Loc loc, Identifier *ident, int flags);
|
Dsymbol *search(Loc loc, Identifier *ident, int flags);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
char *toChars();
|
char *toChars();
|
||||||
|
|
||||||
Import *isImport() { return this; }
|
Import *isImport() { return this; }
|
||||||
};
|
};
|
||||||
|
|||||||
+147
-147
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -34,7 +34,7 @@ Initializer *Initializer::syntaxCopy()
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Initializer *Initializer::semantic(Scope *sc, Type *t, int needInterpret)
|
Initializer *Initializer::semantic(Scope *sc, Type *t, int needInterpret)
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ Initializers *Initializer::arraySyntaxCopy(Initializers *ai)
|
|||||||
{
|
{
|
||||||
a = new Initializers();
|
a = new Initializers();
|
||||||
a->setDim(ai->dim);
|
a->setDim(ai->dim);
|
||||||
for (size_t i = 0; i < a->dim; i++)
|
for (size_t i = 0; i < a->dim; i++)
|
||||||
{ Initializer *e = (Initializer *)ai->data[i];
|
{ Initializer *e = (Initializer *)ai->data[i];
|
||||||
|
|
||||||
e = e->syntaxCopy();
|
e = e->syntaxCopy();
|
||||||
@@ -87,7 +87,7 @@ Initializer *VoidInitializer::syntaxCopy()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Initializer *VoidInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
Initializer *VoidInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
||||||
{
|
{
|
||||||
//printf("VoidInitializer::semantic(t = %p)\n", t);
|
//printf("VoidInitializer::semantic(t = %p)\n", t);
|
||||||
type = t;
|
type = t;
|
||||||
@@ -126,7 +126,7 @@ Initializer *StructInitializer::syntaxCopy()
|
|||||||
assert(field.dim == value.dim);
|
assert(field.dim == value.dim);
|
||||||
ai->field.setDim(field.dim);
|
ai->field.setDim(field.dim);
|
||||||
ai->value.setDim(value.dim);
|
ai->value.setDim(value.dim);
|
||||||
for (size_t i = 0; i < field.dim; i++)
|
for (size_t i = 0; i < field.dim; i++)
|
||||||
{
|
{
|
||||||
ai->field.data[i] = field.data[i];
|
ai->field.data[i] = field.data[i];
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ void StructInitializer::addInit(Identifier *field, Initializer *value)
|
|||||||
this->value.push(value);
|
this->value.push(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
||||||
{
|
{
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
|
|
||||||
@@ -152,35 +152,35 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
|||||||
vars.setDim(field.dim);
|
vars.setDim(field.dim);
|
||||||
t = t->toBasetype();
|
t = t->toBasetype();
|
||||||
if (t->ty == Tstruct)
|
if (t->ty == Tstruct)
|
||||||
{
|
{
|
||||||
unsigned fieldi = 0;
|
unsigned fieldi = 0;
|
||||||
|
|
||||||
TypeStruct *ts = (TypeStruct *)t;
|
TypeStruct *ts = (TypeStruct *)t;
|
||||||
ad = ts->sym;
|
ad = ts->sym;
|
||||||
size_t nfields = ad->fields.dim;
|
size_t nfields = ad->fields.dim;
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
if (((StructDeclaration *)ad)->isnested)
|
if (((StructDeclaration *)ad)->isnested)
|
||||||
nfields--; // don't count pointer to outer
|
nfields--; // don't count pointer to outer
|
||||||
#endif
|
#endif
|
||||||
for (size_t i = 0; i < field.dim; i++)
|
for (size_t i = 0; i < field.dim; i++)
|
||||||
{
|
{
|
||||||
Identifier *id = field[i];
|
Identifier *id = field[i];
|
||||||
Initializer *val = value[i];
|
Initializer *val = value[i];
|
||||||
Dsymbol *s;
|
Dsymbol *s;
|
||||||
VarDeclaration *v;
|
VarDeclaration *v;
|
||||||
|
|
||||||
if (id == NULL)
|
if (id == NULL)
|
||||||
{
|
{
|
||||||
if (fieldi >= nfields)
|
if (fieldi >= nfields)
|
||||||
{ error(loc, "too many initializers for %s", ad->toChars());
|
{ error(loc, "too many initializers for %s", ad->toChars());
|
||||||
errors = 1;
|
errors = 1;
|
||||||
field.remove(i);
|
field.remove(i);
|
||||||
i--;
|
i--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = ad->fields[fieldi];
|
s = ad->fields[fieldi];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -190,28 +190,28 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
|||||||
if (!s)
|
if (!s)
|
||||||
{
|
{
|
||||||
error(loc, "'%s' is not a member of '%s'", id->toChars(), t->toChars());
|
error(loc, "'%s' is not a member of '%s'", id->toChars(), t->toChars());
|
||||||
errors = 1;
|
errors = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
s = s->toAlias();
|
s = s->toAlias();
|
||||||
|
|
||||||
// Find out which field index it is
|
// Find out which field index it is
|
||||||
for (fieldi = 0; 1; fieldi++)
|
for (fieldi = 0; 1; fieldi++)
|
||||||
{
|
{
|
||||||
if (fieldi >= nfields)
|
if (fieldi >= nfields)
|
||||||
{
|
{
|
||||||
error(loc, "%s.%s is not a per-instance initializable field",
|
error(loc, "%s.%s is not a per-instance initializable field",
|
||||||
t->toChars(), s->toChars());
|
t->toChars(), s->toChars());
|
||||||
errors = 1;
|
errors = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (s == ad->fields[fieldi])
|
if (s == ad->fields[fieldi])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s && (v = s->isVarDeclaration()) != NULL)
|
if (s && (v = s->isVarDeclaration()) != NULL)
|
||||||
{
|
{
|
||||||
val = val->semantic(sc, v->type, needInterpret);
|
val = val->semantic(sc, v->type, needInterpret);
|
||||||
value.data[i] = (void *)val;
|
value.data[i] = (void *)val;
|
||||||
vars.data[i] = (void *)v;
|
vars.data[i] = (void *)v;
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
|||||||
fd->endloc = loc;
|
fd->endloc = loc;
|
||||||
Expression *e = new FuncExp(loc, fd);
|
Expression *e = new FuncExp(loc, fd);
|
||||||
ExpInitializer *ie = new ExpInitializer(loc, e);
|
ExpInitializer *ie = new ExpInitializer(loc, e);
|
||||||
return ie->semantic(sc, t, needInterpret);
|
return ie->semantic(sc, t, needInterpret);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -265,97 +265,97 @@ Expression *StructInitializer::toExpression()
|
|||||||
if (!sd)
|
if (!sd)
|
||||||
return NULL;
|
return NULL;
|
||||||
Expressions *elements = new Expressions();
|
Expressions *elements = new Expressions();
|
||||||
size_t nfields = ad->fields.dim;
|
size_t nfields = ad->fields.dim;
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
if (sd->isnested)
|
if (sd->isnested)
|
||||||
nfields--;
|
nfields--;
|
||||||
#endif
|
#endif
|
||||||
elements->setDim(nfields);
|
elements->setDim(nfields);
|
||||||
for (size_t i = 0; i < elements->dim; i++)
|
for (size_t i = 0; i < elements->dim; i++)
|
||||||
{
|
{
|
||||||
elements->data[i] = NULL;
|
elements->data[i] = NULL;
|
||||||
}
|
}
|
||||||
unsigned fieldi = 0;
|
unsigned fieldi = 0;
|
||||||
for (size_t i = 0; i < value.dim; i++)
|
for (size_t i = 0; i < value.dim; i++)
|
||||||
{
|
{
|
||||||
Identifier *id = field[i];
|
Identifier *id = field[i];
|
||||||
if (id)
|
if (id)
|
||||||
{
|
{
|
||||||
Dsymbol * s = ad->search(loc, id, 0);
|
Dsymbol * s = ad->search(loc, id, 0);
|
||||||
if (!s)
|
if (!s)
|
||||||
{
|
{
|
||||||
error(loc, "'%s' is not a member of '%s'", id->toChars(), sd->toChars());
|
error(loc, "'%s' is not a member of '%s'", id->toChars(), sd->toChars());
|
||||||
goto Lno;
|
goto Lno;
|
||||||
}
|
}
|
||||||
s = s->toAlias();
|
s = s->toAlias();
|
||||||
|
|
||||||
// Find out which field index it is
|
// Find out which field index it is
|
||||||
for (fieldi = 0; 1; fieldi++)
|
for (fieldi = 0; 1; fieldi++)
|
||||||
{
|
{
|
||||||
if (fieldi >= nfields)
|
if (fieldi >= nfields)
|
||||||
{
|
{
|
||||||
s->error("is not a per-instance initializable field");
|
s->error("is not a per-instance initializable field");
|
||||||
goto Lno;
|
goto Lno;
|
||||||
}
|
}
|
||||||
if (s == ad->fields[fieldi])
|
if (s == ad->fields[fieldi])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fieldi >= nfields)
|
else if (fieldi >= nfields)
|
||||||
{ error(loc, "too many initializers for '%s'", ad->toChars());
|
{ error(loc, "too many initializers for '%s'", ad->toChars());
|
||||||
goto Lno;
|
goto Lno;
|
||||||
}
|
}
|
||||||
Initializer *iz = (Initializer *)value.data[i];
|
Initializer *iz = (Initializer *)value.data[i];
|
||||||
if (!iz)
|
if (!iz)
|
||||||
goto Lno;
|
goto Lno;
|
||||||
Expression *ex = iz->toExpression();
|
Expression *ex = iz->toExpression();
|
||||||
if (!ex)
|
if (!ex)
|
||||||
goto Lno;
|
goto Lno;
|
||||||
if (elements->data[fieldi])
|
if (elements->data[fieldi])
|
||||||
{ error(loc, "duplicate initializer for field '%s'",
|
{ error(loc, "duplicate initializer for field '%s'",
|
||||||
((Dsymbol *)ad->fields.data[fieldi])->toChars());
|
((Dsymbol *)ad->fields.data[fieldi])->toChars());
|
||||||
goto Lno;
|
goto Lno;
|
||||||
}
|
}
|
||||||
elements->data[fieldi] = ex;
|
elements->data[fieldi] = ex;
|
||||||
++fieldi;
|
++fieldi;
|
||||||
}
|
}
|
||||||
// Now, fill in any missing elements with default initializers.
|
// Now, fill in any missing elements with default initializers.
|
||||||
// We also need to validate any anonymous unions
|
// We also need to validate any anonymous unions
|
||||||
for (size_t i = 0; i < elements->dim; )
|
for (size_t i = 0; i < elements->dim; )
|
||||||
{
|
{
|
||||||
VarDeclaration * vd = ((Dsymbol *)ad->fields.data[i])->isVarDeclaration();
|
VarDeclaration * vd = ((Dsymbol *)ad->fields.data[i])->isVarDeclaration();
|
||||||
int unionSize = ad->numFieldsInUnion(i);
|
int unionSize = ad->numFieldsInUnion(i);
|
||||||
if (unionSize == 1)
|
if (unionSize == 1)
|
||||||
{ // Not a union -- default initialize if missing
|
{ // Not a union -- default initialize if missing
|
||||||
if (!elements->data[i])
|
if (!elements->data[i])
|
||||||
elements->data[i] = vd->type->defaultInit();
|
elements->data[i] = vd->type->defaultInit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // anonymous union -- check for errors
|
{ // anonymous union -- check for errors
|
||||||
int found = -1; // index of the first field with an initializer
|
int found = -1; // index of the first field with an initializer
|
||||||
for (int j = i; j < i + unionSize; ++j)
|
for (int j = i; j < i + unionSize; ++j)
|
||||||
{
|
{
|
||||||
if (!elements->data[j])
|
if (!elements->data[j])
|
||||||
continue;
|
continue;
|
||||||
if (found >= 0)
|
if (found >= 0)
|
||||||
{
|
{
|
||||||
VarDeclaration * v1 = ((Dsymbol *)ad->fields.data[found])->isVarDeclaration();
|
VarDeclaration * v1 = ((Dsymbol *)ad->fields.data[found])->isVarDeclaration();
|
||||||
VarDeclaration * v = ((Dsymbol *)ad->fields.data[j])->isVarDeclaration();
|
VarDeclaration * v = ((Dsymbol *)ad->fields.data[j])->isVarDeclaration();
|
||||||
error(loc, "%s cannot have initializers for fields %s and %s in same union",
|
error(loc, "%s cannot have initializers for fields %s and %s in same union",
|
||||||
ad->toChars(),
|
ad->toChars(),
|
||||||
v1->toChars(), v->toChars());
|
v1->toChars(), v->toChars());
|
||||||
goto Lno;
|
goto Lno;
|
||||||
}
|
}
|
||||||
found = j;
|
found = j;
|
||||||
}
|
}
|
||||||
if (found == -1)
|
if (found == -1)
|
||||||
{
|
{
|
||||||
error(loc, "no initializer for union that contains field %s",
|
error(loc, "no initializer for union that contains field %s",
|
||||||
vd->toChars());
|
vd->toChars());
|
||||||
goto Lno;
|
goto Lno;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i += unionSize;
|
i += unionSize;
|
||||||
}
|
}
|
||||||
e = new StructLiteralExp(loc, sd, elements);
|
e = new StructLiteralExp(loc, sd, elements);
|
||||||
e->type = sd->type;
|
e->type = sd->type;
|
||||||
@@ -371,7 +371,7 @@ void StructInitializer::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
|||||||
{
|
{
|
||||||
//printf("StructInitializer::toCBuffer()\n");
|
//printf("StructInitializer::toCBuffer()\n");
|
||||||
buf->writebyte('{');
|
buf->writebyte('{');
|
||||||
for (size_t i = 0; i < field.dim; i++)
|
for (size_t i = 0; i < field.dim; i++)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
buf->writebyte(',');
|
buf->writebyte(',');
|
||||||
@@ -407,7 +407,7 @@ Initializer *ArrayInitializer::syntaxCopy()
|
|||||||
assert(index.dim == value.dim);
|
assert(index.dim == value.dim);
|
||||||
ai->index.setDim(index.dim);
|
ai->index.setDim(index.dim);
|
||||||
ai->value.setDim(value.dim);
|
ai->value.setDim(value.dim);
|
||||||
for (size_t i = 0; i < ai->value.dim; i++)
|
for (size_t i = 0; i < ai->value.dim; i++)
|
||||||
{ Expression *e = (Expression *)index.data[i];
|
{ Expression *e = (Expression *)index.data[i];
|
||||||
if (e)
|
if (e)
|
||||||
e = e->syntaxCopy();
|
e = e->syntaxCopy();
|
||||||
@@ -428,7 +428,7 @@ void ArrayInitializer::addInit(Expression *index, Initializer *value)
|
|||||||
type = NULL;
|
type = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Initializer *ArrayInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
Initializer *ArrayInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
||||||
{ unsigned i;
|
{ unsigned i;
|
||||||
unsigned length;
|
unsigned length;
|
||||||
const unsigned amax = 0x80000000;
|
const unsigned amax = 0x80000000;
|
||||||
@@ -454,17 +454,17 @@ Initializer *ArrayInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
|||||||
length = 0;
|
length = 0;
|
||||||
for (i = 0; i < index.dim; i++)
|
for (i = 0; i < index.dim; i++)
|
||||||
{
|
{
|
||||||
Expression *idx = index[i];
|
Expression *idx = index[i];
|
||||||
if (idx)
|
if (idx)
|
||||||
{ idx = idx->semantic(sc);
|
{ idx = idx->semantic(sc);
|
||||||
idx = idx->optimize(WANTvalue | WANTinterpret);
|
idx = idx->optimize(WANTvalue | WANTinterpret);
|
||||||
index[i] = idx;
|
index[i] = idx;
|
||||||
length = idx->toInteger();
|
length = idx->toInteger();
|
||||||
}
|
}
|
||||||
|
|
||||||
Initializer *val = value[i];
|
Initializer *val = value[i];
|
||||||
val = val->semantic(sc, t->nextOf(), needInterpret);
|
val = val->semantic(sc, t->nextOf(), needInterpret);
|
||||||
value[i] = val;
|
value[i] = val;
|
||||||
length++;
|
length++;
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
{ error(loc, "array dimension overflow");
|
{ error(loc, "array dimension overflow");
|
||||||
@@ -531,8 +531,8 @@ Expression *ArrayInitializer::toExpression()
|
|||||||
edim = value.dim;
|
edim = value.dim;
|
||||||
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
|
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
|
||||||
{
|
{
|
||||||
if (index[i])
|
if (index[i])
|
||||||
j = (index[i])->toInteger();
|
j = (index[i])->toInteger();
|
||||||
if (j >= edim)
|
if (j >= edim)
|
||||||
edim = j + 1;
|
edim = j + 1;
|
||||||
}
|
}
|
||||||
@@ -542,10 +542,10 @@ Expression *ArrayInitializer::toExpression()
|
|||||||
elements->setDim(edim);
|
elements->setDim(edim);
|
||||||
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
|
for (size_t i = 0, j = 0; i < value.dim; i++, j++)
|
||||||
{
|
{
|
||||||
if (index[i])
|
if (index[i])
|
||||||
j = (index[i])->toInteger();
|
j = (index[i])->toInteger();
|
||||||
assert(j < edim);
|
assert(j < edim);
|
||||||
Initializer *iz = value[i];
|
Initializer *iz = value[i];
|
||||||
if (!iz)
|
if (!iz)
|
||||||
goto Lno;
|
goto Lno;
|
||||||
Expression *ex = iz->toExpression();
|
Expression *ex = iz->toExpression();
|
||||||
@@ -553,7 +553,7 @@ Expression *ArrayInitializer::toExpression()
|
|||||||
{
|
{
|
||||||
goto Lno;
|
goto Lno;
|
||||||
}
|
}
|
||||||
(*elements)[j] = ex;
|
(*elements)[j] = ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill in any missing elements with the default initializer
|
/* Fill in any missing elements with the default initializer
|
||||||
@@ -562,13 +562,13 @@ Expression *ArrayInitializer::toExpression()
|
|||||||
Expression *init = NULL;
|
Expression *init = NULL;
|
||||||
for (size_t i = 0; i < edim; i++)
|
for (size_t i = 0; i < edim; i++)
|
||||||
{
|
{
|
||||||
if (!(*elements)[i])
|
if (!(*elements)[i])
|
||||||
{
|
{
|
||||||
if (!type)
|
if (!type)
|
||||||
goto Lno;
|
goto Lno;
|
||||||
if (!init)
|
if (!init)
|
||||||
init = t->next->defaultInit();
|
init = t->next->defaultInit();
|
||||||
(*elements)[i] = init;
|
(*elements)[i] = init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,30 +588,30 @@ Lno:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Initializer *ArrayInitializer::toAssocArrayInitializer()
|
Initializer *ArrayInitializer::toAssocArrayInitializer()
|
||||||
{
|
{
|
||||||
Expression *e;
|
Expression *e;
|
||||||
|
|
||||||
//printf("ArrayInitializer::toAssocArrayInitializer()\n");
|
//printf("ArrayInitializer::toAssocArrayInitializer()\n");
|
||||||
//static int i; if (++i == 2) halt();
|
//static int i; if (++i == 2) halt();
|
||||||
Expressions *keys = new Expressions();
|
Expressions *keys = new Expressions();
|
||||||
keys->setDim(value.dim);
|
keys->setDim(value.dim);
|
||||||
Expressions *values = new Expressions();
|
Expressions *values = new Expressions();
|
||||||
values->setDim(value.dim);
|
values->setDim(value.dim);
|
||||||
|
|
||||||
for (size_t i = 0; i < value.dim; i++)
|
for (size_t i = 0; i < value.dim; i++)
|
||||||
{
|
{
|
||||||
e = index.tdata()[i];
|
e = index.tdata()[i];
|
||||||
if (!e)
|
if (!e)
|
||||||
goto Lno;
|
goto Lno;
|
||||||
keys->tdata()[i] = e;
|
keys->tdata()[i] = e;
|
||||||
|
|
||||||
Initializer *iz = value.tdata()[i];
|
Initializer *iz = value.tdata()[i];
|
||||||
if (!iz)
|
if (!iz)
|
||||||
goto Lno;
|
goto Lno;
|
||||||
e = iz->toExpression();
|
e = iz->toExpression();
|
||||||
if (!e)
|
if (!e)
|
||||||
goto Lno;
|
goto Lno;
|
||||||
values->tdata()[i] = e;
|
values->tdata()[i] = e;
|
||||||
}
|
}
|
||||||
e = new AssocArrayLiteralExp(loc, keys, values);
|
e = new AssocArrayLiteralExp(loc, keys, values);
|
||||||
return new ExpInitializer(loc, e);
|
return new ExpInitializer(loc, e);
|
||||||
@@ -663,17 +663,17 @@ Laa:
|
|||||||
void ArrayInitializer::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void ArrayInitializer::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->writebyte('[');
|
buf->writebyte('[');
|
||||||
for (size_t i = 0; i < index.dim; i++)
|
for (size_t i = 0; i < index.dim; i++)
|
||||||
{
|
{
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
buf->writebyte(',');
|
buf->writebyte(',');
|
||||||
Expression *ex = index.tdata()[i];
|
Expression *ex = index.tdata()[i];
|
||||||
if (ex)
|
if (ex)
|
||||||
{
|
{
|
||||||
ex->toCBuffer(buf, hgs);
|
ex->toCBuffer(buf, hgs);
|
||||||
buf->writebyte(':');
|
buf->writebyte(':');
|
||||||
}
|
}
|
||||||
Initializer *iz = value.tdata()[i];
|
Initializer *iz = value.tdata()[i];
|
||||||
if (iz)
|
if (iz)
|
||||||
iz->toCBuffer(buf, hgs);
|
iz->toCBuffer(buf, hgs);
|
||||||
}
|
}
|
||||||
@@ -694,19 +694,19 @@ Initializer *ExpInitializer::syntaxCopy()
|
|||||||
return new ExpInitializer(loc, exp->syntaxCopy());
|
return new ExpInitializer(loc, exp->syntaxCopy());
|
||||||
}
|
}
|
||||||
|
|
||||||
Initializer *ExpInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
Initializer *ExpInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
||||||
{
|
{
|
||||||
//printf("ExpInitializer::semantic(%s), type = %s\n", exp->toChars(), t->toChars());
|
//printf("ExpInitializer::semantic(%s), type = %s\n", exp->toChars(), t->toChars());
|
||||||
exp = exp->semantic(sc);
|
exp = exp->semantic(sc);
|
||||||
int wantOptimize = needInterpret ? WANTinterpret|WANTvalue : WANTvalue;
|
int wantOptimize = needInterpret ? WANTinterpret|WANTvalue : WANTvalue;
|
||||||
|
|
||||||
int olderrors = global.errors;
|
int olderrors = global.errors;
|
||||||
exp = exp->optimize(wantOptimize);
|
exp = exp->optimize(wantOptimize);
|
||||||
if (!global.gag && olderrors != global.errors)
|
if (!global.gag && olderrors != global.errors)
|
||||||
return this; // Failed, suppress duplicate error messages
|
return this; // Failed, suppress duplicate error messages
|
||||||
|
|
||||||
if (exp->op == TOKtype)
|
if (exp->op == TOKtype)
|
||||||
error("initializer must be an expression, not '%s'", exp->toChars());
|
error("initializer must be an expression, not '%s'", exp->toChars());
|
||||||
Type *tb = t->toBasetype();
|
Type *tb = t->toBasetype();
|
||||||
|
|
||||||
/* Look for case of initializing a static array with a too-short
|
/* Look for case of initializing a static array with a too-short
|
||||||
@@ -739,7 +739,7 @@ Initializer *ExpInitializer::semantic(Scope *sc, Type *t, int needInterpret)
|
|||||||
|
|
||||||
exp = exp->implicitCastTo(sc, t);
|
exp = exp->implicitCastTo(sc, t);
|
||||||
L1:
|
L1:
|
||||||
exp = exp->optimize(wantOptimize);
|
exp = exp->optimize(wantOptimize);
|
||||||
//printf("-ExpInitializer::semantic(): "); exp->print();
|
//printf("-ExpInitializer::semantic(): "); exp->print();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
+148
-148
@@ -1,148 +1,148 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef INIT_H
|
#ifndef INIT_H
|
||||||
#define INIT_H
|
#define INIT_H
|
||||||
|
|
||||||
#include "root.h"
|
#include "root.h"
|
||||||
|
|
||||||
#include "mars.h"
|
#include "mars.h"
|
||||||
#include "arraytypes.h"
|
#include "arraytypes.h"
|
||||||
|
|
||||||
struct Identifier;
|
struct Identifier;
|
||||||
struct Expression;
|
struct Expression;
|
||||||
struct Scope;
|
struct Scope;
|
||||||
struct Type;
|
struct Type;
|
||||||
struct dt_t;
|
struct dt_t;
|
||||||
struct AggregateDeclaration;
|
struct AggregateDeclaration;
|
||||||
struct VoidInitializer;
|
struct VoidInitializer;
|
||||||
struct StructInitializer;
|
struct StructInitializer;
|
||||||
struct ArrayInitializer;
|
struct ArrayInitializer;
|
||||||
struct ExpInitializer;
|
struct ExpInitializer;
|
||||||
struct HdrGenState;
|
struct HdrGenState;
|
||||||
|
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class StructType;
|
class StructType;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct Initializer : Object
|
struct Initializer : Object
|
||||||
{
|
{
|
||||||
Loc loc;
|
Loc loc;
|
||||||
|
|
||||||
Initializer(Loc loc);
|
Initializer(Loc loc);
|
||||||
virtual Initializer *syntaxCopy();
|
virtual Initializer *syntaxCopy();
|
||||||
// needInterpret is WANTinterpret if must be a manifest constant, 0 if not.
|
// needInterpret is WANTinterpret if must be a manifest constant, 0 if not.
|
||||||
virtual Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
virtual Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
||||||
virtual Type *inferType(Scope *sc);
|
virtual Type *inferType(Scope *sc);
|
||||||
virtual Expression *toExpression() = 0;
|
virtual Expression *toExpression() = 0;
|
||||||
virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0;
|
virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0;
|
||||||
char *toChars();
|
char *toChars();
|
||||||
|
|
||||||
static Initializers *arraySyntaxCopy(Initializers *ai);
|
static Initializers *arraySyntaxCopy(Initializers *ai);
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
virtual dt_t *toDt();
|
virtual dt_t *toDt();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual VoidInitializer *isVoidInitializer() { return NULL; }
|
virtual VoidInitializer *isVoidInitializer() { return NULL; }
|
||||||
virtual StructInitializer *isStructInitializer() { return NULL; }
|
virtual StructInitializer *isStructInitializer() { return NULL; }
|
||||||
virtual ArrayInitializer *isArrayInitializer() { return NULL; }
|
virtual ArrayInitializer *isArrayInitializer() { return NULL; }
|
||||||
virtual ExpInitializer *isExpInitializer() { return NULL; }
|
virtual ExpInitializer *isExpInitializer() { return NULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VoidInitializer : Initializer
|
struct VoidInitializer : Initializer
|
||||||
{
|
{
|
||||||
Type *type; // type that this will initialize to
|
Type *type; // type that this will initialize to
|
||||||
|
|
||||||
VoidInitializer(Loc loc);
|
VoidInitializer(Loc loc);
|
||||||
Initializer *syntaxCopy();
|
Initializer *syntaxCopy();
|
||||||
Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
||||||
Expression *toExpression();
|
Expression *toExpression();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
dt_t *toDt();
|
dt_t *toDt();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual VoidInitializer *isVoidInitializer() { return this; }
|
virtual VoidInitializer *isVoidInitializer() { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StructInitializer : Initializer
|
struct StructInitializer : Initializer
|
||||||
{
|
{
|
||||||
Identifiers field; // of Identifier *'s
|
Identifiers field; // of Identifier *'s
|
||||||
Initializers value; // parallel array of Initializer *'s
|
Initializers value; // parallel array of Initializer *'s
|
||||||
|
|
||||||
VarDeclarations vars; // parallel array of VarDeclaration *'s
|
VarDeclarations vars; // parallel array of VarDeclaration *'s
|
||||||
AggregateDeclaration *ad; // which aggregate this is for
|
AggregateDeclaration *ad; // which aggregate this is for
|
||||||
|
|
||||||
StructInitializer(Loc loc);
|
StructInitializer(Loc loc);
|
||||||
Initializer *syntaxCopy();
|
Initializer *syntaxCopy();
|
||||||
void addInit(Identifier *field, Initializer *value);
|
void addInit(Identifier *field, Initializer *value);
|
||||||
Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
||||||
Expression *toExpression();
|
Expression *toExpression();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
dt_t *toDt();
|
dt_t *toDt();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
StructInitializer *isStructInitializer() { return this; }
|
StructInitializer *isStructInitializer() { return this; }
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
llvm::StructType *ltype;
|
llvm::StructType *ltype;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ArrayInitializer : Initializer
|
struct ArrayInitializer : Initializer
|
||||||
{
|
{
|
||||||
Expressions index; // indices
|
Expressions index; // indices
|
||||||
Initializers value; // of Initializer *'s
|
Initializers value; // of Initializer *'s
|
||||||
unsigned dim; // length of array being initialized
|
unsigned dim; // length of array being initialized
|
||||||
Type *type; // type that array will be used to initialize
|
Type *type; // type that array will be used to initialize
|
||||||
int sem; // !=0 if semantic() is run
|
int sem; // !=0 if semantic() is run
|
||||||
|
|
||||||
ArrayInitializer(Loc loc);
|
ArrayInitializer(Loc loc);
|
||||||
Initializer *syntaxCopy();
|
Initializer *syntaxCopy();
|
||||||
void addInit(Expression *index, Initializer *value);
|
void addInit(Expression *index, Initializer *value);
|
||||||
Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
||||||
Type *inferType(Scope *sc);
|
Type *inferType(Scope *sc);
|
||||||
Expression *toExpression();
|
Expression *toExpression();
|
||||||
Initializer *toAssocArrayInitializer();
|
Initializer *toAssocArrayInitializer();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
dt_t *toDt();
|
dt_t *toDt();
|
||||||
dt_t *toDtBit(); // for bit arrays
|
dt_t *toDtBit(); // for bit arrays
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ArrayInitializer *isArrayInitializer() { return this; }
|
ArrayInitializer *isArrayInitializer() { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ExpInitializer : Initializer
|
struct ExpInitializer : Initializer
|
||||||
{
|
{
|
||||||
Expression *exp;
|
Expression *exp;
|
||||||
|
|
||||||
ExpInitializer(Loc loc, Expression *exp);
|
ExpInitializer(Loc loc, Expression *exp);
|
||||||
Initializer *syntaxCopy();
|
Initializer *syntaxCopy();
|
||||||
Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
Initializer *semantic(Scope *sc, Type *t, int needInterpret);
|
||||||
Type *inferType(Scope *sc);
|
Type *inferType(Scope *sc);
|
||||||
Expression *toExpression();
|
Expression *toExpression();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
dt_t *toDt();
|
dt_t *toDt();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual ExpInitializer *isExpInitializer() { return this; }
|
virtual ExpInitializer *isExpInitializer() { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+369
-369
File diff suppressed because it is too large
Load Diff
+4645
-4645
File diff suppressed because it is too large
Load Diff
+462
-462
@@ -1,462 +1,462 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
// This implements the JSON capability.
|
// This implements the JSON capability.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "rmem.h"
|
#include "rmem.h"
|
||||||
#include "root.h"
|
#include "root.h"
|
||||||
|
|
||||||
#include "mars.h"
|
#include "mars.h"
|
||||||
#include "dsymbol.h"
|
#include "dsymbol.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "template.h"
|
#include "template.h"
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "aggregate.h"
|
#include "aggregate.h"
|
||||||
#include "declaration.h"
|
#include "declaration.h"
|
||||||
#include "enum.h"
|
#include "enum.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "hdrgen.h"
|
#include "hdrgen.h"
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "attrib.h"
|
#include "attrib.h"
|
||||||
#include "cond.h"
|
#include "cond.h"
|
||||||
|
|
||||||
const char Pname[] = "name";
|
const char Pname[] = "name";
|
||||||
const char Pkind[] = "kind";
|
const char Pkind[] = "kind";
|
||||||
const char Pfile[] = "file";
|
const char Pfile[] = "file";
|
||||||
const char Pline[] = "line";
|
const char Pline[] = "line";
|
||||||
const char Ptype[] = "type";
|
const char Ptype[] = "type";
|
||||||
const char Pcomment[] = "comment";
|
const char Pcomment[] = "comment";
|
||||||
const char Pmembers[] = "members";
|
const char Pmembers[] = "members";
|
||||||
const char Pprotection[] = "protection";
|
const char Pprotection[] = "protection";
|
||||||
const char* Pprotectionnames[] = {NULL, "none", "private", "package", "protected", "public", "export"};
|
const char* Pprotectionnames[] = {NULL, "none", "private", "package", "protected", "public", "export"};
|
||||||
|
|
||||||
void JsonRemoveComma(OutBuffer *buf);
|
void JsonRemoveComma(OutBuffer *buf);
|
||||||
|
|
||||||
void json_generate(Modules *modules)
|
void json_generate(Modules *modules)
|
||||||
{ OutBuffer buf;
|
{ OutBuffer buf;
|
||||||
|
|
||||||
buf.writestring("[\n");
|
buf.writestring("[\n");
|
||||||
for (size_t i = 0; i < modules->dim; i++)
|
for (size_t i = 0; i < modules->dim; i++)
|
||||||
{ Module *m = modules->tdata()[i];
|
{ Module *m = modules->tdata()[i];
|
||||||
if (global.params.verbose)
|
if (global.params.verbose)
|
||||||
printf("json gen %s\n", m->toChars());
|
printf("json gen %s\n", m->toChars());
|
||||||
m->toJsonBuffer(&buf);
|
m->toJsonBuffer(&buf);
|
||||||
buf.writestring(",\n");
|
buf.writestring(",\n");
|
||||||
}
|
}
|
||||||
JsonRemoveComma(&buf);
|
JsonRemoveComma(&buf);
|
||||||
buf.writestring("]\n");
|
buf.writestring("]\n");
|
||||||
|
|
||||||
// Write buf to file
|
// Write buf to file
|
||||||
char *arg = global.params.xfilename;
|
char *arg = global.params.xfilename;
|
||||||
if (!arg || !*arg)
|
if (!arg || !*arg)
|
||||||
{ // Generate lib file name from first obj name
|
{ // Generate lib file name from first obj name
|
||||||
char *n = global.params.objfiles->tdata()[0];
|
char *n = global.params.objfiles->tdata()[0];
|
||||||
|
|
||||||
n = FileName::name(n);
|
n = FileName::name(n);
|
||||||
FileName *fn = FileName::forceExt(n, global.json_ext);
|
FileName *fn = FileName::forceExt(n, global.json_ext);
|
||||||
arg = fn->toChars();
|
arg = fn->toChars();
|
||||||
}
|
}
|
||||||
else if (arg[0] == '-' && arg[1] == 0)
|
else if (arg[0] == '-' && arg[1] == 0)
|
||||||
{ // Write to stdout; assume it succeeds
|
{ // Write to stdout; assume it succeeds
|
||||||
int n = fwrite(buf.data, 1, buf.offset, stdout);
|
int n = fwrite(buf.data, 1, buf.offset, stdout);
|
||||||
assert(n == buf.offset); // keep gcc happy about return values
|
assert(n == buf.offset); // keep gcc happy about return values
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if (!FileName::absolute(arg))
|
// if (!FileName::absolute(arg))
|
||||||
// arg = FileName::combine(dir, arg);
|
// arg = FileName::combine(dir, arg);
|
||||||
FileName *jsonfilename = FileName::defaultExt(arg, global.json_ext);
|
FileName *jsonfilename = FileName::defaultExt(arg, global.json_ext);
|
||||||
File *jsonfile = new File(jsonfilename);
|
File *jsonfile = new File(jsonfilename);
|
||||||
assert(jsonfile);
|
assert(jsonfile);
|
||||||
jsonfile->setbuffer(buf.data, buf.offset);
|
jsonfile->setbuffer(buf.data, buf.offset);
|
||||||
jsonfile->ref = 1;
|
jsonfile->ref = 1;
|
||||||
char *pt = FileName::path(jsonfile->toChars());
|
char *pt = FileName::path(jsonfile->toChars());
|
||||||
if (*pt)
|
if (*pt)
|
||||||
FileName::ensurePathExists(pt);
|
FileName::ensurePathExists(pt);
|
||||||
mem.free(pt);
|
mem.free(pt);
|
||||||
jsonfile->writev();
|
jsonfile->writev();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* Encode string into buf, and wrap it in double quotes.
|
* Encode string into buf, and wrap it in double quotes.
|
||||||
*/
|
*/
|
||||||
void JsonString(OutBuffer *buf, const char *s)
|
void JsonString(OutBuffer *buf, const char *s)
|
||||||
{
|
{
|
||||||
buf->writeByte('\"');
|
buf->writeByte('\"');
|
||||||
for (; *s; s++)
|
for (; *s; s++)
|
||||||
{
|
{
|
||||||
unsigned char c = (unsigned char) *s;
|
unsigned char c = (unsigned char) *s;
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case '\n':
|
case '\n':
|
||||||
buf->writestring("\\n");
|
buf->writestring("\\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\r':
|
case '\r':
|
||||||
buf->writestring("\\r");
|
buf->writestring("\\r");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\t':
|
case '\t':
|
||||||
buf->writestring("\\t");
|
buf->writestring("\\t");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\"':
|
case '\"':
|
||||||
buf->writestring("\\\"");
|
buf->writestring("\\\"");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\\':
|
case '\\':
|
||||||
buf->writestring("\\\\");
|
buf->writestring("\\\\");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '/':
|
case '/':
|
||||||
buf->writestring("\\/");
|
buf->writestring("\\/");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\b':
|
case '\b':
|
||||||
buf->writestring("\\b");
|
buf->writestring("\\b");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '\f':
|
case '\f':
|
||||||
buf->writestring("\\f");
|
buf->writestring("\\f");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (c < 0x20)
|
if (c < 0x20)
|
||||||
buf->printf("\\u%04x", c);
|
buf->printf("\\u%04x", c);
|
||||||
else
|
else
|
||||||
// Note that UTF-8 chars pass through here just fine
|
// Note that UTF-8 chars pass through here just fine
|
||||||
buf->writeByte(c);
|
buf->writeByte(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buf->writeByte('\"');
|
buf->writeByte('\"');
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonProperty(OutBuffer *buf, const char *name, const char *value)
|
void JsonProperty(OutBuffer *buf, const char *name, const char *value)
|
||||||
{
|
{
|
||||||
JsonString(buf, name);
|
JsonString(buf, name);
|
||||||
buf->writestring(" : ");
|
buf->writestring(" : ");
|
||||||
JsonString(buf, value);
|
JsonString(buf, value);
|
||||||
buf->writestring(",\n");
|
buf->writestring(",\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonProperty(OutBuffer *buf, const char *name, int value)
|
void JsonProperty(OutBuffer *buf, const char *name, int value)
|
||||||
{
|
{
|
||||||
JsonString(buf, name);
|
JsonString(buf, name);
|
||||||
buf->writestring(" : ");
|
buf->writestring(" : ");
|
||||||
buf->printf("%d", value);
|
buf->printf("%d", value);
|
||||||
buf->writestring(",\n");
|
buf->writestring(",\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonRemoveComma(OutBuffer *buf)
|
void JsonRemoveComma(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
if (buf->offset >= 2 &&
|
if (buf->offset >= 2 &&
|
||||||
buf->data[buf->offset - 2] == ',' &&
|
buf->data[buf->offset - 2] == ',' &&
|
||||||
buf->data[buf->offset - 1] == '\n')
|
buf->data[buf->offset - 1] == '\n')
|
||||||
buf->offset -= 2;
|
buf->offset -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dsymbol::toJsonBuffer(OutBuffer *buf)
|
void Dsymbol::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::toJsonBuffer(OutBuffer *buf)
|
void Module::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
buf->writestring("{\n");
|
buf->writestring("{\n");
|
||||||
|
|
||||||
if (md)
|
if (md)
|
||||||
JsonProperty(buf, Pname, md->toChars());
|
JsonProperty(buf, Pname, md->toChars());
|
||||||
|
|
||||||
JsonProperty(buf, Pkind, kind());
|
JsonProperty(buf, Pkind, kind());
|
||||||
|
|
||||||
JsonProperty(buf, Pfile, srcfile->toChars());
|
JsonProperty(buf, Pfile, srcfile->toChars());
|
||||||
|
|
||||||
if (comment)
|
if (comment)
|
||||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||||
|
|
||||||
JsonString(buf, Pmembers);
|
JsonString(buf, Pmembers);
|
||||||
buf->writestring(" : [\n");
|
buf->writestring(" : [\n");
|
||||||
|
|
||||||
size_t offset = buf->offset;
|
size_t offset = buf->offset;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *s = members->tdata()[i];
|
{ Dsymbol *s = members->tdata()[i];
|
||||||
if (offset != buf->offset)
|
if (offset != buf->offset)
|
||||||
{ buf->writestring(",\n");
|
{ buf->writestring(",\n");
|
||||||
offset = buf->offset;
|
offset = buf->offset;
|
||||||
}
|
}
|
||||||
s->toJsonBuffer(buf);
|
s->toJsonBuffer(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
buf->writestring("]\n");
|
buf->writestring("]\n");
|
||||||
|
|
||||||
buf->writestring("}\n");
|
buf->writestring("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttribDeclaration::toJsonBuffer(OutBuffer *buf)
|
void AttribDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
//printf("AttribDeclaration::toJsonBuffer()\n");
|
//printf("AttribDeclaration::toJsonBuffer()\n");
|
||||||
|
|
||||||
Dsymbols *d = include(NULL, NULL);
|
Dsymbols *d = include(NULL, NULL);
|
||||||
|
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
size_t offset = buf->offset;
|
size_t offset = buf->offset;
|
||||||
for (unsigned i = 0; i < d->dim; i++)
|
for (unsigned i = 0; i < d->dim; i++)
|
||||||
{ Dsymbol *s = d->tdata()[i];
|
{ Dsymbol *s = d->tdata()[i];
|
||||||
//printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars());
|
//printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars());
|
||||||
if (offset != buf->offset)
|
if (offset != buf->offset)
|
||||||
{ buf->writestring(",\n");
|
{ buf->writestring(",\n");
|
||||||
offset = buf->offset;
|
offset = buf->offset;
|
||||||
}
|
}
|
||||||
s->toJsonBuffer(buf);
|
s->toJsonBuffer(buf);
|
||||||
}
|
}
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ConditionalDeclaration::toJsonBuffer(OutBuffer *buf)
|
void ConditionalDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
//printf("ConditionalDeclaration::toJsonBuffer()\n");
|
//printf("ConditionalDeclaration::toJsonBuffer()\n");
|
||||||
if (condition->inc)
|
if (condition->inc)
|
||||||
{
|
{
|
||||||
AttribDeclaration::toJsonBuffer(buf);
|
AttribDeclaration::toJsonBuffer(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InvariantDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void InvariantDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
void DtorDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void DtorDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
void StaticCtorDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void StaticCtorDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
void StaticDtorDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void StaticDtorDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
void ClassInfoDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void ClassInfoDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
void ModuleInfoDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void ModuleInfoDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
void TypeInfoDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void TypeInfoDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
void UnitTestDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void UnitTestDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
void PostBlitDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
void PostBlitDeclaration::toJsonBuffer(OutBuffer *buf) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Declaration::toJsonBuffer(OutBuffer *buf)
|
void Declaration::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
//printf("Declaration::toJsonBuffer()\n");
|
//printf("Declaration::toJsonBuffer()\n");
|
||||||
buf->writestring("{\n");
|
buf->writestring("{\n");
|
||||||
|
|
||||||
JsonProperty(buf, Pname, toChars());
|
JsonProperty(buf, Pname, toChars());
|
||||||
JsonProperty(buf, Pkind, kind());
|
JsonProperty(buf, Pkind, kind());
|
||||||
|
|
||||||
if (prot())
|
if (prot())
|
||||||
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
||||||
|
|
||||||
if (type)
|
if (type)
|
||||||
JsonProperty(buf, Ptype, type->toChars());
|
JsonProperty(buf, Ptype, type->toChars());
|
||||||
|
|
||||||
if (comment)
|
if (comment)
|
||||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||||
|
|
||||||
if (loc.linnum)
|
if (loc.linnum)
|
||||||
JsonProperty(buf, Pline, loc.linnum);
|
JsonProperty(buf, Pline, loc.linnum);
|
||||||
|
|
||||||
TypedefDeclaration *td = isTypedefDeclaration();
|
TypedefDeclaration *td = isTypedefDeclaration();
|
||||||
if (td)
|
if (td)
|
||||||
{
|
{
|
||||||
JsonProperty(buf, "base", td->basetype->toChars());
|
JsonProperty(buf, "base", td->basetype->toChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
buf->writestring("}\n");
|
buf->writestring("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AggregateDeclaration::toJsonBuffer(OutBuffer *buf)
|
void AggregateDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
//printf("AggregateDeclaration::toJsonBuffer()\n");
|
//printf("AggregateDeclaration::toJsonBuffer()\n");
|
||||||
buf->writestring("{\n");
|
buf->writestring("{\n");
|
||||||
|
|
||||||
JsonProperty(buf, Pname, toChars());
|
JsonProperty(buf, Pname, toChars());
|
||||||
JsonProperty(buf, Pkind, kind());
|
JsonProperty(buf, Pkind, kind());
|
||||||
|
|
||||||
if (prot())
|
if (prot())
|
||||||
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
||||||
|
|
||||||
if (comment)
|
if (comment)
|
||||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||||
|
|
||||||
if (loc.linnum)
|
if (loc.linnum)
|
||||||
JsonProperty(buf, Pline, loc.linnum);
|
JsonProperty(buf, Pline, loc.linnum);
|
||||||
|
|
||||||
ClassDeclaration *cd = isClassDeclaration();
|
ClassDeclaration *cd = isClassDeclaration();
|
||||||
if (cd)
|
if (cd)
|
||||||
{
|
{
|
||||||
if (cd->baseClass)
|
if (cd->baseClass)
|
||||||
{
|
{
|
||||||
JsonProperty(buf, "base", cd->baseClass->toChars());
|
JsonProperty(buf, "base", cd->baseClass->toChars());
|
||||||
}
|
}
|
||||||
if (cd->interfaces_dim)
|
if (cd->interfaces_dim)
|
||||||
{
|
{
|
||||||
JsonString(buf, "interfaces");
|
JsonString(buf, "interfaces");
|
||||||
buf->writestring(" : [\n");
|
buf->writestring(" : [\n");
|
||||||
size_t offset = buf->offset;
|
size_t offset = buf->offset;
|
||||||
for (size_t i = 0; i < cd->interfaces_dim; i++)
|
for (size_t i = 0; i < cd->interfaces_dim; i++)
|
||||||
{ BaseClass *b = cd->interfaces[i];
|
{ BaseClass *b = cd->interfaces[i];
|
||||||
if (offset != buf->offset)
|
if (offset != buf->offset)
|
||||||
{ buf->writestring(",\n");
|
{ buf->writestring(",\n");
|
||||||
offset = buf->offset;
|
offset = buf->offset;
|
||||||
}
|
}
|
||||||
JsonString(buf, b->base->toChars());
|
JsonString(buf, b->base->toChars());
|
||||||
}
|
}
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
buf->writestring("],\n");
|
buf->writestring("],\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (members)
|
if (members)
|
||||||
{
|
{
|
||||||
JsonString(buf, Pmembers);
|
JsonString(buf, Pmembers);
|
||||||
buf->writestring(" : [\n");
|
buf->writestring(" : [\n");
|
||||||
size_t offset = buf->offset;
|
size_t offset = buf->offset;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *s = members->tdata()[i];
|
{ Dsymbol *s = members->tdata()[i];
|
||||||
if (offset != buf->offset)
|
if (offset != buf->offset)
|
||||||
{ buf->writestring(",\n");
|
{ buf->writestring(",\n");
|
||||||
offset = buf->offset;
|
offset = buf->offset;
|
||||||
}
|
}
|
||||||
s->toJsonBuffer(buf);
|
s->toJsonBuffer(buf);
|
||||||
}
|
}
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
buf->writestring("]\n");
|
buf->writestring("]\n");
|
||||||
}
|
}
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
|
|
||||||
buf->writestring("}\n");
|
buf->writestring("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemplateDeclaration::toJsonBuffer(OutBuffer *buf)
|
void TemplateDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
//printf("TemplateDeclaration::toJsonBuffer()\n");
|
//printf("TemplateDeclaration::toJsonBuffer()\n");
|
||||||
|
|
||||||
buf->writestring("{\n");
|
buf->writestring("{\n");
|
||||||
|
|
||||||
JsonProperty(buf, Pname, toChars());
|
JsonProperty(buf, Pname, toChars());
|
||||||
JsonProperty(buf, Pkind, kind());
|
JsonProperty(buf, Pkind, kind());
|
||||||
|
|
||||||
if (prot())
|
if (prot())
|
||||||
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
||||||
|
|
||||||
if (comment)
|
if (comment)
|
||||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||||
|
|
||||||
if (loc.linnum)
|
if (loc.linnum)
|
||||||
JsonProperty(buf, Pline, loc.linnum);
|
JsonProperty(buf, Pline, loc.linnum);
|
||||||
|
|
||||||
JsonString(buf, Pmembers);
|
JsonString(buf, Pmembers);
|
||||||
buf->writestring(" : [\n");
|
buf->writestring(" : [\n");
|
||||||
size_t offset = buf->offset;
|
size_t offset = buf->offset;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *s = members->tdata()[i];
|
{ Dsymbol *s = members->tdata()[i];
|
||||||
if (offset != buf->offset)
|
if (offset != buf->offset)
|
||||||
{ buf->writestring(",\n");
|
{ buf->writestring(",\n");
|
||||||
offset = buf->offset;
|
offset = buf->offset;
|
||||||
}
|
}
|
||||||
s->toJsonBuffer(buf);
|
s->toJsonBuffer(buf);
|
||||||
}
|
}
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
buf->writestring("]\n");
|
buf->writestring("]\n");
|
||||||
|
|
||||||
buf->writestring("}\n");
|
buf->writestring("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumDeclaration::toJsonBuffer(OutBuffer *buf)
|
void EnumDeclaration::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
//printf("EnumDeclaration::toJsonBuffer()\n");
|
//printf("EnumDeclaration::toJsonBuffer()\n");
|
||||||
if (isAnonymous())
|
if (isAnonymous())
|
||||||
{
|
{
|
||||||
if (members)
|
if (members)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = members->tdata()[i];
|
Dsymbol *s = members->tdata()[i];
|
||||||
s->toJsonBuffer(buf);
|
s->toJsonBuffer(buf);
|
||||||
buf->writestring(",\n");
|
buf->writestring(",\n");
|
||||||
}
|
}
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf->writestring("{\n");
|
buf->writestring("{\n");
|
||||||
|
|
||||||
JsonProperty(buf, Pname, toChars());
|
JsonProperty(buf, Pname, toChars());
|
||||||
JsonProperty(buf, Pkind, kind());
|
JsonProperty(buf, Pkind, kind());
|
||||||
|
|
||||||
if (prot())
|
if (prot())
|
||||||
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
||||||
|
|
||||||
if (comment)
|
if (comment)
|
||||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||||
|
|
||||||
if (loc.linnum)
|
if (loc.linnum)
|
||||||
JsonProperty(buf, Pline, loc.linnum);
|
JsonProperty(buf, Pline, loc.linnum);
|
||||||
|
|
||||||
if (memtype)
|
if (memtype)
|
||||||
JsonProperty(buf, "base", memtype->toChars());
|
JsonProperty(buf, "base", memtype->toChars());
|
||||||
|
|
||||||
if (members)
|
if (members)
|
||||||
{
|
{
|
||||||
JsonString(buf, Pmembers);
|
JsonString(buf, Pmembers);
|
||||||
buf->writestring(" : [\n");
|
buf->writestring(" : [\n");
|
||||||
size_t offset = buf->offset;
|
size_t offset = buf->offset;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *s = members->tdata()[i];
|
{ Dsymbol *s = members->tdata()[i];
|
||||||
if (offset != buf->offset)
|
if (offset != buf->offset)
|
||||||
{ buf->writestring(",\n");
|
{ buf->writestring(",\n");
|
||||||
offset = buf->offset;
|
offset = buf->offset;
|
||||||
}
|
}
|
||||||
s->toJsonBuffer(buf);
|
s->toJsonBuffer(buf);
|
||||||
}
|
}
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
buf->writestring("]\n");
|
buf->writestring("]\n");
|
||||||
}
|
}
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
|
|
||||||
buf->writestring("}\n");
|
buf->writestring("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnumMember::toJsonBuffer(OutBuffer *buf)
|
void EnumMember::toJsonBuffer(OutBuffer *buf)
|
||||||
{
|
{
|
||||||
//printf("EnumMember::toJsonBuffer()\n");
|
//printf("EnumMember::toJsonBuffer()\n");
|
||||||
buf->writestring("{\n");
|
buf->writestring("{\n");
|
||||||
|
|
||||||
JsonProperty(buf, Pname, toChars());
|
JsonProperty(buf, Pname, toChars());
|
||||||
JsonProperty(buf, Pkind, kind());
|
JsonProperty(buf, Pkind, kind());
|
||||||
|
|
||||||
if (prot())
|
if (prot())
|
||||||
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
JsonProperty(buf, Pprotection, Pprotectionnames[prot()]);
|
||||||
|
|
||||||
if (comment)
|
if (comment)
|
||||||
JsonProperty(buf, Pcomment, (const char *)comment);
|
JsonProperty(buf, Pcomment, (const char *)comment);
|
||||||
|
|
||||||
if (loc.linnum)
|
if (loc.linnum)
|
||||||
JsonProperty(buf, Pline, loc.linnum);
|
JsonProperty(buf, Pline, loc.linnum);
|
||||||
|
|
||||||
JsonRemoveComma(buf);
|
JsonRemoveComma(buf);
|
||||||
buf->writestring("}\n");
|
buf->writestring("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+24
-24
@@ -1,24 +1,24 @@
|
|||||||
|
|
||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2008 by Digital Mars
|
// Copyright (c) 1999-2008 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_JSON_H
|
#ifndef DMD_JSON_H
|
||||||
#define DMD_JSON_H
|
#define DMD_JSON_H
|
||||||
|
|
||||||
#ifdef __DMC__
|
#ifdef __DMC__
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif /* __DMC__ */
|
#endif /* __DMC__ */
|
||||||
|
|
||||||
#include "arraytypes.h"
|
#include "arraytypes.h"
|
||||||
|
|
||||||
void json_generate(Modules *);
|
void json_generate(Modules *);
|
||||||
|
|
||||||
#endif /* DMD_JSON_H */
|
#endif /* DMD_JSON_H */
|
||||||
|
|
||||||
|
|||||||
+53
-53
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
/* Lexical Analyzer */
|
/* Lexical Analyzer */
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ void Token::print()
|
|||||||
|
|
||||||
const char *Token::toChars()
|
const char *Token::toChars()
|
||||||
{ const char *p;
|
{ const char *p;
|
||||||
static char buffer[3 + 3 * sizeof(float80value) + 1];
|
static char buffer[3 + 3 * sizeof(float80value) + 1];
|
||||||
|
|
||||||
p = buffer;
|
p = buffer;
|
||||||
switch (value)
|
switch (value)
|
||||||
@@ -123,11 +123,11 @@ const char *Token::toChars()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TOKint64v:
|
case TOKint64v:
|
||||||
sprintf(buffer,"%jdL",(intmax_t)int64value);
|
sprintf(buffer,"%jdL",(intmax_t)int64value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOKuns64v:
|
case TOKuns64v:
|
||||||
sprintf(buffer,"%juUL",(uintmax_t)uns64value);
|
sprintf(buffer,"%juUL",(uintmax_t)uns64value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#if IN_GCC
|
#if IN_GCC
|
||||||
@@ -304,20 +304,20 @@ void Lexer::error(const char *format, ...)
|
|||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
verror(loc, format, ap);
|
verror(loc, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lexer::error(Loc loc, const char *format, ...)
|
void Lexer::error(Loc loc, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
verror(loc, format, ap);
|
verror(loc, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lexer::verror(Loc loc, const char *format, va_list ap)
|
void Lexer::verror(Loc loc, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
if (mod && !global.gag)
|
if (mod && !global.gag)
|
||||||
{
|
{
|
||||||
char *p = loc.toChars();
|
char *p = loc.toChars();
|
||||||
@@ -333,10 +333,10 @@ void Lexer::verror(Loc loc, const char *format, va_list ap)
|
|||||||
if (global.errors >= 20) // moderate blizzard of cascading messages
|
if (global.errors >= 20) // moderate blizzard of cascading messages
|
||||||
fatal();
|
fatal();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
global.gaggedErrors++;
|
global.gaggedErrors++;
|
||||||
}
|
}
|
||||||
global.errors++;
|
global.errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -736,7 +736,7 @@ void Lexer::scan(Token *t)
|
|||||||
for (const char *p = global.version + 1; 1; p++)
|
for (const char *p = global.version + 1; 1; p++)
|
||||||
{
|
{
|
||||||
char c = *p;
|
char c = *p;
|
||||||
if (isdigit((unsigned char)c))
|
if (isdigit((unsigned char)c))
|
||||||
minor = minor * 10 + c - '0';
|
minor = minor * 10 + c - '0';
|
||||||
else if (c == '.')
|
else if (c == '.')
|
||||||
{ major = minor;
|
{ major = minor;
|
||||||
@@ -1148,12 +1148,12 @@ void Lexer::scan(Token *t)
|
|||||||
else
|
else
|
||||||
t->value = TOKequal; // ==
|
t->value = TOKequal; // ==
|
||||||
}
|
}
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
else if (*p == '>')
|
else if (*p == '>')
|
||||||
{ p++;
|
{ p++;
|
||||||
t->value = TOKgoesto; // =>
|
t->value = TOKgoesto; // =>
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
t->value = TOKassign; // =
|
t->value = TOKassign; // =
|
||||||
return;
|
return;
|
||||||
@@ -2079,13 +2079,13 @@ TOK Lexer::number(Token *t)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c == '.' && p[1] != '.')
|
if (c == '.' && p[1] != '.')
|
||||||
{
|
{
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
if (isalpha(p[1]) || p[1] == '_')
|
if (isalpha(p[1]) || p[1] == '_')
|
||||||
goto done;
|
goto done;
|
||||||
#endif
|
#endif
|
||||||
goto real;
|
goto real;
|
||||||
}
|
}
|
||||||
else if (c == 'i' || c == 'f' || c == 'F' ||
|
else if (c == 'i' || c == 'f' || c == 'F' ||
|
||||||
c == 'e' || c == 'E')
|
c == 'e' || c == 'E')
|
||||||
{
|
{
|
||||||
@@ -2234,7 +2234,7 @@ done:
|
|||||||
p += 2, r = 16;
|
p += 2, r = 16;
|
||||||
else if (p[1] == 'b' || p[1] == 'B')
|
else if (p[1] == 'b' || p[1] == 'B')
|
||||||
p += 2, r = 2;
|
p += 2, r = 2;
|
||||||
else if (isdigit((unsigned char)p[1]))
|
else if (isdigit((unsigned char)p[1]))
|
||||||
p += 1, r = 8;
|
p += 1, r = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2269,7 +2269,7 @@ done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse trailing 'u', 'U', 'l' or 'L' in any combination
|
// Parse trailing 'u', 'U', 'l' or 'L' in any combination
|
||||||
const unsigned char *psuffix = p;
|
const unsigned char *psuffix = p;
|
||||||
while (1)
|
while (1)
|
||||||
{ unsigned char f;
|
{ unsigned char f;
|
||||||
|
|
||||||
@@ -2296,12 +2296,12 @@ done:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
if (state == STATE_octal && n >= 8 && !global.params.useDeprecated)
|
if (state == STATE_octal && n >= 8 && !global.params.useDeprecated)
|
||||||
error("octal literals 0%llo%.*s are deprecated, use std.conv.octal!%llo%.*s instead",
|
error("octal literals 0%llo%.*s are deprecated, use std.conv.octal!%llo%.*s instead",
|
||||||
n, p - psuffix, psuffix, n, p - psuffix, psuffix);
|
n, p - psuffix, psuffix, n, p - psuffix, psuffix);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (flags)
|
switch (flags)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@@ -2582,10 +2582,10 @@ void Lexer::pragma()
|
|||||||
|
|
||||||
scan(&tok);
|
scan(&tok);
|
||||||
if (tok.value == TOKint32v || tok.value == TOKint64v)
|
if (tok.value == TOKint32v || tok.value == TOKint64v)
|
||||||
{ linnum = tok.uns64value - 1;
|
{ linnum = tok.uns64value - 1;
|
||||||
if (linnum != tok.uns64value - 1)
|
if (linnum != tok.uns64value - 1)
|
||||||
error("line number out of range");
|
error("line number out of range");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
|
|
||||||
@@ -3028,7 +3028,7 @@ static Keyword keywords[] =
|
|||||||
{ "__thread", TOKtls },
|
{ "__thread", TOKtls },
|
||||||
{ "__gshared", TOKgshared },
|
{ "__gshared", TOKgshared },
|
||||||
{ "__traits", TOKtraits },
|
{ "__traits", TOKtraits },
|
||||||
{ "__vector", TOKvector },
|
{ "__vector", TOKvector },
|
||||||
{ "__overloadset", TOKoverloadset },
|
{ "__overloadset", TOKoverloadset },
|
||||||
{ "__FILE__", TOKfile },
|
{ "__FILE__", TOKfile },
|
||||||
{ "__LINE__", TOKline },
|
{ "__LINE__", TOKline },
|
||||||
@@ -3048,22 +3048,22 @@ int Token::isKeyword()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Lexer::initKeywords()
|
void Lexer::initKeywords()
|
||||||
{
|
{
|
||||||
unsigned nkeywords = sizeof(keywords) / sizeof(keywords[0]);
|
unsigned nkeywords = sizeof(keywords) / sizeof(keywords[0]);
|
||||||
|
|
||||||
stringtable.init(1543);
|
stringtable.init(1543);
|
||||||
|
|
||||||
if (global.params.Dversion == 1)
|
if (global.params.Dversion == 1)
|
||||||
nkeywords -= 2;
|
nkeywords -= 2;
|
||||||
|
|
||||||
cmtable_init();
|
cmtable_init();
|
||||||
|
|
||||||
for (unsigned u = 0; u < nkeywords; u++)
|
for (unsigned u = 0; u < nkeywords; u++)
|
||||||
{
|
{
|
||||||
//printf("keyword[%d] = '%s'\n",u, keywords[u].name);
|
//printf("keyword[%d] = '%s'\n",u, keywords[u].name);
|
||||||
const char *s = keywords[u].name;
|
const char *s = keywords[u].name;
|
||||||
enum TOK v = keywords[u].value;
|
enum TOK v = keywords[u].value;
|
||||||
StringValue *sv = stringtable.insert(s, strlen(s));
|
StringValue *sv = stringtable.insert(s, strlen(s));
|
||||||
sv->ptrvalue = (void *) new Identifier(sv->lstring.string,v);
|
sv->ptrvalue = (void *) new Identifier(sv->lstring.string,v);
|
||||||
|
|
||||||
//printf("tochars[%d] = '%s'\n",v, s);
|
//printf("tochars[%d] = '%s'\n",v, s);
|
||||||
@@ -3160,7 +3160,7 @@ void Lexer::initKeywords()
|
|||||||
Token::tochars[TOKat] = "@";
|
Token::tochars[TOKat] = "@";
|
||||||
Token::tochars[TOKpow] = "^^";
|
Token::tochars[TOKpow] = "^^";
|
||||||
Token::tochars[TOKpowass] = "^^=";
|
Token::tochars[TOKpowass] = "^^=";
|
||||||
Token::tochars[TOKgoesto] = "=>";
|
Token::tochars[TOKgoesto] = "=>";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For debugging
|
// For debugging
|
||||||
|
|||||||
+1
-1
@@ -304,7 +304,7 @@ struct Lexer
|
|||||||
TOK inreal(Token *t);
|
TOK inreal(Token *t);
|
||||||
void error(const char *format, ...) IS_PRINTF(2);
|
void error(const char *format, ...) IS_PRINTF(2);
|
||||||
void error(Loc loc, const char *format, ...) IS_PRINTF(3);
|
void error(Loc loc, const char *format, ...) IS_PRINTF(3);
|
||||||
void verror(Loc loc, const char *format, va_list ap);
|
void verror(Loc loc, const char *format, va_list ap);
|
||||||
void pragma();
|
void pragma();
|
||||||
unsigned decodeUTF();
|
unsigned decodeUTF();
|
||||||
void getDocComment(Token *t, unsigned lineComment);
|
void getDocComment(Token *t, unsigned lineComment);
|
||||||
|
|||||||
+449
-449
@@ -1,449 +1,449 @@
|
|||||||
|
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
/* Simple macro text processor.
|
/* Simple macro text processor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "rmem.h"
|
#include "rmem.h"
|
||||||
#include "root.h"
|
#include "root.h"
|
||||||
|
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
|
||||||
#define isidstart(c) (isalpha(c) || (c) == '_')
|
#define isidstart(c) (isalpha(c) || (c) == '_')
|
||||||
#define isidchar(c) (isalnum(c) || (c) == '_')
|
#define isidchar(c) (isalnum(c) || (c) == '_')
|
||||||
|
|
||||||
unsigned char *memdup(unsigned char *p, size_t len)
|
unsigned char *memdup(unsigned char *p, size_t len)
|
||||||
{
|
{
|
||||||
return (unsigned char *)memcpy(mem.malloc(len), p, len);
|
return (unsigned char *)memcpy(mem.malloc(len), p, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro::Macro(unsigned char *name, size_t namelen, unsigned char *text, size_t textlen)
|
Macro::Macro(unsigned char *name, size_t namelen, unsigned char *text, size_t textlen)
|
||||||
{
|
{
|
||||||
next = NULL;
|
next = NULL;
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->namelen = namelen;
|
this->namelen = namelen;
|
||||||
|
|
||||||
this->text = text;
|
this->text = text;
|
||||||
this->textlen = textlen;
|
this->textlen = textlen;
|
||||||
#else
|
#else
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->namelen = namelen;
|
this->namelen = namelen;
|
||||||
|
|
||||||
this->text = text;
|
this->text = text;
|
||||||
this->textlen = textlen;
|
this->textlen = textlen;
|
||||||
#endif
|
#endif
|
||||||
inuse = 0;
|
inuse = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Macro *Macro::search(unsigned char *name, size_t namelen)
|
Macro *Macro::search(unsigned char *name, size_t namelen)
|
||||||
{ Macro *table;
|
{ Macro *table;
|
||||||
|
|
||||||
//printf("Macro::search(%.*s)\n", namelen, name);
|
//printf("Macro::search(%.*s)\n", namelen, name);
|
||||||
for (table = this; table; table = table->next)
|
for (table = this; table; table = table->next)
|
||||||
{
|
{
|
||||||
if (table->namelen == namelen &&
|
if (table->namelen == namelen &&
|
||||||
memcmp(table->name, name, namelen) == 0)
|
memcmp(table->name, name, namelen) == 0)
|
||||||
{
|
{
|
||||||
//printf("\tfound %d\n", table->textlen);
|
//printf("\tfound %d\n", table->textlen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *Macro::define(Macro **ptable, unsigned char *name, size_t namelen, unsigned char *text, size_t textlen)
|
Macro *Macro::define(Macro **ptable, unsigned char *name, size_t namelen, unsigned char *text, size_t textlen)
|
||||||
{
|
{
|
||||||
//printf("Macro::define('%.*s' = '%.*s')\n", namelen, name, textlen, text);
|
//printf("Macro::define('%.*s' = '%.*s')\n", namelen, name, textlen, text);
|
||||||
|
|
||||||
Macro *table;
|
Macro *table;
|
||||||
|
|
||||||
//assert(ptable);
|
//assert(ptable);
|
||||||
for (table = *ptable; table; table = table->next)
|
for (table = *ptable; table; table = table->next)
|
||||||
{
|
{
|
||||||
if (table->namelen == namelen &&
|
if (table->namelen == namelen &&
|
||||||
memcmp(table->name, name, namelen) == 0)
|
memcmp(table->name, name, namelen) == 0)
|
||||||
{
|
{
|
||||||
table->text = text;
|
table->text = text;
|
||||||
table->textlen = textlen;
|
table->textlen = textlen;
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table = new Macro(name, namelen, text, textlen);
|
table = new Macro(name, namelen, text, textlen);
|
||||||
table->next = *ptable;
|
table->next = *ptable;
|
||||||
*ptable = table;
|
*ptable = table;
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************
|
/**********************************************************
|
||||||
* Given buffer p[0..end], extract argument marg[0..marglen].
|
* Given buffer p[0..end], extract argument marg[0..marglen].
|
||||||
* Params:
|
* Params:
|
||||||
* n 0: get entire argument
|
* n 0: get entire argument
|
||||||
* 1..9: get nth argument
|
* 1..9: get nth argument
|
||||||
* -1: get 2nd through end
|
* -1: get 2nd through end
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned extractArgN(unsigned char *p, unsigned end, unsigned char **pmarg, unsigned *pmarglen, int n)
|
unsigned extractArgN(unsigned char *p, unsigned end, unsigned char **pmarg, unsigned *pmarglen, int n)
|
||||||
{
|
{
|
||||||
/* Scan forward for matching right parenthesis.
|
/* Scan forward for matching right parenthesis.
|
||||||
* Nest parentheses.
|
* Nest parentheses.
|
||||||
* Skip over $( and $)
|
* Skip over $( and $)
|
||||||
* Skip over "..." and '...' strings inside HTML tags.
|
* Skip over "..." and '...' strings inside HTML tags.
|
||||||
* Skip over <!-- ... --> comments.
|
* Skip over <!-- ... --> comments.
|
||||||
* Skip over previous macro insertions
|
* Skip over previous macro insertions
|
||||||
* Set marglen.
|
* Set marglen.
|
||||||
*/
|
*/
|
||||||
unsigned parens = 1;
|
unsigned parens = 1;
|
||||||
unsigned char instring = 0;
|
unsigned char instring = 0;
|
||||||
unsigned incomment = 0;
|
unsigned incomment = 0;
|
||||||
unsigned intag = 0;
|
unsigned intag = 0;
|
||||||
unsigned inexp = 0;
|
unsigned inexp = 0;
|
||||||
unsigned argn = 0;
|
unsigned argn = 0;
|
||||||
|
|
||||||
unsigned v = 0;
|
unsigned v = 0;
|
||||||
|
|
||||||
Largstart:
|
Largstart:
|
||||||
#if 1
|
#if 1
|
||||||
// Skip first space, if any, to find the start of the macro argument
|
// Skip first space, if any, to find the start of the macro argument
|
||||||
if (v < end && isspace(p[v]))
|
if (v < end && isspace(p[v]))
|
||||||
v++;
|
v++;
|
||||||
#else
|
#else
|
||||||
// Skip past spaces to find the start of the macro argument
|
// Skip past spaces to find the start of the macro argument
|
||||||
for (; v < end && isspace(p[v]); v++)
|
for (; v < end && isspace(p[v]); v++)
|
||||||
;
|
;
|
||||||
#endif
|
#endif
|
||||||
*pmarg = p + v;
|
*pmarg = p + v;
|
||||||
|
|
||||||
for (; v < end; v++)
|
for (; v < end; v++)
|
||||||
{ unsigned char c = p[v];
|
{ unsigned char c = p[v];
|
||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case ',':
|
case ',':
|
||||||
if (!inexp && !instring && !incomment && parens == 1)
|
if (!inexp && !instring && !incomment && parens == 1)
|
||||||
{
|
{
|
||||||
argn++;
|
argn++;
|
||||||
if (argn == 1 && n == -1)
|
if (argn == 1 && n == -1)
|
||||||
{ v++;
|
{ v++;
|
||||||
goto Largstart;
|
goto Largstart;
|
||||||
}
|
}
|
||||||
if (argn == n)
|
if (argn == n)
|
||||||
break;
|
break;
|
||||||
if (argn + 1 == n)
|
if (argn + 1 == n)
|
||||||
{ v++;
|
{ v++;
|
||||||
goto Largstart;
|
goto Largstart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case '(':
|
case '(':
|
||||||
if (!inexp && !instring && !incomment)
|
if (!inexp && !instring && !incomment)
|
||||||
parens++;
|
parens++;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case ')':
|
case ')':
|
||||||
if (!inexp && !instring && !incomment && --parens == 0)
|
if (!inexp && !instring && !incomment && --parens == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case '"':
|
case '"':
|
||||||
case '\'':
|
case '\'':
|
||||||
if (!inexp && !incomment && intag)
|
if (!inexp && !incomment && intag)
|
||||||
{
|
{
|
||||||
if (c == instring)
|
if (c == instring)
|
||||||
instring = 0;
|
instring = 0;
|
||||||
else if (!instring)
|
else if (!instring)
|
||||||
instring = c;
|
instring = c;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case '<':
|
case '<':
|
||||||
if (!inexp && !instring && !incomment)
|
if (!inexp && !instring && !incomment)
|
||||||
{
|
{
|
||||||
if (v + 6 < end &&
|
if (v + 6 < end &&
|
||||||
p[v + 1] == '!' &&
|
p[v + 1] == '!' &&
|
||||||
p[v + 2] == '-' &&
|
p[v + 2] == '-' &&
|
||||||
p[v + 3] == '-')
|
p[v + 3] == '-')
|
||||||
{
|
{
|
||||||
incomment = 1;
|
incomment = 1;
|
||||||
v += 3;
|
v += 3;
|
||||||
}
|
}
|
||||||
else if (v + 2 < end &&
|
else if (v + 2 < end &&
|
||||||
isalpha(p[v + 1]))
|
isalpha(p[v + 1]))
|
||||||
intag = 1;
|
intag = 1;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case '>':
|
case '>':
|
||||||
if (!inexp)
|
if (!inexp)
|
||||||
intag = 0;
|
intag = 0;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case '-':
|
case '-':
|
||||||
if (!inexp &&
|
if (!inexp &&
|
||||||
!instring &&
|
!instring &&
|
||||||
incomment &&
|
incomment &&
|
||||||
v + 2 < end &&
|
v + 2 < end &&
|
||||||
p[v + 1] == '-' &&
|
p[v + 1] == '-' &&
|
||||||
p[v + 2] == '>')
|
p[v + 2] == '>')
|
||||||
{
|
{
|
||||||
incomment = 0;
|
incomment = 0;
|
||||||
v += 2;
|
v += 2;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 0xFF:
|
case 0xFF:
|
||||||
if (v + 1 < end)
|
if (v + 1 < end)
|
||||||
{
|
{
|
||||||
if (p[v + 1] == '{')
|
if (p[v + 1] == '{')
|
||||||
inexp++;
|
inexp++;
|
||||||
else if (p[v + 1] == '}')
|
else if (p[v + 1] == '}')
|
||||||
inexp--;
|
inexp--;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (argn == 0 && n == -1)
|
if (argn == 0 && n == -1)
|
||||||
*pmarg = p + v;
|
*pmarg = p + v;
|
||||||
*pmarglen = p + v - *pmarg;
|
*pmarglen = p + v - *pmarg;
|
||||||
//printf("extractArg%d('%.*s') = '%.*s'\n", n, end, p, *pmarglen, *pmarg);
|
//printf("extractArg%d('%.*s') = '%.*s'\n", n, end, p, *pmarglen, *pmarg);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* Expand macro in place in buf.
|
* Expand macro in place in buf.
|
||||||
* Only look at the text in buf from start to end.
|
* Only look at the text in buf from start to end.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Macro::expand(OutBuffer *buf, unsigned start, unsigned *pend,
|
void Macro::expand(OutBuffer *buf, unsigned start, unsigned *pend,
|
||||||
unsigned char *arg, unsigned arglen)
|
unsigned char *arg, unsigned arglen)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
printf("Macro::expand(buf[%d..%d], arg = '%.*s')\n", start, *pend, arglen, arg);
|
printf("Macro::expand(buf[%d..%d], arg = '%.*s')\n", start, *pend, arglen, arg);
|
||||||
printf("Buf is: '%.*s'\n", *pend - start, buf->data + start);
|
printf("Buf is: '%.*s'\n", *pend - start, buf->data + start);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int nest;
|
static int nest;
|
||||||
if (nest > 100) // limit recursive expansion
|
if (nest > 100) // limit recursive expansion
|
||||||
return;
|
return;
|
||||||
nest++;
|
nest++;
|
||||||
|
|
||||||
unsigned end = *pend;
|
unsigned end = *pend;
|
||||||
assert(start <= end);
|
assert(start <= end);
|
||||||
assert(end <= buf->offset);
|
assert(end <= buf->offset);
|
||||||
|
|
||||||
/* First pass - replace $0
|
/* First pass - replace $0
|
||||||
*/
|
*/
|
||||||
arg = memdup(arg, arglen);
|
arg = memdup(arg, arglen);
|
||||||
for (unsigned u = start; u + 1 < end; )
|
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.
|
/* Look for $0, but not $$0, and replace it with arg.
|
||||||
*/
|
*/
|
||||||
if (p[u] == '$' && (isdigit(p[u + 1]) || p[u + 1] == '+'))
|
if (p[u] == '$' && (isdigit(p[u + 1]) || p[u + 1] == '+'))
|
||||||
{
|
{
|
||||||
if (u > start && p[u - 1] == '$')
|
if (u > start && p[u - 1] == '$')
|
||||||
{ // Don't expand $$0, but replace it with $0
|
{ // Don't expand $$0, but replace it with $0
|
||||||
buf->remove(u - 1, 1);
|
buf->remove(u - 1, 1);
|
||||||
end--;
|
end--;
|
||||||
u += 1; // now u is one past the closing '1'
|
u += 1; // now u is one past the closing '1'
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char c = p[u + 1];
|
unsigned char c = p[u + 1];
|
||||||
int n = (c == '+') ? -1 : c - '0';
|
int n = (c == '+') ? -1 : c - '0';
|
||||||
|
|
||||||
unsigned char *marg;
|
unsigned char *marg;
|
||||||
unsigned marglen;
|
unsigned marglen;
|
||||||
extractArgN(arg, arglen, &marg, &marglen, n);
|
extractArgN(arg, arglen, &marg, &marglen, n);
|
||||||
if (marglen == 0)
|
if (marglen == 0)
|
||||||
{ // Just remove macro invocation
|
{ // Just remove macro invocation
|
||||||
//printf("Replacing '$%c' with '%.*s'\n", p[u + 1], marglen, marg);
|
//printf("Replacing '$%c' with '%.*s'\n", p[u + 1], marglen, marg);
|
||||||
buf->remove(u, 2);
|
buf->remove(u, 2);
|
||||||
end -= 2;
|
end -= 2;
|
||||||
}
|
}
|
||||||
else if (c == '+')
|
else if (c == '+')
|
||||||
{
|
{
|
||||||
// Replace '$+' with 'arg'
|
// Replace '$+' with 'arg'
|
||||||
//printf("Replacing '$%c' with '%.*s'\n", p[u + 1], marglen, marg);
|
//printf("Replacing '$%c' with '%.*s'\n", p[u + 1], marglen, marg);
|
||||||
buf->remove(u, 2);
|
buf->remove(u, 2);
|
||||||
buf->insert(u, marg, marglen);
|
buf->insert(u, marg, marglen);
|
||||||
end += marglen - 2;
|
end += marglen - 2;
|
||||||
|
|
||||||
// Scan replaced text for further expansion
|
// Scan replaced text for further expansion
|
||||||
unsigned mend = u + marglen;
|
unsigned mend = u + marglen;
|
||||||
expand(buf, u, &mend, NULL, 0);
|
expand(buf, u, &mend, NULL, 0);
|
||||||
end += mend - (u + marglen);
|
end += mend - (u + marglen);
|
||||||
u = mend;
|
u = mend;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Replace '$1' with '\xFF{arg\xFF}'
|
// Replace '$1' with '\xFF{arg\xFF}'
|
||||||
//printf("Replacing '$%c' with '\xFF{%.*s\xFF}'\n", p[u + 1], marglen, marg);
|
//printf("Replacing '$%c' with '\xFF{%.*s\xFF}'\n", p[u + 1], marglen, marg);
|
||||||
buf->data[u] = 0xFF;
|
buf->data[u] = 0xFF;
|
||||||
buf->data[u + 1] = '{';
|
buf->data[u + 1] = '{';
|
||||||
buf->insert(u + 2, marg, marglen);
|
buf->insert(u + 2, marg, marglen);
|
||||||
buf->insert(u + 2 + marglen, "\xFF}", 2);
|
buf->insert(u + 2 + marglen, "\xFF}", 2);
|
||||||
end += -2 + 2 + marglen + 2;
|
end += -2 + 2 + marglen + 2;
|
||||||
|
|
||||||
// Scan replaced text for further expansion
|
// Scan replaced text for further expansion
|
||||||
unsigned mend = u + 2 + marglen;
|
unsigned mend = u + 2 + marglen;
|
||||||
expand(buf, u + 2, &mend, NULL, 0);
|
expand(buf, u + 2, &mend, NULL, 0);
|
||||||
end += mend - (u + 2 + marglen);
|
end += mend - (u + 2 + marglen);
|
||||||
u = mend;
|
u = mend;
|
||||||
}
|
}
|
||||||
//printf("u = %d, end = %d\n", u, end);
|
//printf("u = %d, end = %d\n", u, end);
|
||||||
//printf("#%.*s#\n", end, &buf->data[0]);
|
//printf("#%.*s#\n", end, &buf->data[0]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
u++;
|
u++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Second pass - replace other macros
|
/* Second pass - replace other macros
|
||||||
*/
|
*/
|
||||||
for (unsigned u = start; u + 4 < end; )
|
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
|
/* A valid start of macro expansion is $(c, where c is
|
||||||
* an id start character, and not $$(c.
|
* an id start character, and not $$(c.
|
||||||
*/
|
*/
|
||||||
if (p[u] == '$' && p[u + 1] == '(' && isidstart(p[u + 2]))
|
if (p[u] == '$' && p[u + 1] == '(' && isidstart(p[u + 2]))
|
||||||
{
|
{
|
||||||
//printf("\tfound macro start '%c'\n", p[u + 2]);
|
//printf("\tfound macro start '%c'\n", p[u + 2]);
|
||||||
unsigned char *name = p + u + 2;
|
unsigned char *name = p + u + 2;
|
||||||
unsigned namelen = 0;
|
unsigned namelen = 0;
|
||||||
|
|
||||||
unsigned char *marg;
|
unsigned char *marg;
|
||||||
unsigned marglen;
|
unsigned marglen;
|
||||||
|
|
||||||
unsigned v;
|
unsigned v;
|
||||||
/* Scan forward to find end of macro name and
|
/* Scan forward to find end of macro name and
|
||||||
* beginning of macro argument (marg).
|
* beginning of macro argument (marg).
|
||||||
*/
|
*/
|
||||||
for (v = u + 2; v < end; v++)
|
for (v = u + 2; v < end; v++)
|
||||||
{ unsigned char c = p[v];
|
{ unsigned char c = p[v];
|
||||||
|
|
||||||
if (!isidchar(c))
|
if (!isidchar(c))
|
||||||
{ // We've gone past the end of the macro name.
|
{ // We've gone past the end of the macro name.
|
||||||
namelen = v - (u + 2);
|
namelen = v - (u + 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v += extractArgN(p + v, end - v, &marg, &marglen, 0);
|
v += extractArgN(p + v, end - v, &marg, &marglen, 0);
|
||||||
assert(v <= end);
|
assert(v <= end);
|
||||||
|
|
||||||
if (v < end)
|
if (v < end)
|
||||||
{ // v is on the closing ')'
|
{ // v is on the closing ')'
|
||||||
if (u > start && p[u - 1] == '$')
|
if (u > start && p[u - 1] == '$')
|
||||||
{ // Don't expand $$(NAME), but replace it with $(NAME)
|
{ // Don't expand $$(NAME), but replace it with $(NAME)
|
||||||
buf->remove(u - 1, 1);
|
buf->remove(u - 1, 1);
|
||||||
end--;
|
end--;
|
||||||
u = v; // now u is one past the closing ')'
|
u = v; // now u is one past the closing ')'
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Macro *m = search(name, namelen);
|
Macro *m = search(name, namelen);
|
||||||
if (m)
|
if (m)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
if (m->textlen && m->text[0] == ' ')
|
if (m->textlen && m->text[0] == ' ')
|
||||||
{ m->text++;
|
{ m->text++;
|
||||||
m->textlen--;
|
m->textlen--;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (m->inuse && marglen == 0)
|
if (m->inuse && marglen == 0)
|
||||||
{ // Remove macro invocation
|
{ // Remove macro invocation
|
||||||
buf->remove(u, v + 1 - u);
|
buf->remove(u, v + 1 - u);
|
||||||
end -= v + 1 - u;
|
end -= v + 1 - u;
|
||||||
}
|
}
|
||||||
else if (m->inuse && arglen == marglen && memcmp(arg, marg, arglen) == 0)
|
else if (m->inuse && arglen == marglen && memcmp(arg, marg, arglen) == 0)
|
||||||
{ // Recursive expansion; just leave in place
|
{ // Recursive expansion; just leave in place
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//printf("\tmacro '%.*s'(%.*s) = '%.*s'\n", m->namelen, m->name, marglen, marg, m->textlen, m->text);
|
//printf("\tmacro '%.*s'(%.*s) = '%.*s'\n", m->namelen, m->name, marglen, marg, m->textlen, m->text);
|
||||||
#if 1
|
#if 1
|
||||||
marg = memdup(marg, marglen);
|
marg = memdup(marg, marglen);
|
||||||
// Insert replacement text
|
// Insert replacement text
|
||||||
buf->spread(v + 1, 2 + m->textlen + 2);
|
buf->spread(v + 1, 2 + m->textlen + 2);
|
||||||
buf->data[v + 1] = 0xFF;
|
buf->data[v + 1] = 0xFF;
|
||||||
buf->data[v + 2] = '{';
|
buf->data[v + 2] = '{';
|
||||||
memcpy(buf->data + v + 3, m->text, m->textlen);
|
memcpy(buf->data + v + 3, m->text, m->textlen);
|
||||||
buf->data[v + 3 + m->textlen] = 0xFF;
|
buf->data[v + 3 + m->textlen] = 0xFF;
|
||||||
buf->data[v + 3 + m->textlen + 1] = '}';
|
buf->data[v + 3 + m->textlen + 1] = '}';
|
||||||
|
|
||||||
end += 2 + m->textlen + 2;
|
end += 2 + m->textlen + 2;
|
||||||
|
|
||||||
// Scan replaced text for further expansion
|
// Scan replaced text for further expansion
|
||||||
m->inuse++;
|
m->inuse++;
|
||||||
unsigned mend = v + 1 + 2+m->textlen+2;
|
unsigned mend = v + 1 + 2+m->textlen+2;
|
||||||
expand(buf, v + 1, &mend, marg, marglen);
|
expand(buf, v + 1, &mend, marg, marglen);
|
||||||
end += mend - (v + 1 + 2+m->textlen+2);
|
end += mend - (v + 1 + 2+m->textlen+2);
|
||||||
m->inuse--;
|
m->inuse--;
|
||||||
|
|
||||||
buf->remove(u, v + 1 - u);
|
buf->remove(u, v + 1 - u);
|
||||||
end -= v + 1 - u;
|
end -= v + 1 - u;
|
||||||
u += mend - (v + 1);
|
u += mend - (v + 1);
|
||||||
#else
|
#else
|
||||||
// Insert replacement text
|
// Insert replacement text
|
||||||
buf->insert(v + 1, m->text, m->textlen);
|
buf->insert(v + 1, m->text, m->textlen);
|
||||||
end += m->textlen;
|
end += m->textlen;
|
||||||
|
|
||||||
// Scan replaced text for further expansion
|
// Scan replaced text for further expansion
|
||||||
m->inuse++;
|
m->inuse++;
|
||||||
unsigned mend = v + 1 + m->textlen;
|
unsigned mend = v + 1 + m->textlen;
|
||||||
expand(buf, v + 1, &mend, marg, marglen);
|
expand(buf, v + 1, &mend, marg, marglen);
|
||||||
end += mend - (v + 1 + m->textlen);
|
end += mend - (v + 1 + m->textlen);
|
||||||
m->inuse--;
|
m->inuse--;
|
||||||
|
|
||||||
buf->remove(u, v + 1 - u);
|
buf->remove(u, v + 1 - u);
|
||||||
end -= v + 1 - u;
|
end -= v + 1 - u;
|
||||||
u += mend - (v + 1);
|
u += mend - (v + 1);
|
||||||
#endif
|
#endif
|
||||||
mem.free(marg);
|
mem.free(marg);
|
||||||
//printf("u = %d, end = %d\n", u, end);
|
//printf("u = %d, end = %d\n", u, end);
|
||||||
//printf("#%.*s#\n", end - u, &buf->data[u]);
|
//printf("#%.*s#\n", end - u, &buf->data[u]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Replace $(NAME) with nothing
|
// Replace $(NAME) with nothing
|
||||||
buf->remove(u, v + 1 - u);
|
buf->remove(u, v + 1 - u);
|
||||||
end -= (v + 1 - u);
|
end -= (v + 1 - u);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
u++;
|
u++;
|
||||||
}
|
}
|
||||||
mem.free(arg);
|
mem.free(arg);
|
||||||
*pend = end;
|
*pend = end;
|
||||||
nest--;
|
nest--;
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-45
@@ -1,45 +1,45 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_MACRO_H
|
#ifndef DMD_MACRO_H
|
||||||
#define DMD_MACRO_H 1
|
#define DMD_MACRO_H 1
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "root.h"
|
#include "root.h"
|
||||||
|
|
||||||
|
|
||||||
struct Macro
|
struct Macro
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Macro *next; // next in list
|
Macro *next; // next in list
|
||||||
|
|
||||||
unsigned char *name; // macro name
|
unsigned char *name; // macro name
|
||||||
size_t namelen; // length of macro name
|
size_t namelen; // length of macro name
|
||||||
|
|
||||||
unsigned char *text; // macro replacement text
|
unsigned char *text; // macro replacement text
|
||||||
size_t textlen; // length of 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(unsigned char *name, size_t namelen, unsigned char *text, size_t textlen);
|
||||||
Macro *search(unsigned char *name, size_t namelen);
|
Macro *search(unsigned char *name, size_t namelen);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Macro *define(Macro **ptable, unsigned char *name, size_t namelen, unsigned char *text, size_t textlen);
|
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,
|
void expand(OutBuffer *buf, unsigned start, unsigned *pend,
|
||||||
unsigned char *arg, unsigned arglen);
|
unsigned char *arg, unsigned arglen);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+3
-3
@@ -24,7 +24,7 @@
|
|||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
||||||
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
|
#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS
|
||||||
char *cpp_mangle(Dsymbol *s);
|
char *cpp_mangle(Dsymbol *s);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ char *mangle(Declaration *sthis)
|
|||||||
char *id;
|
char *id;
|
||||||
Dsymbol *s;
|
Dsymbol *s;
|
||||||
|
|
||||||
//printf("::mangle(%s), type %s\n", sthis->toChars(), sthis->type->toChars());
|
//printf("::mangle(%s), type %s\n", sthis->toChars(), sthis->type->toChars());
|
||||||
s = sthis;
|
s = sthis;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -122,7 +122,7 @@ char *Declaration::mangle()
|
|||||||
return ident->toChars();
|
return ident->toChars();
|
||||||
|
|
||||||
case LINKcpp:
|
case LINKcpp:
|
||||||
#if DMDV2 && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
|
#if DMDV2 && (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS)
|
||||||
return cpp_mangle(this);
|
return cpp_mangle(this);
|
||||||
#else
|
#else
|
||||||
// Windows C++ mangling is done by C++ back end
|
// Windows C++ mangling is done by C++ back end
|
||||||
|
|||||||
+79
-79
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2012 by Digital Mars
|
// Copyright (c) 1999-2012 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -36,21 +36,21 @@
|
|||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "json.h"
|
#include "json.h"
|
||||||
|
|
||||||
#if WINDOWS_SEH
|
#if WINDOWS_SEH
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
long __cdecl __ehfilter(LPEXCEPTION_POINTERS ep);
|
long __cdecl __ehfilter(LPEXCEPTION_POINTERS ep);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int response_expand(int *pargc, char ***pargv);
|
int response_expand(int *pargc, char ***pargv);
|
||||||
void browse(const char *url);
|
void browse(const char *url);
|
||||||
void getenv_setargv(const char *envvar, int *pargc, char** *pargv);
|
void getenv_setargv(const char *envvar, int *pargc, char** *pargv);
|
||||||
|
|
||||||
void obj_start(char *srcfile);
|
void obj_start(char *srcfile);
|
||||||
void obj_end(Library *library, File *objfile);
|
void obj_end(Library *library, File *objfile);
|
||||||
|
|
||||||
void printCtfePerformanceStats();
|
void printCtfePerformanceStats();
|
||||||
|
|
||||||
Global global;
|
Global global;
|
||||||
|
|
||||||
Global::Global()
|
Global::Global()
|
||||||
@@ -72,9 +72,9 @@ Global::Global()
|
|||||||
obj_ext_alt = "obj";
|
obj_ext_alt = "obj";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
copyright = "Copyright (c) 1999-2012 by Digital Mars and Tomas Lindquist Olsen";
|
copyright = "Copyright (c) 1999-2012 by Digital Mars and Tomas Lindquist Olsen";
|
||||||
written = "written by Walter Bright and Tomas Lindquist Olsen";
|
written = "written by Walter Bright and Tomas Lindquist Olsen";
|
||||||
version = "v1.073";
|
version = "v1.073";
|
||||||
ldc_version = "LDC trunk";
|
ldc_version = "LDC trunk";
|
||||||
llvm_version = "LLVM 3.0";
|
llvm_version = "LLVM 3.0";
|
||||||
global.structalign = 8;
|
global.structalign = 8;
|
||||||
@@ -87,24 +87,24 @@ Global::Global()
|
|||||||
// may run before this one.
|
// may run before this one.
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Global::startGagging()
|
unsigned Global::startGagging()
|
||||||
{
|
{
|
||||||
++gag;
|
++gag;
|
||||||
return gaggedErrors;
|
return gaggedErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Global::endGagging(unsigned oldGagged)
|
bool Global::endGagging(unsigned oldGagged)
|
||||||
{
|
{
|
||||||
bool anyErrs = (gaggedErrors != oldGagged);
|
bool anyErrs = (gaggedErrors != oldGagged);
|
||||||
--gag;
|
--gag;
|
||||||
// Restore the original state of gagged errors; set total errors
|
// Restore the original state of gagged errors; set total errors
|
||||||
// to be original errors + new ungagged errors.
|
// to be original errors + new ungagged errors.
|
||||||
errors -= (gaggedErrors - oldGagged);
|
errors -= (gaggedErrors - oldGagged);
|
||||||
gaggedErrors = oldGagged;
|
gaggedErrors = oldGagged;
|
||||||
return anyErrs;
|
return anyErrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *Loc::toChars() const
|
char *Loc::toChars() const
|
||||||
{
|
{
|
||||||
OutBuffer buf;
|
OutBuffer buf;
|
||||||
@@ -132,7 +132,7 @@ bool Loc::equals(const Loc& loc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
* Print error message
|
* Print error message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void error(Loc loc, const char *format, ...)
|
void error(Loc loc, const char *format, ...)
|
||||||
@@ -151,18 +151,18 @@ void warning(Loc loc, const char *format, ...)
|
|||||||
va_end( ap );
|
va_end( ap );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************
|
/**************************************
|
||||||
* Print supplementary message about the last error
|
* Print supplementary message about the last error
|
||||||
* Used for backtraces, etc
|
* Used for backtraces, etc
|
||||||
*/
|
*/
|
||||||
void errorSupplemental(Loc loc, const char *format, ...)
|
void errorSupplemental(Loc loc, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
verrorSupplemental(loc, format, ap);
|
verrorSupplemental(loc, format, ap);
|
||||||
va_end( ap );
|
va_end( ap );
|
||||||
}
|
}
|
||||||
|
|
||||||
void verror(Loc loc, const char *format, va_list ap)
|
void verror(Loc loc, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
if (!global.gag)
|
if (!global.gag)
|
||||||
@@ -177,34 +177,34 @@ void verror(Loc loc, const char *format, va_list ap)
|
|||||||
vfprintf(stdmsg, format, ap);
|
vfprintf(stdmsg, format, ap);
|
||||||
fprintf(stdmsg, "\n");
|
fprintf(stdmsg, "\n");
|
||||||
fflush(stdmsg);
|
fflush(stdmsg);
|
||||||
//halt();
|
//halt();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
global.gaggedErrors++;
|
global.gaggedErrors++;
|
||||||
}
|
}
|
||||||
global.errors++;
|
global.errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doesn't increase error count, doesn't print "Error:".
|
// Doesn't increase error count, doesn't print "Error:".
|
||||||
void verrorSupplemental(Loc loc, const char *format, va_list ap)
|
void verrorSupplemental(Loc loc, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
if (!global.gag)
|
if (!global.gag)
|
||||||
{
|
{
|
||||||
fprintf(stdmsg, "%s: ", loc.toChars());
|
fprintf(stdmsg, "%s: ", loc.toChars());
|
||||||
#if _MSC_VER
|
#if _MSC_VER
|
||||||
// MS doesn't recognize %zu format
|
// MS doesn't recognize %zu format
|
||||||
OutBuffer tmp;
|
OutBuffer tmp;
|
||||||
tmp.vprintf(format, ap);
|
tmp.vprintf(format, ap);
|
||||||
fprintf(stdmsg, "%s", tmp.toChars());
|
fprintf(stdmsg, "%s", tmp.toChars());
|
||||||
#else
|
#else
|
||||||
vfprintf(stdmsg, format, ap);
|
vfprintf(stdmsg, format, ap);
|
||||||
#endif
|
#endif
|
||||||
fprintf(stdmsg, "\n");
|
fprintf(stdmsg, "\n");
|
||||||
fflush(stdmsg);
|
fflush(stdmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void vwarning(Loc loc, const char *format, va_list ap)
|
void vwarning(Loc loc, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
if (global.params.warnings && !global.gag)
|
if (global.params.warnings && !global.gag)
|
||||||
@@ -252,7 +252,7 @@ void fatal()
|
|||||||
void halt()
|
void halt()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
*(volatile char*)0=0;
|
*(volatile char*)0=0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,11 +277,11 @@ void getenv_setargv(const char *envvar, int *pargc, char** *pargv)
|
|||||||
env = mem.strdup(env); // create our own writable copy
|
env = mem.strdup(env); // create our own writable copy
|
||||||
|
|
||||||
int argc = *pargc;
|
int argc = *pargc;
|
||||||
Strings *argv = new Strings();
|
Strings *argv = new Strings();
|
||||||
argv->setDim(argc);
|
argv->setDim(argc);
|
||||||
|
|
||||||
size_t argc_left = 0;
|
size_t argc_left = 0;
|
||||||
for (size_t i = 0; i < argc; i++) {
|
for (size_t i = 0; i < argc; i++) {
|
||||||
if (!strcmp((*pargv)[i], "-run") || !strcmp((*pargv)[i], "--run")) {
|
if (!strcmp((*pargv)[i], "-run") || !strcmp((*pargv)[i], "--run")) {
|
||||||
// HACK: set flag to indicate we saw '-run' here
|
// HACK: set flag to indicate we saw '-run' here
|
||||||
global.params.run = true;
|
global.params.run = true;
|
||||||
@@ -299,7 +299,7 @@ void getenv_setargv(const char *envvar, int *pargc, char** *pargv)
|
|||||||
argv->push((char*)"");
|
argv->push((char*)"");
|
||||||
argc++;
|
argc++;
|
||||||
|
|
||||||
size_t j = 1; // leave argv[0] alone
|
size_t j = 1; // leave argv[0] alone
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int wildcard = 1; // do wildcard expansion
|
int wildcard = 1; // do wildcard expansion
|
||||||
@@ -378,5 +378,5 @@ Ldone:
|
|||||||
argv->data[argc++] = (void *)(*pargv)[i];
|
argv->data[argc++] = (void *)(*pargv)[i];
|
||||||
|
|
||||||
*pargc = argc;
|
*pargc = argc;
|
||||||
*pargv = argv->tdata();
|
*pargv = argv->tdata();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -496,10 +496,10 @@ typedef uint64_t StorageClass;
|
|||||||
|
|
||||||
void warning(Loc loc, const char *format, ...) IS_PRINTF(2);
|
void warning(Loc loc, const char *format, ...) IS_PRINTF(2);
|
||||||
void error(Loc loc, const char *format, ...) IS_PRINTF(2);
|
void error(Loc loc, const char *format, ...) IS_PRINTF(2);
|
||||||
void errorSupplemental(Loc loc, const char *format, ...);
|
void errorSupplemental(Loc loc, const char *format, ...);
|
||||||
void verror(Loc loc, const char *format, va_list);
|
void verror(Loc loc, const char *format, va_list);
|
||||||
void vwarning(Loc loc, const char *format, va_list);
|
void vwarning(Loc loc, const char *format, va_list);
|
||||||
void verrorSupplemental(Loc loc, const char *format, va_list);
|
void verrorSupplemental(Loc loc, const char *format, va_list);
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
__attribute__((noreturn))
|
__attribute__((noreturn))
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,51 +1,51 @@
|
|||||||
// Copyright (C) 2000-2001 by Chromium Communications
|
// Copyright (C) 2000-2001 by Chromium Communications
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
|
|
||||||
#ifndef ROOT_MEM_H
|
#ifndef ROOT_MEM_H
|
||||||
#define 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);
|
typedef void (*FINALIZERPROC)(void* pObj, void* pClientData);
|
||||||
|
|
||||||
struct GC; // thread specific allocator
|
struct GC; // thread specific allocator
|
||||||
|
|
||||||
struct Mem
|
struct Mem
|
||||||
{
|
{
|
||||||
GC *gc; // pointer to our thread specific allocator
|
GC *gc; // pointer to our thread specific allocator
|
||||||
Mem() { gc = NULL; }
|
Mem() { gc = NULL; }
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
// Derive from Mem to get these storage allocators instead of global new/delete
|
// Derive from Mem to get these storage allocators instead of global new/delete
|
||||||
void * operator new(size_t m_size);
|
void * operator new(size_t m_size);
|
||||||
void * operator new(size_t m_size, Mem *mem);
|
void * operator new(size_t m_size, Mem *mem);
|
||||||
void * operator new(size_t m_size, GC *gc);
|
void * operator new(size_t m_size, GC *gc);
|
||||||
void operator delete(void *p);
|
void operator delete(void *p);
|
||||||
|
|
||||||
void * operator new[](size_t m_size);
|
void * operator new[](size_t m_size);
|
||||||
void operator delete[](void *p);
|
void operator delete[](void *p);
|
||||||
|
|
||||||
char *strdup(const char *s);
|
char *strdup(const char *s);
|
||||||
void *malloc(size_t size);
|
void *malloc(size_t size);
|
||||||
void *malloc_uncollectable(size_t size);
|
void *malloc_uncollectable(size_t size);
|
||||||
void *calloc(size_t size, size_t n);
|
void *calloc(size_t size, size_t n);
|
||||||
void *realloc(void *p, size_t size);
|
void *realloc(void *p, size_t size);
|
||||||
void free(void *p);
|
void free(void *p);
|
||||||
void free_uncollectable(void *p);
|
void free_uncollectable(void *p);
|
||||||
void *mallocdup(void *o, size_t size);
|
void *mallocdup(void *o, size_t size);
|
||||||
void error();
|
void error();
|
||||||
void check(void *p); // validate pointer
|
void check(void *p); // validate pointer
|
||||||
void fullcollect(); // do full garbage collection
|
void fullcollect(); // do full garbage collection
|
||||||
void fullcollectNoStack(); // do full garbage collection, no scan stack
|
void fullcollectNoStack(); // do full garbage collection, no scan stack
|
||||||
void mark(void *pointer);
|
void mark(void *pointer);
|
||||||
void addroots(char* pStart, char* pEnd);
|
void addroots(char* pStart, char* pEnd);
|
||||||
void removeroots(char* pStart);
|
void removeroots(char* pStart);
|
||||||
void setFinalizer(void* pObj, FINALIZERPROC pFn, void* pClientData);
|
void setFinalizer(void* pObj, FINALIZERPROC pFn, void* pClientData);
|
||||||
void setStackBottom(void *bottom);
|
void setStackBottom(void *bottom);
|
||||||
GC *getThreadGC(); // get apartment allocator for this thread
|
GC *getThreadGC(); // get apartment allocator for this thread
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Mem mem;
|
extern Mem mem;
|
||||||
|
|
||||||
#endif /* ROOT_MEM_H */
|
#endif /* ROOT_MEM_H */
|
||||||
|
|||||||
+13
-13
@@ -726,12 +726,12 @@ void Module::importAll(Scope *prevsc)
|
|||||||
if (scope)
|
if (scope)
|
||||||
return; // already done
|
return; // already done
|
||||||
|
|
||||||
if (isDocFile)
|
if (isDocFile)
|
||||||
{
|
{
|
||||||
error("is a Ddoc file, cannot import it");
|
error("is a Ddoc file, cannot import it");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note that modules get their own scope, from scratch.
|
/* Note that modules get their own scope, from scratch.
|
||||||
* This is so regardless of where in the syntax a module
|
* This is so regardless of where in the syntax a module
|
||||||
* gets imported, it is unaffected by context.
|
* gets imported, it is unaffected by context.
|
||||||
@@ -739,14 +739,14 @@ void Module::importAll(Scope *prevsc)
|
|||||||
*/
|
*/
|
||||||
Scope *sc = Scope::createGlobal(this); // create root scope
|
Scope *sc = Scope::createGlobal(this); // create root scope
|
||||||
|
|
||||||
// Add import of "object", even for the "object" module.
|
// Add import of "object", even for the "object" module.
|
||||||
// If it isn't there, some compiler rewrites, like
|
// If it isn't there, some compiler rewrites, like
|
||||||
// classinst == classinst -> .object.opEquals(classinst, classinst)
|
// classinst == classinst -> .object.opEquals(classinst, classinst)
|
||||||
// would fail inside object.d.
|
// would fail inside object.d.
|
||||||
if (members->dim == 0 || ((*members)[0])->ident != Id::object)
|
if (members->dim == 0 || ((*members)[0])->ident != Id::object)
|
||||||
{
|
{
|
||||||
Import *im = new Import(0, NULL, Id::object, NULL, 0);
|
Import *im = new Import(0, NULL, Id::object, NULL, 0);
|
||||||
members->shift(im);
|
members->shift(im);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!symtab)
|
if (!symtab)
|
||||||
|
|||||||
+18
-18
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -51,7 +51,7 @@ struct Package : ScopeDsymbol
|
|||||||
Package(Identifier *ident);
|
Package(Identifier *ident);
|
||||||
const char *kind();
|
const char *kind();
|
||||||
|
|
||||||
static DsymbolTable *resolve(Identifiers *packages, Dsymbol **pparent, Package **ppkg);
|
static DsymbolTable *resolve(Identifiers *packages, Dsymbol **pparent, Package **ppkg);
|
||||||
|
|
||||||
Package *isPackage() { return this; }
|
Package *isPackage() { return this; }
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ struct Module : Package
|
|||||||
{
|
{
|
||||||
static Module *rootModule;
|
static Module *rootModule;
|
||||||
static DsymbolTable *modules; // symbol table of all modules
|
static DsymbolTable *modules; // symbol table of all modules
|
||||||
static Modules amodules; // array of all modules
|
static Modules amodules; // array of all modules
|
||||||
static Dsymbols deferred; // deferred Dsymbol's needing semantic() run on them
|
static Dsymbols deferred; // deferred Dsymbol's needing semantic() run on them
|
||||||
static unsigned dprogress; // progress resolving the deferred list
|
static unsigned dprogress; // progress resolving the deferred list
|
||||||
static void init();
|
static void init();
|
||||||
|
|
||||||
@@ -104,19 +104,19 @@ struct Module : Package
|
|||||||
// i.e. a module that will be taken all the
|
// i.e. a module that will be taken all the
|
||||||
// way to an object file
|
// way to an object file
|
||||||
|
|
||||||
Dsymbols *decldefs; // top level declarations for this Module
|
Dsymbols *decldefs; // top level declarations for this Module
|
||||||
|
|
||||||
Modules aimports; // all imported modules
|
Modules aimports; // all imported modules
|
||||||
|
|
||||||
ModuleInfoDeclaration *vmoduleinfo;
|
ModuleInfoDeclaration *vmoduleinfo;
|
||||||
|
|
||||||
unsigned debuglevel; // debug level
|
unsigned debuglevel; // debug level
|
||||||
Strings *debugids; // debug identifiers
|
Strings *debugids; // debug identifiers
|
||||||
Strings *debugidsNot; // forward referenced debug identifiers
|
Strings *debugidsNot; // forward referenced debug identifiers
|
||||||
|
|
||||||
unsigned versionlevel; // version level
|
unsigned versionlevel; // version level
|
||||||
Strings *versionids; // version identifiers
|
Strings *versionids; // version identifiers
|
||||||
Strings *versionidsNot; // forward referenced version identifiers
|
Strings *versionidsNot; // forward referenced version identifiers
|
||||||
|
|
||||||
Macro *macrotable; // document comment macros
|
Macro *macrotable; // document comment macros
|
||||||
struct Escape *escapetable; // document comment escapes
|
struct Escape *escapetable; // document comment escapes
|
||||||
@@ -129,7 +129,7 @@ struct Module : Package
|
|||||||
Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen);
|
Module(char *arg, Identifier *ident, int doDocComment, int doHdrGen);
|
||||||
~Module();
|
~Module();
|
||||||
|
|
||||||
static Module *load(Loc loc, Identifiers *packages, Identifier *ident);
|
static Module *load(Loc loc, Identifiers *packages, Identifier *ident);
|
||||||
|
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void toJsonBuffer(OutBuffer *buf);
|
void toJsonBuffer(OutBuffer *buf);
|
||||||
@@ -143,13 +143,13 @@ struct Module : Package
|
|||||||
void parse(); // syntactic parse
|
void parse(); // syntactic parse
|
||||||
#endif
|
#endif
|
||||||
void importAll(Scope *sc);
|
void importAll(Scope *sc);
|
||||||
void semantic(); // semantic analysis
|
void semantic(); // semantic analysis
|
||||||
void semantic2(); // pass 2 semantic analysis
|
void semantic2(); // pass 2 semantic analysis
|
||||||
void semantic3(); // pass 3 semantic analysis
|
void semantic3(); // pass 3 semantic analysis
|
||||||
void inlineScan(); // scan for functions to inline
|
void inlineScan(); // scan for functions to inline
|
||||||
void setHdrfile(); // set hdrfile member
|
void setHdrfile(); // set hdrfile member
|
||||||
void genhdrfile(); // generate D import file
|
void genhdrfile(); // generate D import file
|
||||||
void genobjfile(int multiobj);
|
void genobjfile(int multiobj);
|
||||||
// void gensymfile();
|
// void gensymfile();
|
||||||
void gendocfile();
|
void gendocfile();
|
||||||
int needModuleInfo();
|
int needModuleInfo();
|
||||||
@@ -215,10 +215,10 @@ struct Module : Package
|
|||||||
struct ModuleDeclaration
|
struct ModuleDeclaration
|
||||||
{
|
{
|
||||||
Identifier *id;
|
Identifier *id;
|
||||||
Identifiers *packages; // array of Identifier's representing packages
|
Identifiers *packages; // array of Identifier's representing packages
|
||||||
bool safe;
|
bool safe;
|
||||||
|
|
||||||
ModuleDeclaration(Identifiers *packages, Identifier *id);
|
ModuleDeclaration(Identifiers *packages, Identifier *id);
|
||||||
|
|
||||||
char *toChars();
|
char *toChars();
|
||||||
};
|
};
|
||||||
|
|||||||
+57
-57
@@ -190,7 +190,7 @@ void Type::init(Ir* _sir)
|
|||||||
void Type::init()
|
void Type::init()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
stringtable.init(1543);
|
stringtable.init(1543);
|
||||||
deco_stringtable.init();
|
deco_stringtable.init();
|
||||||
Lexer::initKeywords();
|
Lexer::initKeywords();
|
||||||
|
|
||||||
@@ -1821,7 +1821,7 @@ Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
|||||||
arguments->push(e);
|
arguments->push(e);
|
||||||
// LDC, we don't support the getInternalTypeInfo
|
// LDC, we don't support the getInternalTypeInfo
|
||||||
// optimization arbitrarily, not yet at least...
|
// optimization arbitrarily, not yet at least...
|
||||||
arguments->push(n->getTypeInfo(sc));
|
arguments->push(n->getTypeInfo(sc));
|
||||||
e = new CallExp(e->loc, ec, arguments);
|
e = new CallExp(e->loc, ec, arguments);
|
||||||
e->type = next->arrayOf();
|
e->type = next->arrayOf();
|
||||||
}
|
}
|
||||||
@@ -1950,12 +1950,12 @@ void TypeSArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol
|
|||||||
*pe = (Expression *)o;
|
*pe = (Expression *)o;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (o->dyncast() == DYNCAST_TYPE)
|
if (o->dyncast() == DYNCAST_TYPE)
|
||||||
{
|
{
|
||||||
*ps = NULL;
|
*ps = NULL;
|
||||||
*pt = (Type *)o;
|
*pt = (Type *)o;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new TupleDeclaration which
|
/* Create a new TupleDeclaration which
|
||||||
* is a slice [d..d+1] out of the old one.
|
* is a slice [d..d+1] out of the old one.
|
||||||
@@ -1998,7 +1998,7 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc)
|
|||||||
{ error(loc, "tuple index %ju exceeds %u", d, sd->objects->dim);
|
{ error(loc, "tuple index %ju exceeds %u", d, sd->objects->dim);
|
||||||
return Type::terror;
|
return Type::terror;
|
||||||
}
|
}
|
||||||
Object *o = (*sd->objects)[(size_t)d];
|
Object *o = (*sd->objects)[(size_t)d];
|
||||||
if (o->dyncast() != DYNCAST_TYPE)
|
if (o->dyncast() != DYNCAST_TYPE)
|
||||||
{ error(loc, "%s is not a type", toChars());
|
{ error(loc, "%s is not a type", toChars());
|
||||||
return Type::terror;
|
return Type::terror;
|
||||||
@@ -3160,7 +3160,7 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc)
|
|||||||
Scope *argsc = sc->push();
|
Scope *argsc = sc->push();
|
||||||
argsc->stc = 0; // don't inherit storage class
|
argsc->stc = 0; // don't inherit storage class
|
||||||
argsc->protection = PROTpublic;
|
argsc->protection = PROTpublic;
|
||||||
argsc->func = NULL;
|
argsc->func = NULL;
|
||||||
|
|
||||||
size_t dim = Parameter::dim(tf->parameters);
|
size_t dim = Parameter::dim(tf->parameters);
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
@@ -4751,7 +4751,7 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
|||||||
if (!sym->members)
|
if (!sym->members)
|
||||||
{
|
{
|
||||||
error(e->loc, "struct %s is forward referenced", sym->toChars());
|
error(e->loc, "struct %s is forward referenced", sym->toChars());
|
||||||
return new ErrorExp();
|
return new ErrorExp();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If e.tupleof
|
/* If e.tupleof
|
||||||
@@ -4762,11 +4762,11 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
|||||||
* (e.field0, e.field1, e.field2, ...)
|
* (e.field0, e.field1, e.field2, ...)
|
||||||
*/
|
*/
|
||||||
e = e->semantic(sc); // do this before turning on noaccesscheck
|
e = e->semantic(sc); // do this before turning on noaccesscheck
|
||||||
e->type->size(); // do semantic of type
|
e->type->size(); // do semantic of type
|
||||||
Expressions *exps = new Expressions;
|
Expressions *exps = new Expressions;
|
||||||
exps->reserve(sym->fields.dim);
|
exps->reserve(sym->fields.dim);
|
||||||
for (size_t i = 0; i < sym->fields.dim; i++)
|
for (size_t i = 0; i < sym->fields.dim; i++)
|
||||||
{ VarDeclaration *v = sym->fields[i];
|
{ VarDeclaration *v = sym->fields[i];
|
||||||
Expression *fe = new DotVarExp(e->loc, e, v);
|
Expression *fe = new DotVarExp(e->loc, e, v);
|
||||||
exps->push(fe);
|
exps->push(fe);
|
||||||
}
|
}
|
||||||
@@ -4828,8 +4828,8 @@ L1:
|
|||||||
|
|
||||||
TemplateMixin *tm = s->isTemplateMixin();
|
TemplateMixin *tm = s->isTemplateMixin();
|
||||||
if (tm)
|
if (tm)
|
||||||
{
|
{
|
||||||
Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, tm));
|
Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, tm));
|
||||||
de->type = e->type;
|
de->type = e->type;
|
||||||
return de;
|
return de;
|
||||||
}
|
}
|
||||||
@@ -4858,7 +4858,7 @@ L1:
|
|||||||
return de;
|
return de;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->isImport() || s->isModule() || s->isPackage())
|
if (s->isImport() || s->isModule() || s->isPackage())
|
||||||
{
|
{
|
||||||
e = new DsymbolExp(e->loc, s);
|
e = new DsymbolExp(e->loc, s);
|
||||||
e = e->semantic(sc);
|
e = e->semantic(sc);
|
||||||
@@ -4955,7 +4955,7 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc)
|
|||||||
structelems->setDim(sym->fields.dim);
|
structelems->setDim(sym->fields.dim);
|
||||||
for (size_t j = 0; j < structelems->dim; j++)
|
for (size_t j = 0; j < structelems->dim; j++)
|
||||||
{
|
{
|
||||||
VarDeclaration *vd = sym->fields[j];
|
VarDeclaration *vd = sym->fields[j];
|
||||||
Expression *e;
|
Expression *e;
|
||||||
if (vd->init)
|
if (vd->init)
|
||||||
{ if (vd->init->isVoidInitializer())
|
{ if (vd->init->isVoidInitializer())
|
||||||
@@ -4965,7 +4965,7 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
e = vd->type->defaultInitLiteral();
|
e = vd->type->defaultInitLiteral();
|
||||||
structelems->tdata()[j] = e;
|
structelems->tdata()[j] = e;
|
||||||
}
|
}
|
||||||
StructLiteralExp *structinit = new StructLiteralExp(loc, (StructDeclaration *)sym, structelems);
|
StructLiteralExp *structinit = new StructLiteralExp(loc, (StructDeclaration *)sym, structelems);
|
||||||
// Why doesn't the StructLiteralExp constructor do this, when
|
// Why doesn't the StructLiteralExp constructor do this, when
|
||||||
@@ -5026,7 +5026,7 @@ Type *TypeClass::semantic(Loc loc, Scope *sc)
|
|||||||
//printf("TypeClass::semantic(%s)\n", sym->toChars());
|
//printf("TypeClass::semantic(%s)\n", sym->toChars());
|
||||||
if (deco)
|
if (deco)
|
||||||
return this;
|
return this;
|
||||||
//printf("\t%s\n", merge()->deco);
|
//printf("\t%s\n", merge()->deco);
|
||||||
return merge();
|
return merge();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5090,11 +5090,11 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
|||||||
/* Create a TupleExp
|
/* Create a TupleExp
|
||||||
*/
|
*/
|
||||||
e = e->semantic(sc); // do this before turning on noaccesscheck
|
e = e->semantic(sc); // do this before turning on noaccesscheck
|
||||||
e->type->size(); // do semantic of type
|
e->type->size(); // do semantic of type
|
||||||
Expressions *exps = new Expressions;
|
Expressions *exps = new Expressions;
|
||||||
exps->reserve(sym->fields.dim);
|
exps->reserve(sym->fields.dim);
|
||||||
for (size_t i = 0; i < sym->fields.dim; i++)
|
for (size_t i = 0; i < sym->fields.dim; i++)
|
||||||
{ VarDeclaration *v = sym->fields[i];
|
{ VarDeclaration *v = sym->fields[i];
|
||||||
// Don't include hidden 'this' pointer
|
// Don't include hidden 'this' pointer
|
||||||
if (v->isThisDeclaration())
|
if (v->isThisDeclaration())
|
||||||
continue;
|
continue;
|
||||||
@@ -5114,16 +5114,16 @@ L1:
|
|||||||
if (!s)
|
if (!s)
|
||||||
{
|
{
|
||||||
// See if it's a base class
|
// See if it's a base class
|
||||||
if (Dsymbol *cbase = sym->searchBase(e->loc, ident))
|
if (Dsymbol *cbase = sym->searchBase(e->loc, ident))
|
||||||
{
|
{
|
||||||
e = new DotTypeExp(0, e, cbase);
|
e = new DotTypeExp(0, e, cbase);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ident == Id::classinfo)
|
if (ident == Id::classinfo)
|
||||||
{
|
{
|
||||||
assert(ClassDeclaration::classinfo);
|
assert(ClassDeclaration::classinfo);
|
||||||
Type *t = ClassDeclaration::classinfo->type;
|
Type *t = ClassDeclaration::classinfo->type;
|
||||||
if (e->op == TOKtype || e->op == TOKdottype)
|
if (e->op == TOKtype || e->op == TOKdottype)
|
||||||
{
|
{
|
||||||
/* For type.classinfo, we know the classinfo
|
/* For type.classinfo, we know the classinfo
|
||||||
@@ -5272,8 +5272,8 @@ L1:
|
|||||||
|
|
||||||
TemplateMixin *tm = s->isTemplateMixin();
|
TemplateMixin *tm = s->isTemplateMixin();
|
||||||
if (tm)
|
if (tm)
|
||||||
{
|
{
|
||||||
Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, tm));
|
Expression *de = new DotExp(e->loc, e, new ScopeExp(e->loc, tm));
|
||||||
de->type = e->type;
|
de->type = e->type;
|
||||||
return de;
|
return de;
|
||||||
}
|
}
|
||||||
@@ -5302,20 +5302,20 @@ L1:
|
|||||||
return de;
|
return de;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // shouldn't this be here?
|
#if 0 // shouldn't this be here?
|
||||||
if (s->isImport() || s->isModule() || s->isPackage())
|
if (s->isImport() || s->isModule() || s->isPackage())
|
||||||
{
|
{
|
||||||
e = new DsymbolExp(e->loc, s, 0);
|
e = new DsymbolExp(e->loc, s, 0);
|
||||||
e = e->semantic(sc);
|
e = e->semantic(sc);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Declaration *d = s->isDeclaration();
|
Declaration *d = s->isDeclaration();
|
||||||
if (!d)
|
if (!d)
|
||||||
{
|
{
|
||||||
e->error("%s.%s is not a declaration", e->toChars(), ident->toChars());
|
e->error("%s.%s is not a declaration", e->toChars(), ident->toChars());
|
||||||
return new ErrorExp();
|
return new ErrorExp();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->op == TOKtype)
|
if (e->op == TOKtype)
|
||||||
@@ -5344,7 +5344,7 @@ L1:
|
|||||||
{
|
{
|
||||||
e = new ThisExp(e->loc);
|
e = new ThisExp(e->loc);
|
||||||
e = new DotTypeExp(e->loc, e, cd);
|
e = new DotTypeExp(e->loc, e, cd);
|
||||||
DotVarExp *de = new DotVarExp(e->loc, e, d);
|
DotVarExp *de = new DotVarExp(e->loc, e, d);
|
||||||
e = de->semantic(sc);
|
e = de->semantic(sc);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -5354,10 +5354,10 @@ L1:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Rewrite as:
|
/* Rewrite as:
|
||||||
* this.d
|
* this.d
|
||||||
*/
|
*/
|
||||||
DotVarExp *de = new DotVarExp(e->loc, new ThisExp(e->loc), d);
|
DotVarExp *de = new DotVarExp(e->loc, new ThisExp(e->loc), d);
|
||||||
e = de->semantic(sc);
|
e = de->semantic(sc);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
@@ -5383,7 +5383,7 @@ L1:
|
|||||||
if (d->parent && d->toParent()->isModule())
|
if (d->parent && d->toParent()->isModule())
|
||||||
{
|
{
|
||||||
// (e, d)
|
// (e, d)
|
||||||
VarExp *ve = new VarExp(e->loc, d);
|
VarExp *ve = new VarExp(e->loc, d);
|
||||||
e = new CommaExp(e->loc, e, ve);
|
e = new CommaExp(e->loc, e, ve);
|
||||||
e->type = d->type;
|
e->type = d->type;
|
||||||
return e;
|
return e;
|
||||||
@@ -5423,7 +5423,7 @@ MATCH TypeClass::implicitConvTo(Type *to)
|
|||||||
|
|
||||||
ClassDeclaration *cdto = to->isClassHandle();
|
ClassDeclaration *cdto = to->isClassHandle();
|
||||||
if (cdto && cdto->isBaseOf(sym, NULL))
|
if (cdto && cdto->isBaseOf(sym, NULL))
|
||||||
{ //printf("'to' is base\n");
|
{ //printf("'to' is base\n");
|
||||||
return MATCHconvert;
|
return MATCHconvert;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5755,18 +5755,18 @@ Parameters *Parameter::arraySyntaxCopy(Parameters *args)
|
|||||||
a = new Parameters();
|
a = new Parameters();
|
||||||
a->setDim(args->dim);
|
a->setDim(args->dim);
|
||||||
for (size_t i = 0; i < a->dim; i++)
|
for (size_t i = 0; i < a->dim; i++)
|
||||||
{ Parameter *arg = (*args)[i];
|
{ Parameter *arg = (*args)[i];
|
||||||
|
|
||||||
arg = arg->syntaxCopy();
|
arg = arg->syntaxCopy();
|
||||||
(*a)[i] = arg;
|
(*a)[i] = arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Parameter::argsTypesToChars(Parameters *args, int varargs)
|
char *Parameter::argsTypesToChars(Parameters *args, int varargs)
|
||||||
{
|
{
|
||||||
OutBuffer *buf = new OutBuffer();
|
OutBuffer *buf = new OutBuffer();
|
||||||
|
|
||||||
buf->writeByte('(');
|
buf->writeByte('(');
|
||||||
if (args)
|
if (args)
|
||||||
@@ -5776,7 +5776,7 @@ char *Parameter::argsTypesToChars(Parameters *args, int varargs)
|
|||||||
for (size_t i = 0; i < args->dim; i++)
|
for (size_t i = 0; i < args->dim; i++)
|
||||||
{ if (i)
|
{ if (i)
|
||||||
buf->writeByte(',');
|
buf->writeByte(',');
|
||||||
Parameter *arg = args->tdata()[i];
|
Parameter *arg = args->tdata()[i];
|
||||||
argbuf.reset();
|
argbuf.reset();
|
||||||
arg->type->toCBuffer2(&argbuf, &hgs, 0);
|
arg->type->toCBuffer2(&argbuf, &hgs, 0);
|
||||||
buf->write(&argbuf);
|
buf->write(&argbuf);
|
||||||
@@ -5843,7 +5843,7 @@ void Parameter::argsToDecoBuffer(OutBuffer *buf, Parameters *arguments, bool man
|
|||||||
{
|
{
|
||||||
//printf("Parameter::argsToDecoBuffer()\n");
|
//printf("Parameter::argsToDecoBuffer()\n");
|
||||||
// Write argument types
|
// Write argument types
|
||||||
foreach(arguments, &argsToDecoBufferDg, buf);
|
foreach(arguments, &argsToDecoBufferDg, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
@@ -5861,7 +5861,7 @@ static int isTPLDg(void *ctx, size_t n, Parameter *arg, int)
|
|||||||
int Parameter::isTPL(Parameters *arguments)
|
int Parameter::isTPL(Parameters *arguments)
|
||||||
{
|
{
|
||||||
//printf("Parameter::isTPL()\n");
|
//printf("Parameter::isTPL()\n");
|
||||||
return foreach(arguments, &isTPLDg, NULL);
|
return foreach(arguments, &isTPLDg, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
@@ -5910,7 +5910,7 @@ void Parameter::toDecoBuffer(OutBuffer *buf, bool mangle)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("storageClass = x%llx\n", storageClass & (STCin | STCout | STCref | STClazy));
|
printf("storageClass = x%llx\n", storageClass & (STCin | STCout | STCref | STClazy));
|
||||||
halt();
|
halt();
|
||||||
#endif
|
#endif
|
||||||
assert(0);
|
assert(0);
|
||||||
@@ -5931,7 +5931,7 @@ static int dimDg(void *ctx, size_t n, Parameter *, int)
|
|||||||
size_t Parameter::dim(Parameters *args)
|
size_t Parameter::dim(Parameters *args)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
foreach(args, &dimDg, &n);
|
foreach(args, &dimDg, &n);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5976,9 +5976,9 @@ Parameter *Parameter::getNth(Parameters *args, size_t nth, size_t *pn)
|
|||||||
|
|
||||||
int Parameter::foreach(Parameters *args, Parameter::ForeachDg dg, void *ctx, size_t *pn, int flags)
|
int Parameter::foreach(Parameters *args, Parameter::ForeachDg dg, void *ctx, size_t *pn, int flags)
|
||||||
{
|
{
|
||||||
assert(dg);
|
assert(dg);
|
||||||
if (!args)
|
if (!args)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size_t n = pn ? *pn : 0; // take over index
|
size_t n = pn ? *pn : 0; // take over index
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|||||||
+10
-10
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -170,7 +170,7 @@ struct Type : Object
|
|||||||
#define tboolean tbool // result of boolean expression
|
#define tboolean tbool // result of boolean expression
|
||||||
#define tindex tsize_t // array/ptr index
|
#define tindex tsize_t // array/ptr index
|
||||||
static Type *tvoidptr; // void*
|
static Type *tvoidptr; // void*
|
||||||
static Type *tstring; // immutable(char)[]
|
static Type *tstring; // immutable(char)[]
|
||||||
#define terror basic[Terror] // for error recovery
|
#define terror basic[Terror] // for error recovery
|
||||||
|
|
||||||
#define tsize_t basic[Tsize_t] // matches size_t alias
|
#define tsize_t basic[Tsize_t] // matches size_t alias
|
||||||
@@ -223,7 +223,7 @@ struct Type : Object
|
|||||||
virtual d_uns64 size(Loc loc);
|
virtual d_uns64 size(Loc loc);
|
||||||
virtual unsigned alignsize();
|
virtual unsigned alignsize();
|
||||||
virtual Type *semantic(Loc loc, Scope *sc);
|
virtual Type *semantic(Loc loc, Scope *sc);
|
||||||
Type *trySemantic(Loc loc, Scope *sc);
|
Type *trySemantic(Loc loc, Scope *sc);
|
||||||
// append the mangleof or a string uniquely identifying this type to buf
|
// append the mangleof or a string uniquely identifying this type to buf
|
||||||
virtual void toDecoBuffer(OutBuffer *buf, bool mangle);
|
virtual void toDecoBuffer(OutBuffer *buf, bool mangle);
|
||||||
Type *merge();
|
Type *merge();
|
||||||
@@ -510,7 +510,7 @@ struct TypeFunction : Type
|
|||||||
Type *semantic(Loc loc, Scope *sc);
|
Type *semantic(Loc loc, Scope *sc);
|
||||||
void toDecoBuffer(OutBuffer *buf, bool mangle);
|
void toDecoBuffer(OutBuffer *buf, bool mangle);
|
||||||
void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
|
||||||
void toCBufferWithAttributes(OutBuffer *buf, Identifier *ident, HdrGenState* hgs, TypeFunction *attrs, TemplateDeclaration *td);
|
void toCBufferWithAttributes(OutBuffer *buf, Identifier *ident, HdrGenState* hgs, TypeFunction *attrs, TemplateDeclaration *td);
|
||||||
void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
|
void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
|
||||||
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
|
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
|
||||||
TypeInfoDeclaration *getTypeInfoDeclaration();
|
TypeInfoDeclaration *getTypeInfoDeclaration();
|
||||||
@@ -531,8 +531,8 @@ struct TypeFunction : Type
|
|||||||
|
|
||||||
FuncDeclaration* funcdecl;
|
FuncDeclaration* funcdecl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Expression *defaultInit(Loc loc);
|
Expression *defaultInit(Loc loc);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TypeDelegate : Type
|
struct TypeDelegate : Type
|
||||||
@@ -558,7 +558,7 @@ struct TypeDelegate : Type
|
|||||||
struct TypeQualified : Type
|
struct TypeQualified : Type
|
||||||
{
|
{
|
||||||
Loc loc;
|
Loc loc;
|
||||||
Identifiers idents; // array of Identifier's representing ident.ident.ident etc.
|
Identifiers idents; // array of Identifier's representing ident.ident.ident etc.
|
||||||
|
|
||||||
TypeQualified(TY ty, Loc loc);
|
TypeQualified(TY ty, Loc loc);
|
||||||
void syntaxCopyHelper(TypeQualified *t);
|
void syntaxCopyHelper(TypeQualified *t);
|
||||||
@@ -820,9 +820,9 @@ struct Parameter : Object
|
|||||||
static int isTPL(Parameters *arguments);
|
static int isTPL(Parameters *arguments);
|
||||||
static size_t dim(Parameters *arguments);
|
static size_t dim(Parameters *arguments);
|
||||||
static Parameter *getNth(Parameters *arguments, size_t nth, size_t *pn = NULL);
|
static Parameter *getNth(Parameters *arguments, size_t nth, size_t *pn = NULL);
|
||||||
|
|
||||||
typedef int (*ForeachDg)(void *ctx, size_t paramidx, Parameter *param, int flags);
|
typedef int (*ForeachDg)(void *ctx, size_t paramidx, Parameter *param, int flags);
|
||||||
static int foreach(Parameters *args, ForeachDg dg, void *ctx, size_t *pn=NULL, int flags = 0);
|
static int foreach(Parameters *args, ForeachDg dg, void *ctx, size_t *pn=NULL, int flags = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int PTRSIZE;
|
extern int PTRSIZE;
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
|
|||||||
+77
-77
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2012 by Digital Mars
|
// Copyright (c) 1999-2012 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -40,7 +40,7 @@ static real_t zero; // work around DMC bug for now
|
|||||||
* return that initializer.
|
* return that initializer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Expression *fromConstInitializer(int result, Expression *e1)
|
Expression *fromConstInitializer(int result, Expression *e1)
|
||||||
{
|
{
|
||||||
//printf("fromConstInitializer(%s)\n", e1->toChars());
|
//printf("fromConstInitializer(%s)\n", e1->toChars());
|
||||||
if (e1->op == TOKvar)
|
if (e1->op == TOKvar)
|
||||||
@@ -48,13 +48,13 @@ Expression *fromConstInitializer(int result, Expression *e1)
|
|||||||
VarDeclaration *v = ve->var->isVarDeclaration();
|
VarDeclaration *v = ve->var->isVarDeclaration();
|
||||||
if (v && !v->originalType && v->scope) // semantic() not yet run
|
if (v && !v->originalType && v->scope) // semantic() not yet run
|
||||||
v->semantic (v->scope);
|
v->semantic (v->scope);
|
||||||
if (!v || !v->type)
|
if (!v || !v->type)
|
||||||
return e1;
|
return e1;
|
||||||
Type * tb = v->type->toBasetype();
|
Type * tb = v->type->toBasetype();
|
||||||
if (v->isConst() && v->init
|
if (v->isConst() && v->init
|
||||||
&& (result & WANTinterpret || (tb->isscalar() ||
|
&& (result & WANTinterpret || (tb->isscalar() ||
|
||||||
((result & WANTexpand) && (tb->ty != Tsarray && tb->ty != Tstruct))))
|
((result & WANTexpand) && (tb->ty != Tsarray && tb->ty != Tstruct))))
|
||||||
)
|
)
|
||||||
{ Expression *ei = v->init->toExpression();
|
{ Expression *ei = v->init->toExpression();
|
||||||
if (ei && ei->type)
|
if (ei && ei->type)
|
||||||
e1 = ei;
|
e1 = ei;
|
||||||
@@ -72,7 +72,7 @@ Expression *Expression::optimize(int result)
|
|||||||
|
|
||||||
Expression *VarExp::optimize(int result)
|
Expression *VarExp::optimize(int result)
|
||||||
{
|
{
|
||||||
return fromConstInitializer(result, this);
|
return fromConstInitializer(result, this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,11 +122,11 @@ Expression *StructLiteralExp::optimize(int result)
|
|||||||
if (elements)
|
if (elements)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < elements->dim; i++)
|
for (size_t i = 0; i < elements->dim; i++)
|
||||||
{ Expression *e = (*elements)[i];
|
{ Expression *e = (*elements)[i];
|
||||||
if (!e)
|
if (!e)
|
||||||
continue;
|
continue;
|
||||||
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
e = e->optimize(WANTvalue | (result & WANTinterpret));
|
||||||
(*elements)[i] = e;
|
(*elements)[i] = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -329,20 +329,20 @@ Expression *NewExp::optimize(int result)
|
|||||||
if (newargs)
|
if (newargs)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < newargs->dim; i++)
|
for (size_t i = 0; i < newargs->dim; i++)
|
||||||
{ Expression *e = newargs->tdata()[i];
|
{ Expression *e = newargs->tdata()[i];
|
||||||
|
|
||||||
e = e->optimize(WANTvalue);
|
e = e->optimize(WANTvalue);
|
||||||
newargs->tdata()[i] = e;
|
newargs->tdata()[i] = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments)
|
if (arguments)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < arguments->dim; i++)
|
for (size_t i = 0; i < arguments->dim; i++)
|
||||||
{ Expression *e = arguments->tdata()[i];
|
{ Expression *e = arguments->tdata()[i];
|
||||||
|
|
||||||
e = e->optimize(WANTvalue);
|
e = e->optimize(WANTvalue);
|
||||||
arguments->tdata()[i] = e;
|
arguments->tdata()[i] = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -357,10 +357,10 @@ Expression *CallExp::optimize(int result)
|
|||||||
if (arguments)
|
if (arguments)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < arguments->dim; i++)
|
for (size_t i = 0; i < arguments->dim; i++)
|
||||||
{ Expression *e = arguments->tdata()[i];
|
{ Expression *e = arguments->tdata()[i];
|
||||||
|
|
||||||
e = e->optimize(WANTvalue);
|
e = e->optimize(WANTvalue);
|
||||||
arguments->tdata()[i] = e;
|
arguments->tdata()[i] = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ Expression *CastExp::optimize(int result)
|
|||||||
|
|
||||||
e1 = e1->optimize(result);
|
e1 = e1->optimize(result);
|
||||||
if (result & WANTinterpret)
|
if (result & WANTinterpret)
|
||||||
e1 = fromConstInitializer(result, e1);
|
e1 = fromConstInitializer(result, e1);
|
||||||
|
|
||||||
if ((e1->op == TOKstring || e1->op == TOKarrayliteral) &&
|
if ((e1->op == TOKstring || e1->op == TOKarrayliteral) &&
|
||||||
(type->ty == Tpointer || type->ty == Tarray) &&
|
(type->ty == Tpointer || type->ty == Tarray) &&
|
||||||
@@ -466,8 +466,8 @@ Expression *BinExp::optimize(int result)
|
|||||||
{
|
{
|
||||||
dinteger_t i2 = e2->toInteger();
|
dinteger_t i2 = e2->toInteger();
|
||||||
d_uns64 sz = e1->type->size() * 8;
|
d_uns64 sz = e1->type->size() * 8;
|
||||||
if (i2 < 0 || i2 >= sz)
|
if (i2 < 0 || i2 >= sz)
|
||||||
{ error("shift assign by %jd is outside the range 0..%zu", i2, sz - 1);
|
{ error("shift assign by %jd is outside the range 0..%zu", i2, sz - 1);
|
||||||
e2 = new IntegerExp(0);
|
e2 = new IntegerExp(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -561,8 +561,8 @@ Expression *shift_optimize(int result, BinExp *e, Expression *(*shift)(Type *, E
|
|||||||
{
|
{
|
||||||
dinteger_t i2 = e->e2->toInteger();
|
dinteger_t i2 = e->e2->toInteger();
|
||||||
d_uns64 sz = e->e1->type->size() * 8;
|
d_uns64 sz = e->e1->type->size() * 8;
|
||||||
if (i2 < 0 || i2 >= sz)
|
if (i2 < 0 || i2 >= sz)
|
||||||
{ e->error("shift by %jd is outside the range 0..%zu", i2, sz - 1);
|
{ e->error("shift by %jd is outside the range 0..%zu", i2, sz - 1);
|
||||||
e->e2 = new IntegerExp(0);
|
e->e2 = new IntegerExp(0);
|
||||||
}
|
}
|
||||||
if (e->e1->isConst() == 1)
|
if (e->e1->isConst() == 1)
|
||||||
@@ -644,7 +644,7 @@ Expression *CommaExp::optimize(int result)
|
|||||||
|
|
||||||
e1 = e1->optimize(result & WANTinterpret);
|
e1 = e1->optimize(result & WANTinterpret);
|
||||||
e2 = e2->optimize(result);
|
e2 = e2->optimize(result);
|
||||||
if (!e1 || e1->op == TOKint64 || e1->op == TOKfloat64 || !e1->hasSideEffect())
|
if (!e1 || e1->op == TOKint64 || e1->op == TOKfloat64 || !e1->hasSideEffect())
|
||||||
{
|
{
|
||||||
e = e2;
|
e = e2;
|
||||||
if (e)
|
if (e)
|
||||||
@@ -660,7 +660,7 @@ Expression *ArrayLengthExp::optimize(int result)
|
|||||||
{ Expression *e;
|
{ Expression *e;
|
||||||
|
|
||||||
//printf("ArrayLengthExp::optimize(result = %d) %s\n", result, toChars());
|
//printf("ArrayLengthExp::optimize(result = %d) %s\n", result, toChars());
|
||||||
e1 = e1->optimize(WANTvalue | WANTexpand | (result & WANTinterpret));
|
e1 = e1->optimize(WANTvalue | WANTexpand | (result & WANTinterpret));
|
||||||
e = this;
|
e = this;
|
||||||
if (e1->op == TOKstring || e1->op == TOKarrayliteral || e1->op == TOKassocarrayliteral)
|
if (e1->op == TOKstring || e1->op == TOKarrayliteral || e1->op == TOKassocarrayliteral)
|
||||||
{
|
{
|
||||||
@@ -677,8 +677,8 @@ Expression *EqualExp::optimize(int result)
|
|||||||
e2 = e2->optimize(WANTvalue | (result & WANTinterpret));
|
e2 = e2->optimize(WANTvalue | (result & WANTinterpret));
|
||||||
e = this;
|
e = this;
|
||||||
|
|
||||||
Expression *e1 = fromConstInitializer(result, this->e1);
|
Expression *e1 = fromConstInitializer(result, this->e1);
|
||||||
Expression *e2 = fromConstInitializer(result, this->e2);
|
Expression *e2 = fromConstInitializer(result, this->e2);
|
||||||
|
|
||||||
e = Equal(op, type, e1, e2);
|
e = Equal(op, type, e1, e2);
|
||||||
if (e == EXP_CANT_INTERPRET)
|
if (e == EXP_CANT_INTERPRET)
|
||||||
@@ -703,40 +703,40 @@ Expression *IdentityExp::optimize(int result)
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* It is possible for constant folding to change an array expression of
|
/* It is possible for constant folding to change an array expression of
|
||||||
* unknown length, into one where the length is known.
|
* unknown length, into one where the length is known.
|
||||||
* If the expression 'arr' is a literal, set lengthVar to be its length.
|
* If the expression 'arr' is a literal, set lengthVar to be its length.
|
||||||
*/
|
*/
|
||||||
void setLengthVarIfKnown(VarDeclaration *lengthVar, Expression *arr)
|
void setLengthVarIfKnown(VarDeclaration *lengthVar, Expression *arr)
|
||||||
{
|
{
|
||||||
if (!lengthVar)
|
if (!lengthVar)
|
||||||
return;
|
return;
|
||||||
if (lengthVar->init && !lengthVar->init->isVoidInitializer())
|
if (lengthVar->init && !lengthVar->init->isVoidInitializer())
|
||||||
return; // we have previously calculated the length
|
return; // we have previously calculated the length
|
||||||
size_t len;
|
size_t len;
|
||||||
if (arr->op == TOKstring)
|
if (arr->op == TOKstring)
|
||||||
len = ((StringExp *)arr)->len;
|
len = ((StringExp *)arr)->len;
|
||||||
else if (arr->op == TOKarrayliteral)
|
else if (arr->op == TOKarrayliteral)
|
||||||
len = ((ArrayLiteralExp *)arr)->elements->dim;
|
len = ((ArrayLiteralExp *)arr)->elements->dim;
|
||||||
else
|
else
|
||||||
return; // we don't know the length yet
|
return; // we don't know the length yet
|
||||||
|
|
||||||
Expression *dollar = new IntegerExp(0, len, Type::tsize_t);
|
Expression *dollar = new IntegerExp(0, len, Type::tsize_t);
|
||||||
lengthVar->init = new ExpInitializer(0, dollar);
|
lengthVar->init = new ExpInitializer(0, dollar);
|
||||||
lengthVar->storage_class |= STCstatic | STCconst;
|
lengthVar->storage_class |= STCstatic | STCconst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Expression *IndexExp::optimize(int result)
|
Expression *IndexExp::optimize(int result)
|
||||||
{ Expression *e;
|
{ Expression *e;
|
||||||
|
|
||||||
//printf("IndexExp::optimize(result = %d) %s\n", result, toChars());
|
//printf("IndexExp::optimize(result = %d) %s\n", result, toChars());
|
||||||
Expression *e1 = this->e1->optimize(WANTvalue | (result & WANTinterpret));
|
Expression *e1 = this->e1->optimize(WANTvalue | (result & WANTinterpret));
|
||||||
if (result & WANTinterpret)
|
if (result & WANTinterpret)
|
||||||
e1 = fromConstInitializer(result, e1);
|
e1 = fromConstInitializer(result, e1);
|
||||||
// We might know $ now
|
// We might know $ now
|
||||||
setLengthVarIfKnown(lengthVar, e1);
|
setLengthVarIfKnown(lengthVar, e1);
|
||||||
e2 = e2->optimize(WANTvalue | (result & WANTinterpret));
|
e2 = e2->optimize(WANTvalue | (result & WANTinterpret));
|
||||||
e = Index(type, e1, e2);
|
e = Index(type, e1, e2);
|
||||||
if (e == EXP_CANT_INTERPRET)
|
if (e == EXP_CANT_INTERPRET)
|
||||||
@@ -744,7 +744,7 @@ Expression *IndexExp::optimize(int result)
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Expression *SliceExp::optimize(int result)
|
Expression *SliceExp::optimize(int result)
|
||||||
{ Expression *e;
|
{ Expression *e;
|
||||||
|
|
||||||
@@ -761,15 +761,15 @@ Expression *SliceExp::optimize(int result)
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
if (result & WANTinterpret)
|
if (result & WANTinterpret)
|
||||||
e1 = fromConstInitializer(result, e1);
|
e1 = fromConstInitializer(result, e1);
|
||||||
// We might know $ now
|
// We might know $ now
|
||||||
setLengthVarIfKnown(lengthVar, e1);
|
setLengthVarIfKnown(lengthVar, e1);
|
||||||
lwr = lwr->optimize(WANTvalue | (result & WANTinterpret));
|
lwr = lwr->optimize(WANTvalue | (result & WANTinterpret));
|
||||||
upr = upr->optimize(WANTvalue | (result & WANTinterpret));
|
upr = upr->optimize(WANTvalue | (result & WANTinterpret));
|
||||||
e = Slice(type, e1, lwr, upr);
|
e = Slice(type, e1, lwr, upr);
|
||||||
if (e == EXP_CANT_INTERPRET)
|
if (e == EXP_CANT_INTERPRET)
|
||||||
e = this;
|
e = this;
|
||||||
//printf("-SliceExp::optimize() %s\n", e->toChars());
|
//printf("-SliceExp::optimize() %s\n", e->toChars());
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -781,12 +781,12 @@ Expression *AndAndExp::optimize(int result)
|
|||||||
e = this;
|
e = this;
|
||||||
if (e1->isBool(FALSE))
|
if (e1->isBool(FALSE))
|
||||||
{
|
{
|
||||||
if (type->toBasetype()->ty == Tvoid)
|
if (type->toBasetype()->ty == Tvoid)
|
||||||
e = e2;
|
e = e2;
|
||||||
else
|
else
|
||||||
{ e = new CommaExp(loc, e1, new IntegerExp(loc, 0, type));
|
{ e = new CommaExp(loc, e1, new IntegerExp(loc, 0, type));
|
||||||
e->type = type;
|
e->type = type;
|
||||||
}
|
}
|
||||||
e = e->optimize(result);
|
e = e->optimize(result);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -803,11 +803,11 @@ Expression *AndAndExp::optimize(int result)
|
|||||||
e = new IntegerExp(loc, n1 && n2, type);
|
e = new IntegerExp(loc, n1 && n2, type);
|
||||||
}
|
}
|
||||||
else if (e1->isBool(TRUE))
|
else if (e1->isBool(TRUE))
|
||||||
{
|
{
|
||||||
if (type->toBasetype()->ty == Tvoid)
|
if (type->toBasetype()->ty == Tvoid)
|
||||||
e = e2;
|
e = e2;
|
||||||
else e = new BoolExp(loc, e2, type);
|
else e = new BoolExp(loc, e2, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
@@ -838,12 +838,12 @@ Expression *OrOrExp::optimize(int result)
|
|||||||
e = new IntegerExp(loc, n1 || n2, type);
|
e = new IntegerExp(loc, n1 || n2, type);
|
||||||
}
|
}
|
||||||
else if (e1->isBool(FALSE))
|
else if (e1->isBool(FALSE))
|
||||||
{
|
{
|
||||||
if (type->toBasetype()->ty == Tvoid)
|
if (type->toBasetype()->ty == Tvoid)
|
||||||
e = e2;
|
e = e2;
|
||||||
else
|
else
|
||||||
e = new BoolExp(loc, e2, type);
|
e = new BoolExp(loc, e2, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
|
|||||||
+130
-130
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -68,9 +68,9 @@ Parser::Parser(Module *module, unsigned char *base, unsigned length, int doDocCo
|
|||||||
//nextToken(); // start up the scanner
|
//nextToken(); // start up the scanner
|
||||||
}
|
}
|
||||||
|
|
||||||
Dsymbols *Parser::parseModule()
|
Dsymbols *Parser::parseModule()
|
||||||
{
|
{
|
||||||
Dsymbols *decldefs;
|
Dsymbols *decldefs;
|
||||||
|
|
||||||
// ModuleDeclation leads off
|
// ModuleDeclation leads off
|
||||||
if (token.value == TOKmodule)
|
if (token.value == TOKmodule)
|
||||||
@@ -103,14 +103,14 @@ Dsymbols *Parser::parseModule()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Identifiers *a = NULL;
|
Identifiers *a = NULL;
|
||||||
Identifier *id;
|
Identifier *id;
|
||||||
|
|
||||||
id = token.ident;
|
id = token.ident;
|
||||||
while (nextToken() == TOKdot)
|
while (nextToken() == TOKdot)
|
||||||
{
|
{
|
||||||
if (!a)
|
if (!a)
|
||||||
a = new Identifiers();
|
a = new Identifiers();
|
||||||
a->push(id);
|
a->push(id);
|
||||||
nextToken();
|
nextToken();
|
||||||
if (token.value != TOKidentifier)
|
if (token.value != TOKidentifier)
|
||||||
@@ -138,21 +138,21 @@ Lerr:
|
|||||||
while (token.value != TOKsemicolon && token.value != TOKeof)
|
while (token.value != TOKsemicolon && token.value != TOKeof)
|
||||||
nextToken();
|
nextToken();
|
||||||
nextToken();
|
nextToken();
|
||||||
return new Dsymbols();
|
return new Dsymbols();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dsymbols *Parser::parseDeclDefs(int once)
|
Dsymbols *Parser::parseDeclDefs(int once)
|
||||||
{ Dsymbol *s;
|
{ Dsymbol *s;
|
||||||
Dsymbols *decldefs;
|
Dsymbols *decldefs;
|
||||||
Dsymbols *a;
|
Dsymbols *a;
|
||||||
Dsymbols *aelse;
|
Dsymbols *aelse;
|
||||||
enum PROT prot;
|
enum PROT prot;
|
||||||
StorageClass stc;
|
StorageClass stc;
|
||||||
Condition *condition;
|
Condition *condition;
|
||||||
unsigned char *comment;
|
unsigned char *comment;
|
||||||
|
|
||||||
//printf("Parser::parseDeclDefs()\n");
|
//printf("Parser::parseDeclDefs()\n");
|
||||||
decldefs = new Dsymbols();
|
decldefs = new Dsymbols();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
comment = token.blockComment;
|
comment = token.blockComment;
|
||||||
@@ -396,10 +396,10 @@ Dsymbols *Parser::parseDeclDefs(int once)
|
|||||||
if (token.value == TOKlparen)
|
if (token.value == TOKlparen)
|
||||||
{
|
{
|
||||||
nextToken();
|
nextToken();
|
||||||
if (token.value == TOKint32v && token.uns64value > 0)
|
if (token.value == TOKint32v && token.uns64value > 0)
|
||||||
n = (unsigned)token.uns64value;
|
n = (unsigned)token.uns64value;
|
||||||
else
|
else
|
||||||
{ error("positive integer expected, not %s", token.toChars());
|
{ error("positive integer expected, not %s", token.toChars());
|
||||||
n = 1;
|
n = 1;
|
||||||
}
|
}
|
||||||
nextToken();
|
nextToken();
|
||||||
@@ -445,7 +445,7 @@ Dsymbols *Parser::parseDeclDefs(int once)
|
|||||||
nextToken();
|
nextToken();
|
||||||
if (token.value == TOKidentifier)
|
if (token.value == TOKidentifier)
|
||||||
s = new DebugSymbol(loc, token.ident);
|
s = new DebugSymbol(loc, token.ident);
|
||||||
else if (token.value == TOKint32v || token.value == TOKint64v)
|
else if (token.value == TOKint32v || token.value == TOKint64v)
|
||||||
s = new DebugSymbol(loc, (unsigned)token.uns64value);
|
s = new DebugSymbol(loc, (unsigned)token.uns64value);
|
||||||
else
|
else
|
||||||
{ error("identifier or integer expected, not %s", token.toChars());
|
{ error("identifier or integer expected, not %s", token.toChars());
|
||||||
@@ -466,7 +466,7 @@ Dsymbols *Parser::parseDeclDefs(int once)
|
|||||||
nextToken();
|
nextToken();
|
||||||
if (token.value == TOKidentifier)
|
if (token.value == TOKidentifier)
|
||||||
s = new VersionSymbol(loc, token.ident);
|
s = new VersionSymbol(loc, token.ident);
|
||||||
else if (token.value == TOKint32v || token.value == TOKint64v)
|
else if (token.value == TOKint32v || token.value == TOKint64v)
|
||||||
s = new VersionSymbol(loc, (unsigned)token.uns64value);
|
s = new VersionSymbol(loc, (unsigned)token.uns64value);
|
||||||
else
|
else
|
||||||
{ error("identifier or integer expected, not %s", token.toChars());
|
{ error("identifier or integer expected, not %s", token.toChars());
|
||||||
@@ -528,43 +528,43 @@ void Parser::composeStorageClass(StorageClass stc)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/***********************************************
|
/***********************************************
|
||||||
* Parse storage class, lexer is on '@'
|
* Parse storage class, lexer is on '@'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
StorageClass Parser::parseAttribute()
|
StorageClass Parser::parseAttribute()
|
||||||
{
|
{
|
||||||
nextToken();
|
nextToken();
|
||||||
StorageClass stc = 0;
|
StorageClass stc = 0;
|
||||||
if (token.value != TOKidentifier)
|
if (token.value != TOKidentifier)
|
||||||
{
|
{
|
||||||
error("identifier expected after @, not %s", token.toChars());
|
error("identifier expected after @, not %s", token.toChars());
|
||||||
}
|
}
|
||||||
else if (token.ident == Id::property)
|
else if (token.ident == Id::property)
|
||||||
stc = STCproperty;
|
stc = STCproperty;
|
||||||
else if (token.ident == Id::safe)
|
else if (token.ident == Id::safe)
|
||||||
stc = STCsafe;
|
stc = STCsafe;
|
||||||
else if (token.ident == Id::trusted)
|
else if (token.ident == Id::trusted)
|
||||||
stc = STCtrusted;
|
stc = STCtrusted;
|
||||||
else if (token.ident == Id::system)
|
else if (token.ident == Id::system)
|
||||||
stc = STCsystem;
|
stc = STCsystem;
|
||||||
else if (token.ident == Id::disable)
|
else if (token.ident == Id::disable)
|
||||||
stc = STCdisable;
|
stc = STCdisable;
|
||||||
else
|
else
|
||||||
error("valid attribute identifiers are @property, @safe, @trusted, @system, @disable not @%s", token.toChars());
|
error("valid attribute identifiers are @property, @safe, @trusted, @system, @disable not @%s", token.toChars());
|
||||||
return stc;
|
return stc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/********************************************
|
/********************************************
|
||||||
* Parse declarations after an align, protection, or extern decl.
|
* Parse declarations after an align, protection, or extern decl.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Dsymbols *Parser::parseBlock()
|
Dsymbols *Parser::parseBlock()
|
||||||
{
|
{
|
||||||
Dsymbols *a = NULL;
|
Dsymbols *a = NULL;
|
||||||
|
|
||||||
//printf("parseBlock()\n");
|
//printf("parseBlock()\n");
|
||||||
switch (token.value)
|
switch (token.value)
|
||||||
@@ -721,7 +721,7 @@ Condition *Parser::parseDebugCondition()
|
|||||||
|
|
||||||
if (token.value == TOKidentifier)
|
if (token.value == TOKidentifier)
|
||||||
id = token.ident;
|
id = token.ident;
|
||||||
else if (token.value == TOKint32v || token.value == TOKint64v)
|
else if (token.value == TOKint32v || token.value == TOKint64v)
|
||||||
level = (unsigned)token.uns64value;
|
level = (unsigned)token.uns64value;
|
||||||
else
|
else
|
||||||
error("identifier or integer expected, not %s", token.toChars());
|
error("identifier or integer expected, not %s", token.toChars());
|
||||||
@@ -750,7 +750,7 @@ Condition *Parser::parseVersionCondition()
|
|||||||
nextToken();
|
nextToken();
|
||||||
if (token.value == TOKidentifier)
|
if (token.value == TOKidentifier)
|
||||||
id = token.ident;
|
id = token.ident;
|
||||||
else if (token.value == TOKint32v || token.value == TOKint64v)
|
else if (token.value == TOKint32v || token.value == TOKint64v)
|
||||||
level = (unsigned)token.uns64value;
|
level = (unsigned)token.uns64value;
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
/* Allow:
|
/* Allow:
|
||||||
@@ -1137,7 +1137,7 @@ EnumDeclaration *Parser::parseEnum()
|
|||||||
else if (token.value == TOKlcurly)
|
else if (token.value == TOKlcurly)
|
||||||
{
|
{
|
||||||
//printf("enum definition\n");
|
//printf("enum definition\n");
|
||||||
e->members = new Dsymbols();
|
e->members = new Dsymbols();
|
||||||
nextToken();
|
nextToken();
|
||||||
unsigned char *comment = token.blockComment;
|
unsigned char *comment = token.blockComment;
|
||||||
while (token.value != TOKrcurly)
|
while (token.value != TOKrcurly)
|
||||||
@@ -1264,7 +1264,7 @@ Dsymbol *Parser::parseAggregate()
|
|||||||
{
|
{
|
||||||
//printf("aggregate definition\n");
|
//printf("aggregate definition\n");
|
||||||
nextToken();
|
nextToken();
|
||||||
Dsymbols *decl = parseDeclDefs(0);
|
Dsymbols *decl = parseDeclDefs(0);
|
||||||
if (token.value != TOKrcurly)
|
if (token.value != TOKrcurly)
|
||||||
error("} expected following member declarations in aggregate");
|
error("} expected following member declarations in aggregate");
|
||||||
nextToken();
|
nextToken();
|
||||||
@@ -1286,7 +1286,7 @@ Dsymbol *Parser::parseAggregate()
|
|||||||
if (tpl)
|
if (tpl)
|
||||||
{ // Wrap a template around the aggregate declaration
|
{ // Wrap a template around the aggregate declaration
|
||||||
|
|
||||||
Dsymbols *decldefs = new Dsymbols();
|
Dsymbols *decldefs = new Dsymbols();
|
||||||
decldefs->push(a);
|
decldefs->push(a);
|
||||||
TemplateDeclaration *tempdecl =
|
TemplateDeclaration *tempdecl =
|
||||||
new TemplateDeclaration(loc, id, tpl, constraint, decldefs);
|
new TemplateDeclaration(loc, id, tpl, constraint, decldefs);
|
||||||
@@ -1305,44 +1305,44 @@ BaseClasses *Parser::parseBaseClasses()
|
|||||||
|
|
||||||
for (; 1; nextToken())
|
for (; 1; nextToken())
|
||||||
{
|
{
|
||||||
bool prot = false;
|
bool prot = false;
|
||||||
enum PROT protection = PROTpublic;
|
enum PROT protection = PROTpublic;
|
||||||
switch (token.value)
|
switch (token.value)
|
||||||
{
|
{
|
||||||
case TOKprivate:
|
case TOKprivate:
|
||||||
prot = true;
|
prot = true;
|
||||||
protection = PROTprivate;
|
protection = PROTprivate;
|
||||||
nextToken();
|
nextToken();
|
||||||
break;
|
break;
|
||||||
case TOKpackage:
|
case TOKpackage:
|
||||||
prot = true;
|
prot = true;
|
||||||
protection = PROTpackage;
|
protection = PROTpackage;
|
||||||
nextToken();
|
nextToken();
|
||||||
break;
|
break;
|
||||||
case TOKprotected:
|
case TOKprotected:
|
||||||
prot = true;
|
prot = true;
|
||||||
protection = PROTprotected;
|
protection = PROTprotected;
|
||||||
nextToken();
|
nextToken();
|
||||||
break;
|
break;
|
||||||
case TOKpublic:
|
case TOKpublic:
|
||||||
prot = true;
|
prot = true;
|
||||||
protection = PROTpublic;
|
protection = PROTpublic;
|
||||||
nextToken();
|
nextToken();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//if (prot && !global.params.useDeprecated)
|
//if (prot && !global.params.useDeprecated)
|
||||||
//error("use of base class protection is deprecated");
|
//error("use of base class protection is deprecated");
|
||||||
if (token.value == TOKidentifier)
|
if (token.value == TOKidentifier)
|
||||||
{
|
{
|
||||||
BaseClass *b = new BaseClass(parseBasicType(), protection);
|
BaseClass *b = new BaseClass(parseBasicType(), protection);
|
||||||
baseclasses->push(b);
|
baseclasses->push(b);
|
||||||
if (token.value != TOKcomma)
|
if (token.value != TOKcomma)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
error("base classes expected instead of %s", token.toChars());
|
error("base classes expected instead of %s", token.toChars());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return baseclasses;
|
return baseclasses;
|
||||||
@@ -1378,7 +1378,7 @@ TemplateDeclaration *Parser::parseTemplateDeclaration()
|
|||||||
TemplateDeclaration *tempdecl;
|
TemplateDeclaration *tempdecl;
|
||||||
Identifier *id;
|
Identifier *id;
|
||||||
TemplateParameters *tpl;
|
TemplateParameters *tpl;
|
||||||
Dsymbols *decldefs;
|
Dsymbols *decldefs;
|
||||||
Loc loc = this->loc;
|
Loc loc = this->loc;
|
||||||
|
|
||||||
nextToken();
|
nextToken();
|
||||||
@@ -1575,7 +1575,7 @@ Dsymbol *Parser::parseMixin()
|
|||||||
Identifier *id;
|
Identifier *id;
|
||||||
Type *tqual;
|
Type *tqual;
|
||||||
Objects *tiargs;
|
Objects *tiargs;
|
||||||
Identifiers *idents;
|
Identifiers *idents;
|
||||||
|
|
||||||
//printf("parseMixin()\n");
|
//printf("parseMixin()\n");
|
||||||
nextToken();
|
nextToken();
|
||||||
@@ -1606,7 +1606,7 @@ Dsymbol *Parser::parseMixin()
|
|||||||
nextToken();
|
nextToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
idents = new Identifiers();
|
idents = new Identifiers();
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
tiargs = NULL;
|
tiargs = NULL;
|
||||||
@@ -1699,7 +1699,7 @@ Import *Parser::parseImport(Array *decldefs, int isstatic)
|
|||||||
{ Import *s;
|
{ Import *s;
|
||||||
Identifier *id;
|
Identifier *id;
|
||||||
Identifier *aliasid = NULL;
|
Identifier *aliasid = NULL;
|
||||||
Identifiers *a;
|
Identifiers *a;
|
||||||
Loc loc;
|
Loc loc;
|
||||||
|
|
||||||
//printf("Parser::parseImport()\n");
|
//printf("Parser::parseImport()\n");
|
||||||
@@ -1724,7 +1724,7 @@ Import *Parser::parseImport(Array *decldefs, int isstatic)
|
|||||||
while (token.value == TOKdot)
|
while (token.value == TOKdot)
|
||||||
{
|
{
|
||||||
if (!a)
|
if (!a)
|
||||||
a = new Identifiers();
|
a = new Identifiers();
|
||||||
a->push(id);
|
a->push(id);
|
||||||
nextToken();
|
nextToken();
|
||||||
if (token.value != TOKidentifier)
|
if (token.value != TOKidentifier)
|
||||||
@@ -2183,7 +2183,7 @@ Type *Parser::parseDeclarator(Type *t, Identifier **pident, TemplateParameters *
|
|||||||
* Return array of Declaration *'s.
|
* Return array of Declaration *'s.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Dsymbols *Parser::parseDeclarations()
|
Dsymbols *Parser::parseDeclarations()
|
||||||
{
|
{
|
||||||
StorageClass storage_class;
|
StorageClass storage_class;
|
||||||
StorageClass stc;
|
StorageClass stc;
|
||||||
@@ -2191,7 +2191,7 @@ Dsymbols *Parser::parseDeclarations()
|
|||||||
Type *t;
|
Type *t;
|
||||||
Type *tfirst;
|
Type *tfirst;
|
||||||
Identifier *ident;
|
Identifier *ident;
|
||||||
Dsymbols *a;
|
Dsymbols *a;
|
||||||
enum TOK tok = TOKreserved;
|
enum TOK tok = TOKreserved;
|
||||||
unsigned char *comment = token.blockComment;
|
unsigned char *comment = token.blockComment;
|
||||||
enum LINK link = linkage;
|
enum LINK link = linkage;
|
||||||
@@ -2253,7 +2253,7 @@ Dsymbols *Parser::parseDeclarations()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = new Dsymbols();
|
a = new Dsymbols();
|
||||||
|
|
||||||
/* Look for auto initializers:
|
/* Look for auto initializers:
|
||||||
* storage_class identifier = initializer;
|
* storage_class identifier = initializer;
|
||||||
@@ -2340,7 +2340,7 @@ Dsymbols *Parser::parseDeclarations()
|
|||||||
a->push(v);
|
a->push(v);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Dsymbols *ax = new Dsymbols();
|
Dsymbols *ax = new Dsymbols();
|
||||||
ax->push(v);
|
ax->push(v);
|
||||||
Dsymbol *s = new LinkDeclaration(link, ax);
|
Dsymbol *s = new LinkDeclaration(link, ax);
|
||||||
a->push(s);
|
a->push(s);
|
||||||
@@ -2374,14 +2374,14 @@ Dsymbols *Parser::parseDeclarations()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Dsymbols *ax = new Dsymbols();
|
Dsymbols *ax = new Dsymbols();
|
||||||
ax->push(f);
|
ax->push(f);
|
||||||
s = new LinkDeclaration(link, ax);
|
s = new LinkDeclaration(link, ax);
|
||||||
}
|
}
|
||||||
if (tpl) // it's a function template
|
if (tpl) // it's a function template
|
||||||
{
|
{
|
||||||
// Wrap a template around the aggregate declaration
|
// Wrap a template around the aggregate declaration
|
||||||
Dsymbols *decldefs = new Dsymbols();
|
Dsymbols *decldefs = new Dsymbols();
|
||||||
decldefs->push(s);
|
decldefs->push(s);
|
||||||
TemplateDeclaration *tempdecl =
|
TemplateDeclaration *tempdecl =
|
||||||
new TemplateDeclaration(loc, s->ident, tpl, NULL, decldefs);
|
new TemplateDeclaration(loc, s->ident, tpl, NULL, decldefs);
|
||||||
@@ -2405,7 +2405,7 @@ Dsymbols *Parser::parseDeclarations()
|
|||||||
a->push(v);
|
a->push(v);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Dsymbols *ax = new Dsymbols();
|
Dsymbols *ax = new Dsymbols();
|
||||||
ax->push(v);
|
ax->push(v);
|
||||||
Dsymbol *s = new LinkDeclaration(link, ax);
|
Dsymbol *s = new LinkDeclaration(link, ax);
|
||||||
a->push(s);
|
a->push(s);
|
||||||
@@ -2625,7 +2625,7 @@ Initializer *Parser::parseInitializer()
|
|||||||
|
|
||||||
is = new StructInitializer(loc);
|
is = new StructInitializer(loc);
|
||||||
nextToken();
|
nextToken();
|
||||||
comma = 2;
|
comma = 2;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
switch (token.value)
|
switch (token.value)
|
||||||
@@ -2649,8 +2649,8 @@ Initializer *Parser::parseInitializer()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TOKcomma:
|
case TOKcomma:
|
||||||
if (comma == 2)
|
if (comma == 2)
|
||||||
error("expression expected, not ','");
|
error("expression expected, not ','");
|
||||||
nextToken();
|
nextToken();
|
||||||
comma = 2;
|
comma = 2;
|
||||||
continue;
|
continue;
|
||||||
@@ -2664,8 +2664,8 @@ Initializer *Parser::parseInitializer()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (comma == 1)
|
if (comma == 1)
|
||||||
error("comma expected separating field initializers");
|
error("comma expected separating field initializers");
|
||||||
value = parseInitializer();
|
value = parseInitializer();
|
||||||
is->addInit(NULL, value);
|
is->addInit(NULL, value);
|
||||||
comma = 1;
|
comma = 1;
|
||||||
@@ -2714,7 +2714,7 @@ Initializer *Parser::parseInitializer()
|
|||||||
|
|
||||||
ia = new ArrayInitializer(loc);
|
ia = new ArrayInitializer(loc);
|
||||||
nextToken();
|
nextToken();
|
||||||
comma = 2;
|
comma = 2;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
switch (token.value)
|
switch (token.value)
|
||||||
@@ -2751,8 +2751,8 @@ Initializer *Parser::parseInitializer()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case TOKcomma:
|
case TOKcomma:
|
||||||
if (comma == 2)
|
if (comma == 2)
|
||||||
error("expression expected, not ','");
|
error("expression expected, not ','");
|
||||||
nextToken();
|
nextToken();
|
||||||
comma = 2;
|
comma = 2;
|
||||||
continue;
|
continue;
|
||||||
@@ -2955,10 +2955,10 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
{
|
{
|
||||||
Statements *as = new Statements();
|
Statements *as = new Statements();
|
||||||
as->reserve(a->dim);
|
as->reserve(a->dim);
|
||||||
for (size_t i = 0; i < a->dim; i++)
|
for (size_t i = 0; i < a->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *d = (Dsymbol *)a->data[i];
|
Dsymbol *d = (Dsymbol *)a->data[i];
|
||||||
s = new ExpStatement(loc, d);
|
s = new ExpStatement(loc, d);
|
||||||
as->push(s);
|
as->push(s);
|
||||||
}
|
}
|
||||||
s = new CompoundDeclarationStatement(loc, as);
|
s = new CompoundDeclarationStatement(loc, as);
|
||||||
@@ -2966,7 +2966,7 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
else if (a->dim == 1)
|
else if (a->dim == 1)
|
||||||
{
|
{
|
||||||
Dsymbol *d = (Dsymbol *)a->data[0];
|
Dsymbol *d = (Dsymbol *)a->data[0];
|
||||||
s = new ExpStatement(loc, d);
|
s = new ExpStatement(loc, d);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
@@ -2982,7 +2982,7 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
{ Dsymbol *d;
|
{ Dsymbol *d;
|
||||||
|
|
||||||
d = parseAggregate();
|
d = parseAggregate();
|
||||||
s = new ExpStatement(loc, d);
|
s = new ExpStatement(loc, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2990,7 +2990,7 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
{ Dsymbol *d;
|
{ Dsymbol *d;
|
||||||
|
|
||||||
d = parseEnum();
|
d = parseEnum();
|
||||||
s = new ExpStatement(loc, d);
|
s = new ExpStatement(loc, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2999,20 +2999,20 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
if (t->value == TOKlparen)
|
if (t->value == TOKlparen)
|
||||||
{ // mixin(string)
|
{ // mixin(string)
|
||||||
Expression *e = parseAssignExp();
|
Expression *e = parseAssignExp();
|
||||||
check(TOKsemicolon);
|
check(TOKsemicolon);
|
||||||
if (e->op == TOKmixin)
|
if (e->op == TOKmixin)
|
||||||
{
|
{
|
||||||
CompileExp *cpe = (CompileExp *)e;
|
CompileExp *cpe = (CompileExp *)e;
|
||||||
s = new CompileStatement(loc, cpe->e1);
|
s = new CompileStatement(loc, cpe->e1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = new ExpStatement(loc, e);
|
s = new ExpStatement(loc, e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Dsymbol *d = parseMixin();
|
Dsymbol *d = parseMixin();
|
||||||
s = new ExpStatement(loc, d);
|
s = new ExpStatement(loc, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3049,7 +3049,7 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
if (!(flags & PSsemi))
|
if (!(flags & PSsemi))
|
||||||
error("use '{ }' for an empty statement, not a ';'");
|
error("use '{ }' for an empty statement, not a ';'");
|
||||||
nextToken();
|
nextToken();
|
||||||
s = new ExpStatement(loc, (Expression *)NULL);
|
s = new ExpStatement(loc, (Expression *)NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOKdo:
|
case TOKdo:
|
||||||
@@ -3367,7 +3367,7 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
s = new ScopeStatement(loc, s);
|
s = new ScopeStatement(loc, s);
|
||||||
|
|
||||||
// Keep cases in order by building the case statements backwards
|
// Keep cases in order by building the case statements backwards
|
||||||
for (size_t i = cases.dim; i; i--)
|
for (size_t i = cases.dim; i; i--)
|
||||||
{
|
{
|
||||||
exp = (Expression *)cases.data[i - 1];
|
exp = (Expression *)cases.data[i - 1];
|
||||||
s = new CaseStatement(loc, exp, s);
|
s = new CaseStatement(loc, exp, s);
|
||||||
@@ -3506,7 +3506,7 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
|
|
||||||
case TOKtry:
|
case TOKtry:
|
||||||
{ Statement *body;
|
{ Statement *body;
|
||||||
Catches *catches = NULL;
|
Catches *catches = NULL;
|
||||||
Statement *finalbody = NULL;
|
Statement *finalbody = NULL;
|
||||||
|
|
||||||
nextToken();
|
nextToken();
|
||||||
@@ -3536,7 +3536,7 @@ Statement *Parser::parseStatement(int flags)
|
|||||||
handler = parseStatement(0);
|
handler = parseStatement(0);
|
||||||
c = new Catch(loc, t, id, handler);
|
c = new Catch(loc, t, id, handler);
|
||||||
if (!catches)
|
if (!catches)
|
||||||
catches = new Catches();
|
catches = new Catches();
|
||||||
catches->push(c);
|
catches->push(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3975,12 +3975,12 @@ int Parser::isDeclarator(Token **pt, int *haveId, enum TOK endtok)
|
|||||||
case TOKrbracket:
|
case TOKrbracket:
|
||||||
case TOKassign:
|
case TOKassign:
|
||||||
case TOKcomma:
|
case TOKcomma:
|
||||||
case TOKdotdotdot:
|
case TOKdotdotdot:
|
||||||
case TOKsemicolon:
|
case TOKsemicolon:
|
||||||
case TOKlcurly:
|
case TOKlcurly:
|
||||||
case TOKin:
|
case TOKin:
|
||||||
case TOKout:
|
case TOKout:
|
||||||
case TOKbody:
|
case TOKbody:
|
||||||
// The !parens is to disallow unnecessary parentheses
|
// The !parens is to disallow unnecessary parentheses
|
||||||
if (!parens && (endtok == TOKreserved || endtok == t->value))
|
if (!parens && (endtok == TOKreserved || endtok == t->value))
|
||||||
{ *pt = t;
|
{ *pt = t;
|
||||||
@@ -4726,7 +4726,7 @@ Expression *Parser::parsePostExp(Expression *e)
|
|||||||
nextToken();
|
nextToken();
|
||||||
if (token.value == TOKrbracket)
|
if (token.value == TOKrbracket)
|
||||||
{ // array[]
|
{ // array[]
|
||||||
inBrackets--;
|
inBrackets--;
|
||||||
e = new SliceExp(loc, e, NULL, NULL);
|
e = new SliceExp(loc, e, NULL, NULL);
|
||||||
nextToken();
|
nextToken();
|
||||||
}
|
}
|
||||||
@@ -4747,8 +4747,8 @@ Expression *Parser::parsePostExp(Expression *e)
|
|||||||
{
|
{
|
||||||
nextToken();
|
nextToken();
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
Expression *arg = parseAssignExp();
|
Expression *arg = parseAssignExp();
|
||||||
arguments->push(arg);
|
arguments->push(arg);
|
||||||
if (token.value == TOKrbracket)
|
if (token.value == TOKrbracket)
|
||||||
break;
|
break;
|
||||||
@@ -5384,7 +5384,7 @@ Expressions *Parser::parseArguments()
|
|||||||
nextToken();
|
nextToken();
|
||||||
if (token.value != endtok)
|
if (token.value != endtok)
|
||||||
{
|
{
|
||||||
while (token.value != TOKeof)
|
while (token.value != TOKeof)
|
||||||
{
|
{
|
||||||
arg = parseAssignExp();
|
arg = parseAssignExp();
|
||||||
arguments->push(arg);
|
arguments->push(arg);
|
||||||
@@ -5436,7 +5436,7 @@ Expression *Parser::parseNewExp(Expression *thisexp)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
nextToken();
|
nextToken();
|
||||||
Dsymbols *decl = parseDeclDefs(0);
|
Dsymbols *decl = parseDeclDefs(0);
|
||||||
if (token.value != TOKrcurly)
|
if (token.value != TOKrcurly)
|
||||||
error("class member expected");
|
error("class member expected");
|
||||||
nextToken();
|
nextToken();
|
||||||
@@ -5522,7 +5522,7 @@ enum PREC precedence[TOKMAX];
|
|||||||
|
|
||||||
void initPrecedence()
|
void initPrecedence()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < TOKMAX; i++)
|
for (size_t i = 0; i < TOKMAX; i++)
|
||||||
precedence[i] = PREC_zero;
|
precedence[i] = PREC_zero;
|
||||||
|
|
||||||
precedence[TOKtype] = PREC_expr;
|
precedence[TOKtype] = PREC_expr;
|
||||||
@@ -5675,7 +5675,7 @@ void initPrecedence()
|
|||||||
|
|
||||||
precedence[TOKcomma] = PREC_expr;
|
precedence[TOKcomma] = PREC_expr;
|
||||||
precedence[TOKdeclaration] = PREC_expr;
|
precedence[TOKdeclaration] = PREC_expr;
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
// Need to set precedence for TOKgep as well, as expToCBuffer expects it.
|
// Need to set precedence for TOKgep as well, as expToCBuffer expects it.
|
||||||
precedence[TOKgep] = PREC_primary;
|
precedence[TOKgep] = PREC_primary;
|
||||||
|
|||||||
+4
-4
@@ -66,10 +66,10 @@ struct Parser : Lexer
|
|||||||
|
|
||||||
Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
|
Parser(Module *module, unsigned char *base, unsigned length, int doDocComment);
|
||||||
|
|
||||||
Dsymbols *parseModule();
|
Dsymbols *parseModule();
|
||||||
Dsymbols *parseDeclDefs(int once);
|
Dsymbols *parseDeclDefs(int once);
|
||||||
Array *parseAutoDeclarations(StorageClass storageClass, unsigned char *comment);
|
Array *parseAutoDeclarations(StorageClass storageClass, unsigned char *comment);
|
||||||
Dsymbols *parseBlock();
|
Dsymbols *parseBlock();
|
||||||
void composeStorageClass(StorageClass stc);
|
void composeStorageClass(StorageClass stc);
|
||||||
Expression *parseConstraint();
|
Expression *parseConstraint();
|
||||||
TemplateDeclaration *parseTemplateDeclaration();
|
TemplateDeclaration *parseTemplateDeclaration();
|
||||||
@@ -102,7 +102,7 @@ struct Parser : Lexer
|
|||||||
Type *parseBasicType();
|
Type *parseBasicType();
|
||||||
Type *parseBasicType2(Type *t);
|
Type *parseBasicType2(Type *t);
|
||||||
Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL);
|
Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL);
|
||||||
Dsymbols *parseDeclarations();
|
Dsymbols *parseDeclarations();
|
||||||
void parseContracts(FuncDeclaration *f);
|
void parseContracts(FuncDeclaration *f);
|
||||||
Statement *parseStatement(int flags);
|
Statement *parseStatement(int flags);
|
||||||
Initializer *parseInitializer();
|
Initializer *parseInitializer();
|
||||||
|
|||||||
+4
-4
@@ -111,7 +111,7 @@ void *spellerX(const char *seed, size_t seedlen, fp_speller_t fp, void *fparg,
|
|||||||
|
|
||||||
/* Deletions */
|
/* Deletions */
|
||||||
memcpy(buf, seed + 1, seedlen);
|
memcpy(buf, seed + 1, seedlen);
|
||||||
for (size_t i = 0; i < seedlen; i++)
|
for (size_t i = 0; i < seedlen; i++)
|
||||||
{
|
{
|
||||||
//printf("del buf = '%s'\n", buf);
|
//printf("del buf = '%s'\n", buf);
|
||||||
void *p;
|
void *p;
|
||||||
@@ -129,7 +129,7 @@ void *spellerX(const char *seed, size_t seedlen, fp_speller_t fp, void *fparg,
|
|||||||
if (!flag)
|
if (!flag)
|
||||||
{
|
{
|
||||||
memcpy(buf, seed, seedlen + 1);
|
memcpy(buf, seed, seedlen + 1);
|
||||||
for (size_t i = 0; i + 1 < seedlen; i++)
|
for (size_t i = 0; i + 1 < seedlen; i++)
|
||||||
{
|
{
|
||||||
// swap [i] and [i + 1]
|
// swap [i] and [i + 1]
|
||||||
buf[i] = seed[i + 1];
|
buf[i] = seed[i + 1];
|
||||||
@@ -148,7 +148,7 @@ void *spellerX(const char *seed, size_t seedlen, fp_speller_t fp, void *fparg,
|
|||||||
{
|
{
|
||||||
/* Substitutions */
|
/* Substitutions */
|
||||||
memcpy(buf, seed, seedlen + 1);
|
memcpy(buf, seed, seedlen + 1);
|
||||||
for (size_t i = 0; i < seedlen; i++)
|
for (size_t i = 0; i < seedlen; i++)
|
||||||
{
|
{
|
||||||
for (const char *s = charset; *s; s++)
|
for (const char *s = charset; *s; s++)
|
||||||
{
|
{
|
||||||
@@ -168,7 +168,7 @@ void *spellerX(const char *seed, size_t seedlen, fp_speller_t fp, void *fparg,
|
|||||||
|
|
||||||
/* Insertions */
|
/* Insertions */
|
||||||
memcpy(buf + 1, seed, seedlen + 1);
|
memcpy(buf + 1, seed, seedlen + 1);
|
||||||
for (size_t i = 0; i <= seedlen; i++) // yes, do seedlen+1 iterations
|
for (size_t i = 0; i <= seedlen; i++) // yes, do seedlen+1 iterations
|
||||||
{
|
{
|
||||||
for (const char *s = charset; *s; s++)
|
for (const char *s = charset; *s; s++)
|
||||||
{
|
{
|
||||||
|
|||||||
+332
-332
File diff suppressed because it is too large
Load Diff
+69
-69
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -27,7 +27,7 @@ struct Expression;
|
|||||||
struct LabelDsymbol;
|
struct LabelDsymbol;
|
||||||
struct Identifier;
|
struct Identifier;
|
||||||
struct IfStatement;
|
struct IfStatement;
|
||||||
struct ExpStatement;
|
struct ExpStatement;
|
||||||
struct DefaultStatement;
|
struct DefaultStatement;
|
||||||
struct VarDeclaration;
|
struct VarDeclaration;
|
||||||
struct Condition;
|
struct Condition;
|
||||||
@@ -46,9 +46,9 @@ struct GotoStatement;
|
|||||||
struct ScopeStatement;
|
struct ScopeStatement;
|
||||||
struct TryCatchStatement;
|
struct TryCatchStatement;
|
||||||
struct TryFinallyStatement;
|
struct TryFinallyStatement;
|
||||||
struct CaseStatement;
|
struct CaseStatement;
|
||||||
struct DefaultStatement;
|
struct DefaultStatement;
|
||||||
struct LabelStatement;
|
struct LabelStatement;
|
||||||
struct HdrGenState;
|
struct HdrGenState;
|
||||||
struct InterState;
|
struct InterState;
|
||||||
struct CaseStatement;
|
struct CaseStatement;
|
||||||
@@ -123,7 +123,7 @@ struct Statement : Object
|
|||||||
virtual int hasBreak();
|
virtual int hasBreak();
|
||||||
virtual int hasContinue();
|
virtual int hasContinue();
|
||||||
virtual int usesEH();
|
virtual int usesEH();
|
||||||
virtual int blockExit(bool mustNotThrow);
|
virtual int blockExit(bool mustNotThrow);
|
||||||
virtual int comeFrom();
|
virtual int comeFrom();
|
||||||
virtual int isEmpty();
|
virtual int isEmpty();
|
||||||
virtual void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally);
|
virtual void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally);
|
||||||
@@ -132,19 +132,19 @@ struct Statement : Object
|
|||||||
|
|
||||||
virtual int inlineCost(InlineCostState *ics);
|
virtual int inlineCost(InlineCostState *ics);
|
||||||
virtual Expression *doInline(InlineDoState *ids);
|
virtual Expression *doInline(InlineDoState *ids);
|
||||||
virtual Statement *doInlineStatement(InlineDoState *ids);
|
virtual Statement *doInlineStatement(InlineDoState *ids);
|
||||||
virtual Statement *inlineScan(InlineScanState *iss);
|
virtual Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
// Back end
|
// Back end
|
||||||
virtual void toIR(IRState *irs);
|
virtual void toIR(IRState *irs);
|
||||||
|
|
||||||
// Avoid dynamic_cast
|
// Avoid dynamic_cast
|
||||||
virtual ExpStatement *isExpStatement() { return NULL; }
|
virtual ExpStatement *isExpStatement() { return NULL; }
|
||||||
virtual CompoundStatement *isCompoundStatement() { return NULL; }
|
virtual CompoundStatement *isCompoundStatement() { return NULL; }
|
||||||
virtual ReturnStatement *isReturnStatement() { return NULL; }
|
virtual ReturnStatement *isReturnStatement() { return NULL; }
|
||||||
virtual IfStatement *isIfStatement() { return NULL; }
|
virtual IfStatement *isIfStatement() { return NULL; }
|
||||||
virtual CaseStatement* isCaseStatement() { return NULL; }
|
virtual CaseStatement* isCaseStatement() { return NULL; }
|
||||||
virtual DefaultStatement *isDefaultStatement() { return NULL; }
|
virtual DefaultStatement *isDefaultStatement() { return NULL; }
|
||||||
virtual LabelStatement* isLabelStatement() { return NULL; }
|
virtual LabelStatement* isLabelStatement() { return NULL; }
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
@@ -166,18 +166,18 @@ struct ExpStatement : Statement
|
|||||||
Expression *exp;
|
Expression *exp;
|
||||||
|
|
||||||
ExpStatement(Loc loc, Expression *exp);
|
ExpStatement(Loc loc, Expression *exp);
|
||||||
ExpStatement(Loc loc, Dsymbol *s);
|
ExpStatement(Loc loc, Dsymbol *s);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int isEmpty();
|
int isEmpty();
|
||||||
void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally);
|
void scopeCode(Scope *sc, Statement **sentry, Statement **sexit, Statement **sfinally);
|
||||||
|
|
||||||
int inlineCost(InlineCostState *ics);
|
int inlineCost(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Statement *doInlineStatement(InlineDoState *ids);
|
Statement *doInlineStatement(InlineDoState *ids);
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -185,8 +185,8 @@ struct ExpStatement : Statement
|
|||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
void toNakedIR(IRState *irs);
|
void toNakedIR(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ExpStatement *isExpStatement() { return this; }
|
ExpStatement *isExpStatement() { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompileStatement : Statement
|
struct CompileStatement : Statement
|
||||||
@@ -211,7 +211,7 @@ struct CompoundStatement : Statement
|
|||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
virtual Statement *semantic(Scope *sc);
|
virtual Statement *semantic(Scope *sc);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
int isEmpty();
|
int isEmpty();
|
||||||
virtual Statements *flatten(Scope *sc);
|
virtual Statements *flatten(Scope *sc);
|
||||||
@@ -220,7 +220,7 @@ struct CompoundStatement : Statement
|
|||||||
|
|
||||||
int inlineCost(InlineCostState *ics);
|
int inlineCost(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Statement *doInlineStatement(InlineDoState *ids);
|
Statement *doInlineStatement(InlineDoState *ids);
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
virtual void toIR(IRState *irs);
|
virtual void toIR(IRState *irs);
|
||||||
@@ -252,14 +252,14 @@ struct UnrolledLoopStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
int inlineCost(InlineCostState *ics);
|
int inlineCost(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Statement *doInlineStatement(InlineDoState *ids);
|
Statement *doInlineStatement(InlineDoState *ids);
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -277,14 +277,14 @@ struct ScopeStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
int isEmpty();
|
int isEmpty();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
||||||
int inlineCost(InlineCostState *ics);
|
int inlineCost(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Statement *doInlineStatement(InlineDoState *ids);
|
Statement *doInlineStatement(InlineDoState *ids);
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -301,7 +301,7 @@ struct WhileStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -322,7 +322,7 @@ struct DoStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -346,14 +346,14 @@ struct ForStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
int inlineCost(InlineCostState *ics);
|
int inlineCost(InlineCostState *ics);
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
Statement *doInlineStatement(InlineDoState *ids);
|
Statement *doInlineStatement(InlineDoState *ids);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
};
|
};
|
||||||
@@ -370,8 +370,8 @@ struct ForeachStatement : Statement
|
|||||||
|
|
||||||
FuncDeclaration *func; // function we're lexically in
|
FuncDeclaration *func; // function we're lexically in
|
||||||
|
|
||||||
Statements *cases; // put breaks, continues, gotos and returns here
|
Statements *cases; // put breaks, continues, gotos and returns here
|
||||||
CompoundStatements *gotos; // forward referenced goto's go here
|
CompoundStatements *gotos; // forward referenced goto's go here
|
||||||
|
|
||||||
ForeachStatement(Loc loc, enum TOK op, Parameters *arguments, Expression *aggr, Statement *body);
|
ForeachStatement(Loc loc, enum TOK op, Parameters *arguments, Expression *aggr, Statement *body);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
@@ -380,7 +380,7 @@ struct ForeachStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -408,7 +408,7 @@ struct ForeachRangeStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
@@ -434,12 +434,12 @@ struct IfStatement : Statement
|
|||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
IfStatement *isIfStatement() { return this; }
|
IfStatement *isIfStatement() { return this; }
|
||||||
|
|
||||||
int inlineCost(InlineCostState *ics);
|
int inlineCost(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Statement *doInlineStatement(InlineDoState *ids);
|
Statement *doInlineStatement(InlineDoState *ids);
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -456,7 +456,7 @@ struct ConditionalStatement : Statement
|
|||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Statements *flatten(Scope *sc);
|
Statements *flatten(Scope *sc);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
|
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
@@ -471,7 +471,7 @@ struct PragmaStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
|
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
@@ -483,7 +483,7 @@ struct StaticAssertStatement : Statement
|
|||||||
StaticAssertStatement(StaticAssert *sa);
|
StaticAssertStatement(StaticAssert *sa);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
|
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
@@ -495,8 +495,8 @@ struct SwitchStatement : Statement
|
|||||||
|
|
||||||
DefaultStatement *sdefault;
|
DefaultStatement *sdefault;
|
||||||
|
|
||||||
GotoCaseStatements gotoCases; // array of unresolved GotoCaseStatement's
|
GotoCaseStatements gotoCases; // array of unresolved GotoCaseStatement's
|
||||||
CaseStatements *cases; // array of CaseStatement's
|
CaseStatements *cases; // array of CaseStatement's
|
||||||
int hasNoDefault; // !=0 if no default statement
|
int hasNoDefault; // !=0 if no default statement
|
||||||
|
|
||||||
// LDC
|
// LDC
|
||||||
@@ -507,7 +507,7 @@ struct SwitchStatement : Statement
|
|||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int hasBreak();
|
int hasBreak();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
@@ -532,11 +532,11 @@ struct CaseStatement : Statement
|
|||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int compare(Object *obj);
|
int compare(Object *obj);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
CaseStatement *isCaseStatement() { return this; }
|
CaseStatement *isCaseStatement() { return this; }
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
@@ -578,11 +578,11 @@ struct DefaultStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
DefaultStatement *isDefaultStatement() { return this; }
|
DefaultStatement *isDefaultStatement() { return this; }
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
@@ -600,7 +600,7 @@ struct GotoDefaultStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -616,7 +616,7 @@ struct GotoCaseStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -625,7 +625,7 @@ struct GotoCaseStatement : Statement
|
|||||||
struct SwitchErrorStatement : Statement
|
struct SwitchErrorStatement : Statement
|
||||||
{
|
{
|
||||||
SwitchErrorStatement(Loc loc);
|
SwitchErrorStatement(Loc loc);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -639,12 +639,12 @@ struct ReturnStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
||||||
int inlineCost(InlineCostState *ics);
|
int inlineCost(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
Statement *doInlineStatement(InlineDoState *ids);
|
Statement *doInlineStatement(InlineDoState *ids);
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -660,7 +660,7 @@ struct BreakStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -677,7 +677,7 @@ struct ContinueStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -697,7 +697,7 @@ struct SynchronizedStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
@@ -720,7 +720,7 @@ struct WithStatement : Statement
|
|||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
@@ -731,14 +731,14 @@ struct WithStatement : Statement
|
|||||||
struct TryCatchStatement : Statement
|
struct TryCatchStatement : Statement
|
||||||
{
|
{
|
||||||
Statement *body;
|
Statement *body;
|
||||||
Catches *catches;
|
Catches *catches;
|
||||||
|
|
||||||
TryCatchStatement(Loc loc, Statement *body, Catches *catches);
|
TryCatchStatement(Loc loc, Statement *body, Catches *catches);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int hasBreak();
|
int hasBreak();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
@@ -759,7 +759,7 @@ struct Catch : Object
|
|||||||
Catch(Loc loc, Type *t, Identifier *id, Statement *handler);
|
Catch(Loc loc, Type *t, Identifier *id, Statement *handler);
|
||||||
Catch *syntaxCopy();
|
Catch *syntaxCopy();
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -775,7 +775,7 @@ struct TryFinallyStatement : Statement
|
|||||||
int hasBreak();
|
int hasBreak();
|
||||||
int hasContinue();
|
int hasContinue();
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
@@ -790,7 +790,7 @@ struct OnScopeStatement : Statement
|
|||||||
|
|
||||||
OnScopeStatement(Loc loc, TOK tok, Statement *statement);
|
OnScopeStatement(Loc loc, TOK tok, Statement *statement);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
@@ -808,7 +808,7 @@ struct ThrowStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
@@ -824,7 +824,7 @@ struct VolatileStatement : Statement
|
|||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Statements *flatten(Scope *sc);
|
Statements *flatten(Scope *sc);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
@@ -842,7 +842,7 @@ struct GotoStatement : Statement
|
|||||||
GotoStatement(Loc loc, Identifier *ident);
|
GotoStatement(Loc loc, Identifier *ident);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
@@ -858,20 +858,20 @@ struct LabelStatement : Statement
|
|||||||
Statement* enclosingScopeExit;
|
Statement* enclosingScopeExit;
|
||||||
block *lblock; // back end
|
block *lblock; // back end
|
||||||
|
|
||||||
Blocks *fwdrefs; // forward references to this LabelStatement
|
Blocks *fwdrefs; // forward references to this LabelStatement
|
||||||
|
|
||||||
LabelStatement(Loc loc, Identifier *ident, Statement *statement);
|
LabelStatement(Loc loc, Identifier *ident, Statement *statement);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Statements *flatten(Scope *sc);
|
Statements *flatten(Scope *sc);
|
||||||
int usesEH();
|
int usesEH();
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
||||||
Statement *inlineScan(InlineScanState *iss);
|
Statement *inlineScan(InlineScanState *iss);
|
||||||
LabelStatement *isLabelStatement() { return this; }
|
LabelStatement *isLabelStatement() { return this; }
|
||||||
|
|
||||||
void toIR(IRState *irs);
|
void toIR(IRState *irs);
|
||||||
|
|
||||||
@@ -893,14 +893,14 @@ struct AsmStatement : Statement
|
|||||||
Token *tokens;
|
Token *tokens;
|
||||||
code *asmcode;
|
code *asmcode;
|
||||||
unsigned asmalign; // alignment of this statement
|
unsigned asmalign; // alignment of this statement
|
||||||
unsigned regs; // mask of registers modified (must match regm_t in back end)
|
unsigned regs; // mask of registers modified (must match regm_t in back end)
|
||||||
unsigned char refparam; // !=0 if function parameter is referenced
|
unsigned char refparam; // !=0 if function parameter is referenced
|
||||||
unsigned char naked; // !=0 if function is to be naked
|
unsigned char naked; // !=0 if function is to be naked
|
||||||
|
|
||||||
AsmStatement(Loc loc, Token *tokens);
|
AsmStatement(Loc loc, Token *tokens);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int blockExit(bool mustNotThrow);
|
int blockExit(bool mustNotThrow);
|
||||||
int comeFrom();
|
int comeFrom();
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -53,16 +53,16 @@ void StaticAssert::semantic(Scope *sc)
|
|||||||
void StaticAssert::semantic2(Scope *sc)
|
void StaticAssert::semantic2(Scope *sc)
|
||||||
{
|
{
|
||||||
//printf("StaticAssert::semantic2() %s\n", toChars());
|
//printf("StaticAssert::semantic2() %s\n", toChars());
|
||||||
Expression *e = exp->semantic(sc);
|
Expression *e = exp->semantic(sc);
|
||||||
if (e->type == Type::terror)
|
if (e->type == Type::terror)
|
||||||
return;
|
return;
|
||||||
unsigned olderrs = global.errors;
|
unsigned olderrs = global.errors;
|
||||||
e = e->optimize(WANTvalue | WANTinterpret);
|
e = e->optimize(WANTvalue | WANTinterpret);
|
||||||
if (global.errors != olderrs)
|
if (global.errors != olderrs)
|
||||||
{
|
{
|
||||||
errorSupplemental(loc, "while evaluating: static assert(%s)", exp->toChars());
|
errorSupplemental(loc, "while evaluating: static assert(%s)", exp->toChars());
|
||||||
}
|
}
|
||||||
else if (e->isBool(FALSE))
|
else if (e->isBool(FALSE))
|
||||||
{
|
{
|
||||||
if (msg)
|
if (msg)
|
||||||
{ HdrGenState hgs;
|
{ HdrGenState hgs;
|
||||||
|
|||||||
+41
-41
@@ -1,41 +1,41 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_STATICASSERT_H
|
#ifndef DMD_STATICASSERT_H
|
||||||
#define DMD_STATICASSERT_H
|
#define DMD_STATICASSERT_H
|
||||||
|
|
||||||
#ifdef __DMC__
|
#ifdef __DMC__
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif /* __DMC__ */
|
#endif /* __DMC__ */
|
||||||
|
|
||||||
#include "dsymbol.h"
|
#include "dsymbol.h"
|
||||||
|
|
||||||
struct Expression;
|
struct Expression;
|
||||||
struct HdrGenState;
|
struct HdrGenState;
|
||||||
|
|
||||||
struct StaticAssert : Dsymbol
|
struct StaticAssert : Dsymbol
|
||||||
{
|
{
|
||||||
Expression *exp;
|
Expression *exp;
|
||||||
Expression *msg;
|
Expression *msg;
|
||||||
|
|
||||||
StaticAssert(Loc loc, Expression *exp, Expression *msg);
|
StaticAssert(Loc loc, Expression *exp, Expression *msg);
|
||||||
|
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
int addMember(Scope *sc, ScopeDsymbol *sd, int memnum);
|
int addMember(Scope *sc, ScopeDsymbol *sd, int memnum);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void semantic2(Scope *sc);
|
void semantic2(Scope *sc);
|
||||||
void inlineScan();
|
void inlineScan();
|
||||||
int oneMember(Dsymbol **ps);
|
int oneMember(Dsymbol **ps);
|
||||||
void toObjFile(int multiobj);
|
void toObjFile(int multiobj);
|
||||||
const char *kind();
|
const char *kind();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+90
-90
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -51,10 +51,10 @@ AggregateDeclaration::AggregateDeclaration(Loc loc, Identifier *id)
|
|||||||
|
|
||||||
ctor = NULL;
|
ctor = NULL;
|
||||||
defaultCtor = NULL;
|
defaultCtor = NULL;
|
||||||
aliasthis = NULL;
|
aliasthis = NULL;
|
||||||
noDefaultCtor = FALSE;
|
noDefaultCtor = FALSE;
|
||||||
#endif
|
#endif
|
||||||
dtor = NULL;
|
dtor = NULL;
|
||||||
|
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
availableExternally = true; // assume this unless proven otherwise
|
availableExternally = true; // assume this unless proven otherwise
|
||||||
@@ -78,7 +78,7 @@ void AggregateDeclaration::semantic2(Scope *sc)
|
|||||||
sc = sc->push(this);
|
sc = sc->push(this);
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = members->tdata()[i];
|
Dsymbol *s = members->tdata()[i];
|
||||||
s->semantic2(sc);
|
s->semantic2(sc);
|
||||||
}
|
}
|
||||||
sc->pop();
|
sc->pop();
|
||||||
@@ -86,7 +86,7 @@ void AggregateDeclaration::semantic2(Scope *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AggregateDeclaration::semantic3(Scope *sc)
|
void AggregateDeclaration::semantic3(Scope *sc)
|
||||||
{
|
{
|
||||||
// LDC
|
// LDC
|
||||||
if (!global.params.useAvailableExternally)
|
if (!global.params.useAvailableExternally)
|
||||||
availableExternally = false;
|
availableExternally = false;
|
||||||
@@ -95,9 +95,9 @@ void AggregateDeclaration::semantic3(Scope *sc)
|
|||||||
if (members)
|
if (members)
|
||||||
{
|
{
|
||||||
sc = sc->push(this);
|
sc = sc->push(this);
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = members->tdata()[i];
|
Dsymbol *s = members->tdata()[i];
|
||||||
s->semantic3(sc);
|
s->semantic3(sc);
|
||||||
}
|
}
|
||||||
sc->pop();
|
sc->pop();
|
||||||
@@ -105,13 +105,13 @@ void AggregateDeclaration::semantic3(Scope *sc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AggregateDeclaration::inlineScan()
|
void AggregateDeclaration::inlineScan()
|
||||||
{
|
{
|
||||||
//printf("AggregateDeclaration::inlineScan(%s)\n", toChars());
|
//printf("AggregateDeclaration::inlineScan(%s)\n", toChars());
|
||||||
if (members)
|
if (members)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = members->tdata()[i];
|
Dsymbol *s = members->tdata()[i];
|
||||||
//printf("inline scan aggregate symbol '%s'\n", s->toChars());
|
//printf("inline scan aggregate symbol '%s'\n", s->toChars());
|
||||||
s->inlineScan();
|
s->inlineScan();
|
||||||
}
|
}
|
||||||
@@ -142,11 +142,11 @@ int AggregateDeclaration::isDeprecated()
|
|||||||
return isdeprecated;
|
return isdeprecated;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AggregateDeclaration::isExport()
|
int AggregateDeclaration::isExport()
|
||||||
{
|
{
|
||||||
return protection == PROTexport;
|
return protection == PROTexport;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* Do byte or word alignment as necessary.
|
* Do byte or word alignment as necessary.
|
||||||
* Align sizes of 0, as we may not know array sizes yet.
|
* Align sizes of 0, as we may not know array sizes yet.
|
||||||
@@ -161,7 +161,7 @@ void AggregateDeclaration::alignmember(
|
|||||||
if (salign > 1)
|
if (salign > 1)
|
||||||
{
|
{
|
||||||
assert(size != 3);
|
assert(size != 3);
|
||||||
unsigned sa = size;
|
unsigned sa = size;
|
||||||
if (sa == 0 || salign < sa)
|
if (sa == 0 || salign < sa)
|
||||||
sa = salign;
|
sa = salign;
|
||||||
*poffset = (*poffset + sa - 1) & ~(sa - 1);
|
*poffset = (*poffset + sa - 1) & ~(sa - 1);
|
||||||
@@ -222,10 +222,10 @@ void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
|
|||||||
if (!isUnionDeclaration())
|
if (!isUnionDeclaration())
|
||||||
sc->offset = ofs;
|
sc->offset = ofs;
|
||||||
#endif
|
#endif
|
||||||
if (global.params.is64bit && sc->structalign == 8 && memalignsize == 16)
|
if (global.params.is64bit && sc->structalign == 8 && memalignsize == 16)
|
||||||
/* Not sure how to handle this */
|
/* Not sure how to handle this */
|
||||||
;
|
;
|
||||||
else if (sc->structalign < memalignsize)
|
else if (sc->structalign < memalignsize)
|
||||||
memalignsize = sc->structalign;
|
memalignsize = sc->structalign;
|
||||||
if (alignsize < memalignsize)
|
if (alignsize < memalignsize)
|
||||||
alignsize = memalignsize;
|
alignsize = memalignsize;
|
||||||
@@ -236,57 +236,57 @@ void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
|
|||||||
fields.push(v);
|
fields.push(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
* If field[indx] is not part of a union, return indx.
|
* If field[indx] is not part of a union, return indx.
|
||||||
* Otherwise, return the lowest field index of the union.
|
* Otherwise, return the lowest field index of the union.
|
||||||
*/
|
*/
|
||||||
int AggregateDeclaration::firstFieldInUnion(int indx)
|
int AggregateDeclaration::firstFieldInUnion(int indx)
|
||||||
{
|
{
|
||||||
if (isUnionDeclaration())
|
if (isUnionDeclaration())
|
||||||
return 0;
|
return 0;
|
||||||
VarDeclaration * vd = fields.tdata()[indx];
|
VarDeclaration * vd = fields.tdata()[indx];
|
||||||
int firstNonZero = indx; // first index in the union with non-zero size
|
int firstNonZero = indx; // first index in the union with non-zero size
|
||||||
for (; ;)
|
for (; ;)
|
||||||
{
|
{
|
||||||
if (indx == 0)
|
if (indx == 0)
|
||||||
return firstNonZero;
|
return firstNonZero;
|
||||||
VarDeclaration * v = fields.tdata()[indx - 1];
|
VarDeclaration * v = fields.tdata()[indx - 1];
|
||||||
if (v->offset != vd->offset)
|
if (v->offset != vd->offset)
|
||||||
return firstNonZero;
|
return firstNonZero;
|
||||||
--indx;
|
--indx;
|
||||||
/* If it is a zero-length field, it's ambiguous: we don't know if it is
|
/* If it is a zero-length field, it's ambiguous: we don't know if it is
|
||||||
* in the union unless we find an earlier non-zero sized field with the
|
* in the union unless we find an earlier non-zero sized field with the
|
||||||
* same offset.
|
* same offset.
|
||||||
*/
|
*/
|
||||||
if (v->size(loc) != 0)
|
if (v->size(loc) != 0)
|
||||||
firstNonZero = indx;
|
firstNonZero = indx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************
|
/****************************************
|
||||||
* Count the number of fields starting at firstIndex which are part of the
|
* Count the number of fields starting at firstIndex which are part of the
|
||||||
* same union as field[firstIndex]. If not a union, return 1.
|
* same union as field[firstIndex]. If not a union, return 1.
|
||||||
*/
|
*/
|
||||||
int AggregateDeclaration::numFieldsInUnion(int firstIndex)
|
int AggregateDeclaration::numFieldsInUnion(int firstIndex)
|
||||||
{
|
{
|
||||||
VarDeclaration * vd = fields.tdata()[firstIndex];
|
VarDeclaration * vd = fields.tdata()[firstIndex];
|
||||||
/* If it is a zero-length field, AND we can't find an earlier non-zero
|
/* If it is a zero-length field, AND we can't find an earlier non-zero
|
||||||
* sized field with the same offset, we assume it's not part of a union.
|
* sized field with the same offset, we assume it's not part of a union.
|
||||||
*/
|
*/
|
||||||
if (vd->size(loc) == 0 && !isUnionDeclaration() &&
|
if (vd->size(loc) == 0 && !isUnionDeclaration() &&
|
||||||
firstFieldInUnion(firstIndex) == firstIndex)
|
firstFieldInUnion(firstIndex) == firstIndex)
|
||||||
return 1;
|
return 1;
|
||||||
int count = 1;
|
int count = 1;
|
||||||
for (size_t i = firstIndex+1; i < fields.dim; ++i)
|
for (size_t i = firstIndex+1; i < fields.dim; ++i)
|
||||||
{
|
{
|
||||||
VarDeclaration * v = fields.tdata()[i];
|
VarDeclaration * v = fields.tdata()[i];
|
||||||
// If offsets are different, they are not in the same union
|
// If offsets are different, they are not in the same union
|
||||||
if (v->offset != vd->offset)
|
if (v->offset != vd->offset)
|
||||||
break;
|
break;
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************* StructDeclaration ****************************/
|
/********************************* StructDeclaration ****************************/
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ Dsymbol *StructDeclaration::syntaxCopy(Dsymbol *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StructDeclaration::semantic(Scope *sc)
|
void StructDeclaration::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
Scope *sc2;
|
Scope *sc2;
|
||||||
|
|
||||||
//printf("+StructDeclaration::semantic(this=%p, '%s')\n", this, toChars());
|
//printf("+StructDeclaration::semantic(this=%p, '%s')\n", this, toChars());
|
||||||
@@ -370,9 +370,9 @@ void StructDeclaration::semantic(Scope *sc)
|
|||||||
|
|
||||||
if (sizeok == 0) // if not already done the addMember step
|
if (sizeok == 0) // if not already done the addMember step
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = members->tdata()[i];
|
Dsymbol *s = members->tdata()[i];
|
||||||
//printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars());
|
//printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars());
|
||||||
s->addMember(sc, this, 1);
|
s->addMember(sc, this, 1);
|
||||||
}
|
}
|
||||||
@@ -387,13 +387,13 @@ void StructDeclaration::semantic(Scope *sc)
|
|||||||
sc2->protection = PROTpublic;
|
sc2->protection = PROTpublic;
|
||||||
sc2->explicitProtection = 0;
|
sc2->explicitProtection = 0;
|
||||||
|
|
||||||
size_t members_dim = members->dim;
|
size_t members_dim = members->dim;
|
||||||
|
|
||||||
/* Set scope so if there are forward references, we still might be able to
|
/* Set scope so if there are forward references, we still might be able to
|
||||||
* resolve individual members like enums.
|
* resolve individual members like enums.
|
||||||
*/
|
*/
|
||||||
for (size_t i = 0; i < members_dim; i++)
|
for (size_t i = 0; i < members_dim; i++)
|
||||||
{ Dsymbol *s = members->tdata()[i];
|
{ Dsymbol *s = members->tdata()[i];
|
||||||
/* There are problems doing this in the general case because
|
/* There are problems doing this in the general case because
|
||||||
* Scope keeps track of things like 'offset'
|
* Scope keeps track of things like 'offset'
|
||||||
*/
|
*/
|
||||||
@@ -404,9 +404,9 @@ void StructDeclaration::semantic(Scope *sc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < members_dim; i++)
|
for (size_t i = 0; i < members_dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = members->tdata()[i];
|
Dsymbol *s = members->tdata()[i];
|
||||||
s->semantic(sc2);
|
s->semantic(sc2);
|
||||||
#if 0
|
#if 0
|
||||||
if (sizeok == 2)
|
if (sizeok == 2)
|
||||||
@@ -416,10 +416,10 @@ void StructDeclaration::semantic(Scope *sc)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DMDV1
|
#if DMDV1
|
||||||
/* This doesn't work for DMDV2 because (ref S) and (S) parameter
|
/* This doesn't work for DMDV2 because (ref S) and (S) parameter
|
||||||
* lists will overload the same.
|
* lists will overload the same.
|
||||||
*/
|
*/
|
||||||
/* The TypeInfo_Struct is expecting an opEquals and opCmp with
|
/* The TypeInfo_Struct is expecting an opEquals and opCmp with
|
||||||
* a parameter that is a pointer to the struct. But if there
|
* 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
|
* isn't one, but is an opEquals or opCmp with a value, write
|
||||||
@@ -477,7 +477,7 @@ void StructDeclaration::semantic(Scope *sc)
|
|||||||
|
|
||||||
id = Id::cmp;
|
id = Id::cmp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
dtor = buildDtor(sc2);
|
dtor = buildDtor(sc2);
|
||||||
postblit = buildPostBlit(sc2);
|
postblit = buildPostBlit(sc2);
|
||||||
@@ -523,7 +523,7 @@ void StructDeclaration::semantic(Scope *sc)
|
|||||||
|
|
||||||
// Determine if struct is all zeros or not
|
// Determine if struct is all zeros or not
|
||||||
zeroInit = 1;
|
zeroInit = 1;
|
||||||
for (size_t i = 0; i < fields.dim; i++)
|
for (size_t i = 0; i < fields.dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = (Dsymbol *)fields.data[i];
|
Dsymbol *s = (Dsymbol *)fields.data[i];
|
||||||
VarDeclaration *vd = s->isVarDeclaration();
|
VarDeclaration *vd = s->isVarDeclaration();
|
||||||
@@ -566,7 +566,7 @@ Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags)
|
|||||||
{
|
{
|
||||||
//printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars());
|
//printf("%s.StructDeclaration::search('%s')\n", toChars(), ident->toChars());
|
||||||
|
|
||||||
if (scope && !symtab)
|
if (scope && !symtab)
|
||||||
semantic(scope);
|
semantic(scope);
|
||||||
|
|
||||||
if (!members || !symtab)
|
if (!members || !symtab)
|
||||||
@@ -579,7 +579,7 @@ Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->printf("%s ", kind());
|
buf->printf("%s ", kind());
|
||||||
if (!isAnonymous())
|
if (!isAnonymous())
|
||||||
buf->writestring(toChars());
|
buf->writestring(toChars());
|
||||||
@@ -592,9 +592,9 @@ void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
|||||||
buf->writenl();
|
buf->writenl();
|
||||||
buf->writeByte('{');
|
buf->writeByte('{');
|
||||||
buf->writenl();
|
buf->writenl();
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = members->tdata()[i];
|
Dsymbol *s = members->tdata()[i];
|
||||||
|
|
||||||
buf->writestring(" ");
|
buf->writestring(" ");
|
||||||
s->toCBuffer(buf, hgs);
|
s->toCBuffer(buf, hgs);
|
||||||
|
|||||||
+344
-344
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2011 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
@@ -55,7 +55,7 @@ struct TemplateDeclaration : ScopeDsymbol
|
|||||||
|
|
||||||
TemplateParameters *origParameters; // originals for Ddoc
|
TemplateParameters *origParameters; // originals for Ddoc
|
||||||
Expression *constraint;
|
Expression *constraint;
|
||||||
TemplateInstances instances; // array of TemplateInstance's
|
TemplateInstances instances; // array of TemplateInstance's
|
||||||
|
|
||||||
TemplateDeclaration *overnext; // next overloaded TemplateDeclaration
|
TemplateDeclaration *overnext; // next overloaded TemplateDeclaration
|
||||||
TemplateDeclaration *overroot; // first in overnext list
|
TemplateDeclaration *overroot; // first in overnext list
|
||||||
@@ -65,12 +65,12 @@ struct TemplateDeclaration : ScopeDsymbol
|
|||||||
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,
|
TemplateDeclaration(Loc loc, Identifier *id, TemplateParameters *parameters,
|
||||||
Expression *constraint, Dsymbols *decldefs);
|
Expression *constraint, Dsymbols *decldefs);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *);
|
Dsymbol *syntaxCopy(Dsymbol *);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
int overloadInsert(Dsymbol *s);
|
int overloadInsert(Dsymbol *s);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
bool hasStaticCtorOrDtor();
|
bool hasStaticCtorOrDtor();
|
||||||
const char *kind();
|
const char *kind();
|
||||||
char *toChars();
|
char *toChars();
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ struct TemplateParameter
|
|||||||
|
|
||||||
/* Match actual argument against parameter.
|
/* Match actual argument against parameter.
|
||||||
*/
|
*/
|
||||||
virtual MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags = 0) = 0;
|
virtual MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags = 0) = 0;
|
||||||
|
|
||||||
/* Create dummy argument based on parameter.
|
/* Create dummy argument based on parameter.
|
||||||
*/
|
*/
|
||||||
@@ -167,7 +167,7 @@ struct TemplateTypeParameter : TemplateParameter
|
|||||||
Object *specialization();
|
Object *specialization();
|
||||||
Object *defaultArg(Loc loc, Scope *sc);
|
Object *defaultArg(Loc loc, Scope *sc);
|
||||||
int overloadMatch(TemplateParameter *);
|
int overloadMatch(TemplateParameter *);
|
||||||
MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags);
|
MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags);
|
||||||
void *dummyArg();
|
void *dummyArg();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ struct TemplateValueParameter : TemplateParameter
|
|||||||
Expression *specValue;
|
Expression *specValue;
|
||||||
Expression *defaultValue;
|
Expression *defaultValue;
|
||||||
|
|
||||||
static AA *edummies;
|
static AA *edummies;
|
||||||
|
|
||||||
TemplateValueParameter(Loc loc, Identifier *ident, Type *valType, Expression *specValue, Expression *defaultValue);
|
TemplateValueParameter(Loc loc, Identifier *ident, Type *valType, Expression *specValue, Expression *defaultValue);
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ struct TemplateValueParameter : TemplateParameter
|
|||||||
Object *specialization();
|
Object *specialization();
|
||||||
Object *defaultArg(Loc loc, Scope *sc);
|
Object *defaultArg(Loc loc, Scope *sc);
|
||||||
int overloadMatch(TemplateParameter *);
|
int overloadMatch(TemplateParameter *);
|
||||||
MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags);
|
MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags);
|
||||||
void *dummyArg();
|
void *dummyArg();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ struct TemplateAliasParameter : TemplateParameter
|
|||||||
Object *specialization();
|
Object *specialization();
|
||||||
Object *defaultArg(Loc loc, Scope *sc);
|
Object *defaultArg(Loc loc, Scope *sc);
|
||||||
int overloadMatch(TemplateParameter *);
|
int overloadMatch(TemplateParameter *);
|
||||||
MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags);
|
MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags);
|
||||||
void *dummyArg();
|
void *dummyArg();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ struct TemplateTupleParameter : TemplateParameter
|
|||||||
Object *specialization();
|
Object *specialization();
|
||||||
Object *defaultArg(Loc loc, Scope *sc);
|
Object *defaultArg(Loc loc, Scope *sc);
|
||||||
int overloadMatch(TemplateParameter *);
|
int overloadMatch(TemplateParameter *);
|
||||||
MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags);
|
MATCH matchArg(Scope *sc, Objects *tiargs, size_t i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags);
|
||||||
void *dummyArg();
|
void *dummyArg();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -272,7 +272,7 @@ struct TemplateInstance : ScopeDsymbol
|
|||||||
* tiargs = args
|
* tiargs = args
|
||||||
*/
|
*/
|
||||||
Identifier *name;
|
Identifier *name;
|
||||||
//Identifiers idents;
|
//Identifiers idents;
|
||||||
Objects *tiargs; // Array of Types/Expressions of template
|
Objects *tiargs; // Array of Types/Expressions of template
|
||||||
// instance arguments [int*, char, 10*10]
|
// instance arguments [int*, char, 10*10]
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ struct TemplateInstance : ScopeDsymbol
|
|||||||
int havetempdecl; // 1 if used second constructor
|
int havetempdecl; // 1 if used second constructor
|
||||||
Dsymbol *isnested; // if referencing local symbols, this is the context
|
Dsymbol *isnested; // if referencing local symbols, this is the context
|
||||||
int errors; // 1 if compiled with errors
|
int errors; // 1 if compiled with errors
|
||||||
int speculative; // 1 if only instantiated with errors gagged
|
int speculative; // 1 if only instantiated with errors gagged
|
||||||
#ifdef IN_GCC
|
#ifdef IN_GCC
|
||||||
/* On some targets, it is necessary to know whether a symbol
|
/* On some targets, it is necessary to know whether a symbol
|
||||||
will be emitted in the output or not before the symbol
|
will be emitted in the output or not before the symbol
|
||||||
@@ -345,10 +345,10 @@ struct TemplateInstance : ScopeDsymbol
|
|||||||
|
|
||||||
struct TemplateMixin : TemplateInstance
|
struct TemplateMixin : TemplateInstance
|
||||||
{
|
{
|
||||||
Identifiers *idents;
|
Identifiers *idents;
|
||||||
Type *tqual;
|
Type *tqual;
|
||||||
|
|
||||||
TemplateMixin(Loc loc, Identifier *ident, Type *tqual, Identifiers *idents, Objects *tiargs);
|
TemplateMixin(Loc loc, Identifier *ident, Type *tqual, Identifiers *idents, Objects *tiargs);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *s);
|
Dsymbol *syntaxCopy(Dsymbol *s);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void semantic2(Scope *sc);
|
void semantic2(Scope *sc);
|
||||||
|
|||||||
+323
-323
@@ -1,323 +1,323 @@
|
|||||||
|
|
||||||
// Copyright (c) 2003 by Digital Mars
|
// Copyright (c) 2003 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/*******************************
|
/*******************************
|
||||||
* Return !=0 if unicode alpha.
|
* Return !=0 if unicode alpha.
|
||||||
* Use table from C99 Appendix D.
|
* Use table from C99 Appendix D.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int isUniAlpha(unsigned u)
|
int isUniAlpha(unsigned u)
|
||||||
{
|
{
|
||||||
static unsigned short table[][2] =
|
static unsigned short table[][2] =
|
||||||
{
|
{
|
||||||
{ 0x00AA, 0x00AA },
|
{ 0x00AA, 0x00AA },
|
||||||
{ 0x00B5, 0x00B5 },
|
{ 0x00B5, 0x00B5 },
|
||||||
{ 0x00B7, 0x00B7 },
|
{ 0x00B7, 0x00B7 },
|
||||||
{ 0x00BA, 0x00BA },
|
{ 0x00BA, 0x00BA },
|
||||||
{ 0x00C0, 0x00D6 },
|
{ 0x00C0, 0x00D6 },
|
||||||
{ 0x00D8, 0x00F6 },
|
{ 0x00D8, 0x00F6 },
|
||||||
{ 0x00F8, 0x01F5 },
|
{ 0x00F8, 0x01F5 },
|
||||||
{ 0x01FA, 0x0217 },
|
{ 0x01FA, 0x0217 },
|
||||||
{ 0x0250, 0x02A8 },
|
{ 0x0250, 0x02A8 },
|
||||||
{ 0x02B0, 0x02B8 },
|
{ 0x02B0, 0x02B8 },
|
||||||
{ 0x02BB, 0x02BB },
|
{ 0x02BB, 0x02BB },
|
||||||
{ 0x02BD, 0x02C1 },
|
{ 0x02BD, 0x02C1 },
|
||||||
{ 0x02D0, 0x02D1 },
|
{ 0x02D0, 0x02D1 },
|
||||||
{ 0x02E0, 0x02E4 },
|
{ 0x02E0, 0x02E4 },
|
||||||
{ 0x037A, 0x037A },
|
{ 0x037A, 0x037A },
|
||||||
{ 0x0386, 0x0386 },
|
{ 0x0386, 0x0386 },
|
||||||
{ 0x0388, 0x038A },
|
{ 0x0388, 0x038A },
|
||||||
{ 0x038C, 0x038C },
|
{ 0x038C, 0x038C },
|
||||||
{ 0x038E, 0x03A1 },
|
{ 0x038E, 0x03A1 },
|
||||||
{ 0x03A3, 0x03CE },
|
{ 0x03A3, 0x03CE },
|
||||||
{ 0x03D0, 0x03D6 },
|
{ 0x03D0, 0x03D6 },
|
||||||
{ 0x03DA, 0x03DA },
|
{ 0x03DA, 0x03DA },
|
||||||
{ 0x03DC, 0x03DC },
|
{ 0x03DC, 0x03DC },
|
||||||
{ 0x03DE, 0x03DE },
|
{ 0x03DE, 0x03DE },
|
||||||
{ 0x03E0, 0x03E0 },
|
{ 0x03E0, 0x03E0 },
|
||||||
{ 0x03E2, 0x03F3 },
|
{ 0x03E2, 0x03F3 },
|
||||||
{ 0x0401, 0x040C },
|
{ 0x0401, 0x040C },
|
||||||
{ 0x040E, 0x044F },
|
{ 0x040E, 0x044F },
|
||||||
{ 0x0451, 0x045C },
|
{ 0x0451, 0x045C },
|
||||||
{ 0x045E, 0x0481 },
|
{ 0x045E, 0x0481 },
|
||||||
{ 0x0490, 0x04C4 },
|
{ 0x0490, 0x04C4 },
|
||||||
{ 0x04C7, 0x04C8 },
|
{ 0x04C7, 0x04C8 },
|
||||||
{ 0x04CB, 0x04CC },
|
{ 0x04CB, 0x04CC },
|
||||||
{ 0x04D0, 0x04EB },
|
{ 0x04D0, 0x04EB },
|
||||||
{ 0x04EE, 0x04F5 },
|
{ 0x04EE, 0x04F5 },
|
||||||
{ 0x04F8, 0x04F9 },
|
{ 0x04F8, 0x04F9 },
|
||||||
{ 0x0531, 0x0556 },
|
{ 0x0531, 0x0556 },
|
||||||
{ 0x0559, 0x0559 },
|
{ 0x0559, 0x0559 },
|
||||||
{ 0x0561, 0x0587 },
|
{ 0x0561, 0x0587 },
|
||||||
{ 0x05B0, 0x05B9 },
|
{ 0x05B0, 0x05B9 },
|
||||||
{ 0x05BB, 0x05BD },
|
{ 0x05BB, 0x05BD },
|
||||||
{ 0x05BF, 0x05BF },
|
{ 0x05BF, 0x05BF },
|
||||||
{ 0x05C1, 0x05C2 },
|
{ 0x05C1, 0x05C2 },
|
||||||
{ 0x05D0, 0x05EA },
|
{ 0x05D0, 0x05EA },
|
||||||
{ 0x05F0, 0x05F2 },
|
{ 0x05F0, 0x05F2 },
|
||||||
{ 0x0621, 0x063A },
|
{ 0x0621, 0x063A },
|
||||||
{ 0x0640, 0x0652 },
|
{ 0x0640, 0x0652 },
|
||||||
{ 0x0660, 0x0669 },
|
{ 0x0660, 0x0669 },
|
||||||
{ 0x0670, 0x06B7 },
|
{ 0x0670, 0x06B7 },
|
||||||
{ 0x06BA, 0x06BE },
|
{ 0x06BA, 0x06BE },
|
||||||
{ 0x06C0, 0x06CE },
|
{ 0x06C0, 0x06CE },
|
||||||
{ 0x06D0, 0x06DC },
|
{ 0x06D0, 0x06DC },
|
||||||
{ 0x06E5, 0x06E8 },
|
{ 0x06E5, 0x06E8 },
|
||||||
{ 0x06EA, 0x06ED },
|
{ 0x06EA, 0x06ED },
|
||||||
{ 0x06F0, 0x06F9 },
|
{ 0x06F0, 0x06F9 },
|
||||||
{ 0x0901, 0x0903 },
|
{ 0x0901, 0x0903 },
|
||||||
{ 0x0905, 0x0939 },
|
{ 0x0905, 0x0939 },
|
||||||
{ 0x093D, 0x093D },
|
{ 0x093D, 0x093D },
|
||||||
{ 0x093E, 0x094D },
|
{ 0x093E, 0x094D },
|
||||||
{ 0x0950, 0x0952 },
|
{ 0x0950, 0x0952 },
|
||||||
{ 0x0958, 0x0963 },
|
{ 0x0958, 0x0963 },
|
||||||
{ 0x0966, 0x096F },
|
{ 0x0966, 0x096F },
|
||||||
{ 0x0981, 0x0983 },
|
{ 0x0981, 0x0983 },
|
||||||
{ 0x0985, 0x098C },
|
{ 0x0985, 0x098C },
|
||||||
{ 0x098F, 0x0990 },
|
{ 0x098F, 0x0990 },
|
||||||
{ 0x0993, 0x09A8 },
|
{ 0x0993, 0x09A8 },
|
||||||
{ 0x09AA, 0x09B0 },
|
{ 0x09AA, 0x09B0 },
|
||||||
{ 0x09B2, 0x09B2 },
|
{ 0x09B2, 0x09B2 },
|
||||||
{ 0x09B6, 0x09B9 },
|
{ 0x09B6, 0x09B9 },
|
||||||
{ 0x09BE, 0x09C4 },
|
{ 0x09BE, 0x09C4 },
|
||||||
{ 0x09C7, 0x09C8 },
|
{ 0x09C7, 0x09C8 },
|
||||||
{ 0x09CB, 0x09CD },
|
{ 0x09CB, 0x09CD },
|
||||||
{ 0x09DC, 0x09DD },
|
{ 0x09DC, 0x09DD },
|
||||||
{ 0x09DF, 0x09E3 },
|
{ 0x09DF, 0x09E3 },
|
||||||
{ 0x09E6, 0x09EF },
|
{ 0x09E6, 0x09EF },
|
||||||
{ 0x09F0, 0x09F1 },
|
{ 0x09F0, 0x09F1 },
|
||||||
{ 0x0A02, 0x0A02 },
|
{ 0x0A02, 0x0A02 },
|
||||||
{ 0x0A05, 0x0A0A },
|
{ 0x0A05, 0x0A0A },
|
||||||
{ 0x0A0F, 0x0A10 },
|
{ 0x0A0F, 0x0A10 },
|
||||||
{ 0x0A13, 0x0A28 },
|
{ 0x0A13, 0x0A28 },
|
||||||
{ 0x0A2A, 0x0A30 },
|
{ 0x0A2A, 0x0A30 },
|
||||||
{ 0x0A32, 0x0A33 },
|
{ 0x0A32, 0x0A33 },
|
||||||
{ 0x0A35, 0x0A36 },
|
{ 0x0A35, 0x0A36 },
|
||||||
{ 0x0A38, 0x0A39 },
|
{ 0x0A38, 0x0A39 },
|
||||||
{ 0x0A3E, 0x0A42 },
|
{ 0x0A3E, 0x0A42 },
|
||||||
{ 0x0A47, 0x0A48 },
|
{ 0x0A47, 0x0A48 },
|
||||||
{ 0x0A4B, 0x0A4D },
|
{ 0x0A4B, 0x0A4D },
|
||||||
{ 0x0A59, 0x0A5C },
|
{ 0x0A59, 0x0A5C },
|
||||||
{ 0x0A5E, 0x0A5E },
|
{ 0x0A5E, 0x0A5E },
|
||||||
{ 0x0A66, 0x0A6F },
|
{ 0x0A66, 0x0A6F },
|
||||||
{ 0x0A74, 0x0A74 },
|
{ 0x0A74, 0x0A74 },
|
||||||
{ 0x0A81, 0x0A83 },
|
{ 0x0A81, 0x0A83 },
|
||||||
{ 0x0A85, 0x0A8B },
|
{ 0x0A85, 0x0A8B },
|
||||||
{ 0x0A8D, 0x0A8D },
|
{ 0x0A8D, 0x0A8D },
|
||||||
{ 0x0A8F, 0x0A91 },
|
{ 0x0A8F, 0x0A91 },
|
||||||
{ 0x0A93, 0x0AA8 },
|
{ 0x0A93, 0x0AA8 },
|
||||||
{ 0x0AAA, 0x0AB0 },
|
{ 0x0AAA, 0x0AB0 },
|
||||||
{ 0x0AB2, 0x0AB3 },
|
{ 0x0AB2, 0x0AB3 },
|
||||||
{ 0x0AB5, 0x0AB9 },
|
{ 0x0AB5, 0x0AB9 },
|
||||||
{ 0x0ABD, 0x0AC5 },
|
{ 0x0ABD, 0x0AC5 },
|
||||||
{ 0x0AC7, 0x0AC9 },
|
{ 0x0AC7, 0x0AC9 },
|
||||||
{ 0x0ACB, 0x0ACD },
|
{ 0x0ACB, 0x0ACD },
|
||||||
{ 0x0AD0, 0x0AD0 },
|
{ 0x0AD0, 0x0AD0 },
|
||||||
{ 0x0AE0, 0x0AE0 },
|
{ 0x0AE0, 0x0AE0 },
|
||||||
{ 0x0AE6, 0x0AEF },
|
{ 0x0AE6, 0x0AEF },
|
||||||
{ 0x0B01, 0x0B03 },
|
{ 0x0B01, 0x0B03 },
|
||||||
{ 0x0B05, 0x0B0C },
|
{ 0x0B05, 0x0B0C },
|
||||||
{ 0x0B0F, 0x0B10 },
|
{ 0x0B0F, 0x0B10 },
|
||||||
{ 0x0B13, 0x0B28 },
|
{ 0x0B13, 0x0B28 },
|
||||||
{ 0x0B2A, 0x0B30 },
|
{ 0x0B2A, 0x0B30 },
|
||||||
{ 0x0B32, 0x0B33 },
|
{ 0x0B32, 0x0B33 },
|
||||||
{ 0x0B36, 0x0B39 },
|
{ 0x0B36, 0x0B39 },
|
||||||
{ 0x0B3D, 0x0B3D },
|
{ 0x0B3D, 0x0B3D },
|
||||||
{ 0x0B3E, 0x0B43 },
|
{ 0x0B3E, 0x0B43 },
|
||||||
{ 0x0B47, 0x0B48 },
|
{ 0x0B47, 0x0B48 },
|
||||||
{ 0x0B4B, 0x0B4D },
|
{ 0x0B4B, 0x0B4D },
|
||||||
{ 0x0B5C, 0x0B5D },
|
{ 0x0B5C, 0x0B5D },
|
||||||
{ 0x0B5F, 0x0B61 },
|
{ 0x0B5F, 0x0B61 },
|
||||||
{ 0x0B66, 0x0B6F },
|
{ 0x0B66, 0x0B6F },
|
||||||
{ 0x0B82, 0x0B83 },
|
{ 0x0B82, 0x0B83 },
|
||||||
{ 0x0B85, 0x0B8A },
|
{ 0x0B85, 0x0B8A },
|
||||||
{ 0x0B8E, 0x0B90 },
|
{ 0x0B8E, 0x0B90 },
|
||||||
{ 0x0B92, 0x0B95 },
|
{ 0x0B92, 0x0B95 },
|
||||||
{ 0x0B99, 0x0B9A },
|
{ 0x0B99, 0x0B9A },
|
||||||
{ 0x0B9C, 0x0B9C },
|
{ 0x0B9C, 0x0B9C },
|
||||||
{ 0x0B9E, 0x0B9F },
|
{ 0x0B9E, 0x0B9F },
|
||||||
{ 0x0BA3, 0x0BA4 },
|
{ 0x0BA3, 0x0BA4 },
|
||||||
{ 0x0BA8, 0x0BAA },
|
{ 0x0BA8, 0x0BAA },
|
||||||
{ 0x0BAE, 0x0BB5 },
|
{ 0x0BAE, 0x0BB5 },
|
||||||
{ 0x0BB7, 0x0BB9 },
|
{ 0x0BB7, 0x0BB9 },
|
||||||
{ 0x0BBE, 0x0BC2 },
|
{ 0x0BBE, 0x0BC2 },
|
||||||
{ 0x0BC6, 0x0BC8 },
|
{ 0x0BC6, 0x0BC8 },
|
||||||
{ 0x0BCA, 0x0BCD },
|
{ 0x0BCA, 0x0BCD },
|
||||||
{ 0x0BE7, 0x0BEF },
|
{ 0x0BE7, 0x0BEF },
|
||||||
{ 0x0C01, 0x0C03 },
|
{ 0x0C01, 0x0C03 },
|
||||||
{ 0x0C05, 0x0C0C },
|
{ 0x0C05, 0x0C0C },
|
||||||
{ 0x0C0E, 0x0C10 },
|
{ 0x0C0E, 0x0C10 },
|
||||||
{ 0x0C12, 0x0C28 },
|
{ 0x0C12, 0x0C28 },
|
||||||
{ 0x0C2A, 0x0C33 },
|
{ 0x0C2A, 0x0C33 },
|
||||||
{ 0x0C35, 0x0C39 },
|
{ 0x0C35, 0x0C39 },
|
||||||
{ 0x0C3E, 0x0C44 },
|
{ 0x0C3E, 0x0C44 },
|
||||||
{ 0x0C46, 0x0C48 },
|
{ 0x0C46, 0x0C48 },
|
||||||
{ 0x0C4A, 0x0C4D },
|
{ 0x0C4A, 0x0C4D },
|
||||||
{ 0x0C60, 0x0C61 },
|
{ 0x0C60, 0x0C61 },
|
||||||
{ 0x0C66, 0x0C6F },
|
{ 0x0C66, 0x0C6F },
|
||||||
{ 0x0C82, 0x0C83 },
|
{ 0x0C82, 0x0C83 },
|
||||||
{ 0x0C85, 0x0C8C },
|
{ 0x0C85, 0x0C8C },
|
||||||
{ 0x0C8E, 0x0C90 },
|
{ 0x0C8E, 0x0C90 },
|
||||||
{ 0x0C92, 0x0CA8 },
|
{ 0x0C92, 0x0CA8 },
|
||||||
{ 0x0CAA, 0x0CB3 },
|
{ 0x0CAA, 0x0CB3 },
|
||||||
{ 0x0CB5, 0x0CB9 },
|
{ 0x0CB5, 0x0CB9 },
|
||||||
{ 0x0CBE, 0x0CC4 },
|
{ 0x0CBE, 0x0CC4 },
|
||||||
{ 0x0CC6, 0x0CC8 },
|
{ 0x0CC6, 0x0CC8 },
|
||||||
{ 0x0CCA, 0x0CCD },
|
{ 0x0CCA, 0x0CCD },
|
||||||
{ 0x0CDE, 0x0CDE },
|
{ 0x0CDE, 0x0CDE },
|
||||||
{ 0x0CE0, 0x0CE1 },
|
{ 0x0CE0, 0x0CE1 },
|
||||||
{ 0x0CE6, 0x0CEF },
|
{ 0x0CE6, 0x0CEF },
|
||||||
{ 0x0D02, 0x0D03 },
|
{ 0x0D02, 0x0D03 },
|
||||||
{ 0x0D05, 0x0D0C },
|
{ 0x0D05, 0x0D0C },
|
||||||
{ 0x0D0E, 0x0D10 },
|
{ 0x0D0E, 0x0D10 },
|
||||||
{ 0x0D12, 0x0D28 },
|
{ 0x0D12, 0x0D28 },
|
||||||
{ 0x0D2A, 0x0D39 },
|
{ 0x0D2A, 0x0D39 },
|
||||||
{ 0x0D3E, 0x0D43 },
|
{ 0x0D3E, 0x0D43 },
|
||||||
{ 0x0D46, 0x0D48 },
|
{ 0x0D46, 0x0D48 },
|
||||||
{ 0x0D4A, 0x0D4D },
|
{ 0x0D4A, 0x0D4D },
|
||||||
{ 0x0D60, 0x0D61 },
|
{ 0x0D60, 0x0D61 },
|
||||||
{ 0x0D66, 0x0D6F },
|
{ 0x0D66, 0x0D6F },
|
||||||
{ 0x0E01, 0x0E3A },
|
{ 0x0E01, 0x0E3A },
|
||||||
{ 0x0E40, 0x0E5B },
|
{ 0x0E40, 0x0E5B },
|
||||||
// { 0x0E50, 0x0E59 },
|
// { 0x0E50, 0x0E59 },
|
||||||
{ 0x0E81, 0x0E82 },
|
{ 0x0E81, 0x0E82 },
|
||||||
{ 0x0E84, 0x0E84 },
|
{ 0x0E84, 0x0E84 },
|
||||||
{ 0x0E87, 0x0E88 },
|
{ 0x0E87, 0x0E88 },
|
||||||
{ 0x0E8A, 0x0E8A },
|
{ 0x0E8A, 0x0E8A },
|
||||||
{ 0x0E8D, 0x0E8D },
|
{ 0x0E8D, 0x0E8D },
|
||||||
{ 0x0E94, 0x0E97 },
|
{ 0x0E94, 0x0E97 },
|
||||||
{ 0x0E99, 0x0E9F },
|
{ 0x0E99, 0x0E9F },
|
||||||
{ 0x0EA1, 0x0EA3 },
|
{ 0x0EA1, 0x0EA3 },
|
||||||
{ 0x0EA5, 0x0EA5 },
|
{ 0x0EA5, 0x0EA5 },
|
||||||
{ 0x0EA7, 0x0EA7 },
|
{ 0x0EA7, 0x0EA7 },
|
||||||
{ 0x0EAA, 0x0EAB },
|
{ 0x0EAA, 0x0EAB },
|
||||||
{ 0x0EAD, 0x0EAE },
|
{ 0x0EAD, 0x0EAE },
|
||||||
{ 0x0EB0, 0x0EB9 },
|
{ 0x0EB0, 0x0EB9 },
|
||||||
{ 0x0EBB, 0x0EBD },
|
{ 0x0EBB, 0x0EBD },
|
||||||
{ 0x0EC0, 0x0EC4 },
|
{ 0x0EC0, 0x0EC4 },
|
||||||
{ 0x0EC6, 0x0EC6 },
|
{ 0x0EC6, 0x0EC6 },
|
||||||
{ 0x0EC8, 0x0ECD },
|
{ 0x0EC8, 0x0ECD },
|
||||||
{ 0x0ED0, 0x0ED9 },
|
{ 0x0ED0, 0x0ED9 },
|
||||||
{ 0x0EDC, 0x0EDD },
|
{ 0x0EDC, 0x0EDD },
|
||||||
{ 0x0F00, 0x0F00 },
|
{ 0x0F00, 0x0F00 },
|
||||||
{ 0x0F18, 0x0F19 },
|
{ 0x0F18, 0x0F19 },
|
||||||
{ 0x0F20, 0x0F33 },
|
{ 0x0F20, 0x0F33 },
|
||||||
{ 0x0F35, 0x0F35 },
|
{ 0x0F35, 0x0F35 },
|
||||||
{ 0x0F37, 0x0F37 },
|
{ 0x0F37, 0x0F37 },
|
||||||
{ 0x0F39, 0x0F39 },
|
{ 0x0F39, 0x0F39 },
|
||||||
{ 0x0F3E, 0x0F47 },
|
{ 0x0F3E, 0x0F47 },
|
||||||
{ 0x0F49, 0x0F69 },
|
{ 0x0F49, 0x0F69 },
|
||||||
{ 0x0F71, 0x0F84 },
|
{ 0x0F71, 0x0F84 },
|
||||||
{ 0x0F86, 0x0F8B },
|
{ 0x0F86, 0x0F8B },
|
||||||
{ 0x0F90, 0x0F95 },
|
{ 0x0F90, 0x0F95 },
|
||||||
{ 0x0F97, 0x0F97 },
|
{ 0x0F97, 0x0F97 },
|
||||||
{ 0x0F99, 0x0FAD },
|
{ 0x0F99, 0x0FAD },
|
||||||
{ 0x0FB1, 0x0FB7 },
|
{ 0x0FB1, 0x0FB7 },
|
||||||
{ 0x0FB9, 0x0FB9 },
|
{ 0x0FB9, 0x0FB9 },
|
||||||
{ 0x10A0, 0x10C5 },
|
{ 0x10A0, 0x10C5 },
|
||||||
{ 0x10D0, 0x10F6 },
|
{ 0x10D0, 0x10F6 },
|
||||||
{ 0x1E00, 0x1E9B },
|
{ 0x1E00, 0x1E9B },
|
||||||
{ 0x1EA0, 0x1EF9 },
|
{ 0x1EA0, 0x1EF9 },
|
||||||
{ 0x1F00, 0x1F15 },
|
{ 0x1F00, 0x1F15 },
|
||||||
{ 0x1F18, 0x1F1D },
|
{ 0x1F18, 0x1F1D },
|
||||||
{ 0x1F20, 0x1F45 },
|
{ 0x1F20, 0x1F45 },
|
||||||
{ 0x1F48, 0x1F4D },
|
{ 0x1F48, 0x1F4D },
|
||||||
{ 0x1F50, 0x1F57 },
|
{ 0x1F50, 0x1F57 },
|
||||||
{ 0x1F59, 0x1F59 },
|
{ 0x1F59, 0x1F59 },
|
||||||
{ 0x1F5B, 0x1F5B },
|
{ 0x1F5B, 0x1F5B },
|
||||||
{ 0x1F5D, 0x1F5D },
|
{ 0x1F5D, 0x1F5D },
|
||||||
{ 0x1F5F, 0x1F7D },
|
{ 0x1F5F, 0x1F7D },
|
||||||
{ 0x1F80, 0x1FB4 },
|
{ 0x1F80, 0x1FB4 },
|
||||||
{ 0x1FB6, 0x1FBC },
|
{ 0x1FB6, 0x1FBC },
|
||||||
{ 0x1FBE, 0x1FBE },
|
{ 0x1FBE, 0x1FBE },
|
||||||
{ 0x1FC2, 0x1FC4 },
|
{ 0x1FC2, 0x1FC4 },
|
||||||
{ 0x1FC6, 0x1FCC },
|
{ 0x1FC6, 0x1FCC },
|
||||||
{ 0x1FD0, 0x1FD3 },
|
{ 0x1FD0, 0x1FD3 },
|
||||||
{ 0x1FD6, 0x1FDB },
|
{ 0x1FD6, 0x1FDB },
|
||||||
{ 0x1FE0, 0x1FEC },
|
{ 0x1FE0, 0x1FEC },
|
||||||
{ 0x1FF2, 0x1FF4 },
|
{ 0x1FF2, 0x1FF4 },
|
||||||
{ 0x1FF6, 0x1FFC },
|
{ 0x1FF6, 0x1FFC },
|
||||||
{ 0x203F, 0x2040 },
|
{ 0x203F, 0x2040 },
|
||||||
{ 0x207F, 0x207F },
|
{ 0x207F, 0x207F },
|
||||||
{ 0x2102, 0x2102 },
|
{ 0x2102, 0x2102 },
|
||||||
{ 0x2107, 0x2107 },
|
{ 0x2107, 0x2107 },
|
||||||
{ 0x210A, 0x2113 },
|
{ 0x210A, 0x2113 },
|
||||||
{ 0x2115, 0x2115 },
|
{ 0x2115, 0x2115 },
|
||||||
{ 0x2118, 0x211D },
|
{ 0x2118, 0x211D },
|
||||||
{ 0x2124, 0x2124 },
|
{ 0x2124, 0x2124 },
|
||||||
{ 0x2126, 0x2126 },
|
{ 0x2126, 0x2126 },
|
||||||
{ 0x2128, 0x2128 },
|
{ 0x2128, 0x2128 },
|
||||||
{ 0x212A, 0x2131 },
|
{ 0x212A, 0x2131 },
|
||||||
{ 0x2133, 0x2138 },
|
{ 0x2133, 0x2138 },
|
||||||
{ 0x2160, 0x2182 },
|
{ 0x2160, 0x2182 },
|
||||||
{ 0x3005, 0x3007 },
|
{ 0x3005, 0x3007 },
|
||||||
{ 0x3021, 0x3029 },
|
{ 0x3021, 0x3029 },
|
||||||
{ 0x3041, 0x3093 },
|
{ 0x3041, 0x3093 },
|
||||||
{ 0x309B, 0x309C },
|
{ 0x309B, 0x309C },
|
||||||
{ 0x30A1, 0x30F6 },
|
{ 0x30A1, 0x30F6 },
|
||||||
{ 0x30FB, 0x30FC },
|
{ 0x30FB, 0x30FC },
|
||||||
{ 0x3105, 0x312C },
|
{ 0x3105, 0x312C },
|
||||||
{ 0x4E00, 0x9FA5 },
|
{ 0x4E00, 0x9FA5 },
|
||||||
{ 0xAC00, 0xD7A3 },
|
{ 0xAC00, 0xD7A3 },
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++)
|
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++)
|
||||||
{
|
{
|
||||||
//printf("%x\n", table[i][0]);
|
//printf("%x\n", table[i][0]);
|
||||||
assert(table[i][0] <= table[i][1]);
|
assert(table[i][0] <= table[i][1]);
|
||||||
if (i < sizeof(table) / sizeof(table[0]) - 1)
|
if (i < sizeof(table) / sizeof(table[0]) - 1)
|
||||||
assert(table[i][1] < table[i + 1][0]);
|
assert(table[i][1] < table[i + 1][0]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (u > 0xD7A3)
|
if (u > 0xD7A3)
|
||||||
goto Lisnot;
|
goto Lisnot;
|
||||||
|
|
||||||
// Binary search
|
// Binary search
|
||||||
int mid;
|
int mid;
|
||||||
int low;
|
int low;
|
||||||
int high;
|
int high;
|
||||||
|
|
||||||
low = 0;
|
low = 0;
|
||||||
high = sizeof(table) / sizeof(table[0]) - 1;
|
high = sizeof(table) / sizeof(table[0]) - 1;
|
||||||
while (low <= high)
|
while (low <= high)
|
||||||
{
|
{
|
||||||
mid = (low + high) >> 1;
|
mid = (low + high) >> 1;
|
||||||
if (u < table[mid][0])
|
if (u < table[mid][0])
|
||||||
high = mid - 1;
|
high = mid - 1;
|
||||||
else if (u > table[mid][1])
|
else if (u > table[mid][1])
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
else
|
else
|
||||||
goto Lis;
|
goto Lis;
|
||||||
}
|
}
|
||||||
|
|
||||||
Lisnot:
|
Lisnot:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++)
|
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
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Lis:
|
Lis:
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++)
|
for (int i = 0; i < sizeof(table) / sizeof(table[0]); i++)
|
||||||
{
|
{
|
||||||
if (u >= table[i][0] && u <= table[i][1])
|
if (u >= table[i][0] && u <= table[i][1])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
assert(0); // should have been in table
|
assert(0); // should have been in table
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,320 +1,320 @@
|
|||||||
// utf.c
|
// utf.c
|
||||||
// Copyright (c) 2003-2010 by Digital Mars
|
// Copyright (c) 2003-2010 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
// Description of UTF-8 at:
|
// Description of UTF-8 at:
|
||||||
// http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
// http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "utf.h"
|
#include "utf.h"
|
||||||
|
|
||||||
int utf_isValidDchar(dchar_t c)
|
int utf_isValidDchar(dchar_t c)
|
||||||
{
|
{
|
||||||
return c < 0xD800 ||
|
return c < 0xD800 ||
|
||||||
(c > 0xDFFF && c <= 0x10FFFF && c != 0xFFFE && c != 0xFFFF);
|
(c > 0xDFFF && c <= 0x10FFFF && c != 0xFFFE && c != 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unsigned char UTF8stride[256] =
|
static const unsigned char UTF8stride[256] =
|
||||||
{
|
{
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||||
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
|
||||||
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||||
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||||
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
|
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
|
||||||
4,4,4,4,4,4,4,4,5,5,5,5,6,6,0xFF,0xFF,
|
4,4,4,4,4,4,4,4,5,5,5,5,6,6,0xFF,0xFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stride() returns the length of a UTF-8 sequence starting at index i
|
* stride() returns the length of a UTF-8 sequence starting at index i
|
||||||
* in string s.
|
* in string s.
|
||||||
* Returns:
|
* Returns:
|
||||||
* The number of bytes in the UTF-8 sequence or
|
* The number of bytes in the UTF-8 sequence or
|
||||||
* 0xFF meaning s[i] is not the start of of UTF-8 sequence.
|
* 0xFF meaning s[i] is not the start of of UTF-8 sequence.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned stride(unsigned char* s, size_t i)
|
unsigned stride(unsigned char* s, size_t i)
|
||||||
{
|
{
|
||||||
unsigned result = UTF8stride[s[i]];
|
unsigned result = UTF8stride[s[i]];
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************
|
/********************************************
|
||||||
* Decode a single UTF-8 character sequence.
|
* Decode a single UTF-8 character sequence.
|
||||||
* Returns:
|
* Returns:
|
||||||
* NULL success
|
* NULL success
|
||||||
* !=NULL error message string
|
* !=NULL error message string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *utf_decodeChar(unsigned char *s, size_t len, size_t *pidx, dchar_t *presult)
|
const char *utf_decodeChar(unsigned char *s, size_t len, size_t *pidx, dchar_t *presult)
|
||||||
{
|
{
|
||||||
dchar_t V;
|
dchar_t V;
|
||||||
size_t i = *pidx;
|
size_t i = *pidx;
|
||||||
unsigned char u = s[i];
|
unsigned char u = s[i];
|
||||||
|
|
||||||
//printf("utf_decodeChar(s = %02x, %02x, %02x len = %d)\n", u, s[1], s[2], len);
|
//printf("utf_decodeChar(s = %02x, %02x, %02x len = %d)\n", u, s[1], s[2], len);
|
||||||
|
|
||||||
assert(i >= 0 && i < len);
|
assert(i >= 0 && i < len);
|
||||||
|
|
||||||
if (u & 0x80)
|
if (u & 0x80)
|
||||||
{ unsigned n;
|
{ unsigned n;
|
||||||
unsigned char u2;
|
unsigned char u2;
|
||||||
|
|
||||||
/* The following encodings are valid, except for the 5 and 6 byte
|
/* The following encodings are valid, except for the 5 and 6 byte
|
||||||
* combinations:
|
* combinations:
|
||||||
* 0xxxxxxx
|
* 0xxxxxxx
|
||||||
* 110xxxxx 10xxxxxx
|
* 110xxxxx 10xxxxxx
|
||||||
* 1110xxxx 10xxxxxx 10xxxxxx
|
* 1110xxxx 10xxxxxx 10xxxxxx
|
||||||
* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
* 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
* 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
* 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||||
*/
|
*/
|
||||||
for (n = 1; ; n++)
|
for (n = 1; ; n++)
|
||||||
{
|
{
|
||||||
if (n > 4)
|
if (n > 4)
|
||||||
goto Lerr; // only do the first 4 of 6 encodings
|
goto Lerr; // only do the first 4 of 6 encodings
|
||||||
if (((u << n) & 0x80) == 0)
|
if (((u << n) & 0x80) == 0)
|
||||||
{
|
{
|
||||||
if (n == 1)
|
if (n == 1)
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pick off (7 - n) significant bits of B from first byte of octet
|
// Pick off (7 - n) significant bits of B from first byte of octet
|
||||||
V = (dchar_t)(u & ((1 << (7 - n)) - 1));
|
V = (dchar_t)(u & ((1 << (7 - n)) - 1));
|
||||||
|
|
||||||
if (i + (n - 1) >= len)
|
if (i + (n - 1) >= len)
|
||||||
goto Lerr; // off end of string
|
goto Lerr; // off end of string
|
||||||
|
|
||||||
/* The following combinations are overlong, and illegal:
|
/* The following combinations are overlong, and illegal:
|
||||||
* 1100000x (10xxxxxx)
|
* 1100000x (10xxxxxx)
|
||||||
* 11100000 100xxxxx (10xxxxxx)
|
* 11100000 100xxxxx (10xxxxxx)
|
||||||
* 11110000 1000xxxx (10xxxxxx 10xxxxxx)
|
* 11110000 1000xxxx (10xxxxxx 10xxxxxx)
|
||||||
* 11111000 10000xxx (10xxxxxx 10xxxxxx 10xxxxxx)
|
* 11111000 10000xxx (10xxxxxx 10xxxxxx 10xxxxxx)
|
||||||
* 11111100 100000xx (10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
|
* 11111100 100000xx (10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx)
|
||||||
*/
|
*/
|
||||||
u2 = s[i + 1];
|
u2 = s[i + 1];
|
||||||
if ((u & 0xFE) == 0xC0 ||
|
if ((u & 0xFE) == 0xC0 ||
|
||||||
(u == 0xE0 && (u2 & 0xE0) == 0x80) ||
|
(u == 0xE0 && (u2 & 0xE0) == 0x80) ||
|
||||||
(u == 0xF0 && (u2 & 0xF0) == 0x80) ||
|
(u == 0xF0 && (u2 & 0xF0) == 0x80) ||
|
||||||
(u == 0xF8 && (u2 & 0xF8) == 0x80) ||
|
(u == 0xF8 && (u2 & 0xF8) == 0x80) ||
|
||||||
(u == 0xFC && (u2 & 0xFC) == 0x80))
|
(u == 0xFC && (u2 & 0xFC) == 0x80))
|
||||||
goto Lerr; // overlong combination
|
goto Lerr; // overlong combination
|
||||||
|
|
||||||
for (unsigned j = 1; j != n; j++)
|
for (unsigned j = 1; j != n; j++)
|
||||||
{
|
{
|
||||||
u = s[i + j];
|
u = s[i + j];
|
||||||
if ((u & 0xC0) != 0x80)
|
if ((u & 0xC0) != 0x80)
|
||||||
goto Lerr; // trailing bytes are 10xxxxxx
|
goto Lerr; // trailing bytes are 10xxxxxx
|
||||||
V = (V << 6) | (u & 0x3F);
|
V = (V << 6) | (u & 0x3F);
|
||||||
}
|
}
|
||||||
if (!utf_isValidDchar(V))
|
if (!utf_isValidDchar(V))
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
i += n;
|
i += n;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
V = (dchar_t) u;
|
V = (dchar_t) u;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(utf_isValidDchar(V));
|
assert(utf_isValidDchar(V));
|
||||||
*pidx = i;
|
*pidx = i;
|
||||||
*presult = V;
|
*presult = V;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Lerr:
|
Lerr:
|
||||||
*presult = (dchar_t) s[i];
|
*presult = (dchar_t) s[i];
|
||||||
*pidx = i + 1;
|
*pidx = i + 1;
|
||||||
return "invalid UTF-8 sequence";
|
return "invalid UTF-8 sequence";
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
* Validate a UTF-8 string.
|
* Validate a UTF-8 string.
|
||||||
* Returns:
|
* Returns:
|
||||||
* NULL success
|
* NULL success
|
||||||
* !=NULL error message string
|
* !=NULL error message string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *utf_validateString(unsigned char *s, size_t len)
|
const char *utf_validateString(unsigned char *s, size_t len)
|
||||||
{
|
{
|
||||||
size_t idx;
|
size_t idx;
|
||||||
const char *err = NULL;
|
const char *err = NULL;
|
||||||
dchar_t dc;
|
dchar_t dc;
|
||||||
|
|
||||||
for (idx = 0; idx < len; )
|
for (idx = 0; idx < len; )
|
||||||
{
|
{
|
||||||
err = utf_decodeChar(s, len, &idx, &dc);
|
err = utf_decodeChar(s, len, &idx, &dc);
|
||||||
if (err)
|
if (err)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************
|
/********************************************
|
||||||
* Decode a single UTF-16 character sequence.
|
* Decode a single UTF-16 character sequence.
|
||||||
* Returns:
|
* Returns:
|
||||||
* NULL success
|
* NULL success
|
||||||
* !=NULL error message string
|
* !=NULL error message string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
const char *utf_decodeWchar(unsigned short *s, size_t len, size_t *pidx, dchar_t *presult)
|
const char *utf_decodeWchar(unsigned short *s, size_t len, size_t *pidx, dchar_t *presult)
|
||||||
{
|
{
|
||||||
const char *msg;
|
const char *msg;
|
||||||
size_t i = *pidx;
|
size_t i = *pidx;
|
||||||
unsigned u = s[i];
|
unsigned u = s[i];
|
||||||
|
|
||||||
assert(i >= 0 && i < len);
|
assert(i >= 0 && i < len);
|
||||||
if (u & ~0x7F)
|
if (u & ~0x7F)
|
||||||
{ if (u >= 0xD800 && u <= 0xDBFF)
|
{ if (u >= 0xD800 && u <= 0xDBFF)
|
||||||
{ unsigned u2;
|
{ unsigned u2;
|
||||||
|
|
||||||
if (i + 1 == len)
|
if (i + 1 == len)
|
||||||
{ msg = "surrogate UTF-16 high value past end of string";
|
{ msg = "surrogate UTF-16 high value past end of string";
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
}
|
}
|
||||||
u2 = s[i + 1];
|
u2 = s[i + 1];
|
||||||
if (u2 < 0xDC00 || u2 > 0xDFFF)
|
if (u2 < 0xDC00 || u2 > 0xDFFF)
|
||||||
{ msg = "surrogate UTF-16 low value out of range";
|
{ msg = "surrogate UTF-16 low value out of range";
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
}
|
}
|
||||||
u = ((u - 0xD7C0) << 10) + (u2 - 0xDC00);
|
u = ((u - 0xD7C0) << 10) + (u2 - 0xDC00);
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
else if (u >= 0xDC00 && u <= 0xDFFF)
|
else if (u >= 0xDC00 && u <= 0xDFFF)
|
||||||
{ msg = "unpaired surrogate UTF-16 value";
|
{ msg = "unpaired surrogate UTF-16 value";
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
}
|
}
|
||||||
else if (u == 0xFFFE || u == 0xFFFF)
|
else if (u == 0xFFFE || u == 0xFFFF)
|
||||||
{ msg = "illegal UTF-16 value";
|
{ msg = "illegal UTF-16 value";
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(utf_isValidDchar(u));
|
assert(utf_isValidDchar(u));
|
||||||
*pidx = i;
|
*pidx = i;
|
||||||
*presult = (dchar_t)u;
|
*presult = (dchar_t)u;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Lerr:
|
Lerr:
|
||||||
*presult = (dchar_t)s[i];
|
*presult = (dchar_t)s[i];
|
||||||
*pidx = i + 1;
|
*pidx = i + 1;
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void utf_encodeChar(unsigned char *s, dchar_t c)
|
void utf_encodeChar(unsigned char *s, dchar_t c)
|
||||||
{
|
{
|
||||||
if (c <= 0x7F)
|
if (c <= 0x7F)
|
||||||
{
|
{
|
||||||
s[0] = (char) c;
|
s[0] = (char) c;
|
||||||
}
|
}
|
||||||
else if (c <= 0x7FF)
|
else if (c <= 0x7FF)
|
||||||
{
|
{
|
||||||
s[0] = (char)(0xC0 | (c >> 6));
|
s[0] = (char)(0xC0 | (c >> 6));
|
||||||
s[1] = (char)(0x80 | (c & 0x3F));
|
s[1] = (char)(0x80 | (c & 0x3F));
|
||||||
}
|
}
|
||||||
else if (c <= 0xFFFF)
|
else if (c <= 0xFFFF)
|
||||||
{
|
{
|
||||||
s[0] = (char)(0xE0 | (c >> 12));
|
s[0] = (char)(0xE0 | (c >> 12));
|
||||||
s[1] = (char)(0x80 | ((c >> 6) & 0x3F));
|
s[1] = (char)(0x80 | ((c >> 6) & 0x3F));
|
||||||
s[2] = (char)(0x80 | (c & 0x3F));
|
s[2] = (char)(0x80 | (c & 0x3F));
|
||||||
}
|
}
|
||||||
else if (c <= 0x10FFFF)
|
else if (c <= 0x10FFFF)
|
||||||
{
|
{
|
||||||
s[0] = (char)(0xF0 | (c >> 18));
|
s[0] = (char)(0xF0 | (c >> 18));
|
||||||
s[1] = (char)(0x80 | ((c >> 12) & 0x3F));
|
s[1] = (char)(0x80 | ((c >> 12) & 0x3F));
|
||||||
s[2] = (char)(0x80 | ((c >> 6) & 0x3F));
|
s[2] = (char)(0x80 | ((c >> 6) & 0x3F));
|
||||||
s[3] = (char)(0x80 | (c & 0x3F));
|
s[3] = (char)(0x80 | (c & 0x3F));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void utf_encodeWchar(unsigned short *s, dchar_t c)
|
void utf_encodeWchar(unsigned short *s, dchar_t c)
|
||||||
{
|
{
|
||||||
if (c <= 0xFFFF)
|
if (c <= 0xFFFF)
|
||||||
{
|
{
|
||||||
s[0] = (wchar_t) c;
|
s[0] = (wchar_t) c;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s[0] = (wchar_t) ((((c - 0x10000) >> 10) & 0x3FF) + 0xD800);
|
s[0] = (wchar_t) ((((c - 0x10000) >> 10) & 0x3FF) + 0xD800);
|
||||||
s[1] = (wchar_t) (((c - 0x10000) & 0x3FF) + 0xDC00);
|
s[1] = (wchar_t) (((c - 0x10000) & 0x3FF) + 0xDC00);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the code length of c in the encoding.
|
* Returns the code length of c in the encoding.
|
||||||
* The code is returned in character count, not in bytes.
|
* The code is returned in character count, not in bytes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int utf_codeLengthChar(dchar_t c)
|
int utf_codeLengthChar(dchar_t c)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
c <= 0x7F ? 1
|
c <= 0x7F ? 1
|
||||||
: c <= 0x7FF ? 2
|
: c <= 0x7FF ? 2
|
||||||
: c <= 0xFFFF ? 3
|
: c <= 0xFFFF ? 3
|
||||||
: c <= 0x10FFFF ? 4
|
: c <= 0x10FFFF ? 4
|
||||||
: (assert(false), 6);
|
: (assert(false), 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
int utf_codeLengthWchar(dchar_t c)
|
int utf_codeLengthWchar(dchar_t c)
|
||||||
{
|
{
|
||||||
return c <= 0xFFFF ? 1 : 2;
|
return c <= 0xFFFF ? 1 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the code length of c in the encoding.
|
* Returns the code length of c in the encoding.
|
||||||
* sz is the encoding: 1 = utf8, 2 = utf16, 4 = utf32.
|
* sz is the encoding: 1 = utf8, 2 = utf16, 4 = utf32.
|
||||||
* The code is returned in character count, not in bytes.
|
* The code is returned in character count, not in bytes.
|
||||||
*/
|
*/
|
||||||
int utf_codeLength(int sz, dchar_t c)
|
int utf_codeLength(int sz, dchar_t c)
|
||||||
{
|
{
|
||||||
if (sz == 1)
|
if (sz == 1)
|
||||||
return utf_codeLengthChar(c);
|
return utf_codeLengthChar(c);
|
||||||
if (sz == 2)
|
if (sz == 2)
|
||||||
return utf_codeLengthWchar(c);
|
return utf_codeLengthWchar(c);
|
||||||
assert(sz == 4);
|
assert(sz == 4);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void utf_encode(int sz, void *s, dchar_t c)
|
void utf_encode(int sz, void *s, dchar_t c)
|
||||||
{
|
{
|
||||||
if (sz == 1)
|
if (sz == 1)
|
||||||
utf_encodeChar((unsigned char *)s, c);
|
utf_encodeChar((unsigned char *)s, c);
|
||||||
else if (sz == 2)
|
else if (sz == 2)
|
||||||
utf_encodeWchar((unsigned short *)s, c);
|
utf_encodeWchar((unsigned short *)s, c);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert(sz == 4);
|
assert(sz == 4);
|
||||||
memcpy((unsigned char *)s, &c, sz);
|
memcpy((unsigned char *)s, &c, sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// utf.h
|
// utf.h
|
||||||
// Copyright (c) 2003-2010 by Digital Mars
|
// Copyright (c) 2003-2010 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_UTF_H
|
#ifndef DMD_UTF_H
|
||||||
#define DMD_UTF_H
|
#define DMD_UTF_H
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned dchar_t;
|
typedef unsigned dchar_t;
|
||||||
|
|
||||||
int utf_isValidDchar(dchar_t c);
|
int utf_isValidDchar(dchar_t c);
|
||||||
|
|
||||||
const char *utf_decodeChar(unsigned char *s, size_t len, size_t *pidx, dchar_t *presult);
|
const char *utf_decodeChar(unsigned char *s, size_t len, size_t *pidx, dchar_t *presult);
|
||||||
const char *utf_decodeWchar(unsigned short *s, size_t len, size_t *pidx, dchar_t *presult);
|
const char *utf_decodeWchar(unsigned short *s, size_t len, size_t *pidx, dchar_t *presult);
|
||||||
|
|
||||||
const char *utf_validateString(unsigned char *s, size_t len);
|
const char *utf_validateString(unsigned char *s, size_t len);
|
||||||
|
|
||||||
extern int isUniAlpha(dchar_t);
|
extern int isUniAlpha(dchar_t);
|
||||||
|
|
||||||
void utf_encodeChar(unsigned char *s, dchar_t c);
|
void utf_encodeChar(unsigned char *s, dchar_t c);
|
||||||
void utf_encodeWchar(unsigned short *s, dchar_t c);
|
void utf_encodeWchar(unsigned short *s, dchar_t c);
|
||||||
|
|
||||||
int utf_codeLengthChar(dchar_t c);
|
int utf_codeLengthChar(dchar_t c);
|
||||||
int utf_codeLengthWchar(dchar_t c);
|
int utf_codeLengthWchar(dchar_t c);
|
||||||
|
|
||||||
int utf_codeLength(int sz, dchar_t c);
|
int utf_codeLength(int sz, dchar_t c);
|
||||||
void utf_encode(int sz, void *s, dchar_t c);
|
void utf_encode(int sz, void *s, dchar_t c);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+181
-181
@@ -1,181 +1,181 @@
|
|||||||
|
|
||||||
// Copyright (c) 1999-2005 by Digital Mars
|
// Copyright (c) 1999-2005 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "root.h"
|
#include "root.h"
|
||||||
|
|
||||||
#include "identifier.h"
|
#include "identifier.h"
|
||||||
#include "dsymbol.h"
|
#include "dsymbol.h"
|
||||||
#include "cond.h"
|
#include "cond.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* DebugSymbol's happen for statements like:
|
/* DebugSymbol's happen for statements like:
|
||||||
* debug = identifier;
|
* debug = identifier;
|
||||||
* debug = integer;
|
* debug = integer;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DebugSymbol::DebugSymbol(Loc loc, Identifier *ident)
|
DebugSymbol::DebugSymbol(Loc loc, Identifier *ident)
|
||||||
: Dsymbol(ident)
|
: Dsymbol(ident)
|
||||||
{
|
{
|
||||||
this->loc = loc;
|
this->loc = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugSymbol::DebugSymbol(Loc loc, unsigned level)
|
DebugSymbol::DebugSymbol(Loc loc, unsigned level)
|
||||||
: Dsymbol()
|
: Dsymbol()
|
||||||
{
|
{
|
||||||
this->level = level;
|
this->level = level;
|
||||||
this->loc = loc;
|
this->loc = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dsymbol *DebugSymbol::syntaxCopy(Dsymbol *s)
|
Dsymbol *DebugSymbol::syntaxCopy(Dsymbol *s)
|
||||||
{
|
{
|
||||||
assert(!s);
|
assert(!s);
|
||||||
DebugSymbol *ds = new DebugSymbol(loc, ident);
|
DebugSymbol *ds = new DebugSymbol(loc, ident);
|
||||||
ds->level = level;
|
ds->level = level;
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DebugSymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
int DebugSymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
||||||
{
|
{
|
||||||
//printf("DebugSymbol::addMember('%s') %s\n", sd->toChars(), toChars());
|
//printf("DebugSymbol::addMember('%s') %s\n", sd->toChars(), toChars());
|
||||||
Module *m;
|
Module *m;
|
||||||
|
|
||||||
// Do not add the member to the symbol table,
|
// Do not add the member to the symbol table,
|
||||||
// just make sure subsequent debug declarations work.
|
// just make sure subsequent debug declarations work.
|
||||||
m = sd->isModule();
|
m = sd->isModule();
|
||||||
if (ident)
|
if (ident)
|
||||||
{
|
{
|
||||||
if (!m)
|
if (!m)
|
||||||
error("declaration must be at module level");
|
error("declaration must be at module level");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (findCondition(m->debugidsNot, ident))
|
if (findCondition(m->debugidsNot, ident))
|
||||||
error("defined after use");
|
error("defined after use");
|
||||||
if (!m->debugids)
|
if (!m->debugids)
|
||||||
m->debugids = new Strings();
|
m->debugids = new Strings();
|
||||||
m->debugids->push(ident->toChars());
|
m->debugids->push(ident->toChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!m)
|
if (!m)
|
||||||
error("level declaration must be at module level");
|
error("level declaration must be at module level");
|
||||||
else
|
else
|
||||||
m->debuglevel = level;
|
m->debuglevel = level;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugSymbol::semantic(Scope *sc)
|
void DebugSymbol::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
//printf("DebugSymbol::semantic() %s\n", toChars());
|
//printf("DebugSymbol::semantic() %s\n", toChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugSymbol::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void DebugSymbol::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->writestring("debug = ");
|
buf->writestring("debug = ");
|
||||||
if (ident)
|
if (ident)
|
||||||
buf->writestring(ident->toChars());
|
buf->writestring(ident->toChars());
|
||||||
else
|
else
|
||||||
buf->printf("%u", level);
|
buf->printf("%u", level);
|
||||||
buf->writestring(";");
|
buf->writestring(";");
|
||||||
buf->writenl();
|
buf->writenl();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *DebugSymbol::kind()
|
const char *DebugSymbol::kind()
|
||||||
{
|
{
|
||||||
return "debug";
|
return "debug";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
/* VersionSymbol's happen for statements like:
|
/* VersionSymbol's happen for statements like:
|
||||||
* version = identifier;
|
* version = identifier;
|
||||||
* version = integer;
|
* version = integer;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VersionSymbol::VersionSymbol(Loc loc, Identifier *ident)
|
VersionSymbol::VersionSymbol(Loc loc, Identifier *ident)
|
||||||
: Dsymbol(ident)
|
: Dsymbol(ident)
|
||||||
{
|
{
|
||||||
this->loc = loc;
|
this->loc = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionSymbol::VersionSymbol(Loc loc, unsigned level)
|
VersionSymbol::VersionSymbol(Loc loc, unsigned level)
|
||||||
: Dsymbol()
|
: Dsymbol()
|
||||||
{
|
{
|
||||||
this->level = level;
|
this->level = level;
|
||||||
this->loc = loc;
|
this->loc = loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dsymbol *VersionSymbol::syntaxCopy(Dsymbol *s)
|
Dsymbol *VersionSymbol::syntaxCopy(Dsymbol *s)
|
||||||
{
|
{
|
||||||
assert(!s);
|
assert(!s);
|
||||||
VersionSymbol *ds = new VersionSymbol(loc, ident);
|
VersionSymbol *ds = new VersionSymbol(loc, ident);
|
||||||
ds->level = level;
|
ds->level = level;
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VersionSymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
int VersionSymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
||||||
{
|
{
|
||||||
//printf("VersionSymbol::addMember('%s') %s\n", sd->toChars(), toChars());
|
//printf("VersionSymbol::addMember('%s') %s\n", sd->toChars(), toChars());
|
||||||
Module *m;
|
Module *m;
|
||||||
|
|
||||||
// Do not add the member to the symbol table,
|
// Do not add the member to the symbol table,
|
||||||
// just make sure subsequent debug declarations work.
|
// just make sure subsequent debug declarations work.
|
||||||
m = sd->isModule();
|
m = sd->isModule();
|
||||||
if (ident)
|
if (ident)
|
||||||
{
|
{
|
||||||
VersionCondition::checkPredefined(loc, ident->toChars());
|
VersionCondition::checkPredefined(loc, ident->toChars());
|
||||||
if (!m)
|
if (!m)
|
||||||
error("declaration must be at module level");
|
error("declaration must be at module level");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (findCondition(m->versionidsNot, ident))
|
if (findCondition(m->versionidsNot, ident))
|
||||||
error("defined after use");
|
error("defined after use");
|
||||||
if (!m->versionids)
|
if (!m->versionids)
|
||||||
m->versionids = new Strings();
|
m->versionids = new Strings();
|
||||||
m->versionids->push(ident->toChars());
|
m->versionids->push(ident->toChars());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!m)
|
if (!m)
|
||||||
error("level declaration must be at module level");
|
error("level declaration must be at module level");
|
||||||
else
|
else
|
||||||
m->versionlevel = level;
|
m->versionlevel = level;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionSymbol::semantic(Scope *sc)
|
void VersionSymbol::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void VersionSymbol::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void VersionSymbol::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->writestring("version = ");
|
buf->writestring("version = ");
|
||||||
if (ident)
|
if (ident)
|
||||||
buf->writestring(ident->toChars());
|
buf->writestring(ident->toChars());
|
||||||
else
|
else
|
||||||
buf->printf("%u", level);
|
buf->printf("%u", level);
|
||||||
buf->writestring(";");
|
buf->writestring(";");
|
||||||
buf->writenl();
|
buf->writenl();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *VersionSymbol::kind()
|
const char *VersionSymbol::kind()
|
||||||
{
|
{
|
||||||
return "version";
|
return "version";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+51
-51
@@ -1,51 +1,51 @@
|
|||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2006 by Digital Mars
|
// Copyright (c) 1999-2006 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
// License for redistribution is by either the Artistic License
|
// License for redistribution is by either the Artistic License
|
||||||
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
// in artistic.txt, or the GNU General Public License in gnu.txt.
|
||||||
// See the included readme.txt for details.
|
// See the included readme.txt for details.
|
||||||
|
|
||||||
#ifndef DMD_VERSION_H
|
#ifndef DMD_VERSION_H
|
||||||
#define DMD_VERSION_H
|
#define DMD_VERSION_H
|
||||||
|
|
||||||
#ifdef __DMC__
|
#ifdef __DMC__
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif /* __DMC__ */
|
#endif /* __DMC__ */
|
||||||
|
|
||||||
#include "dsymbol.h"
|
#include "dsymbol.h"
|
||||||
|
|
||||||
struct OutBuffer;
|
struct OutBuffer;
|
||||||
struct HdrGenState;
|
struct HdrGenState;
|
||||||
|
|
||||||
struct DebugSymbol : Dsymbol
|
struct DebugSymbol : Dsymbol
|
||||||
{
|
{
|
||||||
unsigned level;
|
unsigned level;
|
||||||
|
|
||||||
DebugSymbol(Loc loc, Identifier *ident);
|
DebugSymbol(Loc loc, Identifier *ident);
|
||||||
DebugSymbol(Loc loc, unsigned level);
|
DebugSymbol(Loc loc, unsigned level);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *);
|
Dsymbol *syntaxCopy(Dsymbol *);
|
||||||
|
|
||||||
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
const char *kind();
|
const char *kind();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VersionSymbol : Dsymbol
|
struct VersionSymbol : Dsymbol
|
||||||
{
|
{
|
||||||
unsigned level;
|
unsigned level;
|
||||||
|
|
||||||
VersionSymbol(Loc loc, Identifier *ident);
|
VersionSymbol(Loc loc, Identifier *ident);
|
||||||
VersionSymbol(Loc loc, unsigned level);
|
VersionSymbol(Loc loc, unsigned level);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *);
|
Dsymbol *syntaxCopy(Dsymbol *);
|
||||||
|
|
||||||
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
int addMember(Scope *sc, ScopeDsymbol *s, int memnum);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
const char *kind();
|
const char *kind();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* DMD_VERSION_H */
|
#endif /* DMD_VERSION_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user