Skip to content

Commit

Permalink
Merge pull request #2010 from yebblies/loc0
Browse files Browse the repository at this point in the history
[DDMD] Do not use implicit conversion from 0 to Loc
  • Loading branch information
MartinNowak committed May 11, 2013
2 parents 1215bc3 + ddcd0c2 commit 604650e
Show file tree
Hide file tree
Showing 40 changed files with 369 additions and 375 deletions.
8 changes: 4 additions & 4 deletions src/argtypes.c
Expand Up @@ -220,8 +220,8 @@ Type *argtypemerge(Type *t1, Type *t2, unsigned offset2)
if (!t2)
return t1;

unsigned sz1 = t1->size(0);
unsigned sz2 = t2->size(0);
unsigned sz1 = t1->size(Loc());
unsigned sz2 = t2->size(Loc());

if (t1->ty != t2->ty &&
(t1->ty == Tfloat80 || t2->ty == Tfloat80))
Expand Down Expand Up @@ -284,7 +284,7 @@ TypeTuple *TypeStruct::toArgTypes()
}
Type *t1 = NULL;
Type *t2 = NULL;
d_uns64 sz = size(0);
d_uns64 sz = size(Loc());
assert(sz < 0xFFFFFFFF);
switch ((unsigned)sz)
{
Expand Down Expand Up @@ -346,7 +346,7 @@ TypeTuple *TypeStruct::toArgTypes()
goto Lmemory;

// Fields that overlap the 8byte boundary goto Lmemory
unsigned fieldsz = f->type->size(0);
unsigned fieldsz = f->type->size(Loc());
if (f->offset < 8 && (f->offset + fieldsz) > 8)
goto Lmemory;
}
Expand Down
44 changes: 22 additions & 22 deletions src/arrayop.c
Expand Up @@ -322,30 +322,30 @@ Expression *BinExp::arrayOp(Scope *sc)
Parameter *p = (*fparams)[0 /*fparams->dim - 1*/];
#if DMDV1
// for (size_t i = 0; i < p.length; i++)
Initializer *init = new ExpInitializer(0, new IntegerExp(0, 0, Type::tsize_t));
Initializer *init = new ExpInitializer(Loc(), new IntegerExp(Loc(), 0, Type::tsize_t));
Dsymbol *d = new VarDeclaration(0, Type::tsize_t, Id::p, init);
Statement *s1 = new ForStatement(0,
new ExpStatement(0, d),
new CmpExp(TOKlt, 0, new IdentifierExp(0, Id::p), new ArrayLengthExp(0, new IdentifierExp(0, p->ident))),
new PostExp(TOKplusplus, 0, new IdentifierExp(0, Id::p)),
new ExpStatement(0, loopbody));
new ExpStatement(Loc(), d),
new CmpExp(TOKlt, Loc(), new IdentifierExp(Loc(), Id::p), new ArrayLengthExp(Loc(), new IdentifierExp(Loc(), p->ident))),
new PostExp(TOKplusplus, Loc(), new IdentifierExp(Loc(), Id::p)),
new ExpStatement(Loc(), loopbody));
#else
// foreach (i; 0 .. p.length)
Statement *s1 = new ForeachRangeStatement(0, TOKforeach,
Statement *s1 = new ForeachRangeStatement(Loc(), TOKforeach,
new Parameter(0, NULL, Id::p, NULL),
new IntegerExp(0, 0, Type::tsize_t),
new ArrayLengthExp(0, new IdentifierExp(0, p->ident)),
new ExpStatement(0, loopbody));
new IntegerExp(Loc(), 0, Type::tsize_t),
new ArrayLengthExp(Loc(), new IdentifierExp(Loc(), p->ident)),
new ExpStatement(Loc(), loopbody));
#endif
Statement *s2 = new ReturnStatement(0, new IdentifierExp(0, p->ident));
Statement *s2 = new ReturnStatement(Loc(), new IdentifierExp(Loc(), p->ident));
//printf("s2: %s\n", s2->toChars());
Statement *fbody = new CompoundStatement(0, s1, s2);
Statement *fbody = new CompoundStatement(Loc(), s1, s2);

