mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 19:36:06 +03:00
Merge DMD r253: refactor: Argument => Parameter
--- dmd/arrayop.c | 30 ++++---- dmd/arraytypes.h | 2 +- dmd/class.c | 8 +- dmd/declaration.c | 10 ++-- dmd/declaration.h | 16 ++-- dmd/doc.c | 12 ++-- dmd/dsymbol.c | 4 +- dmd/expression.c | 48 +++++++------- dmd/expression.h | 32 +++++----- dmd/func.c | 78 +++++++++++----------- dmd/init.c | 2 +- dmd/interpret.c | 8 +- dmd/mtype.c | 190 ++++++++++++++++++++++++++-------------------------- dmd/mtype.h | 32 +++++----- dmd/opover.c | 34 +++++----- dmd/parse.c | 40 ++++++------ dmd/parse.h | 2 +- dmd/statement.c | 90 +++++++++++++------------- dmd/statement.h | 14 ++-- dmd/struct.c | 8 +- dmd/template.c | 30 ++++---- gen/functions.cpp | 10 ++-- gen/functions.h | 2 +- gen/tocall.cpp | 10 ++-- gen/typinf.cpp | 6 +- 25 files changed, 359 insertions(+), 359 deletions(-)
This commit is contained in:
parent
68d53eb635
commit
357dc9c1a9
25 changed files with 359 additions and 359 deletions
|
@ -253,9 +253,9 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||||
* return p;
|
* return p;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Arguments *fparams = new Arguments();
|
Parameters *fparams = new Parameters();
|
||||||
Expression *loopbody = buildArrayLoop(fparams);
|
Expression *loopbody = buildArrayLoop(fparams);
|
||||||
Argument *p = (Argument *)fparams->data[0 /*fparams->dim - 1*/];
|
Parameter *p = (Parameter *)fparams->data[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));
|
||||||
|
@ -268,7 +268,7 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||||
#else
|
#else
|
||||||
// foreach (i; 0 .. p.length)
|
// foreach (i; 0 .. p.length)
|
||||||
Statement *s1 = new ForeachRangeStatement(0, TOKforeach,
|
Statement *s1 = new ForeachRangeStatement(0, TOKforeach,
|
||||||
new Argument(0, NULL, Id::p, NULL),
|
new Parameter(0, NULL, Id::p, NULL),
|
||||||
new IntegerExp(0, 0, Type::tint32),
|
new IntegerExp(0, 0, Type::tint32),
|
||||||
new ArrayLengthExp(0, new IdentifierExp(0, p->ident)),
|
new ArrayLengthExp(0, new IdentifierExp(0, p->ident)),
|
||||||
new ExpStatement(0, loopbody));
|
new ExpStatement(0, loopbody));
|
||||||
|
@ -414,16 +414,16 @@ X(Or)
|
||||||
* and build the parameter list.
|
* and build the parameter list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Expression *Expression::buildArrayLoop(Arguments *fparams)
|
Expression *Expression::buildArrayLoop(Parameters *fparams)
|
||||||
{
|
{
|
||||||
Identifier *id = Identifier::generateId("c", fparams->dim);
|
Identifier *id = Identifier::generateId("c", fparams->dim);
|
||||||
Argument *param = new Argument(0, type, id, NULL);
|
Parameter *param = new Parameter(0, type, id, NULL);
|
||||||
fparams->shift(param);
|
fparams->shift(param);
|
||||||
Expression *e = new IdentifierExp(0, id);
|
Expression *e = new IdentifierExp(0, id);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression *CastExp::buildArrayLoop(Arguments *fparams)
|
Expression *CastExp::buildArrayLoop(Parameters *fparams)
|
||||||
{
|
{
|
||||||
Type *tb = type->toBasetype();
|
Type *tb = type->toBasetype();
|
||||||
if (tb->ty == Tarray || tb->ty == Tsarray)
|
if (tb->ty == Tarray || tb->ty == Tsarray)
|
||||||
|
@ -434,10 +434,10 @@ Expression *CastExp::buildArrayLoop(Arguments *fparams)
|
||||||
return Expression::buildArrayLoop(fparams);
|
return Expression::buildArrayLoop(fparams);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression *SliceExp::buildArrayLoop(Arguments *fparams)
|
Expression *SliceExp::buildArrayLoop(Parameters *fparams)
|
||||||
{
|
{
|
||||||
Identifier *id = Identifier::generateId("p", fparams->dim);
|
Identifier *id = Identifier::generateId("p", fparams->dim);
|
||||||
Argument *param = new Argument(STCconst, type, id, NULL);
|
Parameter *param = new Parameter(STCconst, type, id, NULL);
|
||||||
fparams->shift(param);
|
fparams->shift(param);
|
||||||
Expression *e = new IdentifierExp(0, id);
|
Expression *e = new IdentifierExp(0, id);
|
||||||
Expressions *arguments = new Expressions();
|
Expressions *arguments = new Expressions();
|
||||||
|
@ -447,7 +447,7 @@ Expression *SliceExp::buildArrayLoop(Arguments *fparams)
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression *AssignExp::buildArrayLoop(Arguments *fparams)
|
Expression *AssignExp::buildArrayLoop(Parameters *fparams)
|
||||||
{
|
{
|
||||||
/* Evaluate assign expressions right to left
|
/* Evaluate assign expressions right to left
|
||||||
*/
|
*/
|
||||||
|
@ -461,20 +461,20 @@ Expression *AssignExp::buildArrayLoop(Arguments *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);
|
||||||
Argument *param = (Argument *)fparams->data[0];
|
Parameter *param = (Parameter *)fparams->data[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;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define X(Str) \
|
#define X(Str) \
|
||||||
Expression *Str##AssignExp::buildArrayLoop(Arguments *fparams) \
|
Expression *Str##AssignExp::buildArrayLoop(Parameters *fparams) \
|
||||||
{ \
|
{ \
|
||||||
/* Evaluate assign expressions right to left \
|
/* Evaluate assign expressions right to left \
|
||||||
*/ \
|
*/ \
|
||||||
Expression *ex2 = e2->buildArrayLoop(fparams); \
|
Expression *ex2 = e2->buildArrayLoop(fparams); \
|
||||||
Expression *ex1 = e1->buildArrayLoop(fparams); \
|
Expression *ex1 = e1->buildArrayLoop(fparams); \
|
||||||
Argument *param = (Argument *)fparams->data[0]; \
|
Parameter *param = (Parameter *)fparams->data[0]; \
|
||||||
param->storageClass = 0; \
|
param->storageClass = 0; \
|
||||||
Expression *e = new Str##AssignExp(0, ex1, ex2); \
|
Expression *e = new Str##AssignExp(0, ex1, ex2); \
|
||||||
return e; \
|
return e; \
|
||||||
|
@ -491,14 +491,14 @@ X(Or)
|
||||||
|
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
Expression *NegExp::buildArrayLoop(Arguments *fparams)
|
Expression *NegExp::buildArrayLoop(Parameters *fparams)
|
||||||
{
|
{
|
||||||
Expression *ex1 = e1->buildArrayLoop(fparams);
|
Expression *ex1 = e1->buildArrayLoop(fparams);
|
||||||
Expression *e = new NegExp(0, ex1);
|
Expression *e = new NegExp(0, ex1);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression *ComExp::buildArrayLoop(Arguments *fparams)
|
Expression *ComExp::buildArrayLoop(Parameters *fparams)
|
||||||
{
|
{
|
||||||
Expression *ex1 = e1->buildArrayLoop(fparams);
|
Expression *ex1 = e1->buildArrayLoop(fparams);
|
||||||
Expression *e = new ComExp(0, ex1);
|
Expression *e = new ComExp(0, ex1);
|
||||||
|
@ -506,7 +506,7 @@ Expression *ComExp::buildArrayLoop(Arguments *fparams)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define X(Str) \
|
#define X(Str) \
|
||||||
Expression *Str##Exp::buildArrayLoop(Arguments *fparams) \
|
Expression *Str##Exp::buildArrayLoop(Parameters *fparams) \
|
||||||
{ \
|
{ \
|
||||||
/* Evaluate assign expressions left to right \
|
/* Evaluate assign expressions left to right \
|
||||||
*/ \
|
*/ \
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct Objects : Array { };
|
||||||
|
|
||||||
struct FuncDeclarations : Array { };
|
struct FuncDeclarations : Array { };
|
||||||
|
|
||||||
struct Arguments : Array { };
|
struct Parameters : Array { };
|
||||||
|
|
||||||
struct Identifiers : Array { };
|
struct Identifiers : Array { };
|
||||||
|
|
||||||
|
|
|
@ -283,9 +283,9 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||||
{ TypeTuple *tup = (TypeTuple *)tb;
|
{ TypeTuple *tup = (TypeTuple *)tb;
|
||||||
enum PROT protection = b->protection;
|
enum PROT protection = b->protection;
|
||||||
baseclasses.remove(i);
|
baseclasses.remove(i);
|
||||||
size_t dim = Argument::dim(tup->arguments);
|
size_t dim = Parameter::dim(tup->arguments);
|
||||||
for (size_t j = 0; j < dim; j++)
|
for (size_t j = 0; j < dim; j++)
|
||||||
{ Argument *arg = Argument::getNth(tup->arguments, j);
|
{ Parameter *arg = Parameter::getNth(tup->arguments, j);
|
||||||
b = new BaseClass(arg->type, protection);
|
b = new BaseClass(arg->type, protection);
|
||||||
baseclasses.insert(i + j, b);
|
baseclasses.insert(i + j, b);
|
||||||
}
|
}
|
||||||
|
@ -1087,9 +1087,9 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||||
{ TypeTuple *tup = (TypeTuple *)tb;
|
{ TypeTuple *tup = (TypeTuple *)tb;
|
||||||
enum PROT protection = b->protection;
|
enum PROT protection = b->protection;
|
||||||
baseclasses.remove(i);
|
baseclasses.remove(i);
|
||||||
size_t dim = Argument::dim(tup->arguments);
|
size_t dim = Parameter::dim(tup->arguments);
|
||||||
for (size_t j = 0; j < dim; j++)
|
for (size_t j = 0; j < dim; j++)
|
||||||
{ Argument *arg = Argument::getNth(tup->arguments, j);
|
{ Parameter *arg = Parameter::getNth(tup->arguments, j);
|
||||||
b = new BaseClass(arg->type, protection);
|
b = new BaseClass(arg->type, protection);
|
||||||
baseclasses.insert(i + j, b);
|
baseclasses.insert(i + j, b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ Type *TupleDeclaration::getType()
|
||||||
|
|
||||||
/* We know it's a type tuple, so build the TypeTuple
|
/* We know it's a type tuple, so build the TypeTuple
|
||||||
*/
|
*/
|
||||||
Arguments *args = new Arguments();
|
Parameters *args = new Parameters();
|
||||||
args->setDim(objects->dim);
|
args->setDim(objects->dim);
|
||||||
OutBuffer buf;
|
OutBuffer buf;
|
||||||
int hasdeco = 1;
|
int hasdeco = 1;
|
||||||
|
@ -213,9 +213,9 @@ Type *TupleDeclaration::getType()
|
||||||
buf.printf("_%s_%d", ident->toChars(), i);
|
buf.printf("_%s_%d", ident->toChars(), i);
|
||||||
char *name = (char *)buf.extractData();
|
char *name = (char *)buf.extractData();
|
||||||
Identifier *id = new Identifier(name, TOKidentifier);
|
Identifier *id = new Identifier(name, TOKidentifier);
|
||||||
Argument *arg = new Argument(STCin, t, id, NULL);
|
Parameter *arg = new Parameter(STCin, t, id, NULL);
|
||||||
#else
|
#else
|
||||||
Argument *arg = new Argument(STCin, t, NULL, NULL);
|
Parameter *arg = new Parameter(STCin, t, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
args->data[i] = (void *)arg;
|
args->data[i] = (void *)arg;
|
||||||
if (!t->deco)
|
if (!t->deco)
|
||||||
|
@ -802,13 +802,13 @@ void VarDeclaration::semantic(Scope *sc)
|
||||||
* and add those.
|
* and add those.
|
||||||
*/
|
*/
|
||||||
TypeTuple *tt = (TypeTuple *)tb;
|
TypeTuple *tt = (TypeTuple *)tb;
|
||||||
size_t nelems = Argument::dim(tt->arguments);
|
size_t nelems = Parameter::dim(tt->arguments);
|
||||||
Objects *exps = new Objects();
|
Objects *exps = new Objects();
|
||||||
exps->setDim(nelems);
|
exps->setDim(nelems);
|
||||||
Expression *ie = init ? init->toExpression() : NULL;
|
Expression *ie = init ? init->toExpression() : NULL;
|
||||||
|
|
||||||
for (size_t i = 0; i < nelems; i++)
|
for (size_t i = 0; i < nelems; i++)
|
||||||
{ Argument *arg = Argument::getNth(tt->arguments, i);
|
{ Parameter *arg = Parameter::getNth(tt->arguments, i);
|
||||||
|
|
||||||
OutBuffer buf;
|
OutBuffer buf;
|
||||||
buf.printf("_%s_field_%zu", ident->toChars(), i);
|
buf.printf("_%s_field_%zu", ident->toChars(), i);
|
||||||
|
|
|
@ -765,8 +765,8 @@ struct FuncDeclaration : Declaration
|
||||||
Statement *mergeFensure(Statement *);
|
Statement *mergeFensure(Statement *);
|
||||||
|
|
||||||
// LDC: give argument types to runtime functions
|
// LDC: give argument types to runtime functions
|
||||||
static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, const char *name);
|
static FuncDeclaration *genCfunc(Parameters *args, Type *treturn, const char *name);
|
||||||
static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, Identifier *id);
|
static FuncDeclaration *genCfunc(Parameters *args, Type *treturn, Identifier *id);
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
Symbol *toSymbol();
|
Symbol *toSymbol();
|
||||||
|
@ -848,10 +848,10 @@ struct FuncLiteralDeclaration : FuncDeclaration
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CtorDeclaration : FuncDeclaration
|
struct CtorDeclaration : FuncDeclaration
|
||||||
{ Arguments *arguments;
|
{ Parameters *arguments;
|
||||||
int varargs;
|
int varargs;
|
||||||
|
|
||||||
CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs);
|
CtorDeclaration(Loc loc, Loc endloc, Parameters *arguments, int varargs);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *);
|
Dsymbol *syntaxCopy(Dsymbol *);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
@ -969,10 +969,10 @@ struct UnitTestDeclaration : FuncDeclaration
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NewDeclaration : FuncDeclaration
|
struct NewDeclaration : FuncDeclaration
|
||||||
{ Arguments *arguments;
|
{ Parameters *arguments;
|
||||||
int varargs;
|
int varargs;
|
||||||
|
|
||||||
NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs);
|
NewDeclaration(Loc loc, Loc endloc, Parameters *arguments, int varargs);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *);
|
Dsymbol *syntaxCopy(Dsymbol *);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
@ -986,9 +986,9 @@ struct NewDeclaration : FuncDeclaration
|
||||||
|
|
||||||
|
|
||||||
struct DeleteDeclaration : FuncDeclaration
|
struct DeleteDeclaration : FuncDeclaration
|
||||||
{ Arguments *arguments;
|
{ Parameters *arguments;
|
||||||
|
|
||||||
DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments);
|
DeleteDeclaration(Loc loc, Loc endloc, Parameters *arguments);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *);
|
Dsymbol *syntaxCopy(Dsymbol *);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
12
dmd/doc.c
12
dmd/doc.c
|
@ -96,7 +96,7 @@ unsigned skippastURL(OutBuffer *buf, size_t i);
|
||||||
void highlightText(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset);
|
void highlightText(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset);
|
||||||
void highlightCode(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset);
|
void highlightCode(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset);
|
||||||
void highlightCode2(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset);
|
void highlightCode2(Scope *sc, Dsymbol *s, OutBuffer *buf, unsigned offset);
|
||||||
Argument *isFunctionParameter(Dsymbol *s, unsigned char *p, unsigned len);
|
Parameter *isFunctionParameter(Dsymbol *s, unsigned char *p, unsigned len);
|
||||||
|
|
||||||
int isIdStart(unsigned char *p);
|
int isIdStart(unsigned char *p);
|
||||||
int isIdTail(unsigned char *p);
|
int isIdTail(unsigned char *p);
|
||||||
|
@ -773,7 +773,7 @@ void FuncDeclaration::toDocBuffer(OutBuffer *buf)
|
||||||
tp->toCBuffer(buf, &hgs);
|
tp->toCBuffer(buf, &hgs);
|
||||||
}
|
}
|
||||||
buf->writeByte(')');
|
buf->writeByte(')');
|
||||||
Argument::argsToCBuffer(buf, &hgs, tf->parameters, tf->varargs);
|
Parameter::argsToCBuffer(buf, &hgs, tf->parameters, tf->varargs);
|
||||||
buf->writestring(";\n");
|
buf->writestring(";\n");
|
||||||
|
|
||||||
highlightCode(NULL, this, buf, o);
|
highlightCode(NULL, this, buf, o);
|
||||||
|
@ -790,7 +790,7 @@ void CtorDeclaration::toDocBuffer(OutBuffer *buf)
|
||||||
HdrGenState hgs;
|
HdrGenState hgs;
|
||||||
|
|
||||||
buf->writestring("this");
|
buf->writestring("this");
|
||||||
Argument::argsToCBuffer(buf, &hgs, arguments, varargs);
|
Parameter::argsToCBuffer(buf, &hgs, arguments, varargs);
|
||||||
buf->writestring(";\n");
|
buf->writestring(";\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1154,7 +1154,7 @@ void ParamSection::write(DocComment *dc, Scope *sc, Dsymbol *s, OutBuffer *buf)
|
||||||
unsigned textlen;
|
unsigned textlen;
|
||||||
|
|
||||||
unsigned o;
|
unsigned o;
|
||||||
Argument *arg;
|
Parameter *arg;
|
||||||
|
|
||||||
buf->writestring("$(DDOC_PARAMS \n");
|
buf->writestring("$(DDOC_PARAMS \n");
|
||||||
while (p < pend)
|
while (p < pend)
|
||||||
|
@ -1621,7 +1621,7 @@ int isKeyword(unsigned char *p, unsigned len)
|
||||||
/****************************************************
|
/****************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Argument *isFunctionParameter(Dsymbol *s, unsigned char *p, unsigned len)
|
Parameter *isFunctionParameter(Dsymbol *s, unsigned char *p, unsigned len)
|
||||||
{
|
{
|
||||||
FuncDeclaration *f = s->isFuncDeclaration();
|
FuncDeclaration *f = s->isFuncDeclaration();
|
||||||
|
|
||||||
|
@ -1640,7 +1640,7 @@ Argument *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++)
|
||||||
{ Argument *arg = (Argument *)tf->parameters->data[k];
|
{ Parameter *arg = (Parameter *)tf->parameters->data[k];
|
||||||
|
|
||||||
if (arg->ident && cmp(arg->ident->toChars(), p, len) == 0)
|
if (arg->ident && cmp(arg->ident->toChars(), p, len) == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1005,8 +1005,8 @@ FuncDeclaration *ScopeDsymbol::findGetMembers()
|
||||||
if (!tfgetmembers)
|
if (!tfgetmembers)
|
||||||
{
|
{
|
||||||
Scope sc;
|
Scope sc;
|
||||||
Arguments *arguments = new Arguments;
|
Parameters *arguments = new Parameters;
|
||||||
Arguments *arg = new Argument(STCin, Type::tchar->constOf()->arrayOf(), NULL, NULL);
|
Parameters *arg = new Parameter(STCin, Type::tchar->constOf()->arrayOf(), NULL, NULL);
|
||||||
arguments->push(arg);
|
arguments->push(arg);
|
||||||
|
|
||||||
Type *tret = NULL;
|
Type *tret = NULL;
|
||||||
|
|
|
@ -556,7 +556,7 @@ Expressions *arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt
|
||||||
* Preprocess arguments to function.
|
* Preprocess arguments to function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void preFunctionArguments(Loc loc, Scope *sc, Expressions *exps)
|
void preFunctionParameters(Loc loc, Scope *sc, Expressions *exps)
|
||||||
{
|
{
|
||||||
if (exps)
|
if (exps)
|
||||||
{
|
{
|
||||||
|
@ -627,14 +627,14 @@ Expression *callCpCtor(Loc loc, Scope *sc, Expression *e)
|
||||||
* 4. add hidden _arguments[] argument
|
* 4. add hidden _arguments[] argument
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void functionArguments(Loc loc, Scope *sc, TypeFunction *tf, Expressions *arguments)
|
void functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *arguments)
|
||||||
{
|
{
|
||||||
unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
//printf("functionArguments()\n");
|
//printf("functionParameters()\n");
|
||||||
assert(arguments);
|
assert(arguments);
|
||||||
size_t nargs = arguments ? arguments->dim : 0;
|
size_t nargs = arguments ? arguments->dim : 0;
|
||||||
size_t nparams = Argument::dim(tf->parameters);
|
size_t nparams = Parameter::dim(tf->parameters);
|
||||||
|
|
||||||
if (nargs > nparams && tf->varargs == 0)
|
if (nargs > nparams && tf->varargs == 0)
|
||||||
error(loc, "expected %zu arguments, not %zu for non-variadic function type %s", nparams, nargs, tf->toChars());
|
error(loc, "expected %zu arguments, not %zu for non-variadic function type %s", nparams, nargs, tf->toChars());
|
||||||
|
@ -654,7 +654,7 @@ void functionArguments(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argume
|
||||||
|
|
||||||
if (i < nparams)
|
if (i < nparams)
|
||||||
{
|
{
|
||||||
Argument *p = Argument::getNth(tf->parameters, i);
|
Parameter *p = Parameter::getNth(tf->parameters, i);
|
||||||
|
|
||||||
if (!arg)
|
if (!arg)
|
||||||
{
|
{
|
||||||
|
@ -3610,9 +3610,9 @@ Lagain:
|
||||||
//printf("tb: %s, deco = %s\n", tb->toChars(), tb->deco);
|
//printf("tb: %s, deco = %s\n", tb->toChars(), tb->deco);
|
||||||
|
|
||||||
arrayExpressionSemantic(newargs, sc);
|
arrayExpressionSemantic(newargs, sc);
|
||||||
preFunctionArguments(loc, sc, newargs);
|
preFunctionParameters(loc, sc, newargs);
|
||||||
arrayExpressionSemantic(arguments, sc);
|
arrayExpressionSemantic(arguments, sc);
|
||||||
preFunctionArguments(loc, sc, arguments);
|
preFunctionParameters(loc, sc, arguments);
|
||||||
|
|
||||||
if (thisexp && tb->ty != Tclass)
|
if (thisexp && tb->ty != Tclass)
|
||||||
error("e.new is only for allocating nested classes, not %s", tb->toChars());
|
error("e.new is only for allocating nested classes, not %s", tb->toChars());
|
||||||
|
@ -3727,7 +3727,7 @@ Lagain:
|
||||||
|
|
||||||
if (!arguments)
|
if (!arguments)
|
||||||
arguments = new Expressions();
|
arguments = new Expressions();
|
||||||
functionArguments(loc, sc, tf, arguments);
|
functionParameters(loc, sc, tf, arguments);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3748,7 +3748,7 @@ Lagain:
|
||||||
assert(allocator);
|
assert(allocator);
|
||||||
|
|
||||||
tf = (TypeFunction *)f->type;
|
tf = (TypeFunction *)f->type;
|
||||||
functionArguments(loc, sc, tf, newargs);
|
functionParameters(loc, sc, tf, newargs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3781,7 +3781,7 @@ Lagain:
|
||||||
assert(allocator);
|
assert(allocator);
|
||||||
|
|
||||||
tf = (TypeFunction *)f->type;
|
tf = (TypeFunction *)f->type;
|
||||||
functionArguments(loc, sc, tf, newargs);
|
functionParameters(loc, sc, tf, newargs);
|
||||||
|
|
||||||
e = new VarExp(loc, f);
|
e = new VarExp(loc, f);
|
||||||
e = new CallExp(loc, e, newargs);
|
e = new CallExp(loc, e, newargs);
|
||||||
|
@ -4749,11 +4749,11 @@ Expression *IsExp::semantic(Scope *sc)
|
||||||
goto Lno;
|
goto Lno;
|
||||||
else
|
else
|
||||||
{ ClassDeclaration *cd = ((TypeClass *)targ)->sym;
|
{ ClassDeclaration *cd = ((TypeClass *)targ)->sym;
|
||||||
Arguments *args = new Arguments;
|
Parameters *args = new Parameters;
|
||||||
args->reserve(cd->baseclasses.dim);
|
args->reserve(cd->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 *)cd->baseclasses.data[i];
|
{ BaseClass *b = (BaseClass *)cd->baseclasses.data[i];
|
||||||
args->push(new Argument(STCin, b->type, NULL, NULL));
|
args->push(new Parameter(STCin, b->type, NULL, NULL));
|
||||||
}
|
}
|
||||||
tded = new TypeTuple(args);
|
tded = new TypeTuple(args);
|
||||||
}
|
}
|
||||||
|
@ -4780,14 +4780,14 @@ Expression *IsExp::semantic(Scope *sc)
|
||||||
/* Generate tuple from function parameter types.
|
/* Generate tuple from function parameter types.
|
||||||
*/
|
*/
|
||||||
assert(tded->ty == Tfunction);
|
assert(tded->ty == Tfunction);
|
||||||
Arguments *params = ((TypeFunction *)tded)->parameters;
|
Parameters *params = ((TypeFunction *)tded)->parameters;
|
||||||
size_t dim = Argument::dim(params);
|
size_t dim = Parameter::dim(params);
|
||||||
Arguments *args = new Arguments;
|
Parameters *args = new Parameters;
|
||||||
args->reserve(dim);
|
args->reserve(dim);
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{ Argument *arg = Argument::getNth(params, i);
|
{ Parameter *arg = Parameter::getNth(params, i);
|
||||||
assert(arg && arg->type);
|
assert(arg && arg->type);
|
||||||
args->push(new Argument(arg->storageClass, arg->type, NULL, NULL));
|
args->push(new Parameter(arg->storageClass, arg->type, NULL, NULL));
|
||||||
}
|
}
|
||||||
tded = new TypeTuple(args);
|
tded = new TypeTuple(args);
|
||||||
break;
|
break;
|
||||||
|
@ -6387,7 +6387,7 @@ Lagain:
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayExpressionSemantic(arguments, sc);
|
arrayExpressionSemantic(arguments, sc);
|
||||||
preFunctionArguments(loc, sc, arguments);
|
preFunctionParameters(loc, sc, arguments);
|
||||||
|
|
||||||
if (e1->op == TOKdotvar && t1->ty == Tfunction ||
|
if (e1->op == TOKdotvar && t1->ty == Tfunction ||
|
||||||
e1->op == TOKdottd)
|
e1->op == TOKdottd)
|
||||||
|
@ -6668,7 +6668,7 @@ Lcheckargs:
|
||||||
|
|
||||||
if (!arguments)
|
if (!arguments)
|
||||||
arguments = new Expressions();
|
arguments = new Expressions();
|
||||||
functionArguments(loc, sc, tf, arguments);
|
functionParameters(loc, sc, tf, arguments);
|
||||||
|
|
||||||
assert(type);
|
assert(type);
|
||||||
|
|
||||||
|
@ -7471,7 +7471,7 @@ Expression *SliceExp::semantic(Scope *sc)
|
||||||
}
|
}
|
||||||
else if (e1->op == TOKtype) // slicing a type tuple
|
else if (e1->op == TOKtype) // slicing a type tuple
|
||||||
{ tup = (TypeTuple *)t;
|
{ tup = (TypeTuple *)t;
|
||||||
length = Argument::dim(tup->arguments);
|
length = Parameter::dim(tup->arguments);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -7490,10 +7490,10 @@ Expression *SliceExp::semantic(Scope *sc)
|
||||||
e = new TupleExp(loc, exps);
|
e = new TupleExp(loc, exps);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ Arguments *args = new Arguments;
|
{ Parameters *args = new Parameters;
|
||||||
args->reserve(j2 - j1);
|
args->reserve(j2 - j1);
|
||||||
for (size_t i = j1; i < j2; i++)
|
for (size_t i = j1; i < j2; i++)
|
||||||
{ Argument *arg = Argument::getNth(tup->arguments, i);
|
{ Parameter *arg = Parameter::getNth(tup->arguments, i);
|
||||||
args->push(arg);
|
args->push(arg);
|
||||||
}
|
}
|
||||||
e = new TypeExp(e1->loc, new TypeTuple(args));
|
e = new TypeExp(e1->loc, new TypeTuple(args));
|
||||||
|
@ -7871,7 +7871,7 @@ Expression *IndexExp::semantic(Scope *sc)
|
||||||
else if (e1->op == TOKtype)
|
else if (e1->op == TOKtype)
|
||||||
{
|
{
|
||||||
tup = (TypeTuple *)t1;
|
tup = (TypeTuple *)t1;
|
||||||
length = Argument::dim(tup->arguments);
|
length = Parameter::dim(tup->arguments);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -7882,7 +7882,7 @@ Expression *IndexExp::semantic(Scope *sc)
|
||||||
if (e1->op == TOKtuple)
|
if (e1->op == TOKtuple)
|
||||||
e = (Expression *)te->exps->data[(size_t)index];
|
e = (Expression *)te->exps->data[(size_t)index];
|
||||||
else
|
else
|
||||||
e = new TypeExp(e1->loc, Argument::getNth(tup->arguments, (size_t)index)->type);
|
e = new TypeExp(e1->loc, Parameter::getNth(tup->arguments, (size_t)index)->type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,7 @@ void initPrecedence();
|
||||||
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);
|
||||||
void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Module* from);
|
void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr, Module* from);
|
||||||
void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs);
|
void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs);
|
||||||
void argsToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs);
|
void argsToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs);
|
||||||
void expandTuples(Expressions *exps);
|
void expandTuples(Expressions *exps);
|
||||||
|
@ -161,7 +161,7 @@ struct Expression : Object
|
||||||
|
|
||||||
// For array ops
|
// For array ops
|
||||||
virtual void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
virtual void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
virtual Expression *buildArrayLoop(Arguments *fparams);
|
virtual Expression *buildArrayLoop(Parameters *fparams);
|
||||||
int isArrayOperand();
|
int isArrayOperand();
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
|
@ -1090,7 +1090,7 @@ struct NegExp : UnaExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
|
@ -1120,7 +1120,7 @@ struct ComExp : UnaExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
|
@ -1196,7 +1196,7 @@ struct CastExp : UnaExp
|
||||||
void checkEscape();
|
void checkEscape();
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1232,7 +1232,7 @@ struct SliceExp : UnaExp
|
||||||
#endif
|
#endif
|
||||||
void scanForNestedRef(Scope *sc);
|
void scanForNestedRef(Scope *sc);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
int inlineCost(InlineCostState *ics);
|
int inlineCost(InlineCostState *ics);
|
||||||
Expression *doInline(InlineDoState *ids);
|
Expression *doInline(InlineDoState *ids);
|
||||||
|
@ -1360,7 +1360,7 @@ struct AssignExp : BinExp
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
Identifier *opId(); // For operator overloading
|
Identifier *opId(); // For operator overloading
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
elem *toElem(IRState *irs);
|
elem *toElem(IRState *irs);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1385,7 +1385,7 @@ struct op##AssignExp : BinExp \
|
||||||
Expression *semantic(Scope *sc); \
|
Expression *semantic(Scope *sc); \
|
||||||
Expression *interpret(InterState *istate); \
|
Expression *interpret(InterState *istate); \
|
||||||
X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \
|
X(void buildArrayIdent(OutBuffer *buf, Expressions *arguments);) \
|
||||||
X(Expression *buildArrayLoop(Arguments *fparams);) \
|
X(Expression *buildArrayLoop(Parameters *fparams);) \
|
||||||
\
|
\
|
||||||
Identifier *opId(); /* For operator overloading */ \
|
Identifier *opId(); /* For operator overloading */ \
|
||||||
\
|
\
|
||||||
|
@ -1421,7 +1421,7 @@ struct AddExp : BinExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
int isCommutative();
|
int isCommutative();
|
||||||
|
@ -1444,7 +1444,7 @@ struct MinExp : BinExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
|
@ -1486,7 +1486,7 @@ struct MulExp : BinExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
int isCommutative();
|
int isCommutative();
|
||||||
|
@ -1509,7 +1509,7 @@ struct DivExp : BinExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
|
@ -1531,7 +1531,7 @@ struct ModExp : BinExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
Identifier *opId();
|
Identifier *opId();
|
||||||
|
@ -1613,7 +1613,7 @@ struct AndExp : BinExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
int isCommutative();
|
int isCommutative();
|
||||||
|
@ -1636,7 +1636,7 @@ struct OrExp : BinExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
int isCommutative();
|
int isCommutative();
|
||||||
|
@ -1659,7 +1659,7 @@ struct XorExp : BinExp
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
|
||||||
Expression *buildArrayLoop(Arguments *fparams);
|
Expression *buildArrayLoop(Parameters *fparams);
|
||||||
|
|
||||||
// For operator overloading
|
// For operator overloading
|
||||||
int isCommutative();
|
int isCommutative();
|
||||||
|
|
78
dmd/func.c
78
dmd/func.c
|
@ -178,7 +178,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
f = (TypeFunction *)(type);
|
f = (TypeFunction *)(type);
|
||||||
size_t nparams = Argument::dim(f->parameters);
|
size_t nparams = Parameter::dim(f->parameters);
|
||||||
|
|
||||||
linkage = sc->linkage;
|
linkage = sc->linkage;
|
||||||
// if (!parent)
|
// if (!parent)
|
||||||
|
@ -546,7 +546,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
Argument *arg0 = Argument::getNth(f->parameters, 0);
|
Parameter *arg0 = Parameter::getNth(f->parameters, 0);
|
||||||
if (arg0->type->ty != Tarray ||
|
if (arg0->type->ty != Tarray ||
|
||||||
arg0->type->nextOf()->ty != Tarray ||
|
arg0->type->nextOf()->ty != Tarray ||
|
||||||
arg0->type->nextOf()->nextOf()->ty != Tchar ||
|
arg0->type->nextOf()->nextOf()->ty != Tchar ||
|
||||||
|
@ -580,7 +580,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Argument *arg0 = Argument::getNth(f->parameters, 0);
|
Parameter *arg0 = Parameter::getNth(f->parameters, 0);
|
||||||
Type *t0 = arg0->type->toBasetype();
|
Type *t0 = arg0->type->toBasetype();
|
||||||
Type *tb = sd ? sd->type : cd->type;
|
Type *tb = sd ? sd->type : cd->type;
|
||||||
if (arg0->type->implicitConvTo(tb) ||
|
if (arg0->type->implicitConvTo(tb) ||
|
||||||
|
@ -589,7 +589,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
if (nparams == 1)
|
if (nparams == 1)
|
||||||
goto Lassignerr;
|
goto Lassignerr;
|
||||||
Argument *arg1 = Argument::getNth(f->parameters, 1);
|
Parameter *arg1 = Parameter::getNth(f->parameters, 1);
|
||||||
if (arg1->defaultArg)
|
if (arg1->defaultArg)
|
||||||
goto Lassignerr;
|
goto Lassignerr;
|
||||||
}
|
}
|
||||||
|
@ -630,10 +630,10 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||||
outId = Id::result; // provide a default
|
outId = Id::result; // provide a default
|
||||||
|
|
||||||
Loc loc = fensure->loc;
|
Loc loc = fensure->loc;
|
||||||
Arguments *arguments = new Arguments();
|
Parameters *arguments = new Parameters();
|
||||||
Argument *a = NULL;
|
Parameter *a = NULL;
|
||||||
if (outId)
|
if (outId)
|
||||||
{ a = new Argument(STCref, f->nextOf(), outId, NULL);
|
{ a = new Parameter(STCref, f->nextOf(), outId, NULL);
|
||||||
arguments->push(a);
|
arguments->push(a);
|
||||||
}
|
}
|
||||||
TypeFunction *tf = new TypeFunction(arguments, Type::tvoid, 0, LINKd);
|
TypeFunction *tf = new TypeFunction(arguments, Type::tvoid, 0, LINKd);
|
||||||
|
@ -833,8 +833,8 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
// Turns TypeTuple!(int, int) into two int parameters, for instance.
|
// Turns TypeTuple!(int, int) into two int parameters, for instance.
|
||||||
if (f->parameters)
|
if (f->parameters)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < Argument::dim(f->parameters); i++)
|
for (size_t i = 0; i < Parameter::dim(f->parameters); i++)
|
||||||
{ Argument *arg = (Argument *)Argument::getNth(f->parameters, i);
|
{ Parameter *arg = (Parameter *)Parameter::getNth(f->parameters, i);
|
||||||
Type* nw = arg->type->semantic(0, sc);
|
Type* nw = arg->type->semantic(0, sc);
|
||||||
if (arg->type != nw) {
|
if (arg->type != nw) {
|
||||||
arg->type = nw;
|
arg->type = nw;
|
||||||
|
@ -854,14 +854,14 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
if (f->parameters)
|
if (f->parameters)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < f->parameters->dim; i++)
|
for (size_t i = 0; i < f->parameters->dim; i++)
|
||||||
{ Argument *arg = (Argument *)f->parameters->data[i];
|
{ Parameter *arg = (Parameter *)f->parameters->data[i];
|
||||||
|
|
||||||
//printf("[%d] arg->type->ty = %d %s\n", i, arg->type->ty, arg->type->toChars());
|
//printf("[%d] arg->type->ty = %d %s\n", i, arg->type->ty, arg->type->toChars());
|
||||||
if (arg->type->ty == Ttuple)
|
if (arg->type->ty == Ttuple)
|
||||||
{ TypeTuple *t = (TypeTuple *)arg->type;
|
{ TypeTuple *t = (TypeTuple *)arg->type;
|
||||||
size_t dim = Argument::dim(t->arguments);
|
size_t dim = Parameter::dim(t->arguments);
|
||||||
for (size_t j = 0; j < dim; j++)
|
for (size_t j = 0; j < dim; j++)
|
||||||
{ Argument *narg = Argument::getNth(t->arguments, j);
|
{ Parameter *narg = Parameter::getNth(t->arguments, j);
|
||||||
narg->storageClass = arg->storageClass;
|
narg->storageClass = arg->storageClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -871,7 +871,7 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
/* Declare all the function parameters as variables
|
/* Declare all the function parameters as variables
|
||||||
* and install them in parameters[]
|
* and install them in parameters[]
|
||||||
*/
|
*/
|
||||||
size_t nparams = Argument::dim(f->parameters);
|
size_t nparams = Parameter::dim(f->parameters);
|
||||||
if (nparams)
|
if (nparams)
|
||||||
{ /* 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
|
||||||
|
@ -880,7 +880,7 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
parameters->reserve(nparams);
|
parameters->reserve(nparams);
|
||||||
for (size_t i = 0; i < nparams; i++)
|
for (size_t i = 0; i < nparams; i++)
|
||||||
{
|
{
|
||||||
Argument *arg = Argument::getNth(f->parameters, i);
|
Parameter *arg = Parameter::getNth(f->parameters, i);
|
||||||
Identifier *id = arg->ident;
|
Identifier *id = arg->ident;
|
||||||
if (!id)
|
if (!id)
|
||||||
{
|
{
|
||||||
|
@ -913,17 +913,17 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
if (f->parameters)
|
if (f->parameters)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < f->parameters->dim; i++)
|
for (size_t i = 0; i < f->parameters->dim; i++)
|
||||||
{ Argument *arg = (Argument *)f->parameters->data[i];
|
{ Parameter *arg = (Parameter *)f->parameters->data[i];
|
||||||
|
|
||||||
if (!arg->ident)
|
if (!arg->ident)
|
||||||
continue; // never used, so ignore
|
continue; // never used, so ignore
|
||||||
if (arg->type->ty == Ttuple)
|
if (arg->type->ty == Ttuple)
|
||||||
{ TypeTuple *t = (TypeTuple *)arg->type;
|
{ TypeTuple *t = (TypeTuple *)arg->type;
|
||||||
size_t dim = Argument::dim(t->arguments);
|
size_t dim = Parameter::dim(t->arguments);
|
||||||
Objects *exps = new Objects();
|
Objects *exps = new Objects();
|
||||||
exps->setDim(dim);
|
exps->setDim(dim);
|
||||||
for (size_t j = 0; j < dim; j++)
|
for (size_t j = 0; j < dim; j++)
|
||||||
{ Argument *narg = Argument::getNth(t->arguments, j);
|
{ Parameter *narg = Parameter::getNth(t->arguments, j);
|
||||||
assert(narg->ident);
|
assert(narg->ident);
|
||||||
VarDeclaration *v = sc2->search(0, narg->ident, NULL)->isVarDeclaration();
|
VarDeclaration *v = sc2->search(0, narg->ident, NULL)->isVarDeclaration();
|
||||||
assert(v);
|
assert(v);
|
||||||
|
@ -1985,7 +1985,7 @@ if (arguments)
|
||||||
|
|
||||||
//printf("tf = %s, args = %s\n", tf->deco, ((Expression *)arguments->data[0])->type->deco);
|
//printf("tf = %s, args = %s\n", tf->deco, ((Expression *)arguments->data[0])->type->deco);
|
||||||
error(loc, "%s does not match parameter types (%s)",
|
error(loc, "%s does not match parameter types (%s)",
|
||||||
Argument::argsTypesToChars(tf->parameters, tf->varargs),
|
Parameter::argsTypesToChars(tf->parameters, tf->varargs),
|
||||||
buf.toChars());
|
buf.toChars());
|
||||||
return m.anyf; // as long as it's not a FuncAliasDeclaration
|
return m.anyf; // as long as it's not a FuncAliasDeclaration
|
||||||
}
|
}
|
||||||
|
@ -1997,8 +1997,8 @@ if (arguments)
|
||||||
|
|
||||||
error(loc, "called with argument types:\n\t(%s)\nmatches both:\n\t%s%s\nand:\n\t%s%s",
|
error(loc, "called with argument types:\n\t(%s)\nmatches both:\n\t%s%s\nand:\n\t%s%s",
|
||||||
buf.toChars(),
|
buf.toChars(),
|
||||||
m.lastf->toPrettyChars(), Argument::argsTypesToChars(t1->parameters, t1->varargs),
|
m.lastf->toPrettyChars(), Parameter::argsTypesToChars(t1->parameters, t1->varargs),
|
||||||
m.nextf->toPrettyChars(), Argument::argsTypesToChars(t2->parameters, t2->varargs));
|
m.nextf->toPrettyChars(), Parameter::argsTypesToChars(t2->parameters, t2->varargs));
|
||||||
#else
|
#else
|
||||||
error(loc, "overloads %s and %s both match argument list for %s",
|
error(loc, "overloads %s and %s both match argument list for %s",
|
||||||
m.lastf->type->toChars(),
|
m.lastf->type->toChars(),
|
||||||
|
@ -2034,8 +2034,8 @@ MATCH FuncDeclaration::leastAsSpecialized(FuncDeclaration *g)
|
||||||
|
|
||||||
TypeFunction *tf = (TypeFunction *)type;
|
TypeFunction *tf = (TypeFunction *)type;
|
||||||
TypeFunction *tg = (TypeFunction *)g->type;
|
TypeFunction *tg = (TypeFunction *)g->type;
|
||||||
size_t nfparams = Argument::dim(tf->parameters);
|
size_t nfparams = Parameter::dim(tf->parameters);
|
||||||
size_t ngparams = Argument::dim(tg->parameters);
|
size_t ngparams = Parameter::dim(tg->parameters);
|
||||||
MATCH match = MATCHexact;
|
MATCH match = MATCHexact;
|
||||||
|
|
||||||
/* If both functions have a 'this' pointer, and the mods are not
|
/* If both functions have a 'this' pointer, and the mods are not
|
||||||
|
@ -2058,7 +2058,7 @@ MATCH FuncDeclaration::leastAsSpecialized(FuncDeclaration *g)
|
||||||
args.setDim(nfparams);
|
args.setDim(nfparams);
|
||||||
for (int u = 0; u < nfparams; u++)
|
for (int u = 0; u < nfparams; u++)
|
||||||
{
|
{
|
||||||
Argument *p = Argument::getNth(tf->parameters, u);
|
Parameter *p = Parameter::getNth(tf->parameters, u);
|
||||||
Expression *e;
|
Expression *e;
|
||||||
if (p->storageClass & (STCref | STCout))
|
if (p->storageClass & (STCref | STCout))
|
||||||
{
|
{
|
||||||
|
@ -2393,12 +2393,12 @@ int FuncDeclaration::addPostInvariant()
|
||||||
// LDC: Adjusted to give argument info to the runtime function decl.
|
// LDC: Adjusted to give argument info to the runtime function decl.
|
||||||
//
|
//
|
||||||
|
|
||||||
FuncDeclaration *FuncDeclaration::genCfunc(Arguments *args, Type *treturn, const char *name)
|
FuncDeclaration *FuncDeclaration::genCfunc(Parameters *args, Type *treturn, const char *name)
|
||||||
{
|
{
|
||||||
return genCfunc(args, treturn, Lexer::idPool(name));
|
return genCfunc(args, treturn, Lexer::idPool(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
FuncDeclaration *FuncDeclaration::genCfunc(Arguments *args, Type *treturn, Identifier *id)
|
FuncDeclaration *FuncDeclaration::genCfunc(Parameters *args, Type *treturn, Identifier *id)
|
||||||
{
|
{
|
||||||
FuncDeclaration *fd;
|
FuncDeclaration *fd;
|
||||||
TypeFunction *tf;
|
TypeFunction *tf;
|
||||||
|
@ -2575,7 +2575,7 @@ void FuncLiteralDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
|
|
||||||
/********************************* CtorDeclaration ****************************/
|
/********************************* CtorDeclaration ****************************/
|
||||||
|
|
||||||
CtorDeclaration::CtorDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs)
|
CtorDeclaration::CtorDeclaration(Loc loc, Loc endloc, Parameters *arguments, int varargs)
|
||||||
: FuncDeclaration(loc, endloc, Id::ctor, STCundefined, NULL)
|
: FuncDeclaration(loc, endloc, Id::ctor, STCundefined, NULL)
|
||||||
{
|
{
|
||||||
this->arguments = arguments;
|
this->arguments = arguments;
|
||||||
|
@ -2595,7 +2595,7 @@ Dsymbol *CtorDeclaration::syntaxCopy(Dsymbol *s)
|
||||||
f->fbody = fbody ? fbody->syntaxCopy() : NULL;
|
f->fbody = fbody ? fbody->syntaxCopy() : NULL;
|
||||||
assert(!fthrows); // deprecated
|
assert(!fthrows); // deprecated
|
||||||
|
|
||||||
f->arguments = Argument::arraySyntaxCopy(arguments);
|
f->arguments = Parameter::arraySyntaxCopy(arguments);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2650,7 +2650,7 @@ void CtorDeclaration::semantic(Scope *sc)
|
||||||
sc->pop();
|
sc->pop();
|
||||||
|
|
||||||
// See if it's the default constructor
|
// See if it's the default constructor
|
||||||
if (cd && varargs == 0 && Argument::dim(arguments) == 0)
|
if (cd && varargs == 0 && Parameter::dim(arguments) == 0)
|
||||||
cd->defaultCtor = this;
|
cd->defaultCtor = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2683,7 +2683,7 @@ int CtorDeclaration::addPostInvariant()
|
||||||
void CtorDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void CtorDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->writestring("this");
|
buf->writestring("this");
|
||||||
Argument::argsToCBuffer(buf, hgs, arguments, varargs);
|
Parameter::argsToCBuffer(buf, hgs, arguments, varargs);
|
||||||
bodyToCBuffer(buf, hgs);
|
bodyToCBuffer(buf, hgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3216,7 +3216,7 @@ void UnitTestDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
|
|
||||||
/********************************* NewDeclaration ****************************/
|
/********************************* NewDeclaration ****************************/
|
||||||
|
|
||||||
NewDeclaration::NewDeclaration(Loc loc, Loc endloc, Arguments *arguments, int varargs)
|
NewDeclaration::NewDeclaration(Loc loc, Loc endloc, Parameters *arguments, int varargs)
|
||||||
: FuncDeclaration(loc, endloc, Id::classNew, STCstatic, NULL)
|
: FuncDeclaration(loc, endloc, Id::classNew, STCstatic, NULL)
|
||||||
{
|
{
|
||||||
this->arguments = arguments;
|
this->arguments = arguments;
|
||||||
|
@ -3231,7 +3231,7 @@ Dsymbol *NewDeclaration::syntaxCopy(Dsymbol *s)
|
||||||
|
|
||||||
FuncDeclaration::syntaxCopy(f);
|
FuncDeclaration::syntaxCopy(f);
|
||||||
|
|
||||||
f->arguments = Argument::arraySyntaxCopy(arguments);
|
f->arguments = Parameter::arraySyntaxCopy(arguments);
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -3259,13 +3259,13 @@ void NewDeclaration::semantic(Scope *sc)
|
||||||
|
|
||||||
// Check that there is at least one argument of type size_t
|
// Check that there is at least one argument of type size_t
|
||||||
TypeFunction *tf = (TypeFunction *)type;
|
TypeFunction *tf = (TypeFunction *)type;
|
||||||
if (Argument::dim(tf->parameters) < 1)
|
if (Parameter::dim(tf->parameters) < 1)
|
||||||
{
|
{
|
||||||
error("at least one argument of type size_t expected");
|
error("at least one argument of type size_t expected");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Argument *a = Argument::getNth(tf->parameters, 0);
|
Parameter *a = Parameter::getNth(tf->parameters, 0);
|
||||||
if (!a->type->equals(Type::tsize_t))
|
if (!a->type->equals(Type::tsize_t))
|
||||||
error("first argument must be type size_t, not %s", a->type->toChars());
|
error("first argument must be type size_t, not %s", a->type->toChars());
|
||||||
}
|
}
|
||||||
|
@ -3296,14 +3296,14 @@ int NewDeclaration::addPostInvariant()
|
||||||
void NewDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void NewDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->writestring("new");
|
buf->writestring("new");
|
||||||
Argument::argsToCBuffer(buf, hgs, arguments, varargs);
|
Parameter::argsToCBuffer(buf, hgs, arguments, varargs);
|
||||||
bodyToCBuffer(buf, hgs);
|
bodyToCBuffer(buf, hgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************* DeleteDeclaration ****************************/
|
/********************************* DeleteDeclaration ****************************/
|
||||||
|
|
||||||
DeleteDeclaration::DeleteDeclaration(Loc loc, Loc endloc, Arguments *arguments)
|
DeleteDeclaration::DeleteDeclaration(Loc loc, Loc endloc, Parameters *arguments)
|
||||||
: FuncDeclaration(loc, endloc, Id::classDelete, STCstatic, NULL)
|
: FuncDeclaration(loc, endloc, Id::classDelete, STCstatic, NULL)
|
||||||
{
|
{
|
||||||
this->arguments = arguments;
|
this->arguments = arguments;
|
||||||
|
@ -3317,7 +3317,7 @@ Dsymbol *DeleteDeclaration::syntaxCopy(Dsymbol *s)
|
||||||
|
|
||||||
FuncDeclaration::syntaxCopy(f);
|
FuncDeclaration::syntaxCopy(f);
|
||||||
|
|
||||||
f->arguments = Argument::arraySyntaxCopy(arguments);
|
f->arguments = Parameter::arraySyntaxCopy(arguments);
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -3343,13 +3343,13 @@ void DeleteDeclaration::semantic(Scope *sc)
|
||||||
|
|
||||||
// Check that there is only one argument of type void*
|
// Check that there is only one argument of type void*
|
||||||
TypeFunction *tf = (TypeFunction *)type;
|
TypeFunction *tf = (TypeFunction *)type;
|
||||||
if (Argument::dim(tf->parameters) != 1)
|
if (Parameter::dim(tf->parameters) != 1)
|
||||||
{
|
{
|
||||||
error("one argument of type void* expected");
|
error("one argument of type void* expected");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Argument *a = Argument::getNth(tf->parameters, 0);
|
Parameter *a = Parameter::getNth(tf->parameters, 0);
|
||||||
if (!a->type->equals(Type::tvoid->pointerTo()))
|
if (!a->type->equals(Type::tvoid->pointerTo()))
|
||||||
error("one argument of type void* expected, not %s", a->type->toChars());
|
error("one argument of type void* expected, not %s", a->type->toChars());
|
||||||
}
|
}
|
||||||
|
@ -3385,7 +3385,7 @@ int DeleteDeclaration::addPostInvariant()
|
||||||
void DeleteDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void DeleteDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
buf->writestring("delete");
|
buf->writestring("delete");
|
||||||
Argument::argsToCBuffer(buf, hgs, arguments, 0);
|
Parameter::argsToCBuffer(buf, hgs, arguments, 0);
|
||||||
bodyToCBuffer(buf, hgs);
|
bodyToCBuffer(buf, hgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t)
|
||||||
else if (t->ty == Tdelegate && value.dim == 0)
|
else if (t->ty == Tdelegate && value.dim == 0)
|
||||||
{ /* Rewrite as empty delegate literal { }
|
{ /* Rewrite as empty delegate literal { }
|
||||||
*/
|
*/
|
||||||
Arguments *arguments = new Arguments;
|
Parameters *arguments = new Parameters;
|
||||||
Type *tf = new TypeFunction(arguments, NULL, 0, LINKd);
|
Type *tf = new TypeFunction(arguments, NULL, 0, LINKd);
|
||||||
FuncLiteralDeclaration *fd = new FuncLiteralDeclaration(loc, 0, tf, TOKdelegate, NULL);
|
FuncLiteralDeclaration *fd = new FuncLiteralDeclaration(loc, 0, tf, TOKdelegate, NULL);
|
||||||
fd->fbody = new CompoundStatement(loc, new Statements());
|
fd->fbody = new CompoundStatement(loc, new Statements());
|
||||||
|
|
|
@ -102,9 +102,9 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument
|
||||||
|
|
||||||
// Ensure there are no lazy parameters
|
// Ensure there are no lazy parameters
|
||||||
if (tf->parameters)
|
if (tf->parameters)
|
||||||
{ size_t dim = Argument::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++)
|
||||||
{ Argument *arg = Argument::getNth(tf->parameters, i);
|
{ Parameter *arg = Parameter::getNth(tf->parameters, i);
|
||||||
if (arg->storageClass & STClazy)
|
if (arg->storageClass & STClazy)
|
||||||
{ cantInterpret = 1;
|
{ cantInterpret = 1;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -139,7 +139,7 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument
|
||||||
|
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{ Expression *earg = (Expression *)arguments->data[i];
|
{ Expression *earg = (Expression *)arguments->data[i];
|
||||||
Argument *arg = Argument::getNth(tf->parameters, i);
|
Parameter *arg = Parameter::getNth(tf->parameters, i);
|
||||||
|
|
||||||
if (arg->storageClass & (STCout | STCref))
|
if (arg->storageClass & (STCout | STCref))
|
||||||
{
|
{
|
||||||
|
@ -166,7 +166,7 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument
|
||||||
|
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{ Expression *earg = (Expression *)eargs.data[i];
|
{ Expression *earg = (Expression *)eargs.data[i];
|
||||||
Argument *arg = Argument::getNth(tf->parameters, i);
|
Parameter *arg = Parameter::getNth(tf->parameters, i);
|
||||||
VarDeclaration *v = (VarDeclaration *)parameters->data[i];
|
VarDeclaration *v = (VarDeclaration *)parameters->data[i];
|
||||||
vsave.data[i] = v->value;
|
vsave.data[i] = v->value;
|
||||||
#if LOG
|
#if LOG
|
||||||
|
|
190
dmd/mtype.c
190
dmd/mtype.c
|
@ -1594,16 +1594,16 @@ Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
static FuncDeclaration *adReverseChar_fd = NULL;
|
static FuncDeclaration *adReverseChar_fd = NULL;
|
||||||
if(!adReverseChar_fd) {
|
if(!adReverseChar_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
Type* arrty = Type::tchar->arrayOf();
|
Type* arrty = Type::tchar->arrayOf();
|
||||||
args->push(new Argument(STCin, arrty, NULL, NULL));
|
args->push(new Parameter(STCin, arrty, NULL, NULL));
|
||||||
adReverseChar_fd = FuncDeclaration::genCfunc(args, arrty, "_adReverseChar");
|
adReverseChar_fd = FuncDeclaration::genCfunc(args, arrty, "_adReverseChar");
|
||||||
}
|
}
|
||||||
static FuncDeclaration *adReverseWchar_fd = NULL;
|
static FuncDeclaration *adReverseWchar_fd = NULL;
|
||||||
if(!adReverseWchar_fd) {
|
if(!adReverseWchar_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
Type* arrty = Type::twchar->arrayOf();
|
Type* arrty = Type::twchar->arrayOf();
|
||||||
args->push(new Argument(STCin, arrty, NULL, NULL));
|
args->push(new Parameter(STCin, arrty, NULL, NULL));
|
||||||
adReverseWchar_fd = FuncDeclaration::genCfunc(args, arrty, "_adReverseWchar");
|
adReverseWchar_fd = FuncDeclaration::genCfunc(args, arrty, "_adReverseWchar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1625,16 +1625,16 @@ Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
static FuncDeclaration *adSortChar_fd = NULL;
|
static FuncDeclaration *adSortChar_fd = NULL;
|
||||||
if(!adSortChar_fd) {
|
if(!adSortChar_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
Type* arrty = Type::tchar->arrayOf();
|
Type* arrty = Type::tchar->arrayOf();
|
||||||
args->push(new Argument(STCin, arrty, NULL, NULL));
|
args->push(new Parameter(STCin, arrty, NULL, NULL));
|
||||||
adSortChar_fd = FuncDeclaration::genCfunc(args, arrty, "_adSortChar");
|
adSortChar_fd = FuncDeclaration::genCfunc(args, arrty, "_adSortChar");
|
||||||
}
|
}
|
||||||
static FuncDeclaration *adSortWchar_fd = NULL;
|
static FuncDeclaration *adSortWchar_fd = NULL;
|
||||||
if(!adSortWchar_fd) {
|
if(!adSortWchar_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
Type* arrty = Type::twchar->arrayOf();
|
Type* arrty = Type::twchar->arrayOf();
|
||||||
args->push(new Argument(STCin, arrty, NULL, NULL));
|
args->push(new Parameter(STCin, arrty, NULL, NULL));
|
||||||
adSortWchar_fd = FuncDeclaration::genCfunc(args, arrty, "_adSortWchar");
|
adSortWchar_fd = FuncDeclaration::genCfunc(args, arrty, "_adSortWchar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1660,16 +1660,16 @@ Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
static FuncDeclaration *adDup_fd = NULL;
|
static FuncDeclaration *adDup_fd = NULL;
|
||||||
if(!adDup_fd) {
|
if(!adDup_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL));
|
args->push(new Parameter(STCin, Type::typeinfo->type, NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->arrayOf(), NULL, NULL));
|
||||||
adDup_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::adDup);
|
adDup_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::adDup);
|
||||||
}
|
}
|
||||||
static FuncDeclaration *adReverse_fd = NULL;
|
static FuncDeclaration *adReverse_fd = NULL;
|
||||||
if(!adReverse_fd) {
|
if(!adReverse_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->arrayOf(), NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
|
args->push(new Parameter(STCin, Type::tsize_t, NULL, NULL));
|
||||||
adReverse_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::adReverse);
|
adReverse_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::adReverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1703,16 +1703,16 @@ Expression *TypeArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
static FuncDeclaration *adSort_fd = NULL;
|
static FuncDeclaration *adSort_fd = NULL;
|
||||||
if(!adSort_fd) {
|
if(!adSort_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->arrayOf(), NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL));
|
args->push(new Parameter(STCin, Type::typeinfo->type, NULL, NULL));
|
||||||
adSort_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), "_adSort");
|
adSort_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), "_adSort");
|
||||||
}
|
}
|
||||||
static FuncDeclaration *adSortBit_fd = NULL;
|
static FuncDeclaration *adSortBit_fd = NULL;
|
||||||
if(!adSortBit_fd) {
|
if(!adSortBit_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->arrayOf(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->arrayOf(), NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL));
|
args->push(new Parameter(STCin, Type::typeinfo->type, NULL, NULL));
|
||||||
adSortBit_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), "_adSortBit");
|
adSortBit_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), "_adSortBit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1981,7 +1981,7 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc)
|
||||||
{ error(loc, "tuple index %ju exceeds %u", d, tt->arguments->dim);
|
{ error(loc, "tuple index %ju exceeds %u", d, tt->arguments->dim);
|
||||||
return Type::terror;
|
return Type::terror;
|
||||||
}
|
}
|
||||||
Argument *arg = (Argument *)tt->arguments->data[(size_t)d];
|
Parameter *arg = (Parameter *)tt->arguments->data[(size_t)d];
|
||||||
return arg->type;
|
return arg->type;
|
||||||
}
|
}
|
||||||
case Tfunction:
|
case Tfunction:
|
||||||
|
@ -2401,8 +2401,8 @@ Expression *TypeAArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
static FuncDeclaration *aaLen_fd = NULL;
|
static FuncDeclaration *aaLen_fd = NULL;
|
||||||
if(!aaLen_fd) {
|
if(!aaLen_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
||||||
aaLen_fd = FuncDeclaration::genCfunc(args, Type::tsize_t, Id::aaLen);
|
aaLen_fd = FuncDeclaration::genCfunc(args, Type::tsize_t, Id::aaLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2422,9 +2422,9 @@ Expression *TypeAArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
static FuncDeclaration *aaKeys_fd = NULL;
|
static FuncDeclaration *aaKeys_fd = NULL;
|
||||||
if(!aaKeys_fd) {
|
if(!aaKeys_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
|
args->push(new Parameter(STCin, Type::tsize_t, NULL, NULL));
|
||||||
aaKeys_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::aaKeys);
|
aaKeys_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::aaKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2443,10 +2443,10 @@ Expression *TypeAArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
static FuncDeclaration *aaValues_fd = NULL;
|
static FuncDeclaration *aaValues_fd = NULL;
|
||||||
if(!aaValues_fd) {
|
if(!aaValues_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
|
args->push(new Parameter(STCin, Type::tsize_t, NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
|
args->push(new Parameter(STCin, Type::tsize_t, NULL, NULL));
|
||||||
aaValues_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::aaValues);
|
aaValues_fd = FuncDeclaration::genCfunc(args, Type::tvoid->arrayOf(), Id::aaValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2468,9 +2468,9 @@ Expression *TypeAArray::dotExp(Scope *sc, Expression *e, Identifier *ident)
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
static FuncDeclaration *aaRehash_fd = NULL;
|
static FuncDeclaration *aaRehash_fd = NULL;
|
||||||
if(!aaRehash_fd) {
|
if(!aaRehash_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL));
|
args->push(new Parameter(STCin, Type::typeinfo->type, NULL, NULL));
|
||||||
aaRehash_fd = FuncDeclaration::genCfunc(args, Type::tvoidptr, Id::aaRehash);
|
aaRehash_fd = FuncDeclaration::genCfunc(args, Type::tvoidptr, Id::aaRehash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2708,7 +2708,7 @@ int TypeReference::isZeroInit(Loc loc)
|
||||||
|
|
||||||
/***************************** TypeFunction *****************************/
|
/***************************** TypeFunction *****************************/
|
||||||
|
|
||||||
TypeFunction::TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage)
|
TypeFunction::TypeFunction(Parameters *parameters, Type *treturn, int varargs, enum LINK linkage)
|
||||||
: Type(Tfunction, treturn)
|
: Type(Tfunction, treturn)
|
||||||
{
|
{
|
||||||
//if (!treturn) *(char*)0=0;
|
//if (!treturn) *(char*)0=0;
|
||||||
|
@ -2726,8 +2726,8 @@ TypeFunction::TypeFunction(Arguments *parameters, Type *treturn, int varargs, en
|
||||||
Type *TypeFunction::syntaxCopy()
|
Type *TypeFunction::syntaxCopy()
|
||||||
{
|
{
|
||||||
Type *treturn = next ? next->syntaxCopy() : NULL;
|
Type *treturn = next ? next->syntaxCopy() : NULL;
|
||||||
Arguments *params = Argument::arraySyntaxCopy(parameters);
|
Parameters *params = Parameter::arraySyntaxCopy(parameters);
|
||||||
TypeFunction *t = new TypeFunction(params, treturn, varargs, linkage);
|
Type *t = new TypeFunction(params, treturn, varargs, linkage);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2764,13 +2764,13 @@ int Type::covariant(Type *t)
|
||||||
|
|
||||||
if (t1->parameters && t2->parameters)
|
if (t1->parameters && t2->parameters)
|
||||||
{
|
{
|
||||||
size_t dim = Argument::dim(t1->parameters);
|
size_t dim = Parameter::dim(t1->parameters);
|
||||||
if (dim != Argument::dim(t2->parameters))
|
if (dim != Parameter::dim(t2->parameters))
|
||||||
goto Ldistinct;
|
goto Ldistinct;
|
||||||
|
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{ Argument *arg1 = Argument::getNth(t1->parameters, i);
|
{ Parameter *arg1 = Parameter::getNth(t1->parameters, i);
|
||||||
Argument *arg2 = Argument::getNth(t2->parameters, i);
|
Parameter *arg2 = Parameter::getNth(t2->parameters, i);
|
||||||
|
|
||||||
if (!arg1->type->equals(arg2->type))
|
if (!arg1->type->equals(arg2->type))
|
||||||
goto Ldistinct;
|
goto Ldistinct;
|
||||||
|
@ -2875,7 +2875,7 @@ void TypeFunction::toDecoBuffer(OutBuffer *buf, bool mangle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write argument types
|
// Write argument types
|
||||||
Argument::argsToDecoBuffer(buf, parameters, mangle);
|
Parameter::argsToDecoBuffer(buf, parameters, mangle);
|
||||||
//if (buf->data[buf->offset - 1] == '@') halt();
|
//if (buf->data[buf->offset - 1] == '@') halt();
|
||||||
buf->writeByte('Z' - varargs); // mark end of arg list
|
buf->writeByte('Z' - varargs); // mark end of arg list
|
||||||
next->toDecoBuffer(buf, mangle);
|
next->toDecoBuffer(buf, mangle);
|
||||||
|
@ -2917,7 +2917,7 @@ void TypeFunction::toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs
|
||||||
{ buf->writeByte(' ');
|
{ buf->writeByte(' ');
|
||||||
buf->writestring(ident->toHChars2());
|
buf->writestring(ident->toHChars2());
|
||||||
}
|
}
|
||||||
Argument::argsToCBuffer(buf, hgs, parameters, varargs);
|
Parameter::argsToCBuffer(buf, hgs, parameters, varargs);
|
||||||
inuse--;
|
inuse--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2953,7 +2953,7 @@ void TypeFunction::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod)
|
||||||
if (!hgs->hdrgen && p)
|
if (!hgs->hdrgen && p)
|
||||||
buf->writestring(p);
|
buf->writestring(p);
|
||||||
buf->writestring(" function");
|
buf->writestring(" function");
|
||||||
Argument::argsToCBuffer(buf, hgs, parameters, varargs);
|
Parameter::argsToCBuffer(buf, hgs, parameters, varargs);
|
||||||
inuse--;
|
inuse--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2969,11 +2969,11 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc)
|
||||||
TypeFunction *tf = (TypeFunction *)mem.malloc(sizeof(TypeFunction));
|
TypeFunction *tf = (TypeFunction *)mem.malloc(sizeof(TypeFunction));
|
||||||
memcpy(tf, this, sizeof(TypeFunction));
|
memcpy(tf, this, sizeof(TypeFunction));
|
||||||
if (parameters)
|
if (parameters)
|
||||||
{ tf->parameters = (Arguments *)parameters->copy();
|
{ tf->parameters = (Parameters *)parameters->copy();
|
||||||
for (size_t i = 0; i < parameters->dim; i++)
|
for (size_t i = 0; i < parameters->dim; i++)
|
||||||
{ Argument *arg = (Argument *)parameters->data[i];
|
{ Parameter *arg = (Parameter *)parameters->data[i];
|
||||||
Argument *cpy = (Argument *)mem.malloc(sizeof(Argument));
|
Parameter *cpy = (Parameter *)mem.malloc(sizeof(Parameter));
|
||||||
memcpy(cpy, arg, sizeof(Argument));
|
memcpy(cpy, arg, sizeof(Parameter));
|
||||||
tf->parameters->data[i] = (void *)cpy;
|
tf->parameters->data[i] = (void *)cpy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3006,9 +3006,9 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc)
|
||||||
argsc->stc = 0; // don't inherit storage class
|
argsc->stc = 0; // don't inherit storage class
|
||||||
argsc->protection = PROTpublic;
|
argsc->protection = PROTpublic;
|
||||||
|
|
||||||
size_t dim = Argument::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++)
|
||||||
{ Argument *arg = Argument::getNth(tf->parameters, i);
|
{ Parameter *arg = Parameter::getNth(tf->parameters, i);
|
||||||
|
|
||||||
tf->inuse++;
|
tf->inuse++;
|
||||||
arg->type = arg->type->semantic(loc, argsc);
|
arg->type = arg->type->semantic(loc, argsc);
|
||||||
|
@ -3044,7 +3044,7 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc)
|
||||||
* change.
|
* change.
|
||||||
*/
|
*/
|
||||||
if (t->ty == Ttuple)
|
if (t->ty == Ttuple)
|
||||||
{ dim = Argument::dim(tf->parameters);
|
{ dim = Parameter::dim(tf->parameters);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3059,7 +3059,7 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc)
|
||||||
return terror;
|
return terror;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tf->varargs == 1 && tf->linkage != LINKd && Argument::dim(tf->parameters) == 0)
|
if (tf->varargs == 1 && tf->linkage != LINKd && Parameter::dim(tf->parameters) == 0)
|
||||||
error(loc, "variadic functions with non-D linkage must have at least one parameter");
|
error(loc, "variadic functions with non-D linkage must have at least one parameter");
|
||||||
|
|
||||||
/* Don't return merge(), because arg identifiers and default args
|
/* Don't return merge(), because arg identifiers and default args
|
||||||
|
@ -3081,7 +3081,7 @@ int TypeFunction::callMatch(Expressions *args)
|
||||||
//printf("TypeFunction::callMatch()\n");
|
//printf("TypeFunction::callMatch()\n");
|
||||||
int match = MATCHexact; // assume exact match
|
int match = MATCHexact; // assume exact match
|
||||||
|
|
||||||
size_t nparams = Argument::dim(parameters);
|
size_t nparams = Parameter::dim(parameters);
|
||||||
size_t nargs = args ? args->dim : 0;
|
size_t nargs = args ? args->dim : 0;
|
||||||
if (nparams == nargs)
|
if (nparams == nargs)
|
||||||
;
|
;
|
||||||
|
@ -3098,7 +3098,7 @@ int TypeFunction::callMatch(Expressions *args)
|
||||||
|
|
||||||
// BUG: what about out and ref?
|
// BUG: what about out and ref?
|
||||||
|
|
||||||
Argument *p = Argument::getNth(parameters, u);
|
Parameter *p = Parameter::getNth(parameters, u);
|
||||||
assert(p);
|
assert(p);
|
||||||
if (u >= nargs)
|
if (u >= nargs)
|
||||||
{
|
{
|
||||||
|
@ -3196,7 +3196,7 @@ Type *TypeFunction::reliesOnTident()
|
||||||
if (parameters)
|
if (parameters)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < parameters->dim; i++)
|
for (size_t i = 0; i < parameters->dim; i++)
|
||||||
{ Argument *arg = (Argument *)parameters->data[i];
|
{ Parameter *arg = (Parameter *)parameters->data[i];
|
||||||
Type *t = arg->type->reliesOnTident();
|
Type *t = arg->type->reliesOnTident();
|
||||||
if (t)
|
if (t)
|
||||||
return t;
|
return t;
|
||||||
|
@ -3257,7 +3257,7 @@ void TypeDelegate::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod)
|
||||||
|
|
||||||
tf->next->toCBuffer2(buf, hgs, 0);
|
tf->next->toCBuffer2(buf, hgs, 0);
|
||||||
buf->writestring(" delegate");
|
buf->writestring(" delegate");
|
||||||
Argument::argsToCBuffer(buf, hgs, tf->parameters, tf->varargs);
|
Parameter::argsToCBuffer(buf, hgs, tf->parameters, tf->varargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression *TypeDelegate::defaultInit(Loc loc)
|
Expression *TypeDelegate::defaultInit(Loc loc)
|
||||||
|
@ -5173,7 +5173,7 @@ int TypeClass::hasPointers()
|
||||||
|
|
||||||
/***************************** TypeTuple *****************************/
|
/***************************** TypeTuple *****************************/
|
||||||
|
|
||||||
TypeTuple::TypeTuple(Arguments *arguments)
|
TypeTuple::TypeTuple(Parameters *arguments)
|
||||||
: Type(Ttuple, NULL)
|
: Type(Ttuple, NULL)
|
||||||
{
|
{
|
||||||
//printf("TypeTuple(this = %p)\n", this);
|
//printf("TypeTuple(this = %p)\n", this);
|
||||||
|
@ -5184,7 +5184,7 @@ TypeTuple::TypeTuple(Arguments *arguments)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < arguments->dim; i++)
|
for (size_t i = 0; i < arguments->dim; i++)
|
||||||
{
|
{
|
||||||
Argument *arg = (Argument *)arguments->data[i];
|
Parameter *arg = (Parameter *)arguments->data[i];
|
||||||
assert(arg && arg->type);
|
assert(arg && arg->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5199,7 +5199,7 @@ TypeTuple::TypeTuple(Arguments *arguments)
|
||||||
TypeTuple::TypeTuple(Expressions *exps)
|
TypeTuple::TypeTuple(Expressions *exps)
|
||||||
: Type(Ttuple, NULL)
|
: Type(Ttuple, NULL)
|
||||||
{
|
{
|
||||||
Arguments *arguments = new Arguments;
|
Parameters *arguments = new Parameters;
|
||||||
if (exps)
|
if (exps)
|
||||||
{
|
{
|
||||||
arguments->setDim(exps->dim);
|
arguments->setDim(exps->dim);
|
||||||
|
@ -5207,7 +5207,7 @@ TypeTuple::TypeTuple(Expressions *exps)
|
||||||
{ Expression *e = (Expression *)exps->data[i];
|
{ Expression *e = (Expression *)exps->data[i];
|
||||||
if (e->type->ty == Ttuple)
|
if (e->type->ty == Ttuple)
|
||||||
e->error("cannot form tuple of tuples");
|
e->error("cannot form tuple of tuples");
|
||||||
Argument *arg = new Argument(STCin, e->type, NULL, NULL);
|
Parameter *arg = new Parameter(STCin, e->type, NULL, NULL);
|
||||||
arguments->data[i] = (void *)arg;
|
arguments->data[i] = (void *)arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5216,7 +5216,7 @@ TypeTuple::TypeTuple(Expressions *exps)
|
||||||
|
|
||||||
Type *TypeTuple::syntaxCopy()
|
Type *TypeTuple::syntaxCopy()
|
||||||
{
|
{
|
||||||
Arguments *args = Argument::arraySyntaxCopy(arguments);
|
Parameters *args = Parameter::arraySyntaxCopy(arguments);
|
||||||
Type *t = new TypeTuple(args);
|
Type *t = new TypeTuple(args);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
@ -5249,8 +5249,8 @@ int TypeTuple::equals(Object *o)
|
||||||
if (arguments->dim == tt->arguments->dim)
|
if (arguments->dim == tt->arguments->dim)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < tt->arguments->dim; i++)
|
for (size_t i = 0; i < tt->arguments->dim; i++)
|
||||||
{ Argument *arg1 = (Argument *)arguments->data[i];
|
{ Parameter *arg1 = (Parameter *)arguments->data[i];
|
||||||
Argument *arg2 = (Argument *)tt->arguments->data[i];
|
Parameter *arg2 = (Parameter *)tt->arguments->data[i];
|
||||||
|
|
||||||
if (!arg1->type->equals(arg2->type))
|
if (!arg1->type->equals(arg2->type))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5267,7 +5267,7 @@ Type *TypeTuple::reliesOnTident()
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < arguments->dim; i++)
|
for (size_t i = 0; i < arguments->dim; i++)
|
||||||
{
|
{
|
||||||
Argument *arg = (Argument *)arguments->data[i];
|
Parameter *arg = (Parameter *)arguments->data[i];
|
||||||
Type *t = arg->type->reliesOnTident();
|
Type *t = arg->type->reliesOnTident();
|
||||||
if (t)
|
if (t)
|
||||||
return t;
|
return t;
|
||||||
|
@ -5278,14 +5278,14 @@ Type *TypeTuple::reliesOnTident()
|
||||||
|
|
||||||
void TypeTuple::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod)
|
void TypeTuple::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod)
|
||||||
{
|
{
|
||||||
Argument::argsToCBuffer(buf, hgs, arguments, 0);
|
Parameter::argsToCBuffer(buf, hgs, arguments, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypeTuple::toDecoBuffer(OutBuffer *buf, bool mangle)
|
void TypeTuple::toDecoBuffer(OutBuffer *buf, bool mangle)
|
||||||
{
|
{
|
||||||
//printf("TypeTuple::toDecoBuffer() this = %p\n", this);
|
//printf("TypeTuple::toDecoBuffer() this = %p\n", this);
|
||||||
OutBuffer buf2;
|
OutBuffer buf2;
|
||||||
Argument::argsToDecoBuffer(&buf2, arguments, mangle);
|
Parameter::argsToDecoBuffer(&buf2, arguments, mangle);
|
||||||
unsigned len = buf2.offset;
|
unsigned len = buf2.offset;
|
||||||
buf->printf("%c%d%.*s", mangleChar[ty], len, len, (char *)buf2.extractData());
|
buf->printf("%c%d%.*s", mangleChar[ty], len, len, (char *)buf2.extractData());
|
||||||
}
|
}
|
||||||
|
@ -5352,10 +5352,10 @@ Type *TypeSlice::semantic(Loc loc, Scope *sc)
|
||||||
return Type::terror;
|
return Type::terror;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arguments *args = new Arguments;
|
Parameters *args = new Parameters;
|
||||||
args->reserve(i2 - i1);
|
args->reserve(i2 - i1);
|
||||||
for (size_t i = i1; i < i2; i++)
|
for (size_t i = i1; i < i2; i++)
|
||||||
{ Argument *arg = (Argument *)tt->arguments->data[i];
|
{ Parameter *arg = (Parameter *)tt->arguments->data[i];
|
||||||
args->push(arg);
|
args->push(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5438,9 +5438,9 @@ void TypeSlice::toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod)
|
||||||
buf->printf("%s]", upr->toChars());
|
buf->printf("%s]", upr->toChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************** Argument *****************************/
|
/***************************** Parameter *****************************/
|
||||||
|
|
||||||
Argument::Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg)
|
Parameter::Parameter(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg)
|
||||||
{
|
{
|
||||||
this->type = type;
|
this->type = type;
|
||||||
this->ident = ident;
|
this->ident = ident;
|
||||||
|
@ -5448,24 +5448,24 @@ Argument::Argument(unsigned storageClass, Type *type, Identifier *ident, Express
|
||||||
this->defaultArg = defaultArg;
|
this->defaultArg = defaultArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Argument *Argument::syntaxCopy()
|
Parameter *Parameter::syntaxCopy()
|
||||||
{
|
{
|
||||||
Argument *a = new Argument(storageClass,
|
Parameter *a = new Parameter(storageClass,
|
||||||
type ? type->syntaxCopy() : NULL,
|
type ? type->syntaxCopy() : NULL,
|
||||||
ident,
|
ident,
|
||||||
defaultArg ? defaultArg->syntaxCopy() : NULL);
|
defaultArg ? defaultArg->syntaxCopy() : NULL);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arguments *Argument::arraySyntaxCopy(Arguments *args)
|
Parameters *Parameter::arraySyntaxCopy(Parameters *args)
|
||||||
{ Arguments *a = NULL;
|
{ Parameters *a = NULL;
|
||||||
|
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
a = new Arguments();
|
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++)
|
||||||
{ Argument *arg = (Argument *)args->data[i];
|
{ Parameter *arg = (Parameter *)args->data[i];
|
||||||
|
|
||||||
arg = arg->syntaxCopy();
|
arg = arg->syntaxCopy();
|
||||||
a->data[i] = (void *)arg;
|
a->data[i] = (void *)arg;
|
||||||
|
@ -5474,7 +5474,7 @@ Arguments *Argument::arraySyntaxCopy(Arguments *args)
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *Argument::argsTypesToChars(Arguments *args, int varargs)
|
char *Parameter::argsTypesToChars(Parameters *args, int varargs)
|
||||||
{ OutBuffer *buf;
|
{ OutBuffer *buf;
|
||||||
|
|
||||||
buf = new OutBuffer();
|
buf = new OutBuffer();
|
||||||
|
@ -5486,11 +5486,11 @@ char *Argument::argsTypesToChars(Arguments *args, int varargs)
|
||||||
HdrGenState hgs;
|
HdrGenState hgs;
|
||||||
|
|
||||||
for (i = 0; i < args->dim; i++)
|
for (i = 0; i < args->dim; i++)
|
||||||
{ Argument *arg;
|
{ Parameter *arg;
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
buf->writeByte(',');
|
buf->writeByte(',');
|
||||||
arg = (Argument *)args->data[i];
|
arg = (Parameter *)args->data[i];
|
||||||
argbuf.reset();
|
argbuf.reset();
|
||||||
arg->type->toCBuffer2(&argbuf, &hgs, 0);
|
arg->type->toCBuffer2(&argbuf, &hgs, 0);
|
||||||
buf->write(&argbuf);
|
buf->write(&argbuf);
|
||||||
|
@ -5507,7 +5507,7 @@ char *Argument::argsTypesToChars(Arguments *args, int varargs)
|
||||||
return buf->toChars();
|
return buf->toChars();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Argument::argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *arguments, int varargs)
|
void Parameter::argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Parameters *arguments, int varargs)
|
||||||
{
|
{
|
||||||
buf->writeByte('(');
|
buf->writeByte('(');
|
||||||
if (arguments)
|
if (arguments)
|
||||||
|
@ -5515,11 +5515,11 @@ void Argument::argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *argume
|
||||||
OutBuffer argbuf;
|
OutBuffer argbuf;
|
||||||
|
|
||||||
for (i = 0; i < arguments->dim; i++)
|
for (i = 0; i < arguments->dim; i++)
|
||||||
{ Argument *arg;
|
{ Parameter *arg;
|
||||||
|
|
||||||
if (i)
|
if (i)
|
||||||
buf->writestring(", ");
|
buf->writestring(", ");
|
||||||
arg = (Argument *)arguments->data[i];
|
arg = (Parameter *)arguments->data[i];
|
||||||
if (arg->storageClass & STCout)
|
if (arg->storageClass & STCout)
|
||||||
buf->writestring("out ");
|
buf->writestring("out ");
|
||||||
else if (arg->storageClass & STCref)
|
else if (arg->storageClass & STCref)
|
||||||
|
@ -5547,17 +5547,17 @@ void Argument::argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *argume
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Argument::argsToDecoBuffer(OutBuffer *buf, Arguments *arguments, bool mangle)
|
void Parameter::argsToDecoBuffer(OutBuffer *buf, Parameters *arguments, bool mangle)
|
||||||
{
|
{
|
||||||
//printf("Argument::argsToDecoBuffer()\n");
|
//printf("Parameter::argsToDecoBuffer()\n");
|
||||||
|
|
||||||
// Write argument types
|
// Write argument types
|
||||||
if (arguments)
|
if (arguments)
|
||||||
{
|
{
|
||||||
size_t dim = Argument::dim(arguments);
|
size_t dim = Parameter::dim(arguments);
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{
|
{
|
||||||
Argument *arg = Argument::getNth(arguments, i);
|
Parameter *arg = Parameter::getNth(arguments, i);
|
||||||
arg->toDecoBuffer(buf, mangle);
|
arg->toDecoBuffer(buf, mangle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5569,7 +5569,7 @@ void Argument::argsToDecoBuffer(OutBuffer *buf, Arguments *arguments, bool mangl
|
||||||
* If not, return NULL.
|
* If not, return NULL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Type *Argument::isLazyArray()
|
Type *Parameter::isLazyArray()
|
||||||
{
|
{
|
||||||
// if (inout == Lazy)
|
// if (inout == Lazy)
|
||||||
{
|
{
|
||||||
|
@ -5582,7 +5582,7 @@ Type *Argument::isLazyArray()
|
||||||
TypeDelegate *td = (TypeDelegate *)tel;
|
TypeDelegate *td = (TypeDelegate *)tel;
|
||||||
TypeFunction *tf = (TypeFunction *)td->next;
|
TypeFunction *tf = (TypeFunction *)td->next;
|
||||||
|
|
||||||
if (!tf->varargs && Argument::dim(tf->parameters) == 0)
|
if (!tf->varargs && Parameter::dim(tf->parameters) == 0)
|
||||||
{
|
{
|
||||||
return tf->next; // return type of delegate
|
return tf->next; // return type of delegate
|
||||||
}
|
}
|
||||||
|
@ -5592,7 +5592,7 @@ Type *Argument::isLazyArray()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Argument::toDecoBuffer(OutBuffer *buf, bool mangle)
|
void Parameter::toDecoBuffer(OutBuffer *buf, bool mangle)
|
||||||
{
|
{
|
||||||
switch (storageClass & (STCin | STCout | STCref | STClazy))
|
switch (storageClass & (STCin | STCout | STCref | STClazy))
|
||||||
{ case 0:
|
{ case 0:
|
||||||
|
@ -5620,13 +5620,13 @@ void Argument::toDecoBuffer(OutBuffer *buf, bool mangle)
|
||||||
* Determine number of arguments, folding in tuples.
|
* Determine number of arguments, folding in tuples.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
size_t Argument::dim(Arguments *args)
|
size_t Parameter::dim(Parameters *args)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if (args)
|
if (args)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < args->dim; i++)
|
for (size_t i = 0; i < args->dim; i++)
|
||||||
{ Argument *arg = (Argument *)args->data[i];
|
{ Parameter *arg = (Parameter *)args->data[i];
|
||||||
Type *t = arg->type->toBasetype();
|
Type *t = arg->type->toBasetype();
|
||||||
|
|
||||||
if (t->ty == Ttuple)
|
if (t->ty == Ttuple)
|
||||||
|
@ -5641,21 +5641,21 @@ size_t Argument::dim(Arguments *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************
|
/***************************************
|
||||||
* Get nth Argument, folding in tuples.
|
* Get nth Parameter, folding in tuples.
|
||||||
* Returns:
|
* Returns:
|
||||||
* Argument* nth Argument
|
* Parameter* nth Parameter
|
||||||
* NULL not found, *pn gets incremented by the number
|
* NULL not found, *pn gets incremented by the number
|
||||||
* of Arguments
|
* of Parameters
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Argument *Argument::getNth(Arguments *args, size_t nth, size_t *pn)
|
Parameter *Parameter::getNth(Parameters *args, size_t nth, size_t *pn)
|
||||||
{
|
{
|
||||||
if (!args)
|
if (!args)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
for (size_t i = 0; i < args->dim; i++)
|
for (size_t i = 0; i < args->dim; i++)
|
||||||
{ Argument *arg = (Argument *)args->data[i];
|
{ Parameter *arg = (Parameter *)args->data[i];
|
||||||
Type *t = arg->type->toBasetype();
|
Type *t = arg->type->toBasetype();
|
||||||
|
|
||||||
if (t->ty == Ttuple)
|
if (t->ty == Ttuple)
|
||||||
|
|
32
dmd/mtype.h
32
dmd/mtype.h
|
@ -44,7 +44,7 @@ enum LINK;
|
||||||
|
|
||||||
struct TypeBasic;
|
struct TypeBasic;
|
||||||
struct HdrGenState;
|
struct HdrGenState;
|
||||||
struct Argument;
|
struct Parameter;
|
||||||
|
|
||||||
// Back end
|
// Back end
|
||||||
#if IN_GCC
|
#if IN_GCC
|
||||||
|
@ -451,14 +451,14 @@ enum RET
|
||||||
|
|
||||||
struct TypeFunction : Type
|
struct TypeFunction : Type
|
||||||
{
|
{
|
||||||
Arguments *parameters; // function parameters
|
Parameters *parameters; // function parameters
|
||||||
int varargs; // 1: T t, ...) style for variable number of arguments
|
int varargs; // 1: T t, ...) style for variable number of arguments
|
||||||
// 2: T t ...) style for variable number of arguments
|
// 2: T t ...) style for variable number of arguments
|
||||||
enum LINK linkage; // calling convention
|
enum LINK linkage; // calling convention
|
||||||
|
|
||||||
int inuse;
|
int inuse;
|
||||||
|
|
||||||
TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage);
|
TypeFunction(Parameters *parameters, Type *treturn, int varargs, enum LINK linkage);
|
||||||
Type *syntaxCopy();
|
Type *syntaxCopy();
|
||||||
Type *semantic(Loc loc, Scope *sc);
|
Type *semantic(Loc loc, Scope *sc);
|
||||||
void toDecoBuffer(OutBuffer *buf, bool mangle);
|
void toDecoBuffer(OutBuffer *buf, bool mangle);
|
||||||
|
@ -718,9 +718,9 @@ struct TypeClass : Type
|
||||||
|
|
||||||
struct TypeTuple : Type
|
struct TypeTuple : Type
|
||||||
{
|
{
|
||||||
Arguments *arguments; // types making up the tuple
|
Parameters *arguments; // types making up the tuple
|
||||||
|
|
||||||
TypeTuple(Arguments *arguments);
|
TypeTuple(Parameters *arguments);
|
||||||
TypeTuple(Expressions *exps);
|
TypeTuple(Expressions *exps);
|
||||||
Type *syntaxCopy();
|
Type *syntaxCopy();
|
||||||
Type *semantic(Loc loc, Scope *sc);
|
Type *semantic(Loc loc, Scope *sc);
|
||||||
|
@ -748,7 +748,7 @@ struct TypeSlice : Type
|
||||||
|
|
||||||
//enum InOut { None, In, Out, InOut, Lazy };
|
//enum InOut { None, In, Out, InOut, Lazy };
|
||||||
|
|
||||||
struct Argument : Object
|
struct Parameter : Object
|
||||||
{
|
{
|
||||||
//enum InOut inout;
|
//enum InOut inout;
|
||||||
StorageClass storageClass;
|
StorageClass storageClass;
|
||||||
|
@ -756,18 +756,18 @@ struct Argument : Object
|
||||||
Identifier *ident;
|
Identifier *ident;
|
||||||
Expression *defaultArg;
|
Expression *defaultArg;
|
||||||
|
|
||||||
Argument(StorageClass storageClass, Type *type, Identifier *ident, Expression *defaultArg);
|
Parameter(StorageClass storageClass, Type *type, Identifier *ident, Expression *defaultArg);
|
||||||
Argument *syntaxCopy();
|
Parameter *syntaxCopy();
|
||||||
Type *isLazyArray();
|
Type *isLazyArray();
|
||||||
void toDecoBuffer(OutBuffer *buf, bool mangle);
|
void toDecoBuffer(OutBuffer *buf, bool mangle);
|
||||||
static Arguments *arraySyntaxCopy(Arguments *args);
|
static Parameters *arraySyntaxCopy(Parameters *args);
|
||||||
static char *argsTypesToChars(Arguments *args, int varargs);
|
static char *argsTypesToChars(Parameters *args, int varargs);
|
||||||
static void argsCppMangle(OutBuffer *buf, CppMangleState *cms, Arguments *arguments, int varargs);
|
static void argsCppMangle(OutBuffer *buf, CppMangleState *cms, Parameters *arguments, int varargs);
|
||||||
static void argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *arguments, int varargs);
|
static void argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Parameters *arguments, int varargs);
|
||||||
static void argsToDecoBuffer(OutBuffer *buf, Arguments *arguments, bool mangle);
|
static void argsToDecoBuffer(OutBuffer *buf, Parameters *arguments, bool mangle);
|
||||||
static int isTPL(Arguments *arguments);
|
static int isTPL(Parameters *arguments);
|
||||||
static size_t dim(Arguments *arguments);
|
static size_t dim(Parameters *arguments);
|
||||||
static Argument *getNth(Arguments *arguments, size_t nth, size_t *pn = NULL);
|
static Parameter *getNth(Parameters *arguments, size_t nth, size_t *pn = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int PTRSIZE;
|
extern int PTRSIZE;
|
||||||
|
|
34
dmd/opover.c
34
dmd/opover.c
|
@ -31,8 +31,8 @@
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
|
|
||||||
static Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id);
|
static Expression *build_overload(Loc loc, Scope *sc, Expression *ethis, Expression *earg, Identifier *id);
|
||||||
static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Arguments *arguments);
|
static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Parameters *arguments);
|
||||||
static int inferApplyArgTypesY(TypeFunction *tf, Arguments *arguments);
|
static int inferApplyArgTypesY(TypeFunction *tf, Parameters *arguments);
|
||||||
static void templateResolve(Match *m, TemplateDeclaration *td, Scope *sc, Loc loc, Objects *targsi, Expression *ethis, Expressions *arguments);
|
static void templateResolve(Match *m, TemplateDeclaration *td, Scope *sc, Loc loc, Objects *targsi, Expression *ethis, Expressions *arguments);
|
||||||
|
|
||||||
/******************************** Expression **************************/
|
/******************************** Expression **************************/
|
||||||
|
@ -527,7 +527,7 @@ Dsymbol *search_function(AggregateDeclaration *ad, Identifier *funcid)
|
||||||
* them from the aggregate type.
|
* them from the aggregate type.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Module* from)
|
void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr, Module* from)
|
||||||
{
|
{
|
||||||
if (!arguments || !arguments->dim)
|
if (!arguments || !arguments->dim)
|
||||||
return;
|
return;
|
||||||
|
@ -537,14 +537,14 @@ void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Mod
|
||||||
for (size_t u = 0; 1; u++)
|
for (size_t u = 0; 1; u++)
|
||||||
{ if (u == arguments->dim)
|
{ if (u == arguments->dim)
|
||||||
return;
|
return;
|
||||||
Argument *arg = (Argument *)arguments->data[u];
|
Parameter *arg = (Parameter *)arguments->data[u];
|
||||||
if (!arg->type)
|
if (!arg->type)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
AggregateDeclaration *ad;
|
AggregateDeclaration *ad;
|
||||||
|
|
||||||
Argument *arg = (Argument *)arguments->data[0];
|
Parameter *arg = (Parameter *)arguments->data[0];
|
||||||
Type *taggr = aggr->type;
|
Type *taggr = aggr->type;
|
||||||
if (!taggr)
|
if (!taggr)
|
||||||
return;
|
return;
|
||||||
|
@ -558,7 +558,7 @@ void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Mod
|
||||||
{
|
{
|
||||||
if (!arg->type)
|
if (!arg->type)
|
||||||
arg->type = Type::tsize_t; // key type
|
arg->type = Type::tsize_t; // key type
|
||||||
arg = (Argument *)arguments->data[1];
|
arg = (Parameter *)arguments->data[1];
|
||||||
}
|
}
|
||||||
if (!arg->type && tab->ty != Ttuple)
|
if (!arg->type && tab->ty != Ttuple)
|
||||||
arg->type = tab->nextOf(); // value type
|
arg->type = tab->nextOf(); // value type
|
||||||
|
@ -571,7 +571,7 @@ void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Mod
|
||||||
{
|
{
|
||||||
if (!arg->type)
|
if (!arg->type)
|
||||||
arg->type = taa->index; // key type
|
arg->type = taa->index; // key type
|
||||||
arg = (Argument *)arguments->data[1];
|
arg = (Parameter *)arguments->data[1];
|
||||||
}
|
}
|
||||||
if (!arg->type)
|
if (!arg->type)
|
||||||
arg->type = taa->next; // value type
|
arg->type = taa->next; // value type
|
||||||
|
@ -648,7 +648,7 @@ void inferApplyArgTypes(enum TOK op, Arguments *arguments, Expression *aggr, Mod
|
||||||
|
|
||||||
int fp3(void *param, FuncDeclaration *f)
|
int fp3(void *param, FuncDeclaration *f)
|
||||||
{
|
{
|
||||||
Arguments *arguments = (Arguments *)param;
|
Parameters *arguments = (Parameters *)param;
|
||||||
TypeFunction *tf = (TypeFunction *)f->type;
|
TypeFunction *tf = (TypeFunction *)f->type;
|
||||||
if (inferApplyArgTypesY(tf, arguments) == 1)
|
if (inferApplyArgTypesY(tf, arguments) == 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -657,13 +657,13 @@ int fp3(void *param, FuncDeclaration *f)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Arguments *arguments)
|
static void inferApplyArgTypesX(Module* from, FuncDeclaration *fstart, Parameters *arguments)
|
||||||
{
|
{
|
||||||
overloadApply(from, fstart, &fp3, arguments);
|
overloadApply(from, fstart, &fp3, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments)
|
static void inferApplyArgTypesX(FuncDeclaration *fstart, Parameters *arguments)
|
||||||
{
|
{
|
||||||
Declaration *d;
|
Declaration *d;
|
||||||
Declaration *next;
|
Declaration *next;
|
||||||
|
@ -714,13 +714,13 @@ static void inferApplyArgTypesX(FuncDeclaration *fstart, Arguments *arguments)
|
||||||
* 1 no match for this function
|
* 1 no match for this function
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int inferApplyArgTypesY(TypeFunction *tf, Arguments *arguments)
|
static int inferApplyArgTypesY(TypeFunction *tf, Parameters *arguments)
|
||||||
{ size_t nparams;
|
{ size_t nparams;
|
||||||
Argument *p;
|
Parameter *p;
|
||||||
|
|
||||||
if (Argument::dim(tf->parameters) != 1)
|
if (Parameter::dim(tf->parameters) != 1)
|
||||||
goto Lnomatch;
|
goto Lnomatch;
|
||||||
p = Argument::getNth(tf->parameters, 0);
|
p = Parameter::getNth(tf->parameters, 0);
|
||||||
if (p->type->ty != Tdelegate)
|
if (p->type->ty != Tdelegate)
|
||||||
goto Lnomatch;
|
goto Lnomatch;
|
||||||
tf = (TypeFunction *)p->type->nextOf();
|
tf = (TypeFunction *)p->type->nextOf();
|
||||||
|
@ -729,7 +729,7 @@ static int inferApplyArgTypesY(TypeFunction *tf, Arguments *arguments)
|
||||||
/* We now have tf, the type of the delegate. Match it against
|
/* We now have tf, the type of the delegate. Match it against
|
||||||
* the arguments, filling in missing argument types.
|
* the arguments, filling in missing argument types.
|
||||||
*/
|
*/
|
||||||
nparams = Argument::dim(tf->parameters);
|
nparams = Parameter::dim(tf->parameters);
|
||||||
if (nparams == 0 || tf->varargs)
|
if (nparams == 0 || tf->varargs)
|
||||||
goto Lnomatch; // not enough parameters
|
goto Lnomatch; // not enough parameters
|
||||||
if (arguments->dim != nparams)
|
if (arguments->dim != nparams)
|
||||||
|
@ -737,8 +737,8 @@ static int inferApplyArgTypesY(TypeFunction *tf, Arguments *arguments)
|
||||||
|
|
||||||
for (size_t u = 0; u < nparams; u++)
|
for (size_t u = 0; u < nparams; u++)
|
||||||
{
|
{
|
||||||
Argument *arg = (Argument *)arguments->data[u];
|
Parameter *arg = (Parameter *)arguments->data[u];
|
||||||
Argument *param = Argument::getNth(tf->parameters, u);
|
Parameter *param = Parameter::getNth(tf->parameters, u);
|
||||||
if (arg->type)
|
if (arg->type)
|
||||||
{ if (!arg->type->equals(param->type))
|
{ if (!arg->type->equals(param->type))
|
||||||
{
|
{
|
||||||
|
|
40
dmd/parse.c
40
dmd/parse.c
|
@ -788,7 +788,7 @@ Condition *Parser::parseStaticIfCondition()
|
||||||
Dsymbol *Parser::parseCtor()
|
Dsymbol *Parser::parseCtor()
|
||||||
{
|
{
|
||||||
CtorDeclaration *f;
|
CtorDeclaration *f;
|
||||||
Arguments *arguments;
|
Parameters *arguments;
|
||||||
int varargs;
|
int varargs;
|
||||||
Loc loc = this->loc;
|
Loc loc = this->loc;
|
||||||
|
|
||||||
|
@ -914,7 +914,7 @@ UnitTestDeclaration *Parser::parseUnitTest()
|
||||||
NewDeclaration *Parser::parseNew()
|
NewDeclaration *Parser::parseNew()
|
||||||
{
|
{
|
||||||
NewDeclaration *f;
|
NewDeclaration *f;
|
||||||
Arguments *arguments;
|
Parameters *arguments;
|
||||||
int varargs;
|
int varargs;
|
||||||
Loc loc = this->loc;
|
Loc loc = this->loc;
|
||||||
|
|
||||||
|
@ -934,7 +934,7 @@ NewDeclaration *Parser::parseNew()
|
||||||
DeleteDeclaration *Parser::parseDelete()
|
DeleteDeclaration *Parser::parseDelete()
|
||||||
{
|
{
|
||||||
DeleteDeclaration *f;
|
DeleteDeclaration *f;
|
||||||
Arguments *arguments;
|
Parameters *arguments;
|
||||||
int varargs;
|
int varargs;
|
||||||
Loc loc = this->loc;
|
Loc loc = this->loc;
|
||||||
|
|
||||||
|
@ -951,9 +951,9 @@ DeleteDeclaration *Parser::parseDelete()
|
||||||
* Parse parameter list.
|
* Parse parameter list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Arguments *Parser::parseParameters(int *pvarargs)
|
Parameters *Parser::parseParameters(int *pvarargs)
|
||||||
{
|
{
|
||||||
Arguments *arguments = new Arguments();
|
Parameters *arguments = new Parameters();
|
||||||
int varargs = 0;
|
int varargs = 0;
|
||||||
int hasdefault = 0;
|
int hasdefault = 0;
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ Arguments *Parser::parseParameters(int *pvarargs)
|
||||||
{ Type *tb;
|
{ Type *tb;
|
||||||
Identifier *ai = NULL;
|
Identifier *ai = NULL;
|
||||||
Type *at;
|
Type *at;
|
||||||
Argument *a;
|
Parameter *a;
|
||||||
StorageClass storageClass = 0;
|
StorageClass storageClass = 0;
|
||||||
Expression *ae;
|
Expression *ae;
|
||||||
|
|
||||||
|
@ -1021,12 +1021,12 @@ Arguments *Parser::parseParameters(int *pvarargs)
|
||||||
if (storageClass & (STCout | STCref))
|
if (storageClass & (STCout | STCref))
|
||||||
error("variadic argument cannot be out or ref");
|
error("variadic argument cannot be out or ref");
|
||||||
varargs = 2;
|
varargs = 2;
|
||||||
a = new Argument(storageClass, at, ai, ae);
|
a = new Parameter(storageClass, at, ai, ae);
|
||||||
arguments->push(a);
|
arguments->push(a);
|
||||||
nextToken();
|
nextToken();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
a = new Argument(storageClass, at, ai, ae);
|
a = new Parameter(storageClass, at, ai, ae);
|
||||||
arguments->push(a);
|
arguments->push(a);
|
||||||
if (token.value == TOKcomma)
|
if (token.value == TOKcomma)
|
||||||
{ nextToken();
|
{ nextToken();
|
||||||
|
@ -1950,7 +1950,7 @@ Type *Parser::parseBasicType2(Type *t)
|
||||||
{ // Handle delegate declaration:
|
{ // Handle delegate declaration:
|
||||||
// t delegate(parameter list)
|
// t delegate(parameter list)
|
||||||
// t function(parameter list)
|
// t function(parameter list)
|
||||||
Arguments *arguments;
|
Parameters *arguments;
|
||||||
int varargs;
|
int varargs;
|
||||||
enum TOK save = token.value;
|
enum TOK save = token.value;
|
||||||
|
|
||||||
|
@ -2058,7 +2058,7 @@ Type *Parser::parseDeclarator(Type *t, Identifier **pident, TemplateParameters *
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case TOKlparen:
|
case TOKlparen:
|
||||||
{ Arguments *arguments;
|
{ Parameters *arguments;
|
||||||
int varargs;
|
int varargs;
|
||||||
|
|
||||||
if (tpl)
|
if (tpl)
|
||||||
|
@ -3009,7 +3009,7 @@ Statement *Parser::parseStatement(int flags)
|
||||||
case TOKforeach_reverse:
|
case TOKforeach_reverse:
|
||||||
{
|
{
|
||||||
enum TOK op = token.value;
|
enum TOK op = token.value;
|
||||||
Arguments *arguments;
|
Parameters *arguments;
|
||||||
|
|
||||||
Statement *d;
|
Statement *d;
|
||||||
Statement *body;
|
Statement *body;
|
||||||
|
@ -3018,7 +3018,7 @@ Statement *Parser::parseStatement(int flags)
|
||||||
nextToken();
|
nextToken();
|
||||||
check(TOKlparen);
|
check(TOKlparen);
|
||||||
|
|
||||||
arguments = new Arguments();
|
arguments = new Parameters();
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -3026,7 +3026,7 @@ Statement *Parser::parseStatement(int flags)
|
||||||
Identifier *ai = NULL;
|
Identifier *ai = NULL;
|
||||||
Type *at;
|
Type *at;
|
||||||
unsigned storageClass;
|
unsigned storageClass;
|
||||||
Argument *a;
|
Parameter *a;
|
||||||
|
|
||||||
storageClass = STCin;
|
storageClass = STCin;
|
||||||
if (token.value == TOKinout || token.value == TOKref)
|
if (token.value == TOKinout || token.value == TOKref)
|
||||||
|
@ -3048,7 +3048,7 @@ Statement *Parser::parseStatement(int flags)
|
||||||
if (!ai)
|
if (!ai)
|
||||||
error("no identifier for declarator %s", at->toChars());
|
error("no identifier for declarator %s", at->toChars());
|
||||||
Larg:
|
Larg:
|
||||||
a = new Argument(storageClass, at, ai, NULL);
|
a = new Parameter(storageClass, at, ai, NULL);
|
||||||
arguments->push(a);
|
arguments->push(a);
|
||||||
if (token.value == TOKcomma)
|
if (token.value == TOKcomma)
|
||||||
{ nextToken();
|
{ nextToken();
|
||||||
|
@ -3066,7 +3066,7 @@ Statement *Parser::parseStatement(int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
case TOKif:
|
case TOKif:
|
||||||
{ Argument *arg = NULL;
|
{ Parameter *arg = NULL;
|
||||||
Expression *condition;
|
Expression *condition;
|
||||||
Statement *ifbody;
|
Statement *ifbody;
|
||||||
Statement *elsebody;
|
Statement *elsebody;
|
||||||
|
@ -3082,7 +3082,7 @@ Statement *Parser::parseStatement(int flags)
|
||||||
Token *t = peek(&token);
|
Token *t = peek(&token);
|
||||||
if (t->value == TOKassign)
|
if (t->value == TOKassign)
|
||||||
{
|
{
|
||||||
arg = new Argument(STCin, NULL, token.ident, NULL);
|
arg = new Parameter(STCin, NULL, token.ident, NULL);
|
||||||
nextToken();
|
nextToken();
|
||||||
nextToken();
|
nextToken();
|
||||||
}
|
}
|
||||||
|
@ -3105,7 +3105,7 @@ Statement *Parser::parseStatement(int flags)
|
||||||
tb = parseBasicType();
|
tb = parseBasicType();
|
||||||
at = parseDeclarator(tb, &ai);
|
at = parseDeclarator(tb, &ai);
|
||||||
check(TOKassign);
|
check(TOKassign);
|
||||||
arg = new Argument(STCin, at, ai, NULL);
|
arg = new Parameter(STCin, at, ai, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for " ident;"
|
// Check for " ident;"
|
||||||
|
@ -3114,7 +3114,7 @@ Statement *Parser::parseStatement(int flags)
|
||||||
Token *t = peek(&token);
|
Token *t = peek(&token);
|
||||||
if (t->value == TOKcomma || t->value == TOKsemicolon)
|
if (t->value == TOKcomma || t->value == TOKsemicolon)
|
||||||
{
|
{
|
||||||
arg = new Argument(STCin, NULL, token.ident, NULL);
|
arg = new Parameter(STCin, NULL, token.ident, NULL);
|
||||||
nextToken();
|
nextToken();
|
||||||
nextToken();
|
nextToken();
|
||||||
if (1 || !global.params.useDeprecated)
|
if (1 || !global.params.useDeprecated)
|
||||||
|
@ -4488,7 +4488,7 @@ Expression *Parser::parsePrimaryExp()
|
||||||
/* function type(parameters) { body }
|
/* function type(parameters) { body }
|
||||||
* delegate type(parameters) { body }
|
* delegate type(parameters) { body }
|
||||||
*/
|
*/
|
||||||
Arguments *arguments;
|
Parameters *arguments;
|
||||||
int varargs;
|
int varargs;
|
||||||
FuncLiteralDeclaration *fd;
|
FuncLiteralDeclaration *fd;
|
||||||
Type *t;
|
Type *t;
|
||||||
|
@ -4497,7 +4497,7 @@ Expression *Parser::parsePrimaryExp()
|
||||||
{
|
{
|
||||||
t = NULL;
|
t = NULL;
|
||||||
varargs = 0;
|
varargs = 0;
|
||||||
arguments = new Arguments();
|
arguments = new Parameters();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -93,7 +93,7 @@ struct Parser : Lexer
|
||||||
UnitTestDeclaration *parseUnitTest();
|
UnitTestDeclaration *parseUnitTest();
|
||||||
NewDeclaration *parseNew();
|
NewDeclaration *parseNew();
|
||||||
DeleteDeclaration *parseDelete();
|
DeleteDeclaration *parseDelete();
|
||||||
Arguments *parseParameters(int *pvarargs);
|
Parameters *parseParameters(int *pvarargs);
|
||||||
EnumDeclaration *parseEnum();
|
EnumDeclaration *parseEnum();
|
||||||
Dsymbol *parseAggregate();
|
Dsymbol *parseAggregate();
|
||||||
BaseClasses *parseBaseClasses();
|
BaseClasses *parseBaseClasses();
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ void ForStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
|
|
||||||
/******************************** ForeachStatement ***************************/
|
/******************************** ForeachStatement ***************************/
|
||||||
|
|
||||||
ForeachStatement::ForeachStatement(Loc loc, enum TOK op, Arguments *arguments,
|
ForeachStatement::ForeachStatement(Loc loc, enum TOK op, Parameters *arguments,
|
||||||
Expression *aggr, Statement *body)
|
Expression *aggr, Statement *body)
|
||||||
: Statement(loc)
|
: Statement(loc)
|
||||||
{
|
{
|
||||||
|
@ -1271,7 +1271,7 @@ ForeachStatement::ForeachStatement(Loc loc, enum TOK op, Arguments *arguments,
|
||||||
|
|
||||||
Statement *ForeachStatement::syntaxCopy()
|
Statement *ForeachStatement::syntaxCopy()
|
||||||
{
|
{
|
||||||
Arguments *args = Argument::arraySyntaxCopy(arguments);
|
Parameters *args = Parameter::arraySyntaxCopy(arguments);
|
||||||
Expression *exp = aggr->syntaxCopy();
|
Expression *exp = aggr->syntaxCopy();
|
||||||
ForeachStatement *s = new ForeachStatement(loc, op, args, exp,
|
ForeachStatement *s = new ForeachStatement(loc, op, args, exp,
|
||||||
body ? body->syntaxCopy() : NULL);
|
body ? body->syntaxCopy() : NULL);
|
||||||
|
@ -1334,7 +1334,7 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
}
|
}
|
||||||
else if (aggr->op == TOKtype) // type tuple
|
else if (aggr->op == TOKtype) // type tuple
|
||||||
{
|
{
|
||||||
n = Argument::dim(tuple->arguments);
|
n = Parameter::dim(tuple->arguments);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
|
@ -1345,8 +1345,8 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
if (te)
|
if (te)
|
||||||
e = (Expression *)te->exps->data[k];
|
e = (Expression *)te->exps->data[k];
|
||||||
else
|
else
|
||||||
t = Argument::getNth(tuple->arguments, k)->type;
|
t = Parameter::getNth(tuple->arguments, k)->type;
|
||||||
Argument *arg = (Argument *)arguments->data[0];
|
Parameter *arg = (Parameter *)arguments->data[0];
|
||||||
Statements *st = new Statements();
|
Statements *st = new Statements();
|
||||||
|
|
||||||
if (dim == 2)
|
if (dim == 2)
|
||||||
|
@ -1369,7 +1369,7 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
var->storage_class |= STCconst;
|
var->storage_class |= STCconst;
|
||||||
DeclarationExp *de = new DeclarationExp(loc, var);
|
DeclarationExp *de = new DeclarationExp(loc, var);
|
||||||
st->push(new ExpStatement(loc, de));
|
st->push(new ExpStatement(loc, de));
|
||||||
arg = (Argument *)arguments->data[1]; // value
|
arg = (Parameter *)arguments->data[1]; // value
|
||||||
}
|
}
|
||||||
// Declare value
|
// Declare value
|
||||||
if (arg->storageClass & (STCout | STCref | STClazy))
|
if (arg->storageClass & (STCout | STCref | STClazy))
|
||||||
|
@ -1410,7 +1410,7 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{ Argument *arg = (Argument *)arguments->data[i];
|
{ Parameter *arg = (Parameter *)arguments->data[i];
|
||||||
if (!arg->type)
|
if (!arg->type)
|
||||||
{
|
{
|
||||||
error("cannot infer type for %s", arg->ident->toChars());
|
error("cannot infer type for %s", arg->ident->toChars());
|
||||||
|
@ -1439,10 +1439,10 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
*/
|
*/
|
||||||
tn = tab->nextOf()->toBasetype();
|
tn = tab->nextOf()->toBasetype();
|
||||||
if (tn->ty == Tchar || tn->ty == Twchar || tn->ty == Tdchar)
|
if (tn->ty == Tchar || tn->ty == Twchar || tn->ty == Tdchar)
|
||||||
{ Argument *arg;
|
{ Parameter *arg;
|
||||||
|
|
||||||
int i = (dim == 1) ? 0 : 1; // index of value
|
int i = (dim == 1) ? 0 : 1; // index of value
|
||||||
arg = (Argument *)arguments->data[i];
|
arg = (Parameter *)arguments->data[i];
|
||||||
arg->type = arg->type->semantic(loc, sc);
|
arg->type = arg->type->semantic(loc, sc);
|
||||||
tnv = arg->type->toBasetype();
|
tnv = arg->type->toBasetype();
|
||||||
if (tnv->ty != tn->ty &&
|
if (tnv->ty != tn->ty &&
|
||||||
|
@ -1451,7 +1451,7 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
if (arg->storageClass & STCref)
|
if (arg->storageClass & STCref)
|
||||||
error("foreach: value of UTF conversion cannot be ref");
|
error("foreach: value of UTF conversion cannot be ref");
|
||||||
if (dim == 2)
|
if (dim == 2)
|
||||||
{ arg = (Argument *)arguments->data[0];
|
{ arg = (Parameter *)arguments->data[0];
|
||||||
if (arg->storageClass & STCref)
|
if (arg->storageClass & STCref)
|
||||||
error("foreach: key cannot be ref");
|
error("foreach: key cannot be ref");
|
||||||
}
|
}
|
||||||
|
@ -1461,7 +1461,7 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
|
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{ // Declare args
|
{ // Declare args
|
||||||
Argument *arg = (Argument *)arguments->data[i];
|
Parameter *arg = (Parameter *)arguments->data[i];
|
||||||
Type *argtype = arg->type->semantic(loc, sc);
|
Type *argtype = arg->type->semantic(loc, sc);
|
||||||
VarDeclaration *var;
|
VarDeclaration *var;
|
||||||
|
|
||||||
|
@ -1639,7 +1639,7 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
e = new VarExp(loc, r);
|
e = new VarExp(loc, r);
|
||||||
Expression *einit = new DotIdExp(loc, e, idhead);
|
Expression *einit = new DotIdExp(loc, e, idhead);
|
||||||
// einit = einit->semantic(sc);
|
// einit = einit->semantic(sc);
|
||||||
Argument *arg = (Argument *)arguments->data[0];
|
Parameter *arg = (Parameter *)arguments->data[0];
|
||||||
VarDeclaration *ve = new VarDeclaration(loc, arg->type, arg->ident, new ExpInitializer(loc, einit));
|
VarDeclaration *ve = new VarDeclaration(loc, arg->type, arg->ident, new ExpInitializer(loc, einit));
|
||||||
ve->storage_class |= STCforeach;
|
ve->storage_class |= STCforeach;
|
||||||
ve->storage_class |= arg->storageClass & (STCin | STCout | STCref | STC_TYPECTOR);
|
ve->storage_class |= arg->storageClass & (STCin | STCout | STCref | STC_TYPECTOR);
|
||||||
|
@ -1663,11 +1663,11 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
case Tdelegate:
|
case Tdelegate:
|
||||||
Lapply:
|
Lapply:
|
||||||
{ FuncDeclaration *fdapply;
|
{ FuncDeclaration *fdapply;
|
||||||
Arguments *args;
|
Parameters *args;
|
||||||
Expression *ec;
|
Expression *ec;
|
||||||
Expression *e;
|
Expression *e;
|
||||||
FuncLiteralDeclaration *fld;
|
FuncLiteralDeclaration *fld;
|
||||||
Argument *a;
|
Parameter *a;
|
||||||
Type *t;
|
Type *t;
|
||||||
Expression *flde;
|
Expression *flde;
|
||||||
Identifier *id;
|
Identifier *id;
|
||||||
|
@ -1694,9 +1694,9 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
/* Turn body into the function literal:
|
/* Turn body into the function literal:
|
||||||
* int delegate(ref T arg) { body }
|
* int delegate(ref T arg) { body }
|
||||||
*/
|
*/
|
||||||
args = new Arguments();
|
args = new Parameters();
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{ Argument *arg = (Argument *)arguments->data[i];
|
{ Parameter *arg = (Parameter *)arguments->data[i];
|
||||||
|
|
||||||
arg->type = arg->type->semantic(loc, sc);
|
arg->type = arg->type->semantic(loc, sc);
|
||||||
if (arg->storageClass & STCref)
|
if (arg->storageClass & STCref)
|
||||||
|
@ -1714,7 +1714,7 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
s = new DeclarationStatement(0, v);
|
s = new DeclarationStatement(0, v);
|
||||||
body = new CompoundStatement(loc, s, body);
|
body = new CompoundStatement(loc, s, body);
|
||||||
}
|
}
|
||||||
a = new Argument(STCref, arg->type, id, NULL);
|
a = new Parameter(STCref, arg->type, id, NULL);
|
||||||
args->push(a);
|
args->push(a);
|
||||||
}
|
}
|
||||||
t = new TypeFunction(args, Type::tint32, 0, LINKd);
|
t = new TypeFunction(args, Type::tint32, 0, LINKd);
|
||||||
|
@ -1739,14 +1739,14 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
if (tab->ty == Taarray)
|
if (tab->ty == Taarray)
|
||||||
{
|
{
|
||||||
// Check types
|
// Check types
|
||||||
Argument *arg = (Argument *)arguments->data[0];
|
Parameter *arg = (Parameter *)arguments->data[0];
|
||||||
if (dim == 2)
|
if (dim == 2)
|
||||||
{
|
{
|
||||||
if (arg->storageClass & STCref)
|
if (arg->storageClass & STCref)
|
||||||
error("foreach: index cannot be ref");
|
error("foreach: index cannot be ref");
|
||||||
if (!arg->type->equals(taa->index))
|
if (!arg->type->equals(taa->index))
|
||||||
error("foreach: index must be type %s, not %s", taa->index->toChars(), arg->type->toChars());
|
error("foreach: index must be type %s, not %s", taa->index->toChars(), arg->type->toChars());
|
||||||
arg = (Argument *)arguments->data[1];
|
arg = (Parameter *)arguments->data[1];
|
||||||
}
|
}
|
||||||
if (!arg->type->equals(taa->nextOf()))
|
if (!arg->type->equals(taa->nextOf()))
|
||||||
error("foreach: value must be type %s, not %s", taa->nextOf()->toChars(), arg->type->toChars());
|
error("foreach: value must be type %s, not %s", taa->nextOf()->toChars(), arg->type->toChars());
|
||||||
|
@ -1758,26 +1758,26 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
static FuncDeclaration *aaApply2_fd = NULL;
|
static FuncDeclaration *aaApply2_fd = NULL;
|
||||||
static TypeDelegate* aaApply2_dg;
|
static TypeDelegate* aaApply2_dg;
|
||||||
if(!aaApply2_fd) {
|
if(!aaApply2_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
|
args->push(new Parameter(STCin, Type::tsize_t, NULL, NULL));
|
||||||
Arguments* dgargs = new Arguments;
|
Parameters* dgargs = new Parameters;
|
||||||
dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
|
dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL));
|
||||||
dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
|
dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL));
|
||||||
aaApply2_dg = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
|
aaApply2_dg = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
|
||||||
args->push(new Argument(STCin, aaApply2_dg, NULL, NULL));
|
args->push(new Parameter(STCin, aaApply2_dg, NULL, NULL));
|
||||||
aaApply2_fd = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply2");
|
aaApply2_fd = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply2");
|
||||||
}
|
}
|
||||||
static FuncDeclaration *aaApply_fd = NULL;
|
static FuncDeclaration *aaApply_fd = NULL;
|
||||||
static TypeDelegate* aaApply_dg;
|
static TypeDelegate* aaApply_dg;
|
||||||
if(!aaApply_fd) {
|
if(!aaApply_fd) {
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
args->push(new Parameter(STCin, Type::tvoid->pointerTo(), NULL, NULL));
|
||||||
args->push(new Argument(STCin, Type::tsize_t, NULL, NULL));
|
args->push(new Parameter(STCin, Type::tsize_t, NULL, NULL));
|
||||||
Arguments* dgargs = new Arguments;
|
Parameters* dgargs = new Parameters;
|
||||||
dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
|
dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL));
|
||||||
aaApply_dg = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
|
aaApply_dg = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
|
||||||
args->push(new Argument(STCin, aaApply_dg, NULL, NULL));
|
args->push(new Parameter(STCin, aaApply_dg, NULL, NULL));
|
||||||
aaApply_fd = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply");
|
aaApply_fd = FuncDeclaration::genCfunc(args, Type::tindex, "_aaApply");
|
||||||
}
|
}
|
||||||
if (dim == 2) {
|
if (dim == 2) {
|
||||||
|
@ -1839,20 +1839,20 @@ Statement *ForeachStatement::semantic(Scope *sc)
|
||||||
#endif
|
#endif
|
||||||
assert(j < sizeof(fdname));
|
assert(j < sizeof(fdname));
|
||||||
//LDC: Build arguments.
|
//LDC: Build arguments.
|
||||||
Arguments* args = new Arguments;
|
Parameters* args = new Parameters;
|
||||||
args->push(new Argument(STCin, tn->arrayOf(), NULL, NULL));
|
args->push(new Parameter(STCin, tn->arrayOf(), NULL, NULL));
|
||||||
if (dim == 2) {
|
if (dim == 2) {
|
||||||
Arguments* dgargs = new Arguments;
|
Parameters* dgargs = new Parameters;
|
||||||
dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
|
dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL));
|
||||||
dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
|
dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL));
|
||||||
dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
|
dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
|
||||||
args->push(new Argument(STCin, dgty, NULL, NULL));
|
args->push(new Parameter(STCin, dgty, NULL, NULL));
|
||||||
fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname);
|
fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname);
|
||||||
} else {
|
} else {
|
||||||
Arguments* dgargs = new Arguments;
|
Parameters* dgargs = new Parameters;
|
||||||
dgargs->push(new Argument(STCin, Type::tvoidptr, NULL, NULL));
|
dgargs->push(new Parameter(STCin, Type::tvoidptr, NULL, NULL));
|
||||||
dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
|
dgty = new TypeDelegate(new TypeFunction(dgargs, Type::tindex, 0, LINKd));
|
||||||
args->push(new Argument(STCin, dgty, NULL, NULL));
|
args->push(new Parameter(STCin, dgty, NULL, NULL));
|
||||||
fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname);
|
fdapply = FuncDeclaration::genCfunc(args, Type::tindex, fdname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1980,7 +1980,7 @@ void ForeachStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
buf->writestring(" (");
|
buf->writestring(" (");
|
||||||
for (int i = 0; i < arguments->dim; i++)
|
for (int i = 0; i < arguments->dim; i++)
|
||||||
{
|
{
|
||||||
Argument *a = (Argument *)arguments->data[i];
|
Parameter *a = (Parameter *)arguments->data[i];
|
||||||
if (i)
|
if (i)
|
||||||
buf->writestring(", ");
|
buf->writestring(", ");
|
||||||
if (a->storageClass & STCref)
|
if (a->storageClass & STCref)
|
||||||
|
@ -2007,7 +2007,7 @@ void ForeachStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
|
|
||||||
ForeachRangeStatement::ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg,
|
ForeachRangeStatement::ForeachRangeStatement(Loc loc, enum TOK op, Parameter *arg,
|
||||||
Expression *lwr, Expression *upr, Statement *body)
|
Expression *lwr, Expression *upr, Statement *body)
|
||||||
: Statement(loc)
|
: Statement(loc)
|
||||||
{
|
{
|
||||||
|
@ -2215,7 +2215,7 @@ void ForeachRangeStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
|
|
||||||
/******************************** IfStatement ***************************/
|
/******************************** IfStatement ***************************/
|
||||||
|
|
||||||
IfStatement::IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody)
|
IfStatement::IfStatement(Loc loc, Parameter *arg, Expression *condition, Statement *ifbody, Statement *elsebody)
|
||||||
: Statement(loc)
|
: Statement(loc)
|
||||||
{
|
{
|
||||||
this->arg = arg;
|
this->arg = arg;
|
||||||
|
@ -2235,7 +2235,7 @@ Statement *IfStatement::syntaxCopy()
|
||||||
if (elsebody)
|
if (elsebody)
|
||||||
e = elsebody->syntaxCopy();
|
e = elsebody->syntaxCopy();
|
||||||
|
|
||||||
Argument *a = arg ? arg->syntaxCopy() : NULL;
|
Parameter *a = arg ? arg->syntaxCopy() : NULL;
|
||||||
IfStatement *s = new IfStatement(loc, a, condition->syntaxCopy(), i, e);
|
IfStatement *s = new IfStatement(loc, a, condition->syntaxCopy(), i, e);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct InlineDoState;
|
||||||
struct InlineScanState;
|
struct InlineScanState;
|
||||||
struct ReturnStatement;
|
struct ReturnStatement;
|
||||||
struct CompoundStatement;
|
struct CompoundStatement;
|
||||||
struct Argument;
|
struct Parameter;
|
||||||
struct StaticAssert;
|
struct StaticAssert;
|
||||||
struct AsmStatement;
|
struct AsmStatement;
|
||||||
struct AsmBlockStatement;
|
struct AsmBlockStatement;
|
||||||
|
@ -354,7 +354,7 @@ struct ForStatement : Statement
|
||||||
struct ForeachStatement : Statement
|
struct ForeachStatement : Statement
|
||||||
{
|
{
|
||||||
enum TOK op; // TOKforeach or TOKforeach_reverse
|
enum TOK op; // TOKforeach or TOKforeach_reverse
|
||||||
Arguments *arguments; // array of Argument*'s
|
Parameters *arguments; // array of Parameter*'s
|
||||||
Expression *aggr;
|
Expression *aggr;
|
||||||
Statement *body;
|
Statement *body;
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ struct ForeachStatement : Statement
|
||||||
Array cases; // put breaks, continues, gotos and returns here
|
Array cases; // put breaks, continues, gotos and returns here
|
||||||
Array gotos; // forward referenced goto's go here
|
Array gotos; // forward referenced goto's go here
|
||||||
|
|
||||||
ForeachStatement(Loc loc, enum TOK op, Arguments *arguments, Expression *aggr, Statement *body);
|
ForeachStatement(Loc loc, enum TOK op, Parameters *arguments, Expression *aggr, Statement *body);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
int hasBreak();
|
int hasBreak();
|
||||||
|
@ -386,14 +386,14 @@ struct ForeachStatement : Statement
|
||||||
struct ForeachRangeStatement : Statement
|
struct ForeachRangeStatement : Statement
|
||||||
{
|
{
|
||||||
enum TOK op; // TOKforeach or TOKforeach_reverse
|
enum TOK op; // TOKforeach or TOKforeach_reverse
|
||||||
Argument *arg; // loop index variable
|
Parameter *arg; // loop index variable
|
||||||
Expression *lwr;
|
Expression *lwr;
|
||||||
Expression *upr;
|
Expression *upr;
|
||||||
Statement *body;
|
Statement *body;
|
||||||
|
|
||||||
VarDeclaration *key;
|
VarDeclaration *key;
|
||||||
|
|
||||||
ForeachRangeStatement(Loc loc, enum TOK op, Argument *arg,
|
ForeachRangeStatement(Loc loc, enum TOK op, Parameter *arg,
|
||||||
Expression *lwr, Expression *upr, Statement *body);
|
Expression *lwr, Expression *upr, Statement *body);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
|
@ -413,14 +413,14 @@ struct ForeachRangeStatement : Statement
|
||||||
|
|
||||||
struct IfStatement : Statement
|
struct IfStatement : Statement
|
||||||
{
|
{
|
||||||
Argument *arg;
|
Parameter *arg;
|
||||||
Expression *condition;
|
Expression *condition;
|
||||||
Statement *ifbody;
|
Statement *ifbody;
|
||||||
Statement *elsebody;
|
Statement *elsebody;
|
||||||
|
|
||||||
VarDeclaration *match; // for MatchExpression results
|
VarDeclaration *match; // for MatchExpression results
|
||||||
|
|
||||||
IfStatement(Loc loc, Argument *arg, Expression *condition, Statement *ifbody, Statement *elsebody);
|
IfStatement(Loc loc, Parameter *arg, Expression *condition, Statement *ifbody, Statement *elsebody);
|
||||||
Statement *syntaxCopy();
|
Statement *syntaxCopy();
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
Expression *interpret(InterState *istate);
|
Expression *interpret(InterState *istate);
|
||||||
|
|
|
@ -330,8 +330,8 @@ void StructDeclaration::semantic(Scope *sc)
|
||||||
|
|
||||||
TypeFunction *tfeqptr;
|
TypeFunction *tfeqptr;
|
||||||
{
|
{
|
||||||
Arguments *arguments = new Arguments;
|
Parameters *arguments = new Parameters;
|
||||||
Argument *arg = new Argument(STCin, handle, Id::p, NULL);
|
Parameter *arg = new Parameter(STCin, handle, Id::p, NULL);
|
||||||
|
|
||||||
arguments->push(arg);
|
arguments->push(arg);
|
||||||
tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
||||||
|
@ -340,8 +340,8 @@ void StructDeclaration::semantic(Scope *sc)
|
||||||
|
|
||||||
TypeFunction *tfeq;
|
TypeFunction *tfeq;
|
||||||
{
|
{
|
||||||
Arguments *arguments = new Arguments;
|
Parameters *arguments = new Parameters;
|
||||||
Argument *arg = new Argument(STCin, type, NULL, NULL);
|
Parameter *arg = new Parameter(STCin, type, NULL, NULL);
|
||||||
|
|
||||||
arguments->push(arg);
|
arguments->push(arg);
|
||||||
tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
tfeq = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
||||||
|
|
|
@ -847,7 +847,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Loc loc, Objects *targsi,
|
||||||
assert(fd->type->ty == Tfunction);
|
assert(fd->type->ty == Tfunction);
|
||||||
fdtype = (TypeFunction *)fd->type;
|
fdtype = (TypeFunction *)fd->type;
|
||||||
|
|
||||||
nfparams = Argument::dim(fdtype->parameters); // number of function parameters
|
nfparams = Parameter::dim(fdtype->parameters); // number of function parameters
|
||||||
nfargs = fargs ? fargs->dim : 0; // number of function arguments
|
nfargs = fargs ? fargs->dim : 0; // number of function arguments
|
||||||
|
|
||||||
/* Check for match of function arguments with variadic template
|
/* Check for match of function arguments with variadic template
|
||||||
|
@ -877,7 +877,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Loc loc, Objects *targsi,
|
||||||
*/
|
*/
|
||||||
for (fptupindex = 0; fptupindex < nfparams; fptupindex++)
|
for (fptupindex = 0; fptupindex < nfparams; fptupindex++)
|
||||||
{
|
{
|
||||||
Argument *fparam = (Argument *)fdtype->parameters->data[fptupindex];
|
Parameter *fparam = (Parameter *)fdtype->parameters->data[fptupindex];
|
||||||
if (fparam->type->ty != Tident)
|
if (fparam->type->ty != Tident)
|
||||||
continue;
|
continue;
|
||||||
TypeIdentifier *tid = (TypeIdentifier *)fparam->type;
|
TypeIdentifier *tid = (TypeIdentifier *)fparam->type;
|
||||||
|
@ -951,7 +951,7 @@ L2:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Argument *fparam = Argument::getNth(fdtype->parameters, i);
|
Parameter *fparam = Parameter::getNth(fdtype->parameters, i);
|
||||||
|
|
||||||
if (i >= nfargs) // if not enough arguments
|
if (i >= nfargs) // if not enough arguments
|
||||||
{
|
{
|
||||||
|
@ -996,7 +996,7 @@ L2:
|
||||||
TypeDelegate *td = (TypeDelegate *)fparam->type->toBasetype();
|
TypeDelegate *td = (TypeDelegate *)fparam->type->toBasetype();
|
||||||
TypeFunction *tf = (TypeFunction *)td->next;
|
TypeFunction *tf = (TypeFunction *)td->next;
|
||||||
|
|
||||||
if (!tf->varargs && Argument::dim(tf->parameters) == 0)
|
if (!tf->varargs && Parameter::dim(tf->parameters) == 0)
|
||||||
{
|
{
|
||||||
m = farg->type->deduceType(paramscope, tf->next, parameters, &dedtypes);
|
m = farg->type->deduceType(paramscope, tf->next, parameters, &dedtypes);
|
||||||
if (!m && tf->next->toBasetype()->ty == Tvoid)
|
if (!m && tf->next->toBasetype()->ty == Tvoid)
|
||||||
|
@ -1744,8 +1744,8 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para
|
||||||
linkage != tp->linkage)
|
linkage != tp->linkage)
|
||||||
return MATCHnomatch;
|
return MATCHnomatch;
|
||||||
|
|
||||||
size_t nfargs = Argument::dim(this->parameters);
|
size_t nfargs = Parameter::dim(this->parameters);
|
||||||
size_t nfparams = Argument::dim(tp->parameters);
|
size_t nfparams = Parameter::dim(tp->parameters);
|
||||||
|
|
||||||
/* See if tuple match
|
/* See if tuple match
|
||||||
*/
|
*/
|
||||||
|
@ -1754,7 +1754,7 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para
|
||||||
/* See if 'A' of the template parameter matches 'A'
|
/* See if 'A' of the template parameter matches 'A'
|
||||||
* of the type of the last function parameter.
|
* of the type of the last function parameter.
|
||||||
*/
|
*/
|
||||||
Argument *fparam = Argument::getNth(tp->parameters, nfparams - 1);
|
Parameter *fparam = Parameter::getNth(tp->parameters, nfparams - 1);
|
||||||
if (fparam->type->ty != Tident)
|
if (fparam->type->ty != Tident)
|
||||||
goto L1;
|
goto L1;
|
||||||
TypeIdentifier *tid = (TypeIdentifier *)fparam->type;
|
TypeIdentifier *tid = (TypeIdentifier *)fparam->type;
|
||||||
|
@ -1787,7 +1787,7 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para
|
||||||
if (!t || t->objects.dim != tuple_dim)
|
if (!t || t->objects.dim != tuple_dim)
|
||||||
return MATCHnomatch;
|
return MATCHnomatch;
|
||||||
for (size_t i = 0; i < tuple_dim; i++)
|
for (size_t i = 0; i < tuple_dim; i++)
|
||||||
{ Argument *arg = Argument::getNth(this->parameters, nfparams - 1 + i);
|
{ Parameter *arg = Parameter::getNth(this->parameters, nfparams - 1 + i);
|
||||||
if (!arg->type->equals((Object *)t->objects.data[i]))
|
if (!arg->type->equals((Object *)t->objects.data[i]))
|
||||||
return MATCHnomatch;
|
return MATCHnomatch;
|
||||||
}
|
}
|
||||||
|
@ -1797,7 +1797,7 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para
|
||||||
Tuple *t = new Tuple();
|
Tuple *t = new Tuple();
|
||||||
t->objects.setDim(tuple_dim);
|
t->objects.setDim(tuple_dim);
|
||||||
for (size_t i = 0; i < tuple_dim; i++)
|
for (size_t i = 0; i < tuple_dim; i++)
|
||||||
{ Argument *arg = Argument::getNth(this->parameters, nfparams - 1 + i);
|
{ Parameter *arg = Parameter::getNth(this->parameters, nfparams - 1 + i);
|
||||||
t->objects.data[i] = (void *)arg->type;
|
t->objects.data[i] = (void *)arg->type;
|
||||||
}
|
}
|
||||||
dedtypes->data[tupi] = (void *)t;
|
dedtypes->data[tupi] = (void *)t;
|
||||||
|
@ -1812,8 +1812,8 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para
|
||||||
L2:
|
L2:
|
||||||
for (size_t i = 0; i < nfparams; i++)
|
for (size_t i = 0; i < nfparams; i++)
|
||||||
{
|
{
|
||||||
Argument *a = Argument::getNth(this->parameters, i);
|
Parameter *a = Parameter::getNth(this->parameters, i);
|
||||||
Argument *ap = Argument::getNth(tp->parameters, i);
|
Parameter *ap = Parameter::getNth(tp->parameters, i);
|
||||||
if (a->storageClass != ap->storageClass ||
|
if (a->storageClass != ap->storageClass ||
|
||||||
!a->type->deduceType(sc, ap->type, parameters, dedtypes))
|
!a->type->deduceType(sc, ap->type, parameters, dedtypes))
|
||||||
return MATCHnomatch;
|
return MATCHnomatch;
|
||||||
|
@ -2406,7 +2406,7 @@ void TemplateTypeParameter::print(Object *oarg, Object *oded)
|
||||||
printf("\tSpecialization: %s\n", specType->toChars());
|
printf("\tSpecialization: %s\n", specType->toChars());
|
||||||
if (defaultType)
|
if (defaultType)
|
||||||
printf("\tDefault: %s\n", defaultType->toChars());
|
printf("\tDefault: %s\n", defaultType->toChars());
|
||||||
printf("\tArgument: %s\n", t ? t->toChars() : "NULL");
|
printf("\tParameter: %s\n", t ? t->toChars() : "NULL");
|
||||||
printf("\tDeduced Type: %s\n", ta->toChars());
|
printf("\tDeduced Type: %s\n", ta->toChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2622,7 +2622,7 @@ void TemplateAliasParameter::print(Object *oarg, Object *oded)
|
||||||
Dsymbol *sa = isDsymbol(oded);
|
Dsymbol *sa = isDsymbol(oded);
|
||||||
assert(sa);
|
assert(sa);
|
||||||
|
|
||||||
printf("\tArgument alias: %s\n", sa->toChars());
|
printf("\tParameter alias: %s\n", sa->toChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TemplateAliasParameter::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void TemplateAliasParameter::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
|
@ -2866,7 +2866,7 @@ void TemplateValueParameter::print(Object *oarg, Object *oded)
|
||||||
|
|
||||||
if (specValue)
|
if (specValue)
|
||||||
printf("\tSpecialization: %s\n", specValue->toChars());
|
printf("\tSpecialization: %s\n", specValue->toChars());
|
||||||
printf("\tArgument Value: %s\n", ea ? ea->toChars() : "NULL");
|
printf("\tParameter Value: %s\n", ea ? ea->toChars() : "NULL");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3580,7 +3580,7 @@ void TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f
|
||||||
if (dim)
|
if (dim)
|
||||||
{ tiargs->reserve(dim);
|
{ tiargs->reserve(dim);
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{ Argument *arg = (Argument *)tt->arguments->data[i];
|
{ Parameter *arg = (Parameter *)tt->arguments->data[i];
|
||||||
tiargs->insert(j + i, arg->type);
|
tiargs->insert(j + i, arg->type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,7 @@ const llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nest
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this _Dmain() doesn't have an argument, we force it to have one
|
// if this _Dmain() doesn't have an argument, we force it to have one
|
||||||
int nargs = Argument::dim(f->parameters);
|
int nargs = Parameter::dim(f->parameters);
|
||||||
|
|
||||||
if (ismain && nargs == 0)
|
if (ismain && nargs == 0)
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ const llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nest
|
||||||
else for (int i = 0; i < nargs; i++)
|
else for (int i = 0; i < nargs; i++)
|
||||||
{
|
{
|
||||||
// get argument
|
// get argument
|
||||||
Argument* arg = Argument::getNth(f->parameters, i);
|
Parameter* arg = Parameter::getNth(f->parameters, i);
|
||||||
|
|
||||||
// reference semantics? ref, out and static arrays are
|
// reference semantics? ref, out and static arrays are
|
||||||
bool byref = (arg->storageClass & (STCref|STCout)) || (arg->type->toBasetype()->ty == Tsarray);
|
bool byref = (arg->storageClass & (STCref|STCout)) || (arg->type->toBasetype()->ty == Tsarray);
|
||||||
|
@ -381,12 +381,12 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati
|
||||||
#undef ADD_PA
|
#undef ADD_PA
|
||||||
|
|
||||||
// set attrs on the rest of the arguments
|
// set attrs on the rest of the arguments
|
||||||
size_t n = Argument::dim(f->parameters);
|
size_t n = Parameter::dim(f->parameters);
|
||||||
LLSmallVector<unsigned,8> attrptr(n, 0);
|
LLSmallVector<unsigned,8> attrptr(n, 0);
|
||||||
|
|
||||||
for (size_t k = 0; k < n; ++k)
|
for (size_t k = 0; k < n; ++k)
|
||||||
{
|
{
|
||||||
Argument* fnarg = Argument::getNth(f->parameters, k);
|
Parameter* fnarg = Parameter::getNth(f->parameters, k);
|
||||||
assert(fnarg);
|
assert(fnarg);
|
||||||
|
|
||||||
attrptr[k] = f->fty.args[k]->attrs;
|
attrptr[k] = f->fty.args[k]->attrs;
|
||||||
|
@ -862,7 +862,7 @@ const llvm::FunctionType* DtoBaseFunctionType(FuncDeclaration* fdecl)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
DValue* DtoArgument(Argument* fnarg, Expression* argexp)
|
DValue* DtoArgument(Parameter* fnarg, Expression* argexp)
|
||||||
{
|
{
|
||||||
Logger::println("DtoArgument");
|
Logger::println("DtoArgument");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
|
@ -25,7 +25,7 @@ void DtoDefineFunction(FuncDeclaration* fd);
|
||||||
void DtoDefineNakedFunction(FuncDeclaration* fd);
|
void DtoDefineNakedFunction(FuncDeclaration* fd);
|
||||||
void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl);
|
void emitABIReturnAsmStmt(IRAsmBlock* asmblock, Loc loc, FuncDeclaration* fdecl);
|
||||||
|
|
||||||
DValue* DtoArgument(Argument* fnarg, Expression* argexp);
|
DValue* DtoArgument(Parameter* fnarg, Expression* argexp);
|
||||||
void DtoVariadicArgument(Expression* argexp, llvm::Value* dst);
|
void DtoVariadicArgument(Expression* argexp, llvm::Value* dst);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -128,7 +128,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::Attribut
|
||||||
std::vector<const LLType*> vtypes;
|
std::vector<const LLType*> vtypes;
|
||||||
|
|
||||||
// number of non variadic args
|
// number of non variadic args
|
||||||
int begin = Argument::dim(tf->parameters);
|
int begin = Parameter::dim(tf->parameters);
|
||||||
Logger::println("num non vararg params = %d", begin);
|
Logger::println("num non vararg params = %d", begin);
|
||||||
|
|
||||||
// get n args in arguments list
|
// get n args in arguments list
|
||||||
|
@ -232,7 +232,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, std::vector<llvm::Attribut
|
||||||
// pass non variadic args
|
// pass non variadic args
|
||||||
for (int i=0; i<begin; i++)
|
for (int i=0; i<begin; i++)
|
||||||
{
|
{
|
||||||
Argument* fnarg = Argument::getNth(tf->parameters, i);
|
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
|
||||||
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
|
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
|
||||||
args.push_back(argval->getRVal());
|
args.push_back(argval->getRVal());
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
||||||
//Logger::cout() << "LLVM functype: " << *callable->getType() << '\n';
|
//Logger::cout() << "LLVM functype: " << *callable->getType() << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t n = Argument::dim(tf->parameters);
|
size_t n = Parameter::dim(tf->parameters);
|
||||||
|
|
||||||
LLSmallVector<unsigned, 10> attrptr(n, 0);
|
LLSmallVector<unsigned, 10> attrptr(n, 0);
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
||||||
int beg = argiter-argbegin;
|
int beg = argiter-argbegin;
|
||||||
for (int i=0; i<n; i++)
|
for (int i=0; i<n; i++)
|
||||||
{
|
{
|
||||||
Argument* fnarg = Argument::getNth(tf->parameters, i);
|
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
|
||||||
assert(fnarg);
|
assert(fnarg);
|
||||||
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
|
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
|
||||||
|
|
||||||
|
@ -504,7 +504,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
||||||
{
|
{
|
||||||
for (int i=n; i<n_arguments; i++)
|
for (int i=n; i<n_arguments; i++)
|
||||||
{
|
{
|
||||||
Argument* fnarg = Argument::getNth(tf->parameters, i);
|
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
|
||||||
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
|
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
|
||||||
LLValue* arg = argval->getRVal();
|
LLValue* arg = argval->getRVal();
|
||||||
|
|
||||||
|
|
|
@ -617,8 +617,8 @@ void TypeInfoStructDeclaration::llvmDefine()
|
||||||
TypeFunction *tfeqptr;
|
TypeFunction *tfeqptr;
|
||||||
{
|
{
|
||||||
Scope sc;
|
Scope sc;
|
||||||
Arguments *arguments = new Arguments;
|
Parameters *arguments = new Parameters;
|
||||||
Argument *arg = new Argument(STCin, tc->pointerTo(), NULL, NULL);
|
Parameter *arg = new Parameter(STCin, tc->pointerTo(), NULL, NULL);
|
||||||
arguments->push(arg);
|
arguments->push(arg);
|
||||||
tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
tfeqptr = new TypeFunction(arguments, Type::tint32, 0, LINKd);
|
||||||
tfeqptr = (TypeFunction *)tfeqptr->semantic(0, &sc);
|
tfeqptr = (TypeFunction *)tfeqptr->semantic(0, &sc);
|
||||||
|
@ -732,7 +732,7 @@ void TypeInfoTupleDeclaration::llvmDefine()
|
||||||
|
|
||||||
for (size_t i = 0; i < dim; i++)
|
for (size_t i = 0; i < dim; i++)
|
||||||
{
|
{
|
||||||
Argument *arg = (Argument *)tu->arguments->data[i];
|
Parameter *arg = (Parameter *)tu->arguments->data[i];
|
||||||
arrInits.push_back(DtoTypeInfoOf(arg->type, true));
|
arrInits.push_back(DtoTypeInfoOf(arg->type, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue