mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 00:55:49 +03:00
Merge dmdfe 2.057
This commit is contained in:
parent
4e8afa8858
commit
88cff99bd4
32 changed files with 2518 additions and 1378 deletions
|
@ -241,6 +241,7 @@ struct ClassDeclaration : AggregateDeclaration
|
||||||
static ClassDeclaration *classinfo;
|
static ClassDeclaration *classinfo;
|
||||||
static ClassDeclaration *throwable;
|
static ClassDeclaration *throwable;
|
||||||
static ClassDeclaration *exception;
|
static ClassDeclaration *exception;
|
||||||
|
static ClassDeclaration *errorException;
|
||||||
|
|
||||||
ClassDeclaration *baseClass; // NULL only if this is Object
|
ClassDeclaration *baseClass; // NULL only if this is Object
|
||||||
#if DMDV1
|
#if DMDV1
|
||||||
|
|
|
@ -47,8 +47,6 @@ void AliasThis::semantic(Scope *sc)
|
||||||
ad = parent->isAggregateDeclaration();
|
ad = parent->isAggregateDeclaration();
|
||||||
if (ad)
|
if (ad)
|
||||||
{
|
{
|
||||||
if (ad->aliasthis)
|
|
||||||
error("there can be only one alias this");
|
|
||||||
assert(ad->members);
|
assert(ad->members);
|
||||||
Dsymbol *s = ad->search(loc, ident, 0);
|
Dsymbol *s = ad->search(loc, ident, 0);
|
||||||
if (!s)
|
if (!s)
|
||||||
|
@ -58,6 +56,8 @@ void AliasThis::semantic(Scope *sc)
|
||||||
else
|
else
|
||||||
::error(loc, "undefined identifier %s", ident->toChars());
|
::error(loc, "undefined identifier %s", ident->toChars());
|
||||||
}
|
}
|
||||||
|
else if (ad->aliasthis && s != ad->aliasthis)
|
||||||
|
error("there can be only one alias this");
|
||||||
ad->aliasthis = s;
|
ad->aliasthis = s;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -155,7 +155,7 @@ void AttribDeclaration::semantic(Scope *sc)
|
||||||
//printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d);
|
//printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d);
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < d->dim; i++)
|
for (size_t i = 0; i < d->dim; i++)
|
||||||
{
|
{
|
||||||
Dsymbol *s = d->tdata()[i];
|
Dsymbol *s = d->tdata()[i];
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ void AttribDeclaration::semantic2(Scope *sc)
|
||||||
|
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < d->dim; i++)
|
for (size_t i = 0; i < d->dim; i++)
|
||||||
{ Dsymbol *s = d->tdata()[i];
|
{ Dsymbol *s = d->tdata()[i];
|
||||||
s->semantic2(sc);
|
s->semantic2(sc);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ void AttribDeclaration::semantic3(Scope *sc)
|
||||||
|
|
||||||
if (d)
|
if (d)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < d->dim; i++)
|
for (size_t i = 0; i < d->dim; i++)
|
||||||
{ Dsymbol *s = d->tdata()[i];
|
{ Dsymbol *s = d->tdata()[i];
|
||||||
s->semantic3(sc);
|
s->semantic3(sc);
|
||||||
}
|
}
|
||||||
|
@ -297,6 +297,22 @@ int AttribDeclaration::hasPointers()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AttribDeclaration::hasStaticCtorOrDtor()
|
||||||
|
{
|
||||||
|
Dsymbols *d = include(NULL, NULL);
|
||||||
|
|
||||||
|
if (d)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < d->dim; i++)
|
||||||
|
{
|
||||||
|
Dsymbol *s = (*d)[i];
|
||||||
|
if (s->hasStaticCtorOrDtor())
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
const char *AttribDeclaration::kind()
|
const char *AttribDeclaration::kind()
|
||||||
{
|
{
|
||||||
return "attribute";
|
return "attribute";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2010 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
|
@ -49,6 +49,7 @@ struct AttribDeclaration : Dsymbol
|
||||||
const char *kind();
|
const char *kind();
|
||||||
int oneMember(Dsymbol **ps);
|
int oneMember(Dsymbol **ps);
|
||||||
int hasPointers();
|
int hasPointers();
|
||||||
|
bool hasStaticCtorOrDtor();
|
||||||
void checkCtorConstInit();
|
void checkCtorConstInit();
|
||||||
void addLocalClass(ClassDeclarations *);
|
void addLocalClass(ClassDeclarations *);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
|
96
dmd2/cast.c
96
dmd2/cast.c
|
@ -395,23 +395,13 @@ MATCH NullExp::implicitConvTo(Type *t)
|
||||||
if (this->type->equals(t))
|
if (this->type->equals(t))
|
||||||
return MATCHexact;
|
return MATCHexact;
|
||||||
|
|
||||||
/* Allow implicit conversions from invariant to mutable|const,
|
/* Allow implicit conversions from immutable to mutable|const,
|
||||||
* and mutable to invariant. It works because, after all, a null
|
* and mutable to immutable. It works because, after all, a null
|
||||||
* doesn't actually point to anything.
|
* doesn't actually point to anything.
|
||||||
*/
|
*/
|
||||||
if (t->invariantOf()->equals(type->invariantOf()))
|
if (t->invariantOf()->equals(type->invariantOf()))
|
||||||
return MATCHconst;
|
return MATCHconst;
|
||||||
|
|
||||||
// NULL implicitly converts to any pointer type or dynamic array
|
|
||||||
if (type->ty == Tpointer && type->nextOf()->ty == Tvoid)
|
|
||||||
{
|
|
||||||
if (t->ty == Ttypedef)
|
|
||||||
t = ((TypeTypedef *)t)->sym->basetype;
|
|
||||||
if (t->ty == Tpointer || t->ty == Tarray ||
|
|
||||||
t->ty == Taarray || t->ty == Tclass ||
|
|
||||||
t->ty == Tdelegate)
|
|
||||||
return committed ? MATCHconvert : MATCHexact;
|
|
||||||
}
|
|
||||||
return Expression::implicitConvTo(t);
|
return Expression::implicitConvTo(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,18 +913,18 @@ Expression *ComplexExp::castTo(Scope *sc, Type *t)
|
||||||
|
|
||||||
|
|
||||||
Expression *NullExp::castTo(Scope *sc, Type *t)
|
Expression *NullExp::castTo(Scope *sc, Type *t)
|
||||||
{ NullExp *e;
|
{
|
||||||
Type *tb;
|
|
||||||
|
|
||||||
//printf("NullExp::castTo(t = %p)\n", t);
|
//printf("NullExp::castTo(t = %p)\n", t);
|
||||||
if (type == t)
|
if (type == t)
|
||||||
{
|
{
|
||||||
committed = 1;
|
committed = 1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
e = (NullExp *)copy();
|
|
||||||
|
NullExp *e = (NullExp *)copy();
|
||||||
e->committed = 1;
|
e->committed = 1;
|
||||||
tb = t->toBasetype();
|
Type *tb = t->toBasetype();
|
||||||
|
#if 0
|
||||||
e->type = type->toBasetype();
|
e->type = type->toBasetype();
|
||||||
if (tb != e->type)
|
if (tb != e->type)
|
||||||
{
|
{
|
||||||
|
@ -943,7 +933,6 @@ Expression *NullExp::castTo(Scope *sc, Type *t)
|
||||||
(tb->ty == Tpointer || tb->ty == Tarray || tb->ty == Taarray ||
|
(tb->ty == Tpointer || tb->ty == Tarray || tb->ty == Taarray ||
|
||||||
tb->ty == Tdelegate))
|
tb->ty == Tdelegate))
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if (tb->ty == Tdelegate)
|
if (tb->ty == Tdelegate)
|
||||||
{ TypeDelegate *td = (TypeDelegate *)tb;
|
{ TypeDelegate *td = (TypeDelegate *)tb;
|
||||||
TypeFunction *tf = (TypeFunction *)td->nextOf();
|
TypeFunction *tf = (TypeFunction *)td->nextOf();
|
||||||
|
@ -955,13 +944,19 @@ Expression *NullExp::castTo(Scope *sc, Type *t)
|
||||||
return Expression::castTo(sc, t);
|
return Expression::castTo(sc, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return e->Expression::castTo(sc, t);
|
//return e->Expression::castTo(sc, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (tb->ty == Tvoid)
|
||||||
|
{
|
||||||
|
e->type = type->toBasetype();
|
||||||
|
return e->Expression::castTo(sc, t);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
e->type = t;
|
e->type = t;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
@ -1946,6 +1941,15 @@ Lagain:
|
||||||
}
|
}
|
||||||
else if (t1->ty == Tstruct && t2->ty == Tstruct)
|
else if (t1->ty == Tstruct && t2->ty == Tstruct)
|
||||||
{
|
{
|
||||||
|
if (t1->mod != t2->mod)
|
||||||
|
{
|
||||||
|
unsigned char mod = MODmerge(t1->mod, t2->mod);
|
||||||
|
t1 = t1->castMod(mod);
|
||||||
|
t2 = t2->castMod(mod);
|
||||||
|
t = t1;
|
||||||
|
goto Lagain;
|
||||||
|
}
|
||||||
|
|
||||||
TypeStruct *ts1 = (TypeStruct *)t1;
|
TypeStruct *ts1 = (TypeStruct *)t1;
|
||||||
TypeStruct *ts2 = (TypeStruct *)t2;
|
TypeStruct *ts2 = (TypeStruct *)t2;
|
||||||
if (ts1->sym != ts2->sym)
|
if (ts1->sym != ts2->sym)
|
||||||
|
@ -1972,7 +1976,8 @@ Lagain:
|
||||||
e1b = resolveProperties(sc, e1b);
|
e1b = resolveProperties(sc, e1b);
|
||||||
i2 = e1b->implicitConvTo(t2);
|
i2 = e1b->implicitConvTo(t2);
|
||||||
}
|
}
|
||||||
assert(!(i1 && i2));
|
if (i1 && i2)
|
||||||
|
goto Lincompatible;
|
||||||
|
|
||||||
if (i1)
|
if (i1)
|
||||||
goto Lt1;
|
goto Lt1;
|
||||||
|
@ -1987,9 +1992,41 @@ Lagain:
|
||||||
{ e2 = e2b;
|
{ e2 = e2b;
|
||||||
t2 = e2b->type->toBasetype();
|
t2 = e2b->type->toBasetype();
|
||||||
}
|
}
|
||||||
|
t = t1;
|
||||||
goto Lagain;
|
goto Lagain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (t1->ty == Tstruct || t2->ty == Tstruct)
|
||||||
|
{
|
||||||
|
if (t1->mod != t2->mod)
|
||||||
|
{
|
||||||
|
unsigned char mod = MODmerge(t1->mod, t2->mod);
|
||||||
|
t1 = t1->castMod(mod);
|
||||||
|
t2 = t2->castMod(mod);
|
||||||
|
t = t1;
|
||||||
|
goto Lagain;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t1->ty == Tstruct && ((TypeStruct *)t1)->sym->aliasthis)
|
||||||
|
{
|
||||||
|
e1 = new DotIdExp(e1->loc, e1, ((TypeStruct *)t1)->sym->aliasthis->ident);
|
||||||
|
e1 = e1->semantic(sc);
|
||||||
|
e1 = resolveProperties(sc, e1);
|
||||||
|
t1 = e1->type;
|
||||||
|
t = t1;
|
||||||
|
goto Lagain;
|
||||||
|
}
|
||||||
|
if (t2->ty == Tstruct && ((TypeStruct *)t2)->sym->aliasthis)
|
||||||
|
{
|
||||||
|
e2 = new DotIdExp(e2->loc, e2, ((TypeStruct *)t2)->sym->aliasthis->ident);
|
||||||
|
e2 = e2->semantic(sc);
|
||||||
|
e2 = resolveProperties(sc, e2);
|
||||||
|
t2 = e2->type;
|
||||||
|
t = t2;
|
||||||
|
goto Lagain;
|
||||||
|
}
|
||||||
|
goto Lincompatible;
|
||||||
|
}
|
||||||
else if ((e1->op == TOKstring || e1->op == TOKnull) && e1->implicitConvTo(t2))
|
else if ((e1->op == TOKstring || e1->op == TOKnull) && e1->implicitConvTo(t2))
|
||||||
{
|
{
|
||||||
goto Lt2;
|
goto Lt2;
|
||||||
|
@ -2091,18 +2128,11 @@ Expression *BinExp::typeCombine(Scope *sc)
|
||||||
|
|
||||||
if (op == TOKmin || op == TOKadd)
|
if (op == TOKmin || op == TOKadd)
|
||||||
{
|
{
|
||||||
// struct+struct, where the structs are the same type, and class+class are errors
|
// struct+struct, and class+class are errors
|
||||||
if (t1->ty == Tstruct)
|
if (t1->ty == Tstruct && t2->ty == Tstruct)
|
||||||
{
|
goto Lerror;
|
||||||
if (t2->ty == Tstruct &&
|
else if (t1->ty == Tclass && t2->ty == Tclass)
|
||||||
((TypeStruct *)t1)->sym == ((TypeStruct *)t2)->sym)
|
goto Lerror;
|
||||||
goto Lerror;
|
|
||||||
}
|
|
||||||
else if (t1->ty == Tclass)
|
|
||||||
{
|
|
||||||
if (t2->ty == Tclass)
|
|
||||||
goto Lerror;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!typeMerge(sc, this, &type, &e1, &e2))
|
if (!typeMerge(sc, this, &type, &e1, &e2))
|
||||||
|
|
|
@ -33,6 +33,7 @@ ClassDeclaration *ClassDeclaration::classinfo;
|
||||||
ClassDeclaration *ClassDeclaration::object;
|
ClassDeclaration *ClassDeclaration::object;
|
||||||
ClassDeclaration *ClassDeclaration::throwable;
|
ClassDeclaration *ClassDeclaration::throwable;
|
||||||
ClassDeclaration *ClassDeclaration::exception;
|
ClassDeclaration *ClassDeclaration::exception;
|
||||||
|
ClassDeclaration *ClassDeclaration::errorException;
|
||||||
|
|
||||||
ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses)
|
ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *baseclasses)
|
||||||
: AggregateDeclaration(loc, id)
|
: AggregateDeclaration(loc, id)
|
||||||
|
@ -197,6 +198,12 @@ ClassDeclaration::ClassDeclaration(Loc loc, Identifier *id, BaseClasses *basecla
|
||||||
exception = this;
|
exception = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id == Id::Error)
|
||||||
|
{ if (errorException)
|
||||||
|
errorException->error("%s", msg);
|
||||||
|
errorException = this;
|
||||||
|
}
|
||||||
|
|
||||||
//if (id == Id::ClassInfo)
|
//if (id == Id::ClassInfo)
|
||||||
if (id == Id::TypeInfo_Class)
|
if (id == Id::TypeInfo_Class)
|
||||||
{ if (classinfo)
|
{ if (classinfo)
|
||||||
|
|
16
dmd2/clone.c
16
dmd2/clone.c
|
@ -93,9 +93,8 @@ FuncDeclaration *StructDeclaration::buildOpAssign(Scope *sc)
|
||||||
|
|
||||||
FuncDeclaration *fop = NULL;
|
FuncDeclaration *fop = NULL;
|
||||||
|
|
||||||
Parameter *param = new Parameter(STCnodtor, type, Id::p, NULL);
|
|
||||||
Parameters *fparams = new Parameters;
|
Parameters *fparams = new Parameters;
|
||||||
fparams->push(param);
|
fparams->push(new Parameter(STCnodtor, type, Id::p, NULL));
|
||||||
Type *ftype = new TypeFunction(fparams, handle, FALSE, LINKd);
|
Type *ftype = new TypeFunction(fparams, handle, FALSE, LINKd);
|
||||||
#if STRUCTTHISREF
|
#if STRUCTTHISREF
|
||||||
((TypeFunction *)ftype)->isref = 1;
|
((TypeFunction *)ftype)->isref = 1;
|
||||||
|
@ -428,14 +427,17 @@ FuncDeclaration *StructDeclaration::buildCpCtor(Scope *sc)
|
||||||
{
|
{
|
||||||
//printf("generating cpctor\n");
|
//printf("generating cpctor\n");
|
||||||
|
|
||||||
Parameter *param = new Parameter(STCref, type->constOf(), Id::p, NULL);
|
StorageClass stc = postblit->storage_class &
|
||||||
|
(STCdisable | STCsafe | STCtrusted | STCsystem | STCpure | STCnothrow);
|
||||||
|
if (stc & (STCsafe | STCtrusted))
|
||||||
|
stc = stc & ~STCsafe | STCtrusted;
|
||||||
|
|
||||||
Parameters *fparams = new Parameters;
|
Parameters *fparams = new Parameters;
|
||||||
fparams->push(param);
|
fparams->push(new Parameter(STCref, type->constOf(), Id::p, NULL));
|
||||||
Type *ftype = new TypeFunction(fparams, Type::tvoid, FALSE, LINKd);
|
Type *ftype = new TypeFunction(fparams, Type::tvoid, FALSE, LINKd, stc);
|
||||||
ftype->mod = MODconst;
|
ftype->mod = MODconst;
|
||||||
|
|
||||||
fcp = new FuncDeclaration(loc, 0, Id::cpctor, STCundefined, ftype);
|
fcp = new FuncDeclaration(loc, 0, Id::cpctor, stc, ftype);
|
||||||
fcp->storage_class |= postblit->storage_class & STCdisable;
|
|
||||||
|
|
||||||
if (!(fcp->storage_class & STCdisable))
|
if (!(fcp->storage_class & STCdisable))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1551,7 +1551,17 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2)
|
||||||
else if (e1->op == TOKnull && e2->op == TOKnull)
|
else if (e1->op == TOKnull && e2->op == TOKnull)
|
||||||
{
|
{
|
||||||
if (type == e1->type)
|
if (type == e1->type)
|
||||||
return e1;
|
{
|
||||||
|
// Handle null ~= null
|
||||||
|
if (t1->ty == Tarray && t2 == t1->nextOf())
|
||||||
|
{
|
||||||
|
e = new ArrayLiteralExp(e1->loc, e2);
|
||||||
|
e->type = type;
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return e1;
|
||||||
|
}
|
||||||
if (type == e2->type)
|
if (type == e2->type)
|
||||||
return e2;
|
return e2;
|
||||||
return new NullExp(e1->loc, type);
|
return new NullExp(e1->loc, type);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "expression.h"
|
#include "expression.h"
|
||||||
|
#include "statement.h"
|
||||||
#include "hdrgen.h"
|
#include "hdrgen.h"
|
||||||
|
|
||||||
/********************************* Declaration ****************************/
|
/********************************* Declaration ****************************/
|
||||||
|
@ -700,7 +701,7 @@ VarDeclaration::VarDeclaration(Loc loc, Type *type, Identifier *id, Initializer
|
||||||
aliassym = NULL;
|
aliassym = NULL;
|
||||||
onstack = 0;
|
onstack = 0;
|
||||||
canassign = 0;
|
canassign = 0;
|
||||||
setValueNull();
|
ctfeAdrOnStack = (size_t)(-1);
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
rundtor = NULL;
|
rundtor = NULL;
|
||||||
edtor = NULL;
|
edtor = NULL;
|
||||||
|
@ -1162,9 +1163,15 @@ Lnomatch:
|
||||||
{
|
{
|
||||||
error("only parameters or stack based variables can be inout");
|
error("only parameters or stack based variables can be inout");
|
||||||
}
|
}
|
||||||
if (sc->func && !sc->func->type->hasWild())
|
FuncDeclaration *func = sc->func;
|
||||||
|
if (func)
|
||||||
{
|
{
|
||||||
error("inout variables can only be declared inside inout functions");
|
if (func->fes)
|
||||||
|
func = func->fes->func;
|
||||||
|
if (!func->type->hasWild())
|
||||||
|
{
|
||||||
|
error("inout variables can only be declared inside inout functions");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,8 +1708,12 @@ void VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
|
||||||
// The current function
|
// The current function
|
||||||
FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();
|
FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();
|
||||||
|
|
||||||
if (fdv && fdthis && fdv != fdthis)
|
if (fdv && fdthis && fdv != fdthis/* && fdthis->ident != Id::ensure*/)
|
||||||
{
|
{
|
||||||
|
/* __ensure is always called directly,
|
||||||
|
* so it never becomes closure.
|
||||||
|
*/
|
||||||
|
|
||||||
if (loc.filename)
|
if (loc.filename)
|
||||||
fdthis->getLevel(loc, fdv);
|
fdthis->getLevel(loc, fdv);
|
||||||
|
|
||||||
|
@ -1720,7 +1731,6 @@ void VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
|
||||||
if (s == this)
|
if (s == this)
|
||||||
goto L2;
|
goto L2;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdv->closureVars.push(this);
|
fdv->closureVars.push(this);
|
||||||
L2: ;
|
L2: ;
|
||||||
|
|
||||||
|
|
|
@ -286,13 +286,15 @@ struct VarDeclaration : Declaration
|
||||||
int canassign; // it can be assigned to
|
int canassign; // it can be assigned to
|
||||||
Dsymbol *aliassym; // if redone as alias to another symbol
|
Dsymbol *aliassym; // if redone as alias to another symbol
|
||||||
|
|
||||||
// When interpreting, these hold the value (NULL if value not determinable)
|
// When interpreting, these point to the value (NULL if value not determinable)
|
||||||
|
// The index of this variable on the CTFE stack, -1 if not allocated
|
||||||
|
size_t ctfeAdrOnStack;
|
||||||
// The various functions are used only to detect compiler CTFE bugs
|
// The various functions are used only to detect compiler CTFE bugs
|
||||||
Expression *literalvalue;
|
Expression *getValue();
|
||||||
Expression *getValue() { return literalvalue; }
|
bool hasValue();
|
||||||
void setValueNull();
|
void setValueNull();
|
||||||
void setValueWithoutChecking(Expression *newval);
|
void setValueWithoutChecking(Expression *newval);
|
||||||
void createRefValue(Expression *newval); // struct or array literal
|
void createRefValue(Expression *newval);
|
||||||
void setRefValue(Expression *newval);
|
void setRefValue(Expression *newval);
|
||||||
void setStackValue(Expression *newval);
|
void setStackValue(Expression *newval);
|
||||||
void createStackValue(Expression *newval);
|
void createStackValue(Expression *newval);
|
||||||
|
@ -782,6 +784,7 @@ struct FuncDeclaration : Declaration
|
||||||
void semantic3(Scope *sc);
|
void semantic3(Scope *sc);
|
||||||
// called from semantic3
|
// called from semantic3
|
||||||
void varArgs(Scope *sc, TypeFunction*, VarDeclaration *&, VarDeclaration *&);
|
void varArgs(Scope *sc, TypeFunction*, VarDeclaration *&, VarDeclaration *&);
|
||||||
|
VarDeclaration *declareThis(Scope *sc, AggregateDeclaration *ad);
|
||||||
int equals(Object *o);
|
int equals(Object *o);
|
||||||
|
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
@ -932,7 +935,7 @@ struct CtorDeclaration : FuncDeclaration
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
struct PostBlitDeclaration : FuncDeclaration
|
struct PostBlitDeclaration : FuncDeclaration
|
||||||
{
|
{
|
||||||
PostBlitDeclaration(Loc loc, Loc endloc);
|
PostBlitDeclaration(Loc loc, Loc endloc, StorageClass stc = STCundefined);
|
||||||
PostBlitDeclaration(Loc loc, Loc endloc, Identifier *id);
|
PostBlitDeclaration(Loc loc, Loc endloc, Identifier *id);
|
||||||
Dsymbol *syntaxCopy(Dsymbol *);
|
Dsymbol *syntaxCopy(Dsymbol *);
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
|
@ -977,6 +980,7 @@ struct StaticCtorDeclaration : FuncDeclaration
|
||||||
int isVirtual();
|
int isVirtual();
|
||||||
int addPreInvariant();
|
int addPreInvariant();
|
||||||
int addPostInvariant();
|
int addPostInvariant();
|
||||||
|
bool hasStaticCtorOrDtor();
|
||||||
void emitComment(Scope *sc);
|
void emitComment(Scope *sc);
|
||||||
void toJsonBuffer(OutBuffer *buf);
|
void toJsonBuffer(OutBuffer *buf);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
@ -1004,6 +1008,7 @@ struct StaticDtorDeclaration : FuncDeclaration
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
AggregateDeclaration *isThis();
|
AggregateDeclaration *isThis();
|
||||||
int isVirtual();
|
int isVirtual();
|
||||||
|
bool hasStaticCtorOrDtor();
|
||||||
int addPreInvariant();
|
int addPreInvariant();
|
||||||
int addPostInvariant();
|
int addPostInvariant();
|
||||||
void emitComment(Scope *sc);
|
void emitComment(Scope *sc);
|
||||||
|
|
189
dmd2/dsymbol.c
189
dmd2/dsymbol.c
|
@ -167,6 +167,12 @@ int Dsymbol::hasPointers()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Dsymbol::hasStaticCtorOrDtor()
|
||||||
|
{
|
||||||
|
//printf("Dsymbol::hasStaticCtorOrDtor() %s\n", toChars());
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
char *Dsymbol::toChars()
|
char *Dsymbol::toChars()
|
||||||
{
|
{
|
||||||
return ident ? ident->toChars() : (char *)"__anonymous";
|
return ident ? ident->toChars() : (char *)"__anonymous";
|
||||||
|
@ -1013,36 +1019,41 @@ Dsymbol *ScopeDsymbol::symtabInsert(Dsymbol *s)
|
||||||
return symtab->insert(s);
|
return symtab->insert(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************
|
||||||
|
* Return true if any of the members are static ctors or static dtors, or if
|
||||||
|
* any members have members that are.
|
||||||
|
*/
|
||||||
|
|
||||||
|
bool ScopeDsymbol::hasStaticCtorOrDtor()
|
||||||
|
{
|
||||||
|
if (members)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
|
{ Dsymbol *member = (*members)[i];
|
||||||
|
|
||||||
|
if (member->hasStaticCtorOrDtor())
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************
|
/***************************************
|
||||||
* Determine number of Dsymbols, folding in AttribDeclaration members.
|
* Determine number of Dsymbols, folding in AttribDeclaration members.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
|
static int dimDg(void *ctx, size_t n, Dsymbol *)
|
||||||
|
{
|
||||||
|
++*(size_t *)ctx;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
size_t ScopeDsymbol::dim(Dsymbols *members)
|
size_t ScopeDsymbol::dim(Dsymbols *members)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if (members)
|
if (members)
|
||||||
{
|
foreach(members, &dimDg, &n);
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
|
||||||
{ Dsymbol *s = (*members)[i];
|
|
||||||
AttribDeclaration *a = s->isAttribDeclaration();
|
|
||||||
TemplateMixin *tm = s->isTemplateMixin();
|
|
||||||
TemplateInstance *ti = s->isTemplateInstance();
|
|
||||||
|
|
||||||
if (a)
|
|
||||||
{
|
|
||||||
n += dim(a->decl);
|
|
||||||
}
|
|
||||||
else if (tm)
|
|
||||||
{
|
|
||||||
n += dim(tm->members);
|
|
||||||
}
|
|
||||||
else if (ti)
|
|
||||||
;
|
|
||||||
else
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1056,41 +1067,65 @@ size_t ScopeDsymbol::dim(Dsymbols *members)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
|
struct GetNthSymbolCtx
|
||||||
|
{
|
||||||
|
size_t nth;
|
||||||
|
Dsymbol *sym;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int getNthSymbolDg(void *ctx, size_t n, Dsymbol *sym)
|
||||||
|
{
|
||||||
|
GetNthSymbolCtx *p = (GetNthSymbolCtx *)ctx;
|
||||||
|
if (n == p->nth)
|
||||||
|
{ p->sym = sym;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn)
|
Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn)
|
||||||
{
|
{
|
||||||
if (!members)
|
GetNthSymbolCtx ctx = { nth, NULL };
|
||||||
return NULL;
|
int res = foreach(members, &getNthSymbolDg, &ctx);
|
||||||
|
return res ? ctx.sym : NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t n = 0;
|
/***************************************
|
||||||
|
* Expands attribute declarations in members in depth first
|
||||||
|
* order. Calls dg(void *ctx, size_t symidx, Dsymbol *sym) for each
|
||||||
|
* member.
|
||||||
|
* If dg returns !=0, stops and returns that value else returns 0.
|
||||||
|
* Use this function to avoid the O(N + N^2/2) complexity of
|
||||||
|
* calculating dim and calling N times getNth.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if DMDV2
|
||||||
|
int ScopeDsymbol::foreach(Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *ctx, size_t *pn)
|
||||||
|
{
|
||||||
|
assert(members);
|
||||||
|
|
||||||
|
size_t n = pn ? *pn : 0; // take over index
|
||||||
|
int result = 0;
|
||||||
for (size_t i = 0; i < members->dim; i++)
|
for (size_t i = 0; i < members->dim; i++)
|
||||||
{ Dsymbol *s = (*members)[i];
|
{ Dsymbol *s = (*members)[i];
|
||||||
AttribDeclaration *a = s->isAttribDeclaration();
|
|
||||||
TemplateMixin *tm = s->isTemplateMixin();
|
|
||||||
TemplateInstance *ti = s->isTemplateInstance();
|
|
||||||
|
|
||||||
if (a)
|
if (AttribDeclaration *a = s->isAttribDeclaration())
|
||||||
{
|
result = foreach(a->decl, dg, ctx, &n);
|
||||||
s = getNth(a->decl, nth - n, &n);
|
else if (TemplateMixin *tm = s->isTemplateMixin())
|
||||||
if (s)
|
result = foreach(tm->members, dg, ctx, &n);
|
||||||
return s;
|
else if (s->isTemplateInstance())
|
||||||
}
|
|
||||||
else if (tm)
|
|
||||||
{
|
|
||||||
s = getNth(tm->members, nth - n, &n);
|
|
||||||
if (s)
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
else if (ti)
|
|
||||||
;
|
;
|
||||||
else if (n == nth)
|
|
||||||
return s;
|
|
||||||
else
|
else
|
||||||
n++;
|
result = dg(ctx, n++, s);
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pn)
|
if (pn)
|
||||||
*pn += n;
|
*pn = n; // update index
|
||||||
return NULL;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1150,7 +1185,7 @@ Dsymbol *WithScopeSymbol::search(Loc loc, Identifier *ident, int flags)
|
||||||
ArrayScopeSymbol::ArrayScopeSymbol(Scope *sc, Expression *e)
|
ArrayScopeSymbol::ArrayScopeSymbol(Scope *sc, Expression *e)
|
||||||
: ScopeDsymbol()
|
: ScopeDsymbol()
|
||||||
{
|
{
|
||||||
assert(e->op == TOKindex || e->op == TOKslice);
|
assert(e->op == TOKindex || e->op == TOKslice || e->op == TOKarray);
|
||||||
exp = e;
|
exp = e;
|
||||||
type = NULL;
|
type = NULL;
|
||||||
td = NULL;
|
td = NULL;
|
||||||
|
@ -1225,6 +1260,68 @@ Dsymbol *ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags)
|
||||||
pvar = &se->lengthVar;
|
pvar = &se->lengthVar;
|
||||||
ce = se->e1;
|
ce = se->e1;
|
||||||
}
|
}
|
||||||
|
else if (exp->op == TOKarray)
|
||||||
|
{ /* array[e0, e1, e2, e3] where e0, e1, e2 are some function of $
|
||||||
|
* $ is a opDollar!(dim)() where dim is the dimension(0,1,2,...)
|
||||||
|
*/
|
||||||
|
ArrayExp *ae = (ArrayExp *)exp;
|
||||||
|
AggregateDeclaration *ad = NULL;
|
||||||
|
|
||||||
|
Type *t = ae->e1->type->toBasetype();
|
||||||
|
if (t->ty == Tclass)
|
||||||
|
{
|
||||||
|
ad = ((TypeClass *)t)->sym;
|
||||||
|
}
|
||||||
|
else if (t->ty == Tstruct)
|
||||||
|
{
|
||||||
|
ad = ((TypeStruct *)t)->sym;
|
||||||
|
}
|
||||||
|
assert(ad);
|
||||||
|
|
||||||
|
Dsymbol *dsym = search_function(ad, Id::opDollar);
|
||||||
|
if (!dsym) // no dollar exists -- search in higher scope
|
||||||
|
return NULL;
|
||||||
|
VarDeclaration *v = ae->lengthVar;
|
||||||
|
if (!v)
|
||||||
|
{ // $ is lazily initialized. Create it now.
|
||||||
|
TemplateDeclaration *td = dsym->isTemplateDeclaration();
|
||||||
|
if (td)
|
||||||
|
{ // Instantiate opDollar!(dim) with the index as a template argument
|
||||||
|
Objects *tdargs = new Objects();
|
||||||
|
tdargs->setDim(1);
|
||||||
|
|
||||||
|
Expression *x = new IntegerExp(0, ae->currentDimension, Type::tsize_t);
|
||||||
|
x = x->semantic(sc);
|
||||||
|
tdargs->data[0] = x;
|
||||||
|
|
||||||
|
//TemplateInstance *ti = new TemplateInstance(loc, td, tdargs);
|
||||||
|
//ti->semantic(sc);
|
||||||
|
|
||||||
|
DotTemplateInstanceExp *dte = new DotTemplateInstanceExp(loc, ae->e1, td->ident, tdargs);
|
||||||
|
|
||||||
|
v = new VarDeclaration(loc, NULL, Id::dollar, new ExpInitializer(0, dte));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* opDollar exists, but it's a function, not a template.
|
||||||
|
* This is acceptable ONLY for single-dimension indexing.
|
||||||
|
* Note that it's impossible to have both template & function opDollar,
|
||||||
|
* because both take no arguments.
|
||||||
|
*/
|
||||||
|
if (ae->arguments->dim != 1) {
|
||||||
|
ae->error("%s only defines opDollar for one dimension", ad->toChars());
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
FuncDeclaration *fd = dsym->isFuncDeclaration();
|
||||||
|
assert(fd);
|
||||||
|
Expression * x = new DotVarExp(loc, ae->e1, fd);
|
||||||
|
|
||||||
|
v = new VarDeclaration(loc, NULL, Id::dollar, new ExpInitializer(0, x));
|
||||||
|
}
|
||||||
|
v->semantic(sc);
|
||||||
|
ae->lengthVar = v;
|
||||||
|
}
|
||||||
|
return v;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
/* Didn't find $, look in enclosing scope(s).
|
/* Didn't find $, look in enclosing scope(s).
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -206,6 +206,7 @@ struct Dsymbol : Object
|
||||||
virtual int oneMember(Dsymbol **ps);
|
virtual int oneMember(Dsymbol **ps);
|
||||||
static int oneMembers(Dsymbols *members, Dsymbol **ps);
|
static int oneMembers(Dsymbols *members, Dsymbol **ps);
|
||||||
virtual int hasPointers();
|
virtual int hasPointers();
|
||||||
|
virtual bool hasStaticCtorOrDtor();
|
||||||
virtual void addLocalClass(ClassDeclarations *) { }
|
virtual void addLocalClass(ClassDeclarations *) { }
|
||||||
virtual void checkCtorConstInit() { }
|
virtual void checkCtorConstInit() { }
|
||||||
|
|
||||||
|
@ -305,12 +306,16 @@ struct ScopeDsymbol : Dsymbol
|
||||||
const char *kind();
|
const char *kind();
|
||||||
FuncDeclaration *findGetMembers();
|
FuncDeclaration *findGetMembers();
|
||||||
virtual Dsymbol *symtabInsert(Dsymbol *s);
|
virtual Dsymbol *symtabInsert(Dsymbol *s);
|
||||||
|
bool hasStaticCtorOrDtor();
|
||||||
|
|
||||||
void emitMemberComments(Scope *sc);
|
void emitMemberComments(Scope *sc);
|
||||||
|
|
||||||
static size_t dim(Dsymbols *members);
|
static size_t dim(Dsymbols *members);
|
||||||
static Dsymbol *getNth(Dsymbols *members, size_t nth, size_t *pn = NULL);
|
static Dsymbol *getNth(Dsymbols *members, size_t nth, size_t *pn = NULL);
|
||||||
|
|
||||||
|
typedef int (*ForeachDg)(void *ctx, size_t idx, Dsymbol *s);
|
||||||
|
static int foreach(Dsymbols *members, ForeachDg dg, void *ctx, size_t *pn=NULL);
|
||||||
|
|
||||||
ScopeDsymbol *isScopeDsymbol() { return this; }
|
ScopeDsymbol *isScopeDsymbol() { return this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -181,6 +181,15 @@ FuncDeclaration *hasThis(Scope *sc)
|
||||||
fdthis = sc->parent->isFuncDeclaration();
|
fdthis = sc->parent->isFuncDeclaration();
|
||||||
//printf("fdthis = %p, '%s'\n", fdthis, fdthis ? fdthis->toChars() : "");
|
//printf("fdthis = %p, '%s'\n", fdthis, fdthis ? fdthis->toChars() : "");
|
||||||
|
|
||||||
|
/* Special case for inside template constraint
|
||||||
|
*/
|
||||||
|
if (fdthis && (sc->flags & SCOPEstaticif) && fdthis->parent->isTemplateDeclaration())
|
||||||
|
{
|
||||||
|
//TemplateDeclaration *td = fdthis->parent->isTemplateDeclaration();
|
||||||
|
//printf("[%s] td = %s, fdthis->vthis = %p\n", td->loc.toChars(), td->toChars(), fdthis->vthis);
|
||||||
|
return fdthis->vthis ? fdthis : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Go upwards until we find the enclosing member function
|
// Go upwards until we find the enclosing member function
|
||||||
fd = fdthis;
|
fd = fdthis;
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -828,14 +837,12 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf,
|
||||||
L1:
|
L1:
|
||||||
if (!(p->storageClass & STClazy && p->type->ty == Tvoid))
|
if (!(p->storageClass & STClazy && p->type->ty == Tvoid))
|
||||||
{
|
{
|
||||||
if (p->type->hasWild())
|
unsigned mod = arg->type->wildConvTo(p->type);
|
||||||
{ unsigned mod = p->type->wildMatch(arg->type);
|
if (mod)
|
||||||
if (mod)
|
{
|
||||||
{
|
wildmatch |= mod;
|
||||||
wildmatch |= mod;
|
arg = arg->implicitCastTo(sc, p->type->substWildTo(mod));
|
||||||
arg = arg->implicitCastTo(sc, p->type->substWildTo(mod));
|
arg = arg->optimize(WANTvalue);
|
||||||
arg = arg->optimize(WANTvalue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (p->type != arg->type)
|
else if (p->type != arg->type)
|
||||||
{
|
{
|
||||||
|
@ -2996,8 +3003,7 @@ SuperExp::SuperExp(Loc loc)
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression *SuperExp::semantic(Scope *sc)
|
Expression *SuperExp::semantic(Scope *sc)
|
||||||
{ FuncDeclaration *fd;
|
{
|
||||||
FuncDeclaration *fdthis;
|
|
||||||
ClassDeclaration *cd;
|
ClassDeclaration *cd;
|
||||||
Dsymbol *s;
|
Dsymbol *s;
|
||||||
|
|
||||||
|
@ -3007,22 +3013,22 @@ Expression *SuperExp::semantic(Scope *sc)
|
||||||
if (type)
|
if (type)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
|
FuncDeclaration *fd = hasThis(sc);
|
||||||
|
|
||||||
/* Special case for typeof(this) and typeof(super) since both
|
/* Special case for typeof(this) and typeof(super) since both
|
||||||
* should work even if they are not inside a non-static member function
|
* should work even if they are not inside a non-static member function
|
||||||
*/
|
*/
|
||||||
if (sc->intypeof)
|
if (!fd && sc->intypeof)
|
||||||
{
|
{
|
||||||
// Find enclosing class
|
// Find enclosing class
|
||||||
for (Dsymbol *s = sc->parent; 1; s = s->parent)
|
for (Dsymbol *s = sc->getStructClassScope(); 1; s = s->parent)
|
||||||
{
|
{
|
||||||
ClassDeclaration *cd;
|
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
{
|
{
|
||||||
error("%s is not in a class scope", toChars());
|
error("%s is not in a class scope", toChars());
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
}
|
}
|
||||||
cd = s->isClassDeclaration();
|
ClassDeclaration *cd = s->isClassDeclaration();
|
||||||
if (cd)
|
if (cd)
|
||||||
{
|
{
|
||||||
cd = cd->baseClass;
|
cd = cd->baseClass;
|
||||||
|
@ -3035,11 +3041,9 @@ Expression *SuperExp::semantic(Scope *sc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fdthis = sc->parent->isFuncDeclaration();
|
|
||||||
fd = hasThis(sc);
|
|
||||||
if (!fd)
|
if (!fd)
|
||||||
goto Lerr;
|
goto Lerr;
|
||||||
|
|
||||||
assert(fd->vthis);
|
assert(fd->vthis);
|
||||||
var = fd->vthis;
|
var = fd->vthis;
|
||||||
assert(var->parent);
|
assert(var->parent);
|
||||||
|
@ -3060,6 +3064,7 @@ Expression *SuperExp::semantic(Scope *sc)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
type = cd->baseClass->type;
|
type = cd->baseClass->type;
|
||||||
|
type = type->castMod(var->type->mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
var->isVarDeclaration()->checkNestedReference(sc, loc);
|
var->isVarDeclaration()->checkNestedReference(sc, loc);
|
||||||
|
@ -3096,7 +3101,7 @@ Expression *NullExp::semantic(Scope *sc)
|
||||||
#endif
|
#endif
|
||||||
// NULL is the same as (void *)0
|
// NULL is the same as (void *)0
|
||||||
if (!type)
|
if (!type)
|
||||||
type = Type::tvoid->pointerTo();
|
type = Type::tnull;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3519,10 +3524,19 @@ void StringExp::toMangleBuffer(OutBuffer *buf)
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
buf->reserve(1 + 11 + 2 * qlen);
|
||||||
buf->writeByte(m);
|
buf->writeByte(m);
|
||||||
buf->printf("%d_", qlen);
|
buf->printf("%d_", qlen); // nbytes <= 11
|
||||||
for (size_t i = 0; i < qlen; i++)
|
|
||||||
buf->printf("%02x", q[i]);
|
for (unsigned char *p = buf->data + buf->offset, *pend = p + 2 * qlen;
|
||||||
|
p < pend; p += 2, ++q)
|
||||||
|
{
|
||||||
|
unsigned char hi = *q >> 4 & 0xF;
|
||||||
|
p[0] = (hi < 10 ? hi + '0' : hi - 10 + 'a');
|
||||||
|
unsigned char lo = *q & 0xF;
|
||||||
|
p[1] = (lo < 10 ? lo + '0' : lo - 10 + 'a');
|
||||||
|
}
|
||||||
|
buf->offset += 2 * qlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************ ArrayLiteralExp ************************************/
|
/************************ ArrayLiteralExp ************************************/
|
||||||
|
@ -4146,6 +4160,10 @@ Lagain:
|
||||||
//printf("sds = %s, '%s'\n", sds->kind(), sds->toChars());
|
//printf("sds = %s, '%s'\n", sds->kind(), sds->toChars());
|
||||||
//printf("\tparent = '%s'\n", sds->parent->toChars());
|
//printf("\tparent = '%s'\n", sds->parent->toChars());
|
||||||
sds->semantic(sc);
|
sds->semantic(sc);
|
||||||
|
|
||||||
|
AggregateDeclaration *ad = sds->isAggregateDeclaration();
|
||||||
|
if (ad)
|
||||||
|
return (new TypeExp(loc, ad->type))->semantic(sc);
|
||||||
}
|
}
|
||||||
type = Type::tvoid;
|
type = Type::tvoid;
|
||||||
//printf("-2ScopeExp::semantic() %s\n", toChars());
|
//printf("-2ScopeExp::semantic() %s\n", toChars());
|
||||||
|
@ -7147,6 +7165,131 @@ Expression *CallExp::syntaxCopy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Expression *CallExp::resolveUFCS(Scope *sc)
|
||||||
|
{
|
||||||
|
Expression *ethis = NULL;
|
||||||
|
DotIdExp *dotid;
|
||||||
|
DotTemplateInstanceExp *dotti;
|
||||||
|
Identifier *ident;
|
||||||
|
|
||||||
|
if (e1->op == TOKdot)
|
||||||
|
{
|
||||||
|
dotid = (DotIdExp *)e1;
|
||||||
|
ident = dotid->ident;
|
||||||
|
ethis = dotid->e1 = dotid->e1->semantic(sc);
|
||||||
|
if (ethis->op == TOKdotexp)
|
||||||
|
return NULL;
|
||||||
|
ethis = resolveProperties(sc, ethis);
|
||||||
|
}
|
||||||
|
else if (e1->op == TOKdotti)
|
||||||
|
{
|
||||||
|
dotti = (DotTemplateInstanceExp *)e1;
|
||||||
|
ident = dotti->ti->name;
|
||||||
|
ethis = dotti->e1 = dotti->e1->semantic(sc);
|
||||||
|
if (ethis->op == TOKdotexp)
|
||||||
|
return NULL;
|
||||||
|
ethis = resolveProperties(sc, ethis);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ethis && ethis->type)
|
||||||
|
{
|
||||||
|
AggregateDeclaration *ad;
|
||||||
|
Lagain:
|
||||||
|
Type *tthis = ethis->type->toBasetype();
|
||||||
|
if (tthis->ty == Tclass)
|
||||||
|
{
|
||||||
|
ad = ((TypeClass *)tthis)->sym;
|
||||||
|
if (search_function(ad, ident))
|
||||||
|
return NULL;
|
||||||
|
goto L1;
|
||||||
|
}
|
||||||
|
else if (tthis->ty == Tstruct)
|
||||||
|
{
|
||||||
|
ad = ((TypeStruct *)tthis)->sym;
|
||||||
|
if (search_function(ad, ident))
|
||||||
|
return NULL;
|
||||||
|
L1:
|
||||||
|
if (ad->aliasthis)
|
||||||
|
{
|
||||||
|
ethis = new DotIdExp(ethis->loc, ethis, ad->aliasthis->ident);
|
||||||
|
ethis = ethis->semantic(sc);
|
||||||
|
ethis = resolveProperties(sc, ethis);
|
||||||
|
goto Lagain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (tthis->ty == Taarray && e1->op == TOKdot)
|
||||||
|
{
|
||||||
|
if (ident == Id::remove)
|
||||||
|
{
|
||||||
|
/* Transform:
|
||||||
|
* aa.remove(arg) into delete aa[arg]
|
||||||
|
*/
|
||||||
|
if (!arguments || arguments->dim != 1)
|
||||||
|
{ error("expected key as argument to aa.remove()");
|
||||||
|
return new ErrorExp();
|
||||||
|
}
|
||||||
|
Expression *key = arguments->tdata()[0];
|
||||||
|
key = key->semantic(sc);
|
||||||
|
key = resolveProperties(sc, key);
|
||||||
|
key->rvalue();
|
||||||
|
|
||||||
|
TypeAArray *taa = (TypeAArray *)tthis;
|
||||||
|
key = key->implicitCastTo(sc, taa->index);
|
||||||
|
|
||||||
|
return new RemoveExp(loc, ethis, key);
|
||||||
|
}
|
||||||
|
else if (ident == Id::apply || ident == Id::applyReverse)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ TypeAArray *taa = (TypeAArray *)tthis;
|
||||||
|
assert(taa->ty == Taarray);
|
||||||
|
StructDeclaration *sd = taa->getImpl();
|
||||||
|
Dsymbol *s = sd->search(0, ident, 2);
|
||||||
|
if (s)
|
||||||
|
return NULL;
|
||||||
|
goto Lshift;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (tthis->ty == Tarray || tthis->ty == Tsarray)
|
||||||
|
{
|
||||||
|
Lshift:
|
||||||
|
if (!arguments)
|
||||||
|
arguments = new Expressions();
|
||||||
|
arguments->shift(ethis);
|
||||||
|
if (e1->op == TOKdot)
|
||||||
|
{
|
||||||
|
/* Transform:
|
||||||
|
* array.id(args) into .id(array,args)
|
||||||
|
*/
|
||||||
|
#if DMDV2
|
||||||
|
e1 = new DotIdExp(dotid->loc,
|
||||||
|
new IdentifierExp(dotid->loc, Id::empty),
|
||||||
|
ident);
|
||||||
|
#else
|
||||||
|
e1 = new IdentifierExp(dotid->loc, ident);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (e1->op == TOKdotti)
|
||||||
|
{
|
||||||
|
/* Transform:
|
||||||
|
* array.foo!(tiargs)(args) into .foo!(tiargs)(array,args)
|
||||||
|
*/
|
||||||
|
#if DMDV2
|
||||||
|
e1 = new DotExp(dotti->loc,
|
||||||
|
new IdentifierExp(dotti->loc, Id::empty),
|
||||||
|
new ScopeExp(dotti->loc, dotti->ti));
|
||||||
|
#else
|
||||||
|
e1 = new ScopeExp(dotti->loc, dotti->ti);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
//printf("-> this = %s\n", toChars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Expression *CallExp::semantic(Scope *sc)
|
Expression *CallExp::semantic(Scope *sc)
|
||||||
{
|
{
|
||||||
TypeFunction *tf;
|
TypeFunction *tf;
|
||||||
|
@ -7177,61 +7320,9 @@ Expression *CallExp::semantic(Scope *sc)
|
||||||
return semantic(sc);
|
return semantic(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Transform:
|
Expression *e = resolveUFCS(sc);
|
||||||
* array.id(args) into .id(array,args)
|
if (e)
|
||||||
* aa.remove(arg) into delete aa[arg]
|
return e;
|
||||||
*/
|
|
||||||
if (e1->op == TOKdot)
|
|
||||||
{
|
|
||||||
// BUG: we should handle array.a.b.c.e(args) too
|
|
||||||
|
|
||||||
DotIdExp *dotid = (DotIdExp *)(e1);
|
|
||||||
dotid->e1 = dotid->e1->semantic(sc);
|
|
||||||
assert(dotid->e1);
|
|
||||||
if (dotid->e1->type)
|
|
||||||
{
|
|
||||||
TY e1ty = dotid->e1->type->toBasetype()->ty;
|
|
||||||
if (e1ty == Taarray && dotid->ident == Id::remove)
|
|
||||||
{
|
|
||||||
if (!arguments || arguments->dim != 1)
|
|
||||||
{ error("expected key as argument to aa.remove()");
|
|
||||||
return new ErrorExp();
|
|
||||||
}
|
|
||||||
Expression *key = arguments->tdata()[0];
|
|
||||||
key = key->semantic(sc);
|
|
||||||
key = resolveProperties(sc, key);
|
|
||||||
key->rvalue();
|
|
||||||
|
|
||||||
TypeAArray *taa = (TypeAArray *)dotid->e1->type->toBasetype();
|
|
||||||
key = key->implicitCastTo(sc, taa->index);
|
|
||||||
|
|
||||||
return new RemoveExp(loc, dotid->e1, key);
|
|
||||||
}
|
|
||||||
else if (e1ty == Tarray || e1ty == Tsarray ||
|
|
||||||
(e1ty == Taarray && dotid->ident != Id::apply && dotid->ident != Id::applyReverse))
|
|
||||||
{
|
|
||||||
if (e1ty == Taarray)
|
|
||||||
{ TypeAArray *taa = (TypeAArray *)dotid->e1->type->toBasetype();
|
|
||||||
assert(taa->ty == Taarray);
|
|
||||||
StructDeclaration *sd = taa->getImpl();
|
|
||||||
Dsymbol *s = sd->search(0, dotid->ident, 2);
|
|
||||||
if (s)
|
|
||||||
goto L2;
|
|
||||||
}
|
|
||||||
if (!arguments)
|
|
||||||
arguments = new Expressions();
|
|
||||||
arguments->shift(dotid->e1);
|
|
||||||
#if DMDV2
|
|
||||||
e1 = new DotIdExp(dotid->loc, new IdentifierExp(dotid->loc, Id::empty), dotid->ident);
|
|
||||||
#else
|
|
||||||
e1 = new IdentifierExp(dotid->loc, dotid->ident);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
L2:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
/* This recognizes:
|
/* This recognizes:
|
||||||
|
@ -7769,7 +7860,7 @@ Lagain:
|
||||||
if (sc->func->setImpure())
|
if (sc->func->setImpure())
|
||||||
error("pure function '%s' cannot call impure function pointer '%s'", sc->func->toChars(), e1->toChars());
|
error("pure function '%s' cannot call impure function pointer '%s'", sc->func->toChars(), e1->toChars());
|
||||||
}
|
}
|
||||||
if (sc->func && !((TypeFunction *)t1)->trust <= TRUSTsystem)
|
if (sc->func && ((TypeFunction *)t1)->trust <= TRUSTsystem)
|
||||||
{
|
{
|
||||||
if (sc->func->setUnsafe())
|
if (sc->func->setUnsafe())
|
||||||
error("safe function '%s' cannot call system function pointer '%s'", sc->func->toChars(), e1->toChars());
|
error("safe function '%s' cannot call system function pointer '%s'", sc->func->toChars(), e1->toChars());
|
||||||
|
@ -8181,6 +8272,8 @@ Expression *PtrExp::semantic(Scope *sc)
|
||||||
|
|
||||||
case Tsarray:
|
case Tsarray:
|
||||||
case Tarray:
|
case Tarray:
|
||||||
|
if (!global.params.useDeprecated)
|
||||||
|
error("using * on an array is deprecated; use *(%s).ptr instead", e1->toChars());
|
||||||
type = ((TypeArray *)tb)->next;
|
type = ((TypeArray *)tb)->next;
|
||||||
e1 = e1->castTo(sc, type->pointerTo());
|
e1 = e1->castTo(sc, type->pointerTo());
|
||||||
break;
|
break;
|
||||||
|
@ -9095,6 +9188,8 @@ ArrayExp::ArrayExp(Loc loc, Expression *e1, Expressions *args)
|
||||||
: UnaExp(loc, TOKarray, sizeof(ArrayExp), e1)
|
: UnaExp(loc, TOKarray, sizeof(ArrayExp), e1)
|
||||||
{
|
{
|
||||||
arguments = args;
|
arguments = args;
|
||||||
|
lengthVar = NULL;
|
||||||
|
currentDimension = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expression *ArrayExp::syntaxCopy()
|
Expression *ArrayExp::syntaxCopy()
|
||||||
|
@ -9639,6 +9734,29 @@ Expression *AssignExp::semantic(Scope *sc)
|
||||||
// Rewrite (a[i] = value) to (a.opIndexAssign(value, i))
|
// Rewrite (a[i] = value) to (a.opIndexAssign(value, i))
|
||||||
if (search_function(ad, Id::indexass))
|
if (search_function(ad, Id::indexass))
|
||||||
{ Expression *e = new DotIdExp(loc, ae->e1, Id::indexass);
|
{ Expression *e = new DotIdExp(loc, ae->e1, Id::indexass);
|
||||||
|
// Deal with $
|
||||||
|
for (size_t i = 0; i < ae->arguments->dim; i++)
|
||||||
|
{ Expression *x = ae->arguments->tdata()[i];
|
||||||
|
// Create scope for '$' variable for this dimension
|
||||||
|
ArrayScopeSymbol *sym = new ArrayScopeSymbol(sc, ae);
|
||||||
|
sym->loc = loc;
|
||||||
|
sym->parent = sc->scopesym;
|
||||||
|
sc = sc->push(sym);
|
||||||
|
ae->lengthVar = NULL; // Create it only if required
|
||||||
|
ae->currentDimension = i; // Dimension for $, if required
|
||||||
|
|
||||||
|
x = x->semantic(sc);
|
||||||
|
if (!x->type)
|
||||||
|
ae->error("%s has no value", x->toChars());
|
||||||
|
if (ae->lengthVar)
|
||||||
|
{ // If $ was used, declare it now
|
||||||
|
Expression *av = new DeclarationExp(ae->loc, ae->lengthVar);
|
||||||
|
x = new CommaExp(0, av, x);
|
||||||
|
x->semantic(sc);
|
||||||
|
}
|
||||||
|
ae->arguments->tdata()[i] = x;
|
||||||
|
sc = sc->pop();
|
||||||
|
}
|
||||||
Expressions *a = (Expressions *)ae->arguments->copy();
|
Expressions *a = (Expressions *)ae->arguments->copy();
|
||||||
|
|
||||||
a->insert(0, e2);
|
a->insert(0, e2);
|
||||||
|
@ -10089,7 +10207,7 @@ Expression *AssignExp::checkToBoolean(Scope *sc)
|
||||||
// if (a = b) ...
|
// if (a = b) ...
|
||||||
// are usually mistakes.
|
// are usually mistakes.
|
||||||
|
|
||||||
error("'=' does not give a boolean result");
|
error("assignment cannot be used as a condition, perhaps == was meant?");
|
||||||
return new ErrorExp();
|
return new ErrorExp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10865,7 +10983,7 @@ Expression *MinExp::semantic(Scope *sc)
|
||||||
else if (t2->isintegral())
|
else if (t2->isintegral())
|
||||||
e = scaleFactor(sc);
|
e = scaleFactor(sc);
|
||||||
else
|
else
|
||||||
{ error("incompatible types for minus");
|
{ error("can't subtract %s from pointer", t2->toChars());
|
||||||
return new ErrorExp();
|
return new ErrorExp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11762,7 +11880,33 @@ Expression *CmpExp::semantic(Scope *sc)
|
||||||
return new ErrorExp();
|
return new ErrorExp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Expression *eb1 = e1;
|
||||||
|
Expression *eb2 = e2;
|
||||||
|
|
||||||
typeCombine(sc);
|
typeCombine(sc);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// For integer comparisons, ensure the combined type can hold both arguments.
|
||||||
|
if (type && type->isintegral() && (op == TOKlt || op == TOKle ||
|
||||||
|
op == TOKgt || op == TOKge))
|
||||||
|
{
|
||||||
|
IntRange trange = IntRange::fromType(type);
|
||||||
|
|
||||||
|
Expression *errorexp = 0;
|
||||||
|
if (!trange.contains(eb1->getIntRange()))
|
||||||
|
errorexp = eb1;
|
||||||
|
if (!trange.contains(eb2->getIntRange()))
|
||||||
|
errorexp = eb2;
|
||||||
|
|
||||||
|
if (errorexp)
|
||||||
|
{
|
||||||
|
error("implicit conversion of '%s' to '%s' is unsafe in '(%s) %s (%s)'",
|
||||||
|
errorexp->toChars(), type->toChars(), eb1->toChars(), Token::toChars(op), eb2->toChars());
|
||||||
|
return new ErrorExp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
type = Type::tboolean;
|
type = Type::tboolean;
|
||||||
|
|
||||||
// Special handling for array comparisons
|
// Special handling for array comparisons
|
||||||
|
|
|
@ -1135,6 +1135,7 @@ struct CallExp : UnaExp
|
||||||
CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2);
|
CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2);
|
||||||
|
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
|
Expression *resolveUFCS(Scope *sc);
|
||||||
Expression *semantic(Scope *sc);
|
Expression *semantic(Scope *sc);
|
||||||
Expression *optimize(int result);
|
Expression *optimize(int result);
|
||||||
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
Expression *interpret(InterState *istate, CtfeGoal goal = ctfeNeedRvalue);
|
||||||
|
@ -1402,6 +1403,8 @@ struct ArrayLengthExp : UnaExp
|
||||||
struct ArrayExp : UnaExp
|
struct ArrayExp : UnaExp
|
||||||
{
|
{
|
||||||
Expressions *arguments; // Array of Expression's
|
Expressions *arguments; // Array of Expression's
|
||||||
|
size_t currentDimension; // for opDollar
|
||||||
|
VarDeclaration *lengthVar;
|
||||||
|
|
||||||
ArrayExp(Loc loc, Expression *e1, Expressions *arguments);
|
ArrayExp(Loc loc, Expression *e1, Expressions *arguments);
|
||||||
Expression *syntaxCopy();
|
Expression *syntaxCopy();
|
||||||
|
|
163
dmd2/func.c
163
dmd2/func.c
|
@ -423,7 +423,7 @@ void FuncDeclaration::semantic(Scope *sc)
|
||||||
// ctor = (CtorDeclaration *)this;
|
// ctor = (CtorDeclaration *)this;
|
||||||
// if (!cd->ctor)
|
// if (!cd->ctor)
|
||||||
// cd->ctor = ctor;
|
// cd->ctor = ctor;
|
||||||
return;
|
goto Ldone;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -923,7 +923,8 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
sc2->sw = NULL;
|
sc2->sw = NULL;
|
||||||
sc2->fes = fes;
|
sc2->fes = fes;
|
||||||
sc2->linkage = LINKd;
|
sc2->linkage = LINKd;
|
||||||
sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract | STCdeprecated |
|
sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract |
|
||||||
|
STCdeprecated | STCoverride |
|
||||||
STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref |
|
STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref |
|
||||||
STCproperty | STCsafe | STCtrusted | STCsystem);
|
STCproperty | STCsafe | STCtrusted | STCsystem);
|
||||||
sc2->protection = PROTpublic;
|
sc2->protection = PROTpublic;
|
||||||
|
@ -941,76 +942,16 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
// Declare 'this'
|
// Declare 'this'
|
||||||
AggregateDeclaration *ad = isThis();
|
AggregateDeclaration *ad = isThis();
|
||||||
if (ad)
|
if (ad)
|
||||||
{ VarDeclaration *v;
|
{
|
||||||
|
|
||||||
if (isFuncLiteralDeclaration() && isNested() && !sc->intypeof)
|
if (isFuncLiteralDeclaration() && isNested() && !sc->intypeof)
|
||||||
{
|
{
|
||||||
error("function literals cannot be class members");
|
error("function literals cannot be class members");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
assert(!isNested() || sc->intypeof); // can't be both member and nested
|
assert(!isNested() || sc->intypeof); // can't be both member and nested
|
||||||
assert(ad->handle);
|
|
||||||
Type *thandle = ad->handle;
|
|
||||||
#if STRUCTTHISREF
|
|
||||||
thandle = thandle->addMod(type->mod);
|
|
||||||
thandle = thandle->addStorageClass(storage_class);
|
|
||||||
//if (isPure())
|
|
||||||
//thandle = thandle->addMod(MODconst);
|
|
||||||
#else
|
|
||||||
if (storage_class & STCconst || type->isConst())
|
|
||||||
{
|
|
||||||
assert(0); // BUG: shared not handled
|
|
||||||
if (thandle->ty == Tclass)
|
|
||||||
thandle = thandle->constOf();
|
|
||||||
else
|
|
||||||
{ assert(thandle->ty == Tpointer);
|
|
||||||
thandle = thandle->nextOf()->constOf()->pointerTo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (storage_class & STCimmutable || type->isImmutable())
|
|
||||||
{
|
|
||||||
if (thandle->ty == Tclass)
|
|
||||||
thandle = thandle->invariantOf();
|
|
||||||
else
|
|
||||||
{ assert(thandle->ty == Tpointer);
|
|
||||||
thandle = thandle->nextOf()->invariantOf()->pointerTo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (storage_class & STCshared || type->isShared())
|
|
||||||
{
|
|
||||||
assert(0); // not implemented
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
v = new ThisDeclaration(loc, thandle);
|
|
||||||
//v = new ThisDeclaration(loc, isCtorDeclaration() ? ad->handle : thandle);
|
|
||||||
v->storage_class |= STCparameter;
|
|
||||||
#if STRUCTTHISREF
|
|
||||||
if (thandle->ty == Tstruct)
|
|
||||||
v->storage_class |= STCref;
|
|
||||||
#endif
|
|
||||||
v->semantic(sc2);
|
|
||||||
if (!sc2->insert(v))
|
|
||||||
assert(0);
|
|
||||||
v->parent = this;
|
|
||||||
vthis = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (isNested())
|
|
||||||
{
|
|
||||||
/* The 'this' for a nested function is the link to the
|
|
||||||
* enclosing function's stack frame.
|
|
||||||
* Note that nested functions and member functions are disjoint.
|
|
||||||
*/
|
|
||||||
VarDeclaration *v = new ThisDeclaration(loc, Type::tvoid->pointerTo());
|
|
||||||
v->storage_class |= STCparameter;
|
|
||||||
v->semantic(sc2);
|
|
||||||
if (!sc2->insert(v))
|
|
||||||
assert(0);
|
|
||||||
v->parent = this;
|
|
||||||
vthis = v;
|
|
||||||
}
|
}
|
||||||
|
vthis = declareThis(sc2, ad);
|
||||||
|
|
||||||
// Declare hidden variable _arguments[] and _argptr
|
// Declare hidden variable _arguments[] and _argptr
|
||||||
if (f->varargs == 1)
|
if (f->varargs == 1)
|
||||||
|
@ -1363,7 +1304,7 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
if (!type->nextOf())
|
if (!type->nextOf())
|
||||||
{
|
{
|
||||||
((TypeFunction *)type)->next = Type::tvoid;
|
((TypeFunction *)type)->next = Type::tvoid;
|
||||||
type = type->semantic(loc, sc);
|
//type = type->semantic(loc, sc); // Removed with 6902
|
||||||
}
|
}
|
||||||
f = (TypeFunction *)type;
|
f = (TypeFunction *)type;
|
||||||
}
|
}
|
||||||
|
@ -1835,6 +1776,12 @@ void FuncDeclaration::semantic3(Scope *sc)
|
||||||
f->trust = TRUSTsafe;
|
f->trust = TRUSTsafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do semantic type AFTER pure/nothrow inference.
|
||||||
|
if (inferRetType)
|
||||||
|
{
|
||||||
|
type = type->semantic(loc, sc);
|
||||||
|
}
|
||||||
|
|
||||||
if (global.gag && global.errors != nerrors)
|
if (global.gag && global.errors != nerrors)
|
||||||
semanticRun = PASSsemanticdone; // Ensure errors get reported again
|
semanticRun = PASSsemanticdone; // Ensure errors get reported again
|
||||||
else
|
else
|
||||||
|
@ -1852,6 +1799,76 @@ void FuncDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
bodyToCBuffer(buf, hgs);
|
bodyToCBuffer(buf, hgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VarDeclaration *FuncDeclaration::declareThis(Scope *sc, AggregateDeclaration *ad)
|
||||||
|
{
|
||||||
|
if (ad)
|
||||||
|
{ VarDeclaration *v;
|
||||||
|
|
||||||
|
{
|
||||||
|
assert(ad->handle);
|
||||||
|
Type *thandle = ad->handle;
|
||||||
|
#if STRUCTTHISREF
|
||||||
|
thandle = thandle->addMod(type->mod);
|
||||||
|
thandle = thandle->addStorageClass(storage_class);
|
||||||
|
//if (isPure())
|
||||||
|
//thandle = thandle->addMod(MODconst);
|
||||||
|
#else
|
||||||
|
if (storage_class & STCconst || type->isConst())
|
||||||
|
{
|
||||||
|
assert(0); // BUG: shared not handled
|
||||||
|
if (thandle->ty == Tclass)
|
||||||
|
thandle = thandle->constOf();
|
||||||
|
else
|
||||||
|
{ assert(thandle->ty == Tpointer);
|
||||||
|
thandle = thandle->nextOf()->constOf()->pointerTo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (storage_class & STCimmutable || type->isImmutable())
|
||||||
|
{
|
||||||
|
if (thandle->ty == Tclass)
|
||||||
|
thandle = thandle->invariantOf();
|
||||||
|
else
|
||||||
|
{ assert(thandle->ty == Tpointer);
|
||||||
|
thandle = thandle->nextOf()->invariantOf()->pointerTo();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (storage_class & STCshared || type->isShared())
|
||||||
|
{
|
||||||
|
assert(0); // not implemented
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
v = new ThisDeclaration(loc, thandle);
|
||||||
|
//v = new ThisDeclaration(loc, isCtorDeclaration() ? ad->handle : thandle);
|
||||||
|
v->storage_class |= STCparameter;
|
||||||
|
#if STRUCTTHISREF
|
||||||
|
if (thandle->ty == Tstruct)
|
||||||
|
v->storage_class |= STCref;
|
||||||
|
#endif
|
||||||
|
v->semantic(sc);
|
||||||
|
if (!sc->insert(v))
|
||||||
|
assert(0);
|
||||||
|
v->parent = this;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (isNested())
|
||||||
|
{
|
||||||
|
/* The 'this' for a nested function is the link to the
|
||||||
|
* enclosing function's stack frame.
|
||||||
|
* Note that nested functions and member functions are disjoint.
|
||||||
|
*/
|
||||||
|
VarDeclaration *v = new ThisDeclaration(loc, Type::tvoid->pointerTo());
|
||||||
|
v->storage_class |= STCparameter;
|
||||||
|
v->semantic(sc);
|
||||||
|
if (!sc->insert(v))
|
||||||
|
assert(0);
|
||||||
|
v->parent = this;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int FuncDeclaration::equals(Object *o)
|
int FuncDeclaration::equals(Object *o)
|
||||||
{
|
{
|
||||||
if (this == o)
|
if (this == o)
|
||||||
|
@ -3313,8 +3330,8 @@ int CtorDeclaration::addPostInvariant()
|
||||||
/********************************* PostBlitDeclaration ****************************/
|
/********************************* PostBlitDeclaration ****************************/
|
||||||
|
|
||||||
#if DMDV2
|
#if DMDV2
|
||||||
PostBlitDeclaration::PostBlitDeclaration(Loc loc, Loc endloc)
|
PostBlitDeclaration::PostBlitDeclaration(Loc loc, Loc endloc, StorageClass stc)
|
||||||
: FuncDeclaration(loc, endloc, Id::_postblit, STCundefined, NULL)
|
: FuncDeclaration(loc, endloc, Id::_postblit, stc, NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3347,7 +3364,7 @@ void PostBlitDeclaration::semantic(Scope *sc)
|
||||||
ad->postblits.push(this);
|
ad->postblits.push(this);
|
||||||
|
|
||||||
if (!type)
|
if (!type)
|
||||||
type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd);
|
type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd, storage_class);
|
||||||
|
|
||||||
sc = sc->push();
|
sc = sc->push();
|
||||||
sc->stc &= ~STCstatic; // not static
|
sc->stc &= ~STCstatic; // not static
|
||||||
|
@ -3557,6 +3574,11 @@ int StaticCtorDeclaration::isVirtual()
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StaticCtorDeclaration::hasStaticCtorOrDtor()
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int StaticCtorDeclaration::addPreInvariant()
|
int StaticCtorDeclaration::addPreInvariant()
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -3684,6 +3706,11 @@ int StaticDtorDeclaration::isVirtual()
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool StaticDtorDeclaration::hasStaticCtorOrDtor()
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int StaticDtorDeclaration::addPreInvariant()
|
int StaticDtorDeclaration::addPreInvariant()
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -66,6 +66,7 @@ Msgtable msgtable[] =
|
||||||
{ "Exception" },
|
{ "Exception" },
|
||||||
{ "AssociativeArray" },
|
{ "AssociativeArray" },
|
||||||
{ "Throwable" },
|
{ "Throwable" },
|
||||||
|
{ "Error" },
|
||||||
{ "withSym", "__withSym" },
|
{ "withSym", "__withSym" },
|
||||||
{ "result", "__result" },
|
{ "result", "__result" },
|
||||||
{ "returnLabel", "__returnLabel" },
|
{ "returnLabel", "__returnLabel" },
|
||||||
|
@ -215,6 +216,7 @@ Msgtable msgtable[] =
|
||||||
{ "opStar" },
|
{ "opStar" },
|
||||||
{ "opDot" },
|
{ "opDot" },
|
||||||
{ "opDispatch" },
|
{ "opDispatch" },
|
||||||
|
{ "opDollar" },
|
||||||
{ "opUnary" },
|
{ "opUnary" },
|
||||||
{ "opIndexUnary" },
|
{ "opIndexUnary" },
|
||||||
{ "opSliceUnary" },
|
{ "opSliceUnary" },
|
||||||
|
|
1837
dmd2/interpret.c
1837
dmd2/interpret.c
File diff suppressed because it is too large
Load diff
|
@ -21,7 +21,7 @@
|
||||||
static uinteger_t copySign(uinteger_t x, bool sign)
|
static uinteger_t copySign(uinteger_t x, bool sign)
|
||||||
{
|
{
|
||||||
// return sign ? -x : x;
|
// return sign ? -x : x;
|
||||||
return (x - sign) ^ -sign;
|
return (x - (uinteger_t)sign) ^ -(uinteger_t)sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef UINT64_MAX
|
#ifndef UINT64_MAX
|
||||||
|
|
|
@ -54,6 +54,8 @@ void obj_start(char *srcfile);
|
||||||
void obj_end(Library *library, File *objfile);
|
void obj_end(Library *library, File *objfile);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void printCtfePerformanceStats();
|
||||||
|
|
||||||
Global global;
|
Global global;
|
||||||
|
|
||||||
Global::Global()
|
Global::Global()
|
||||||
|
@ -100,7 +102,7 @@ Global::Global()
|
||||||
"\nMSIL back-end (alpha release) by Cristian L. Vlasceanu and associates.";
|
"\nMSIL back-end (alpha release) by Cristian L. Vlasceanu and associates.";
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
version = "v2.056";
|
version = "v2.057";
|
||||||
#if IN_LLVM
|
#if IN_LLVM
|
||||||
ldc_version = "LDC trunk";
|
ldc_version = "LDC trunk";
|
||||||
llvm_version = "LLVM 3.0";
|
llvm_version = "LLVM 3.0";
|
||||||
|
@ -1318,6 +1320,8 @@ int main(int argc, char *argv[])
|
||||||
if (global.errors || global.warnings)
|
if (global.errors || global.warnings)
|
||||||
fatal();
|
fatal();
|
||||||
|
|
||||||
|
printCtfePerformanceStats();
|
||||||
|
|
||||||
Library *library = NULL;
|
Library *library = NULL;
|
||||||
if (global.params.lib)
|
if (global.params.lib)
|
||||||
{
|
{
|
||||||
|
|
693
dmd2/mtype.c
693
dmd2/mtype.c
File diff suppressed because it is too large
Load diff
52
dmd2/mtype.h
52
dmd2/mtype.h
|
@ -70,8 +70,8 @@ enum ENUMTY
|
||||||
Tident,
|
Tident,
|
||||||
Tclass,
|
Tclass,
|
||||||
Tstruct,
|
Tstruct,
|
||||||
|
|
||||||
Tenum,
|
Tenum,
|
||||||
|
|
||||||
Ttypedef,
|
Ttypedef,
|
||||||
Tdelegate,
|
Tdelegate,
|
||||||
Tnone,
|
Tnone,
|
||||||
|
@ -81,8 +81,8 @@ enum ENUMTY
|
||||||
Tint16,
|
Tint16,
|
||||||
Tuns16,
|
Tuns16,
|
||||||
Tint32,
|
Tint32,
|
||||||
|
|
||||||
Tuns32,
|
Tuns32,
|
||||||
|
|
||||||
Tint64,
|
Tint64,
|
||||||
Tuns64,
|
Tuns64,
|
||||||
Tfloat32,
|
Tfloat32,
|
||||||
|
@ -92,8 +92,8 @@ enum ENUMTY
|
||||||
Timaginary64,
|
Timaginary64,
|
||||||
Timaginary80,
|
Timaginary80,
|
||||||
Tcomplex32,
|
Tcomplex32,
|
||||||
|
|
||||||
Tcomplex64,
|
Tcomplex64,
|
||||||
|
|
||||||
Tcomplex80,
|
Tcomplex80,
|
||||||
Tbool,
|
Tbool,
|
||||||
Tchar,
|
Tchar,
|
||||||
|
@ -102,10 +102,11 @@ enum ENUMTY
|
||||||
Terror,
|
Terror,
|
||||||
Tinstance,
|
Tinstance,
|
||||||
Ttypeof,
|
Ttypeof,
|
||||||
|
|
||||||
Ttuple,
|
Ttuple,
|
||||||
Tslice,
|
Tslice,
|
||||||
|
|
||||||
Treturn,
|
Treturn,
|
||||||
|
Tnull,
|
||||||
TMAX
|
TMAX
|
||||||
};
|
};
|
||||||
typedef unsigned char TY; // ENUMTY
|
typedef unsigned char TY; // ENUMTY
|
||||||
|
@ -187,6 +188,8 @@ struct Type : Object
|
||||||
static Type *tstring; // immutable(char)[]
|
static Type *tstring; // immutable(char)[]
|
||||||
#define terror basic[Terror] // for error recovery
|
#define terror basic[Terror] // for error recovery
|
||||||
|
|
||||||
|
#define tnull basic[Tnull] // for null type
|
||||||
|
|
||||||
#define tsize_t basic[Tsize_t] // matches size_t alias
|
#define tsize_t basic[Tsize_t] // matches size_t alias
|
||||||
#define tptrdiff_t basic[Tptrdiff_t] // matches ptrdiff_t alias
|
#define tptrdiff_t basic[Tptrdiff_t] // matches ptrdiff_t alias
|
||||||
#define thash_t tsize_t // matches hash_t alias
|
#define thash_t tsize_t // matches hash_t alias
|
||||||
|
@ -293,6 +296,7 @@ struct Type : Object
|
||||||
Type *pointerTo();
|
Type *pointerTo();
|
||||||
Type *referenceTo();
|
Type *referenceTo();
|
||||||
Type *arrayOf();
|
Type *arrayOf();
|
||||||
|
Type *aliasthisOf();
|
||||||
virtual Type *makeConst();
|
virtual Type *makeConst();
|
||||||
virtual Type *makeInvariant();
|
virtual Type *makeInvariant();
|
||||||
virtual Type *makeShared();
|
virtual Type *makeShared();
|
||||||
|
@ -302,10 +306,12 @@ struct Type : Object
|
||||||
virtual Type *makeMutable();
|
virtual Type *makeMutable();
|
||||||
virtual Dsymbol *toDsymbol(Scope *sc);
|
virtual Dsymbol *toDsymbol(Scope *sc);
|
||||||
virtual Type *toBasetype();
|
virtual Type *toBasetype();
|
||||||
virtual Type *toHeadMutable();
|
|
||||||
virtual int isBaseOf(Type *t, int *poffset);
|
virtual int isBaseOf(Type *t, int *poffset);
|
||||||
virtual MATCH constConv(Type *to);
|
|
||||||
virtual MATCH implicitConvTo(Type *to);
|
virtual MATCH implicitConvTo(Type *to);
|
||||||
|
virtual MATCH constConv(Type *to);
|
||||||
|
virtual unsigned wildConvTo(Type *tprm);
|
||||||
|
Type *substWildTo(unsigned mod);
|
||||||
|
virtual Type *toHeadMutable();
|
||||||
virtual ClassDeclaration *isClassHandle();
|
virtual ClassDeclaration *isClassHandle();
|
||||||
virtual Expression *getProperty(Loc loc, Identifier *ident);
|
virtual Expression *getProperty(Loc loc, Identifier *ident);
|
||||||
virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
|
virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
|
||||||
|
@ -326,8 +332,6 @@ struct Type : Object
|
||||||
virtual int builtinTypeInfo();
|
virtual int builtinTypeInfo();
|
||||||
virtual Type *reliesOnTident();
|
virtual Type *reliesOnTident();
|
||||||
virtual int hasWild();
|
virtual int hasWild();
|
||||||
unsigned wildMatch(Type *targ);
|
|
||||||
Type *substWildTo(unsigned mod);
|
|
||||||
virtual Expression *toExpression();
|
virtual Expression *toExpression();
|
||||||
virtual int hasPointers();
|
virtual int hasPointers();
|
||||||
virtual TypeTuple *toArgTypes();
|
virtual TypeTuple *toArgTypes();
|
||||||
|
@ -359,6 +363,7 @@ struct Type : Object
|
||||||
struct TypeError : Type
|
struct TypeError : Type
|
||||||
{
|
{
|
||||||
TypeError();
|
TypeError();
|
||||||
|
Type *syntaxCopy();
|
||||||
|
|
||||||
void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
|
||||||
|
|
||||||
|
@ -387,6 +392,7 @@ struct TypeNext : Type
|
||||||
Type *makeSharedWild();
|
Type *makeSharedWild();
|
||||||
Type *makeMutable();
|
Type *makeMutable();
|
||||||
MATCH constConv(Type *to);
|
MATCH constConv(Type *to);
|
||||||
|
unsigned wildConvTo(Type *tprm);
|
||||||
void transitive();
|
void transitive();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -788,6 +794,7 @@ struct TypeStruct : Type
|
||||||
TypeTuple *toArgTypes();
|
TypeTuple *toArgTypes();
|
||||||
MATCH implicitConvTo(Type *to);
|
MATCH implicitConvTo(Type *to);
|
||||||
MATCH constConv(Type *to);
|
MATCH constConv(Type *to);
|
||||||
|
unsigned wildConvTo(Type *tprm);
|
||||||
Type *toHeadMutable();
|
Type *toHeadMutable();
|
||||||
#if CPP_MANGLE
|
#if CPP_MANGLE
|
||||||
void toCppMangle(OutBuffer *buf, CppMangleState *cms);
|
void toCppMangle(OutBuffer *buf, CppMangleState *cms);
|
||||||
|
@ -874,6 +881,7 @@ struct TypeTypedef : Type
|
||||||
Type *toBasetype();
|
Type *toBasetype();
|
||||||
MATCH implicitConvTo(Type *to);
|
MATCH implicitConvTo(Type *to);
|
||||||
MATCH constConv(Type *to);
|
MATCH constConv(Type *to);
|
||||||
|
Type *toHeadMutable();
|
||||||
Expression *defaultInit(Loc loc);
|
Expression *defaultInit(Loc loc);
|
||||||
Expression *defaultInitLiteral(Loc loc);
|
Expression *defaultInitLiteral(Loc loc);
|
||||||
int isZeroInit(Loc loc);
|
int isZeroInit(Loc loc);
|
||||||
|
@ -885,7 +893,6 @@ struct TypeTypedef : Type
|
||||||
int hasPointers();
|
int hasPointers();
|
||||||
TypeTuple *toArgTypes();
|
TypeTuple *toArgTypes();
|
||||||
int hasWild();
|
int hasWild();
|
||||||
Type *toHeadMutable();
|
|
||||||
#if CPP_MANGLE
|
#if CPP_MANGLE
|
||||||
void toCppMangle(OutBuffer *buf, CppMangleState *cms);
|
void toCppMangle(OutBuffer *buf, CppMangleState *cms);
|
||||||
#endif
|
#endif
|
||||||
|
@ -912,6 +919,9 @@ struct TypeClass : Type
|
||||||
ClassDeclaration *isClassHandle();
|
ClassDeclaration *isClassHandle();
|
||||||
int isBaseOf(Type *t, int *poffset);
|
int isBaseOf(Type *t, int *poffset);
|
||||||
MATCH implicitConvTo(Type *to);
|
MATCH implicitConvTo(Type *to);
|
||||||
|
MATCH constConv(Type *to);
|
||||||
|
unsigned wildConvTo(Type *tprm);
|
||||||
|
Type *toHeadMutable();
|
||||||
Expression *defaultInit(Loc loc);
|
Expression *defaultInit(Loc loc);
|
||||||
int isZeroInit(Loc loc);
|
int isZeroInit(Loc loc);
|
||||||
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes, unsigned *wildmatch = NULL);
|
MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes, unsigned *wildmatch = NULL);
|
||||||
|
@ -921,13 +931,9 @@ struct TypeClass : Type
|
||||||
int hasPointers();
|
int hasPointers();
|
||||||
TypeTuple *toArgTypes();
|
TypeTuple *toArgTypes();
|
||||||
int builtinTypeInfo();
|
int builtinTypeInfo();
|
||||||
#if DMDV2
|
|
||||||
Type *toHeadMutable();
|
|
||||||
MATCH constConv(Type *to);
|
|
||||||
#if CPP_MANGLE
|
#if CPP_MANGLE
|
||||||
void toCppMangle(OutBuffer *buf, CppMangleState *cms);
|
void toCppMangle(OutBuffer *buf, CppMangleState *cms);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#if IN_DMD
|
#if IN_DMD
|
||||||
type *toCtype();
|
type *toCtype();
|
||||||
|
@ -967,6 +973,23 @@ struct TypeSlice : TypeNext
|
||||||
void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
|
void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TypeNull : Type
|
||||||
|
{
|
||||||
|
TypeNull();
|
||||||
|
|
||||||
|
Type *syntaxCopy();
|
||||||
|
void toDecoBuffer(OutBuffer *buf, int flag);
|
||||||
|
MATCH implicitConvTo(Type *to);
|
||||||
|
|
||||||
|
void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
|
||||||
|
|
||||||
|
d_uns64 size(Loc loc);
|
||||||
|
//Expression *getProperty(Loc loc, Identifier *ident);
|
||||||
|
//Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
|
||||||
|
Expression *defaultInit(Loc loc);
|
||||||
|
//Expression *defaultInitLiteral(Loc loc);
|
||||||
|
};
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
//enum InOut { None, In, Out, InOut, Lazy };
|
//enum InOut { None, In, Out, InOut, Lazy };
|
||||||
|
@ -991,6 +1014,9 @@ struct Parameter : Object
|
||||||
static int isTPL(Parameters *arguments);
|
static int isTPL(Parameters *arguments);
|
||||||
static size_t dim(Parameters *arguments);
|
static size_t dim(Parameters *arguments);
|
||||||
static Parameter *getNth(Parameters *arguments, size_t nth, size_t *pn = NULL);
|
static Parameter *getNth(Parameters *arguments, size_t nth, size_t *pn = NULL);
|
||||||
|
|
||||||
|
typedef int (*ForeachDg)(void *ctx, size_t paramidx, Parameter *param, int flags);
|
||||||
|
static int foreach(Parameters *args, ForeachDg dg, void *ctx, size_t *pn=NULL, int flags = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int PTRSIZE;
|
extern int PTRSIZE;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "mtype.h"
|
#include "mtype.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
#include "expression.h"
|
#include "expression.h"
|
||||||
|
#include "scope.h"
|
||||||
#include "id.h"
|
#include "id.h"
|
||||||
#include "declaration.h"
|
#include "declaration.h"
|
||||||
#include "aggregate.h"
|
#include "aggregate.h"
|
||||||
|
@ -373,6 +374,29 @@ Expression *ArrayExp::op_overload(Scope *sc)
|
||||||
Dsymbol *fd = search_function(ad, opId());
|
Dsymbol *fd = search_function(ad, opId());
|
||||||
if (fd)
|
if (fd)
|
||||||
{
|
{
|
||||||
|
for (size_t i = 0; i < arguments->dim; i++)
|
||||||
|
{ Expression *x = arguments->tdata()[i];
|
||||||
|
// Create scope for '$' variable for this dimension
|
||||||
|
ArrayScopeSymbol *sym = new ArrayScopeSymbol(sc, this);
|
||||||
|
sym->loc = loc;
|
||||||
|
sym->parent = sc->scopesym;
|
||||||
|
sc = sc->push(sym);
|
||||||
|
lengthVar = NULL; // Create it only if required
|
||||||
|
currentDimension = i; // Dimension for $, if required
|
||||||
|
|
||||||
|
x = x->semantic(sc);
|
||||||
|
if (!x->type)
|
||||||
|
error("%s has no value", x->toChars());
|
||||||
|
if (lengthVar)
|
||||||
|
{ // If $ was used, declare it now
|
||||||
|
Expression *av = new DeclarationExp(loc, lengthVar);
|
||||||
|
x = new CommaExp(0, av, x);
|
||||||
|
x->semantic(sc);
|
||||||
|
}
|
||||||
|
arguments->tdata()[i] = x;
|
||||||
|
sc = sc->pop();
|
||||||
|
}
|
||||||
|
|
||||||
/* Rewrite op e1[arguments] as:
|
/* Rewrite op e1[arguments] as:
|
||||||
* e1.opIndex(arguments)
|
* e1.opIndex(arguments)
|
||||||
*/
|
*/
|
||||||
|
|
54
dmd2/parse.c
54
dmd2/parse.c
|
@ -266,6 +266,8 @@ Dsymbols *Parser::parseDeclDefs(int once)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!global.params.useDeprecated)
|
||||||
|
error("use of 'invariant' rather than 'immutable' is deprecated");
|
||||||
stc = STCimmutable;
|
stc = STCimmutable;
|
||||||
goto Lstc;
|
goto Lstc;
|
||||||
}
|
}
|
||||||
|
@ -407,7 +409,11 @@ Dsymbols *Parser::parseDeclDefs(int once)
|
||||||
else if (token.value == TOKwild)
|
else if (token.value == TOKwild)
|
||||||
stc = STCwild;
|
stc = STCwild;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (token.value == TOKinvariant && !global.params.useDeprecated)
|
||||||
|
error("use of 'invariant' rather than 'immutable' is deprecated");
|
||||||
stc = STCimmutable;
|
stc = STCimmutable;
|
||||||
|
}
|
||||||
goto Lstc;
|
goto Lstc;
|
||||||
case TOKfinal: stc = STCfinal; goto Lstc;
|
case TOKfinal: stc = STCfinal; goto Lstc;
|
||||||
case TOKauto: stc = STCauto; goto Lstc;
|
case TOKauto: stc = STCauto; goto Lstc;
|
||||||
|
@ -981,7 +987,8 @@ Dsymbol *Parser::parseCtor()
|
||||||
nextToken();
|
nextToken();
|
||||||
nextToken();
|
nextToken();
|
||||||
check(TOKrparen);
|
check(TOKrparen);
|
||||||
PostBlitDeclaration *f = new PostBlitDeclaration(loc, 0);
|
StorageClass stc = parsePostfix();
|
||||||
|
PostBlitDeclaration *f = new PostBlitDeclaration(loc, 0, stc);
|
||||||
parseContracts(f);
|
parseContracts(f);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -1278,6 +1285,8 @@ Parameters *Parser::parseParameters(int *pvarargs)
|
||||||
case TOKimmutable:
|
case TOKimmutable:
|
||||||
if (peek(&token)->value == TOKlparen)
|
if (peek(&token)->value == TOKlparen)
|
||||||
goto Ldefault;
|
goto Ldefault;
|
||||||
|
if (token.value == TOKinvariant && !global.params.useDeprecated)
|
||||||
|
error("use of 'invariant' rather than 'immutable' is deprecated");
|
||||||
stc = STCimmutable;
|
stc = STCimmutable;
|
||||||
goto L2;
|
goto L2;
|
||||||
|
|
||||||
|
@ -2366,7 +2375,9 @@ Type *Parser::parseBasicType()
|
||||||
check(TOKlparen);
|
check(TOKlparen);
|
||||||
t = parseType();
|
t = parseType();
|
||||||
check(TOKrparen);
|
check(TOKrparen);
|
||||||
if (t->isShared())
|
if (t->isImmutable())
|
||||||
|
;
|
||||||
|
else if (t->isShared())
|
||||||
t = t->makeSharedConst();
|
t = t->makeSharedConst();
|
||||||
else
|
else
|
||||||
t = t->makeConst();
|
t = t->makeConst();
|
||||||
|
@ -2390,7 +2401,9 @@ Type *Parser::parseBasicType()
|
||||||
check(TOKlparen);
|
check(TOKlparen);
|
||||||
t = parseType();
|
t = parseType();
|
||||||
check(TOKrparen);
|
check(TOKrparen);
|
||||||
if (t->isConst())
|
if (t->isImmutable())
|
||||||
|
;
|
||||||
|
else if (t->isConst())
|
||||||
t = t->makeSharedConst();
|
t = t->makeSharedConst();
|
||||||
else if (t->isWild())
|
else if (t->isWild())
|
||||||
t = t->makeSharedWild();
|
t = t->makeSharedWild();
|
||||||
|
@ -2404,7 +2417,9 @@ Type *Parser::parseBasicType()
|
||||||
check(TOKlparen);
|
check(TOKlparen);
|
||||||
t = parseType();
|
t = parseType();
|
||||||
check(TOKrparen);
|
check(TOKrparen);
|
||||||
if (t->isShared())
|
if (t->isImmutable()/* || t->isConst()*/)
|
||||||
|
;
|
||||||
|
else if (t->isShared())
|
||||||
t = t->makeSharedWild();
|
t = t->makeSharedWild();
|
||||||
else
|
else
|
||||||
t = t->makeWild();
|
t = t->makeWild();
|
||||||
|
@ -2511,7 +2526,7 @@ Type *Parser::parseBasicType2(Type *t)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Type *Parser::parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl, StorageClass storage_class)
|
Type *Parser::parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl, StorageClass storage_class, int* pdisable)
|
||||||
{ Type *ts;
|
{ Type *ts;
|
||||||
|
|
||||||
//printf("parseDeclarator(tpl = %p)\n", tpl);
|
//printf("parseDeclarator(tpl = %p)\n", tpl);
|
||||||
|
@ -2643,6 +2658,8 @@ Type *Parser::parseDeclarator(Type *t, Identifier **pident, TemplateParameters *
|
||||||
stc |= storage_class; // merge prefix storage classes
|
stc |= storage_class; // merge prefix storage classes
|
||||||
Type *tf = new TypeFunction(arguments, t, varargs, linkage, stc);
|
Type *tf = new TypeFunction(arguments, t, varargs, linkage, stc);
|
||||||
tf = tf->addSTC(stc);
|
tf = tf->addSTC(stc);
|
||||||
|
if (pdisable)
|
||||||
|
*pdisable = stc & STCdisable ? 1 : 0;
|
||||||
|
|
||||||
/* Insert tf into
|
/* Insert tf into
|
||||||
* ts -> ... -> t
|
* ts -> ... -> t
|
||||||
|
@ -2673,6 +2690,7 @@ Type *Parser::parseDeclarator(Type *t, Identifier **pident, TemplateParameters *
|
||||||
Dsymbols *Parser::parseDeclarations(StorageClass storage_class, unsigned char *comment)
|
Dsymbols *Parser::parseDeclarations(StorageClass storage_class, unsigned char *comment)
|
||||||
{
|
{
|
||||||
StorageClass stc;
|
StorageClass stc;
|
||||||
|
int disable;
|
||||||
Type *ts;
|
Type *ts;
|
||||||
Type *t;
|
Type *t;
|
||||||
Type *tfirst;
|
Type *tfirst;
|
||||||
|
@ -2711,6 +2729,8 @@ Dsymbols *Parser::parseDeclarations(StorageClass storage_class, unsigned char *c
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TOKtypedef:
|
case TOKtypedef:
|
||||||
|
if (!global.params.useDeprecated)
|
||||||
|
error("use of typedef is deprecated; use alias instead");
|
||||||
tok = token.value;
|
tok = token.value;
|
||||||
nextToken();
|
nextToken();
|
||||||
break;
|
break;
|
||||||
|
@ -2731,6 +2751,8 @@ Dsymbols *Parser::parseDeclarations(StorageClass storage_class, unsigned char *c
|
||||||
case TOKimmutable:
|
case TOKimmutable:
|
||||||
if (peek(&token)->value == TOKlparen)
|
if (peek(&token)->value == TOKlparen)
|
||||||
break;
|
break;
|
||||||
|
if (token.value == TOKinvariant && !global.params.useDeprecated)
|
||||||
|
error("use of 'invariant' rather than 'immutable' is deprecated");
|
||||||
stc = STCimmutable;
|
stc = STCimmutable;
|
||||||
goto L1;
|
goto L1;
|
||||||
|
|
||||||
|
@ -2814,7 +2836,11 @@ Dsymbols *Parser::parseDeclarations(StorageClass storage_class, unsigned char *c
|
||||||
token.value == TOKidentifier &&
|
token.value == TOKidentifier &&
|
||||||
(tk = peek(&token))->value == TOKlparen &&
|
(tk = peek(&token))->value == TOKlparen &&
|
||||||
skipParens(tk, &tk) &&
|
skipParens(tk, &tk) &&
|
||||||
peek(tk)->value == TOKlparen)
|
((tk = peek(tk)), 1) &&
|
||||||
|
skipAttributes(tk, &tk) &&
|
||||||
|
(tk->value == TOKlparen ||
|
||||||
|
tk->value == TOKlcurly)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
ts = NULL;
|
ts = NULL;
|
||||||
}
|
}
|
||||||
|
@ -2835,7 +2861,7 @@ L2:
|
||||||
TemplateParameters *tpl = NULL;
|
TemplateParameters *tpl = NULL;
|
||||||
|
|
||||||
ident = NULL;
|
ident = NULL;
|
||||||
t = parseDeclarator(ts, &ident, &tpl, storage_class);
|
t = parseDeclarator(ts, &ident, &tpl, storage_class, &disable);
|
||||||
assert(t);
|
assert(t);
|
||||||
if (!tfirst)
|
if (!tfirst)
|
||||||
tfirst = t;
|
tfirst = t;
|
||||||
|
@ -2855,7 +2881,10 @@ L2:
|
||||||
init = parseInitializer();
|
init = parseInitializer();
|
||||||
}
|
}
|
||||||
if (tok == TOKtypedef)
|
if (tok == TOKtypedef)
|
||||||
v = new TypedefDeclaration(loc, ident, t, init);
|
{ v = new TypedefDeclaration(loc, ident, t, init);
|
||||||
|
if (!global.params.useDeprecated)
|
||||||
|
error("use of typedef is deprecated; use alias instead");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ if (init)
|
{ if (init)
|
||||||
error("alias cannot have initializer");
|
error("alias cannot have initializer");
|
||||||
|
@ -2902,7 +2931,7 @@ L2:
|
||||||
//printf("%s funcdecl t = %s, storage_class = x%lx\n", loc.toChars(), t->toChars(), storage_class);
|
//printf("%s funcdecl t = %s, storage_class = x%lx\n", loc.toChars(), t->toChars(), storage_class);
|
||||||
|
|
||||||
FuncDeclaration *f =
|
FuncDeclaration *f =
|
||||||
new FuncDeclaration(loc, 0, ident, storage_class, t);
|
new FuncDeclaration(loc, 0, ident, storage_class | (disable ? STCdisable : 0), t);
|
||||||
addComment(f, comment);
|
addComment(f, comment);
|
||||||
if (tpl)
|
if (tpl)
|
||||||
constraint = parseConstraint();
|
constraint = parseConstraint();
|
||||||
|
@ -5031,7 +5060,8 @@ int Parser::skipAttributes(Token *t, Token **pt)
|
||||||
//case TOKmanifest:
|
//case TOKmanifest:
|
||||||
break;
|
break;
|
||||||
case TOKat:
|
case TOKat:
|
||||||
if (parseAttribute() == STCundefined)
|
t = peek(t);
|
||||||
|
if (t->value == TOKidentifier)
|
||||||
break;
|
break;
|
||||||
goto Lerror;
|
goto Lerror;
|
||||||
default:
|
default:
|
||||||
|
@ -5335,6 +5365,8 @@ Expression *Parser::parsePrimaryExp()
|
||||||
token.value == TOKdelegate ||
|
token.value == TOKdelegate ||
|
||||||
token.value == TOKreturn))
|
token.value == TOKreturn))
|
||||||
{
|
{
|
||||||
|
if (token.value == TOKinvariant && !global.params.useDeprecated)
|
||||||
|
error("use of 'invariant' rather than 'immutable' is deprecated");
|
||||||
tok2 = token.value;
|
tok2 = token.value;
|
||||||
nextToken();
|
nextToken();
|
||||||
}
|
}
|
||||||
|
@ -5708,6 +5740,8 @@ Expression *Parser::parseUnaryExp()
|
||||||
}
|
}
|
||||||
else if ((token.value == TOKimmutable || token.value == TOKinvariant) && peekNext() == TOKrparen)
|
else if ((token.value == TOKimmutable || token.value == TOKinvariant) && peekNext() == TOKrparen)
|
||||||
{
|
{
|
||||||
|
if (token.value == TOKinvariant && !global.params.useDeprecated)
|
||||||
|
error("use of 'invariant' rather than 'immutable' is deprecated");
|
||||||
m = MODimmutable;
|
m = MODimmutable;
|
||||||
goto Lmod2;
|
goto Lmod2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ struct Parser : Lexer
|
||||||
Type *parseType(Identifier **pident = NULL, TemplateParameters **tpl = NULL);
|
Type *parseType(Identifier **pident = NULL, TemplateParameters **tpl = NULL);
|
||||||
Type *parseBasicType();
|
Type *parseBasicType();
|
||||||
Type *parseBasicType2(Type *t);
|
Type *parseBasicType2(Type *t);
|
||||||
Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL, StorageClass storage_class = 0);
|
Type *parseDeclarator(Type *t, Identifier **pident, TemplateParameters **tpl = NULL, StorageClass storage_class = 0, int* pdisable = NULL);
|
||||||
Dsymbols *parseDeclarations(StorageClass storage_class, unsigned char *comment);
|
Dsymbols *parseDeclarations(StorageClass storage_class, unsigned char *comment);
|
||||||
void parseContracts(FuncDeclaration *f);
|
void parseContracts(FuncDeclaration *f);
|
||||||
void checkDanglingElse(Loc elseloc);
|
void checkDanglingElse(Loc elseloc);
|
||||||
|
|
|
@ -449,6 +449,12 @@ Statement *CompileStatement::semantic(Scope *sc)
|
||||||
return s->semantic(sc);
|
return s->semantic(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CompileStatement::blockExit(bool mustNotThrow)
|
||||||
|
{
|
||||||
|
assert(global.errors);
|
||||||
|
return BEfallthru;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************** CompoundStatement ***************************/
|
/******************************** CompoundStatement ***************************/
|
||||||
|
|
||||||
|
@ -1493,6 +1499,7 @@ Lretry:
|
||||||
{ // Declare key
|
{ // Declare key
|
||||||
if (arg->storageClass & (STCout | STCref | STClazy))
|
if (arg->storageClass & (STCout | STCref | STClazy))
|
||||||
error("no storage class for key %s", arg->ident->toChars());
|
error("no storage class for key %s", arg->ident->toChars());
|
||||||
|
arg->type = arg->type->semantic(loc, sc);
|
||||||
TY keyty = arg->type->ty;
|
TY keyty = arg->type->ty;
|
||||||
if (keyty != Tint32 && keyty != Tuns32)
|
if (keyty != Tint32 && keyty != Tuns32)
|
||||||
{
|
{
|
||||||
|
@ -3707,9 +3714,26 @@ Statement *ReturnStatement::semantic(Scope *sc)
|
||||||
Type *tfret = tf->nextOf();
|
Type *tfret = tf->nextOf();
|
||||||
if (tfret)
|
if (tfret)
|
||||||
{
|
{
|
||||||
if (tfret != Type::terror && !exp->type->equals(tfret))
|
if (tfret != Type::terror)
|
||||||
error("mismatched function return type inference of %s and %s",
|
{
|
||||||
exp->type->toChars(), tfret->toChars());
|
if (!exp->type->equals(tfret))
|
||||||
|
{
|
||||||
|
int m1 = exp->type->implicitConvTo(tfret);
|
||||||
|
int m2 = tfret->implicitConvTo(exp->type);
|
||||||
|
//printf("exp->type = %s m2<-->m1 tret %s\n", exp->type->toChars(), tfret->toChars());
|
||||||
|
//printf("m1 = %d, m2 = %d\n", m1, m2);
|
||||||
|
|
||||||
|
if (m1 && m2)
|
||||||
|
;
|
||||||
|
else if (!m1 && m2)
|
||||||
|
tf->next = exp->type;
|
||||||
|
else if (m1 && !m2)
|
||||||
|
;
|
||||||
|
else
|
||||||
|
error("mismatched function return type inference of %s and %s",
|
||||||
|
exp->type->toChars(), tfret->toChars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* The "refness" is determined by the first return statement,
|
/* The "refness" is determined by the first return statement,
|
||||||
* not all of them. This means:
|
* not all of them. This means:
|
||||||
|
@ -3739,7 +3763,7 @@ Statement *ReturnStatement::semantic(Scope *sc)
|
||||||
tf->isref = FALSE; // return by value
|
tf->isref = FALSE; // return by value
|
||||||
}
|
}
|
||||||
tf->next = exp->type;
|
tf->next = exp->type;
|
||||||
fd->type = tf->semantic(loc, sc);
|
//fd->type = tf->semantic(loc, sc); // Removed with 6902
|
||||||
if (!fd->tintro)
|
if (!fd->tintro)
|
||||||
{ tret = fd->type->nextOf();
|
{ tret = fd->type->nextOf();
|
||||||
tbret = tret->toBasetype();
|
tbret = tret->toBasetype();
|
||||||
|
@ -3755,6 +3779,8 @@ Statement *ReturnStatement::semantic(Scope *sc)
|
||||||
exp = exp->castTo(sc, exp->type->invariantOf());
|
exp = exp->castTo(sc, exp->type->invariantOf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fd->tintro)
|
||||||
|
exp = exp->implicitCastTo(sc, fd->type->nextOf());
|
||||||
exp = exp->implicitCastTo(sc, tret);
|
exp = exp->implicitCastTo(sc, tret);
|
||||||
if (!((TypeFunction *)fd->type)->isref)
|
if (!((TypeFunction *)fd->type)->isref)
|
||||||
exp = exp->optimize(WANTvalue);
|
exp = exp->optimize(WANTvalue);
|
||||||
|
|
|
@ -211,6 +211,7 @@ struct CompileStatement : Statement
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
Statements *flatten(Scope *sc);
|
Statements *flatten(Scope *sc);
|
||||||
Statement *semantic(Scope *sc);
|
Statement *semantic(Scope *sc);
|
||||||
|
int blockExit(bool mustNotThrow);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompoundStatement : Statement
|
struct CompoundStatement : Statement
|
||||||
|
|
239
dmd2/template.c
239
dmd2/template.c
|
@ -766,7 +766,25 @@ MATCH TemplateDeclaration::matchWithInstance(TemplateInstance *ti,
|
||||||
Expression *e = constraint->syntaxCopy();
|
Expression *e = constraint->syntaxCopy();
|
||||||
Scope *sc = paramscope->push();
|
Scope *sc = paramscope->push();
|
||||||
sc->flags |= SCOPEstaticif;
|
sc->flags |= SCOPEstaticif;
|
||||||
|
|
||||||
|
FuncDeclaration *fd = onemember && onemember->toAlias() ?
|
||||||
|
onemember->toAlias()->isFuncDeclaration() : NULL;
|
||||||
|
Dsymbol *s = parent;
|
||||||
|
while (s->isTemplateInstance() || s->isTemplateMixin())
|
||||||
|
s = s->parent;
|
||||||
|
AggregateDeclaration *ad = s->isAggregateDeclaration();
|
||||||
|
VarDeclaration *vthissave;
|
||||||
|
if (fd && ad)
|
||||||
|
{
|
||||||
|
vthissave = fd->vthis;
|
||||||
|
fd->vthis = fd->declareThis(paramscope, ad);
|
||||||
|
}
|
||||||
|
|
||||||
e = e->semantic(sc);
|
e = e->semantic(sc);
|
||||||
|
|
||||||
|
if (fd && fd->vthis)
|
||||||
|
fd->vthis = vthissave;
|
||||||
|
|
||||||
sc->pop();
|
sc->pop();
|
||||||
e = e->optimize(WANTvalue | WANTinterpret);
|
e = e->optimize(WANTvalue | WANTinterpret);
|
||||||
if (e->isBool(TRUE))
|
if (e->isBool(TRUE))
|
||||||
|
@ -924,7 +942,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
printf("\nTemplateDeclaration::deduceFunctionTemplateMatch() %s\n", toChars());
|
printf("\nTemplateDeclaration::deduceFunctionTemplateMatch() %s\n", toChars());
|
||||||
for (i = 0; i < fargs->dim; i++)
|
for (size_t i = 0; i < fargs->dim; i++)
|
||||||
{ Expression *e = fargs->tdata()[i];
|
{ Expression *e = fargs->tdata()[i];
|
||||||
printf("\tfarg[%d] is %s, type is %s\n", i, e->toChars(), e->type->toChars());
|
printf("\tfarg[%d] is %s, type is %s\n", i, e->toChars(), e->type->toChars());
|
||||||
}
|
}
|
||||||
|
@ -1188,7 +1206,9 @@ L2:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ Expression *farg = fargs->tdata()[i];
|
{
|
||||||
|
Expression *farg = fargs->tdata()[i];
|
||||||
|
Lretry:
|
||||||
#if 0
|
#if 0
|
||||||
printf("\tfarg->type = %s\n", farg->type->toChars());
|
printf("\tfarg->type = %s\n", farg->type->toChars());
|
||||||
printf("\tfparam->type = %s\n", fparam->type->toChars());
|
printf("\tfparam->type = %s\n", fparam->type->toChars());
|
||||||
|
@ -1208,6 +1228,14 @@ L2:
|
||||||
argtype = argtype->invariantOf();
|
argtype = argtype->invariantOf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove top const for dynamic array types and pointer types
|
||||||
|
*/
|
||||||
|
if ((argtype->ty == Tarray || argtype->ty == Tpointer) &&
|
||||||
|
!argtype->isMutable())
|
||||||
|
{
|
||||||
|
argtype = argtype->mutableOf();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MATCH m;
|
MATCH m;
|
||||||
|
@ -1219,18 +1247,41 @@ L2:
|
||||||
|
|
||||||
/* If no match, see if there's a conversion to a delegate
|
/* If no match, see if there's a conversion to a delegate
|
||||||
*/
|
*/
|
||||||
if (!m && fparam->type->toBasetype()->ty == Tdelegate)
|
if (!m)
|
||||||
{
|
{ Type *tbp = fparam->type->toBasetype();
|
||||||
TypeDelegate *td = (TypeDelegate *)fparam->type->toBasetype();
|
Type *tba = farg->type->toBasetype();
|
||||||
TypeFunction *tf = (TypeFunction *)td->next;
|
AggregateDeclaration *ad;
|
||||||
|
if (tbp->ty == Tdelegate)
|
||||||
if (!tf->varargs && Parameter::dim(tf->parameters) == 0)
|
|
||||||
{
|
{
|
||||||
m = farg->type->deduceType(paramscope, tf->next, parameters, &dedtypes);
|
TypeDelegate *td = (TypeDelegate *)fparam->type->toBasetype();
|
||||||
if (!m && tf->next->toBasetype()->ty == Tvoid)
|
TypeFunction *tf = (TypeFunction *)td->next;
|
||||||
m = MATCHconvert;
|
|
||||||
|
if (!tf->varargs && Parameter::dim(tf->parameters) == 0)
|
||||||
|
{
|
||||||
|
m = farg->type->deduceType(paramscope, tf->next, parameters, &dedtypes);
|
||||||
|
if (!m && tf->next->toBasetype()->ty == Tvoid)
|
||||||
|
m = MATCHconvert;
|
||||||
|
}
|
||||||
|
//printf("\tm2 = %d\n", m);
|
||||||
|
}
|
||||||
|
else if (tba->ty == Tclass)
|
||||||
|
{
|
||||||
|
ad = ((TypeClass *)tba)->sym;
|
||||||
|
goto Lad;
|
||||||
|
}
|
||||||
|
else if (tba->ty == Tstruct)
|
||||||
|
{
|
||||||
|
ad = ((TypeStruct *)tba)->sym;
|
||||||
|
Lad:
|
||||||
|
if (ad->aliasthis)
|
||||||
|
{
|
||||||
|
Expression *e = new DotIdExp(farg->loc, farg, ad->aliasthis->ident);
|
||||||
|
e = e->semantic(sc);
|
||||||
|
e = resolveProperties(sc, e);
|
||||||
|
farg = e;
|
||||||
|
goto Lretry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//printf("\tm2 = %d\n", m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m)
|
if (m)
|
||||||
|
@ -1399,8 +1450,24 @@ Lmatch:
|
||||||
|
|
||||||
int nerrors = global.errors;
|
int nerrors = global.errors;
|
||||||
|
|
||||||
|
FuncDeclaration *fd = onemember && onemember->toAlias() ?
|
||||||
|
onemember->toAlias()->isFuncDeclaration() : NULL;
|
||||||
|
Dsymbol *s = parent;
|
||||||
|
while (s->isTemplateInstance() || s->isTemplateMixin())
|
||||||
|
s = s->parent;
|
||||||
|
AggregateDeclaration *ad = s->isAggregateDeclaration();
|
||||||
|
VarDeclaration *vthissave;
|
||||||
|
if (fd && ad)
|
||||||
|
{
|
||||||
|
vthissave = fd->vthis;
|
||||||
|
fd->vthis = fd->declareThis(paramscope, ad);
|
||||||
|
}
|
||||||
|
|
||||||
e = e->semantic(paramscope);
|
e = e->semantic(paramscope);
|
||||||
|
|
||||||
|
if (fd && fd->vthis)
|
||||||
|
fd->vthis = vthissave;
|
||||||
|
|
||||||
previous = pr.prev; // unlink from threaded list
|
previous = pr.prev; // unlink from threaded list
|
||||||
|
|
||||||
if (nerrors != global.errors) // if any errors from evaluating the constraint, no match
|
if (nerrors != global.errors) // if any errors from evaluating the constraint, no match
|
||||||
|
@ -1682,6 +1749,11 @@ FuncDeclaration *TemplateDeclaration::deduceFunctionTemplate(Scope *sc, Loc loc,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TemplateDeclaration::hasStaticCtorOrDtor()
|
||||||
|
{
|
||||||
|
return FALSE; // don't scan uninstantiated templates
|
||||||
|
}
|
||||||
|
|
||||||
void TemplateDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
void TemplateDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||||
{
|
{
|
||||||
#if 0 // Should handle template functions for doc generation
|
#if 0 // Should handle template functions for doc generation
|
||||||
|
@ -2107,33 +2179,23 @@ MATCH TypeSArray::deduceType(Scope *sc, Type *tparam, TemplateParameters *parame
|
||||||
// Extra check that array dimensions must match
|
// Extra check that array dimensions must match
|
||||||
if (tparam)
|
if (tparam)
|
||||||
{
|
{
|
||||||
|
if (tparam->ty == Tarray)
|
||||||
|
{ MATCH m;
|
||||||
|
|
||||||
|
m = next->deduceType(sc, tparam->nextOf(), parameters, dedtypes, wildmatch);
|
||||||
|
if (m == MATCHexact)
|
||||||
|
m = MATCHconvert;
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
Identifier *id = NULL;
|
||||||
if (tparam->ty == Tsarray)
|
if (tparam->ty == Tsarray)
|
||||||
{
|
{
|
||||||
TypeSArray *tp = (TypeSArray *)tparam;
|
TypeSArray *tp = (TypeSArray *)tparam;
|
||||||
|
|
||||||
if (tp->dim->op == TOKvar &&
|
if (tp->dim->op == TOKvar &&
|
||||||
((VarExp *)tp->dim)->var->storage_class & STCtemplateparameter)
|
((VarExp *)tp->dim)->var->storage_class & STCtemplateparameter)
|
||||||
{ int i = templateIdentifierLookup(((VarExp *)tp->dim)->var->ident, parameters);
|
{
|
||||||
// This code matches code in TypeInstance::deduceType()
|
id = ((VarExp *)tp->dim)->var->ident;
|
||||||
if (i == -1)
|
|
||||||
goto Lnomatch;
|
|
||||||
TemplateParameter *tp = parameters->tdata()[i];
|
|
||||||
TemplateValueParameter *tvp = tp->isTemplateValueParameter();
|
|
||||||
if (!tvp)
|
|
||||||
goto Lnomatch;
|
|
||||||
Expression *e = (Expression *)dedtypes->tdata()[i];
|
|
||||||
if (e)
|
|
||||||
{
|
|
||||||
if (!dim->equals(e))
|
|
||||||
goto Lnomatch;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ Type *vt = tvp->valType->semantic(0, sc);
|
|
||||||
MATCH m = (MATCH)dim->implicitConvTo(vt);
|
|
||||||
if (!m)
|
|
||||||
goto Lnomatch;
|
|
||||||
dedtypes->tdata()[i] = dim;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (dim->toInteger() != tp->dim->toInteger())
|
else if (dim->toInteger() != tp->dim->toInteger())
|
||||||
return MATCHnomatch;
|
return MATCHnomatch;
|
||||||
|
@ -2141,43 +2203,37 @@ MATCH TypeSArray::deduceType(Scope *sc, Type *tparam, TemplateParameters *parame
|
||||||
else if (tparam->ty == Taarray)
|
else if (tparam->ty == Taarray)
|
||||||
{
|
{
|
||||||
TypeAArray *tp = (TypeAArray *)tparam;
|
TypeAArray *tp = (TypeAArray *)tparam;
|
||||||
if (tp->index->ty == Tident)
|
if (tp->index->ty == Tident &&
|
||||||
{ TypeIdentifier *tident = (TypeIdentifier *)tp->index;
|
((TypeIdentifier *)tp->index)->idents.dim == 0)
|
||||||
|
{
|
||||||
if (tident->idents.dim == 0)
|
id = ((TypeIdentifier *)tp->index)->ident;
|
||||||
{ Identifier *id = tident->ident;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < parameters->dim; i++)
|
|
||||||
{
|
|
||||||
TemplateParameter *tp = parameters->tdata()[i];
|
|
||||||
|
|
||||||
if (tp->ident->equals(id))
|
|
||||||
{ // Found the corresponding template parameter
|
|
||||||
TemplateValueParameter *tvp = tp->isTemplateValueParameter();
|
|
||||||
if (!tvp || !tvp->valType->isintegral())
|
|
||||||
goto Lnomatch;
|
|
||||||
|
|
||||||
if (dedtypes->tdata()[i])
|
|
||||||
{
|
|
||||||
if (!dim->equals(dedtypes->tdata()[i]))
|
|
||||||
goto Lnomatch;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ dedtypes->tdata()[i] = dim;
|
|
||||||
}
|
|
||||||
return next->deduceType(sc, tparam->nextOf(), parameters, dedtypes, wildmatch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tparam->ty == Tarray)
|
if (id)
|
||||||
{ MATCH m;
|
{
|
||||||
|
// This code matches code in TypeInstance::deduceType()
|
||||||
m = next->deduceType(sc, tparam->nextOf(), parameters, dedtypes, wildmatch);
|
int i = templateIdentifierLookup(id, parameters);
|
||||||
if (m == MATCHexact)
|
if (i == -1)
|
||||||
m = MATCHconvert;
|
goto Lnomatch;
|
||||||
return m;
|
TemplateParameter *tprm = parameters->tdata()[i];
|
||||||
|
TemplateValueParameter *tvp = tprm->isTemplateValueParameter();
|
||||||
|
if (!tvp)
|
||||||
|
goto Lnomatch;
|
||||||
|
Expression *e = (Expression *)dedtypes->tdata()[i];
|
||||||
|
if (e)
|
||||||
|
{
|
||||||
|
if (!dim->equals(e))
|
||||||
|
goto Lnomatch;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Type *vt = tvp->valType->semantic(0, sc);
|
||||||
|
MATCH m = (MATCH)dim->implicitConvTo(vt);
|
||||||
|
if (!m)
|
||||||
|
goto Lnomatch;
|
||||||
|
dedtypes->tdata()[i] = dim;
|
||||||
|
}
|
||||||
|
return next->deduceType(sc, tparam->nextOf(), parameters, dedtypes, wildmatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Type::deduceType(sc, tparam, parameters, dedtypes, wildmatch);
|
return Type::deduceType(sc, tparam, parameters, dedtypes, wildmatch);
|
||||||
|
@ -2228,6 +2284,7 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para
|
||||||
{
|
{
|
||||||
Parameter *fparam = Parameter::getNth(tp->parameters, i);
|
Parameter *fparam = Parameter::getNth(tp->parameters, i);
|
||||||
fparam->type = fparam->type->addStorageClass(fparam->storageClass);
|
fparam->type = fparam->type->addStorageClass(fparam->storageClass);
|
||||||
|
fparam->storageClass &= ~(STC_TYPECTOR | STCin);
|
||||||
}
|
}
|
||||||
//printf("\t-> this = %d, ", ty); print();
|
//printf("\t-> this = %d, ", ty); print();
|
||||||
//printf("\t-> tparam = %d, ", tparam->ty); tparam->print();
|
//printf("\t-> tparam = %d, ", tparam->ty); tparam->print();
|
||||||
|
@ -3490,6 +3547,19 @@ MATCH TemplateValueParameter::matchArg(Scope *sc,
|
||||||
ei = ei->optimize(WANTvalue | WANTinterpret);
|
ei = ei->optimize(WANTvalue | WANTinterpret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("\tvalType: %s, ty = %d\n", valType->toChars(), valType->ty);
|
||||||
|
vt = valType->semantic(0, sc);
|
||||||
|
//printf("ei: %s, ei->type: %s\n", ei->toChars(), ei->type->toChars());
|
||||||
|
//printf("vt = %s\n", vt->toChars());
|
||||||
|
|
||||||
|
if (ei->type)
|
||||||
|
{
|
||||||
|
m = (MATCH)ei->implicitConvTo(vt);
|
||||||
|
//printf("m: %d\n", m);
|
||||||
|
if (!m)
|
||||||
|
goto Lnomatch;
|
||||||
|
}
|
||||||
|
|
||||||
if (specValue)
|
if (specValue)
|
||||||
{
|
{
|
||||||
if (!ei || ei == edummy)
|
if (!ei || ei == edummy)
|
||||||
|
@ -3504,6 +3574,7 @@ MATCH TemplateValueParameter::matchArg(Scope *sc,
|
||||||
|
|
||||||
ei = ei->syntaxCopy();
|
ei = ei->syntaxCopy();
|
||||||
ei = ei->semantic(sc);
|
ei = ei->semantic(sc);
|
||||||
|
ei = ei->implicitCastTo(sc, vt);
|
||||||
ei = ei->optimize(WANTvalue | WANTinterpret);
|
ei = ei->optimize(WANTvalue | WANTinterpret);
|
||||||
//ei->type = ei->type->toHeadMutable();
|
//ei->type = ei->type->toHeadMutable();
|
||||||
//printf("\tei: %s, %s\n", ei->toChars(), ei->type->toChars());
|
//printf("\tei: %s, %s\n", ei->toChars(), ei->type->toChars());
|
||||||
|
@ -3511,24 +3582,20 @@ MATCH TemplateValueParameter::matchArg(Scope *sc,
|
||||||
if (!ei->equals(e))
|
if (!ei->equals(e))
|
||||||
goto Lnomatch;
|
goto Lnomatch;
|
||||||
}
|
}
|
||||||
else if (dedtypes->tdata()[i])
|
else
|
||||||
{ // Must match already deduced value
|
|
||||||
Expression *e = (Expression *)dedtypes->tdata()[i];
|
|
||||||
|
|
||||||
if (!ei || !ei->equals(e))
|
|
||||||
goto Lnomatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
//printf("\tvalType: %s, ty = %d\n", valType->toChars(), valType->ty);
|
|
||||||
vt = valType->semantic(0, sc);
|
|
||||||
//printf("ei: %s, ei->type: %s\n", ei->toChars(), ei->type->toChars());
|
|
||||||
//printf("vt = %s\n", vt->toChars());
|
|
||||||
if (ei->type)
|
|
||||||
{
|
{
|
||||||
m = (MATCH)ei->implicitConvTo(vt);
|
if (dedtypes->tdata()[i])
|
||||||
//printf("m: %d\n", m);
|
{ // Must match already deduced value
|
||||||
if (!m)
|
Expression *e = (Expression *)dedtypes->tdata()[i];
|
||||||
goto Lnomatch;
|
|
||||||
|
if (!ei || !ei->equals(e))
|
||||||
|
goto Lnomatch;
|
||||||
|
}
|
||||||
|
else if (m != MATCHexact)
|
||||||
|
{
|
||||||
|
ei = ei->implicitCastTo(sc, vt);
|
||||||
|
ei = ei->optimize(WANTvalue | WANTinterpret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dedtypes->tdata()[i] = ei;
|
dedtypes->tdata()[i] = ei;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
// Compiler implementation of the D programming language
|
// Compiler implementation of the D programming language
|
||||||
// Copyright (c) 1999-2010 by Digital Mars
|
// Copyright (c) 1999-2011 by Digital Mars
|
||||||
// All Rights Reserved
|
// All Rights Reserved
|
||||||
// written by Walter Bright
|
// written by Walter Bright
|
||||||
// http://www.digitalmars.com
|
// http://www.digitalmars.com
|
||||||
|
@ -81,6 +81,7 @@ struct TemplateDeclaration : ScopeDsymbol
|
||||||
void semantic(Scope *sc);
|
void semantic(Scope *sc);
|
||||||
int overloadInsert(Dsymbol *s);
|
int overloadInsert(Dsymbol *s);
|
||||||
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
|
||||||
|
bool hasStaticCtorOrDtor();
|
||||||
const char *kind();
|
const char *kind();
|
||||||
char *toChars();
|
char *toChars();
|
||||||
|
|
||||||
|
|
|
@ -258,9 +258,21 @@ Expression *TraitsExp::semantic(Scope *sc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ident == Id::hasMember)
|
if (ident == Id::hasMember)
|
||||||
{ /* Take any errors as meaning it wasn't found
|
{
|
||||||
|
if (t)
|
||||||
|
{
|
||||||
|
Dsymbol *sym = t->toDsymbol(sc);
|
||||||
|
Dsymbol *sm = sym->search(loc, id, 0);
|
||||||
|
if (sm)
|
||||||
|
goto Ltrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Take any errors as meaning it wasn't found
|
||||||
*/
|
*/
|
||||||
e = e->trySemantic(sc);
|
Scope *sc2 = sc->push();
|
||||||
|
//sc2->inHasMember++;
|
||||||
|
e = e->trySemantic(sc2);
|
||||||
|
sc2->pop();
|
||||||
if (!e)
|
if (!e)
|
||||||
{ if (global.gag)
|
{ if (global.gag)
|
||||||
{
|
{
|
||||||
|
@ -344,40 +356,56 @@ Expression *TraitsExp::semantic(Scope *sc)
|
||||||
error("%s %s has no members", s->kind(), s->toChars());
|
error("%s %s has no members", s->kind(), s->toChars());
|
||||||
goto Lfalse;
|
goto Lfalse;
|
||||||
}
|
}
|
||||||
Expressions *exps = new Expressions;
|
|
||||||
while (1)
|
// use a struct as local function
|
||||||
{ size_t sddim = ScopeDsymbol::dim(sd->members);
|
struct PushIdentsDg
|
||||||
for (size_t i = 0; i < sddim; i++)
|
{
|
||||||
|
static int dg(void *ctx, size_t n, Dsymbol *sm)
|
||||||
{
|
{
|
||||||
Dsymbol *sm = ScopeDsymbol::getNth(sd->members, i);
|
|
||||||
if (!sm)
|
if (!sm)
|
||||||
break;
|
return 1;
|
||||||
//printf("\t[%i] %s %s\n", i, sm->kind(), sm->toChars());
|
//printf("\t[%i] %s %s\n", i, sm->kind(), sm->toChars());
|
||||||
if (sm->ident)
|
if (sm->ident)
|
||||||
{
|
{
|
||||||
//printf("\t%s\n", sm->ident->toChars());
|
//printf("\t%s\n", sm->ident->toChars());
|
||||||
char *str = sm->ident->toChars();
|
Identifiers *idents = (Identifiers *)ctx;
|
||||||
|
|
||||||
/* Skip if already present in exps[]
|
/* Skip if already present in idents[]
|
||||||
*/
|
*/
|
||||||
for (size_t j = 0; j < exps->dim; j++)
|
for (size_t j = 0; j < idents->dim; j++)
|
||||||
{ StringExp *se2 = (StringExp *)exps->tdata()[j];
|
{ Identifier *id = idents->tdata()[j];
|
||||||
if (strcmp(str, (char *)se2->string) == 0)
|
if (id == sm->ident)
|
||||||
goto Lnext;
|
return 0;
|
||||||
|
#ifdef DEBUG
|
||||||
|
// Avoid using strcmp in the first place due to the performance impact in an O(N^2) loop.
|
||||||
|
assert(strcmp(id->toChars(), sm->ident->toChars()) != 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
StringExp *se = new StringExp(loc, str);
|
idents->push(sm->ident);
|
||||||
exps->push(se);
|
|
||||||
}
|
}
|
||||||
Lnext:
|
return 0;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
ClassDeclaration *cd = sd->isClassDeclaration();
|
};
|
||||||
if (cd && cd->baseClass && ident == Id::allMembers)
|
|
||||||
sd = cd->baseClass; // do again with base class
|
Identifiers *idents = new Identifiers;
|
||||||
else
|
ScopeDsymbol::foreach(sd->members, &PushIdentsDg::dg, idents);
|
||||||
break;
|
|
||||||
|
ClassDeclaration *cd = sd->isClassDeclaration();
|
||||||
|
if (cd && cd->baseClass && ident == Id::allMembers)
|
||||||
|
{ sd = cd->baseClass; // do again with base class
|
||||||
|
ScopeDsymbol::foreach(sd->members, &PushIdentsDg::dg, idents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Turn Identifiers into StringExps reusing the allocated array
|
||||||
|
assert(sizeof(Expressions) == sizeof(Identifiers));
|
||||||
|
Expressions *exps = (Expressions *)idents;
|
||||||
|
for (size_t i = 0; i < idents->dim; i++)
|
||||||
|
{ Identifier *id = idents->tdata()[i];
|
||||||
|
StringExp *se = new StringExp(loc, id->toChars());
|
||||||
|
exps->tdata()[i] = se;
|
||||||
|
}
|
||||||
|
|
||||||
#if DMDV1
|
#if DMDV1
|
||||||
Expression *e = new ArrayLiteralExp(loc, exps);
|
Expression *e = new ArrayLiteralExp(loc, exps);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -306,10 +306,13 @@ void DtoResolveFunction(FuncDeclaration* fdecl)
|
||||||
if (fdecl->ir.resolved) return;
|
if (fdecl->ir.resolved) return;
|
||||||
fdecl->ir.resolved = true;
|
fdecl->ir.resolved = true;
|
||||||
|
|
||||||
// If errors occurred compiling it, such as bugzilla 6118
|
|
||||||
Type *type = fdecl->type;
|
Type *type = fdecl->type;
|
||||||
if (type && type->ty == Tfunction && ((TypeFunction *)type)->next->ty == Terror)
|
// If errors occurred compiling it, such as bugzilla 6118
|
||||||
return;
|
if (type && type->ty == Tfunction) {
|
||||||
|
Type *next = ((TypeFunction *)type)->next;
|
||||||
|
if (!next || next->ty == Terror)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//printf("resolve function: %s\n", fdecl->toPrettyChars());
|
//printf("resolve function: %s\n", fdecl->toPrettyChars());
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 24e79c6c38b4cfc9aca1d3583a1c0fffc102c9ce
|
Subproject commit 10e4512f453fcafde9448a41c672ee7315229963
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2bebc8f8ba261b41fb0252b225232b8f46051b57
|
Subproject commit 1f6264e94236e5cd20d211e136f05a88cb536b00
|
Loading…
Add table
Add a link
Reference in a new issue