/* Construct the function
*/
TypeFunction *ftype = new TypeFunction(fparams, type, 0, LINKc);
//printf("ftype: %s\n", ftype->toChars());
fd = new FuncDeclaration(loc, 0, ident, STCundefined, ftype);
fd = new FuncDeclaration(loc, Loc(), ident, STCundefined, ftype);
fd->fbody = fbody;
fd->protection = PROTpublic;
fd->linkage = LINKc;
Expand All @@ -372,7 +372,7 @@ Expression *BinExp::arrayOp(Scope *sc)

/* Call the function fd(arguments)
*/
Expression *ec = new VarExp(0, fd);
Expression *ec = new VarExp(Loc(), fd);
Expression *e = new CallExp(loc, ec, arguments);
e->type = type;
return e;
Expand Down Expand Up @@ -503,7 +503,7 @@ Expression *Expression::buildArrayLoop(Parameters *fparams)
Identifier *id = Identifier::generateId("c", fparams->dim);
Parameter *param = new Parameter(0, type, id, NULL);
fparams->shift(param);
Expression *e = new IdentifierExp(0, id);
Expression *e = new IdentifierExp(Loc(), id);
return e;
}

Expand All @@ -523,11 +523,11 @@ Expression *SliceExp::buildArrayLoop(Parameters *fparams)
Identifier *id = Identifier::generateId("p", fparams->dim);
Parameter *param = new Parameter(STCconst, type, id, NULL);
fparams->shift(param);
Expression *e = new IdentifierExp(0, id);
Expression *e = new IdentifierExp(Loc(), id);
Expressions *arguments = new Expressions();
Expression *index = new IdentifierExp(0, Id::p);
Expression *index = new IdentifierExp(Loc(), Id::p);
arguments->push(index);
e = new ArrayExp(0, e, arguments);
e = new ArrayExp(Loc(), e, arguments);
return e;
}

Expand All @@ -542,12 +542,12 @@ Expression *AssignExp::buildArrayLoop(Parameters *fparams)
* where b is a byte fails because (c + p[i]) is an int
* which cannot be implicitly cast to byte.
*/
ex2 = new CastExp(0, ex2, e1->type->nextOf());
ex2 = new CastExp(Loc(), ex2, e1->type->nextOf());
#endif
Expression *ex1 = e1->buildArrayLoop(fparams);
Parameter *param = (*fparams)[0];
param->storageClass = 0;
Expression *e = new AssignExp(0, ex1, ex2);
Expression *e = new AssignExp(Loc(), ex1, ex2);
return e;
}

Expand Down Expand Up @@ -581,14 +581,14 @@ X(Pow)
Expression *NegExp::buildArrayLoop(Parameters *fparams)
{
Expression *ex1 = e1->buildArrayLoop(fparams);
Expression *e = new NegExp(0, ex1);
Expression *e = new NegExp(Loc(), ex1);
return e;
}

Expression *ComExp::buildArrayLoop(Parameters *fparams)
{
Expression *ex1 = e1->buildArrayLoop(fparams);
Expression *e = new ComExp(0, ex1);
Expression *e = new ComExp(Loc(), ex1);
return e;
}

Expand All @@ -599,7 +599,7 @@ Expression *Str##Exp::buildArrayLoop(Parameters *fparams) \
*/ \
Expression *ex1 = e1->buildArrayLoop(fparams); \
Expression *ex2 = e2->buildArrayLoop(fparams); \
Expression *e = new Str##Exp(0, ex1, ex2); \
Expression *e = new Str##Exp(Loc(), ex1, ex2); \
return e; \
}

Expand Down
8 changes: 4 additions & 4 deletions src/attrib.c
Expand Up @@ -1536,8 +1536,8 @@ Expressions *UserAttributeDeclaration::concat(Expressions *udas1, Expressions *u
* (do not append to left operand, as this is a copy-on-write operation)
*/
udas = new Expressions();
udas->push(new TupleExp(0, udas1));
udas->push(new TupleExp(0, udas2));
udas->push(new TupleExp(Loc(), udas1));
udas->push(new TupleExp(Loc(), udas2));
}
return udas;
}
Expand All @@ -1562,8 +1562,8 @@ void UserAttributeDeclaration::setScope(Scope *sc)
{
// Create a tuple that combines them
Expressions *exps = new Expressions();
exps->push(new TupleExp(0, newsc->userAttributes));
exps->push(new TupleExp(0, atts));
exps->push(new TupleExp(Loc(), newsc->userAttributes));
exps->push(new TupleExp(Loc(), atts));
newsc->userAttributes = exps;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/cgobj.c
Expand Up @@ -2248,7 +2248,7 @@ size_t Obj::mangle(Symbol *s,char *dest)
#if SCPP
synerr(EM_identifier_too_long, name, len - IDMAX, IDMAX);
#elif MARS
// error(0, "identifier %s is too long by %d characters", name, len - IDMAX);
// error(Loc(), "identifier %s is too long by %d characters", name, len - IDMAX);
#else
assert(0);
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/builtin.c
Expand Up @@ -163,27 +163,27 @@ Expression *eval_builtin(Loc loc, enum BUILTIN builtin, Expressions *arguments)
{
case BUILTINsin:
if (arg0->op == TOKfloat64)
e = new RealExp(0, sinl(arg0->toReal()), arg0->type);
e = new RealExp(Loc(), sinl(arg0->toReal()), arg0->type);
break;

case BUILTINcos:
if (arg0->op == TOKfloat64)
e = new RealExp(0, cosl(arg0->toReal()), arg0->type);
e = new RealExp(Loc(), cosl(arg0->toReal()), arg0->type);
break;

case BUILTINtan:
if (arg0->op == TOKfloat64)
e = new RealExp(0, tanl(arg0->toReal()), arg0->type);
e = new RealExp(Loc(), tanl(arg0->toReal()), arg0->type);
break;

case BUILTINsqrt:
if (arg0->op == TOKfloat64)
e = new RealExp(0, sqrtl(arg0->toReal()), arg0->type);
e = new RealExp(Loc(), sqrtl(arg0->toReal()), arg0->type);
break;

case BUILTINfabs:
if (arg0->op == TOKfloat64)
e = new RealExp(0, fabsl(arg0->toReal()), arg0->type);
e = new RealExp(Loc(), fabsl(arg0->toReal()), arg0->type);
break;
// These math intrinsics are not yet implemented
case BUILTINatan2:
Expand Down
6 changes: 3 additions & 3 deletions src/cast.c
Expand Up @@ -1022,7 +1022,7 @@ Type *SliceExp::toStaticArrayType()
{
size_t len = upr->toUInteger() - lwr->toUInteger();
return new TypeSArray(type->toBasetype()->nextOf(),
new IntegerExp(0, len, Type::tindex));
new IntegerExp(Loc(), len, Type::tindex));
}
}
return NULL;
Expand Down Expand Up @@ -2063,7 +2063,7 @@ Expression *BinExp::scaleFactor(Scope *sc)
if (!t->equals(t2b))
e2 = e2->castTo(sc, t);
eoff = e2;
e2 = new MulExp(loc, e2, new IntegerExp(0, stride, t));
e2 = new MulExp(loc, e2, new IntegerExp(Loc(), stride, t));
e2->type = t;
type = e1->type;
}
Expand All @@ -2079,7 +2079,7 @@ Expression *BinExp::scaleFactor(Scope *sc)
else
e = e1;
eoff = e;
e = new MulExp(loc, e, new IntegerExp(0, stride, t));
e = new MulExp(loc, e, new IntegerExp(Loc(), stride, t));
e->type = t;
type = e2->type;
e1 = e2;
Expand Down
12 changes: 6 additions & 6 deletions src/class.c
Expand Up @@ -686,7 +686,7 @@ void ClassDeclaration::semantic(Scope *sc)
/* Look for special member functions.
* They must be in this class, not in a base class.
*/
ctor = search(0, Id::ctor, 0);
ctor = search(Loc(), Id::ctor, 0);
#if DMDV1
if (ctor && (ctor->toParent() != this || !ctor->isCtorDeclaration()))
ctor = NULL;
Expand All @@ -704,8 +704,8 @@ void ClassDeclaration::semantic(Scope *sc)
// inv = NULL;

// Can be in base class
aggNew = (NewDeclaration *)search(0, Id::classNew, 0);
aggDelete = (DeleteDeclaration *)search(0, Id::classDelete, 0);
aggNew = (NewDeclaration *)search(Loc(), Id::classNew, 0);
aggDelete = (DeleteDeclaration *)search(Loc(), Id::classDelete, 0);

// If this class has no constructor, but base class has a default
// ctor, create a constructor:
Expand All @@ -716,8 +716,8 @@ void ClassDeclaration::semantic(Scope *sc)
{
//printf("Creating default this(){} for class %s\n", toChars());
Type *tf = new TypeFunction(NULL, NULL, 0, LINKd, 0);
CtorDeclaration *ctor = new CtorDeclaration(loc, 0, 0, tf);
ctor->fbody = new CompoundStatement(0, new Statements());
CtorDeclaration *ctor = new CtorDeclaration(loc, Loc(), 0, tf);
ctor->fbody = new CompoundStatement(Loc(), new Statements());
members->push(ctor);
ctor->addMember(sc, this, 1);
*sc = scsave; // why? What about sc->nofree?
Expand Down Expand Up @@ -1002,7 +1002,7 @@ int isf(void *param, FuncDeclaration *fd)
int ClassDeclaration::isFuncHidden(FuncDeclaration *fd)
{
//printf("ClassDeclaration::isFuncHidden(class = %s, fd = %s)\n", toChars(), fd->toChars());
Dsymbol *s = search(0, fd->ident, 4|2);
Dsymbol *s = search(Loc(), fd->ident, 4|2);
if (!s)
{ //printf("not found\n");
/* Because, due to a hack, if there are multiple definitions
Expand Down
18 changes: 9 additions & 9 deletions src/clone.c
Expand Up @@ -184,7 +184,7 @@ FuncDeclaration *StructDeclaration::buildOpAssign(Scope *sc)
Type *ftype = new TypeFunction(fparams, handle, FALSE, LINKd);
((TypeFunction *)ftype)->isref = 1;

FuncDeclaration *fop = new FuncDeclaration(loc, 0, Id::assign, STCundefined, ftype);
FuncDeclaration *fop = new FuncDeclaration(loc, Loc(), Id::assign, STCundefined, ftype);

Expression *e = NULL;
if (dtor || postblit)
Expand Down Expand Up @@ -411,7 +411,7 @@ FuncDeclaration *StructDeclaration::buildXopEquals(Scope *sc)
* return p == q;
* }
*/
Loc loc = 0; // errors are gagged, so loc is not need
Loc loc = Loc(); // errors are gagged, so loc is not need

Parameters *parameters = new Parameters;
parameters->push(new Parameter(STCref | STCconst, type, Id::p, NULL));
Expand All @@ -420,11 +420,11 @@ FuncDeclaration *StructDeclaration::buildXopEquals(Scope *sc)
tf = (TypeFunction *)tf->semantic(loc, sc);

Identifier *id = Lexer::idPool("__xopEquals");
FuncDeclaration *fop = new FuncDeclaration(loc, 0, id, STCstatic, tf);
FuncDeclaration *fop = new FuncDeclaration(loc, Loc(), id, STCstatic, tf);

Expression *e1 = new IdentifierExp(loc, Id::p);
Expression *e2 = new IdentifierExp(loc, Id::q);
Expression *e = new EqualExp(TOKequal, 0, e1, e2);
Expression *e = new EqualExp(TOKequal, Loc(), e1, e2);

fop->fbody = new ReturnStatement(loc, e);

Expand Down Expand Up @@ -505,7 +505,7 @@ FuncDeclaration *StructDeclaration::buildCpCtor(Scope *sc)
Type *ftype = new TypeFunction(fparams, Type::tvoid, 0, LINKd, stc);
ftype->mod = MODconst;

FuncDeclaration *fcp = new FuncDeclaration(loc, 0, Id::cpctor, stc, ftype);
FuncDeclaration *fcp = new FuncDeclaration(loc, Loc(), Id::cpctor, stc, ftype);

if (!(stc & STCdisable))
{
Expand Down Expand Up @@ -611,7 +611,7 @@ FuncDeclaration *StructDeclaration::buildPostBlit(Scope *sc)
*/
if (e || (stc & STCdisable))
{ //printf("Building __fieldPostBlit()\n");
PostBlitDeclaration *dd = new PostBlitDeclaration(loc, 0, stc, Lexer::idPool("__fieldPostBlit"));
PostBlitDeclaration *dd = new PostBlitDeclaration(loc, Loc(), stc, Lexer::idPool("__fieldPostBlit"));
dd->fbody = new ExpStatement(loc, e);
postblits.shift(dd);
members->push(dd);
Expand Down Expand Up @@ -643,7 +643,7 @@ FuncDeclaration *StructDeclaration::buildPostBlit(Scope *sc)
ex = new CallExp(loc, ex);
e = Expression::combine(e, ex);
}
PostBlitDeclaration *dd = new PostBlitDeclaration(loc, 0, stc, Lexer::idPool("__aggrPostBlit"));
PostBlitDeclaration *dd = new PostBlitDeclaration(loc, Loc(), stc, Lexer::idPool("__aggrPostBlit"));
dd->fbody = new ExpStatement(loc, e);
members->push(dd);
dd->semantic(sc);
Expand Down Expand Up @@ -723,7 +723,7 @@ FuncDeclaration *AggregateDeclaration::buildDtor(Scope *sc)
*/
if (e || (stc & STCdisable))
{ //printf("Building __fieldDtor()\n");
DtorDeclaration *dd = new DtorDeclaration(loc, 0, stc, Lexer::idPool("__fieldDtor"));
DtorDeclaration *dd = new DtorDeclaration(loc, Loc(), stc, Lexer::idPool("__fieldDtor"));
dd->fbody = new ExpStatement(loc, e);
dtors.shift(dd);
members->push(dd);
Expand Down Expand Up @@ -756,7 +756,7 @@ FuncDeclaration *AggregateDeclaration::buildDtor(Scope *sc)
ex = new CallExp(loc, ex);
e = Expression::combine(ex, e);
}
DtorDeclaration *dd = new DtorDeclaration(loc, 0, stc, Lexer::idPool("__aggrDtor"));
DtorDeclaration *dd = new DtorDeclaration(loc, Loc(), stc, Lexer::idPool("__aggrDtor"));
dd->fbody = new ExpStatement(loc, e);
members->push(dd);
dd->semantic(sc);
Expand Down
4 changes: 2 additions & 2 deletions src/cond.c
Expand Up @@ -52,7 +52,7 @@ Condition::Condition(Loc loc)
/* ============================================================ */

DVCondition::DVCondition(Module *mod, unsigned level, Identifier *ident)
: Condition(0)
: Condition(Loc())
{
this->mod = mod;
this->level = level;
Expand Down Expand Up @@ -162,7 +162,7 @@ void VersionCondition::checkPredefined(Loc loc, const char *ident)

void VersionCondition::addGlobalIdent(const char *ident)
{
checkPredefined(0, ident);
checkPredefined(Loc(), ident);
addPredefinedGlobalIdent(ident);
}

Expand Down
4 changes: 2 additions & 2 deletions src/ctfeexpr.c
Expand Up @@ -380,13 +380,13 @@ Expression *paintTypeOntoLiteral(Type *type, Expression *lit)
else if (lit->op == TOKarrayliteral)
{
e = new SliceExp(lit->loc, lit,
new IntegerExp(0, 0, Type::tsize_t), ArrayLength(Type::tsize_t, lit));
new IntegerExp(Loc(), 0, Type::tsize_t), ArrayLength(Type::tsize_t, lit));
}
else if (lit->op == TOKstring)
{
// For strings, we need to introduce another level of indirection
e = new SliceExp(lit->loc, lit,
new IntegerExp(0, 0, Type::tsize_t), ArrayLength(Type::tsize_t, lit));
new IntegerExp(Loc(), 0, Type::tsize_t), ArrayLength(Type::tsize_t, lit));
}
else if (lit->op == TOKassocarrayliteral)
{
Expand Down

0 comments on commit 604650e

Please sign in to comment.