Skip to content

Commit

Permalink
Remove DMDV1 and DMDV2 from the interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
yebblies committed Feb 7, 2014
1 parent 10b2e55 commit e1f9b68
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 168 deletions.
31 changes: 1 addition & 30 deletions src/ctfeexpr.c
Expand Up @@ -305,11 +305,7 @@ Expression *copyLiteral(Expression *e)
m = copyLiteral(m);
(*newelems)[i] = m;
}
#if DMDV2
StructLiteralExp *r = new StructLiteralExp(e->loc, se->sd, newelems, se->stype);
#else
StructLiteralExp *r = new StructLiteralExp(e->loc, se->sd, newelems);
#endif
r->type = e->type;
r->ownedByCtfe = true;
r->origin = ((StructLiteralExp*)e)->origin;
Expand All @@ -336,12 +332,8 @@ Expression *copyLiteral(Expression *e)
r = new IndexExp(e->loc, ((IndexExp *)e)->e1, ((IndexExp *)e)->e2);
else if (e->op == TOKdotvar)
{
#if DMDV2
r = new DotVarExp(e->loc, ((DotVarExp *)e)->e1,
((DotVarExp *)e)->var, ((DotVarExp *)e)->hasOverloads);
#else
r = new DotVarExp(e->loc, ((DotVarExp *)e)->e1, ((DotVarExp *)e)->var);
#endif
}
else
assert(0);
Expand Down Expand Up @@ -522,7 +514,6 @@ bool isAssocArray(Type *t)
t = t->toBasetype();
if (t->ty == Taarray)
return true;
#if DMDV2
if (t->ty != Tstruct)
return false;
StructDeclaration *sym = ((TypeStruct *)t)->sym;
Expand All @@ -532,7 +523,6 @@ bool isAssocArray(Type *t)
{
return true;
}
#endif
return false;
}

Expand All @@ -542,17 +532,12 @@ TypeAArray *toBuiltinAAType(Type *t)
t = t->toBasetype();
if (t->ty == Taarray)
return (TypeAArray *)t;
#if DMDV2
assert(t->ty == Tstruct);
StructDeclaration *sym = ((TypeStruct *)t)->sym;
assert(sym->ident == Id::AssociativeArray);
TemplateInstance *ti = sym->parent->isTemplateInstance();
assert(ti);
return new TypeAArray((Type *)(*ti->tiargs)[1], (Type *)(*ti->tiargs)[0]);
#else
assert(0);
return NULL;
#endif
}

/************** TypeInfo operations ************************************/
Expand Down Expand Up @@ -594,11 +579,9 @@ bool isSafePointerCast(Type *srcPointee, Type *destPointee)
destPointee = destPointee->nextOf();
}

#if DMDV2
// It's OK if both are the same (modulo const)
srcPointee = srcPointee->castMod(0);
destPointee = destPointee->castMod(0);
#endif
if (srcPointee == destPointee)
return true;

Expand Down Expand Up @@ -1766,12 +1749,10 @@ Expression *ctfeCast(Loc loc, Type *type, Type *to, Expression *e)
// Allow TypeInfo type painting
if (isTypeInfo_Class(e->type) && e->type->implicitConvTo(to))
return paintTypeOntoLiteral(to, e);
#if DMDV2
// Allow casting away const for struct literals
if (e->op == TOKstructliteral &&
e->type->toBasetype()->castMod(0) == to->toBasetype()->castMod(0))
return paintTypeOntoLiteral(to, e);
#endif
Expression *r = Cast(type, to, e);
if (r == EXP_CANT_INTERPRET)
error(loc, "cannot cast %s to %s at compile time", e->toChars(), to->toChars());
Expand Down Expand Up @@ -1849,13 +1830,8 @@ void assignInPlace(Expression *dest, Expression *src)
void recursiveBlockAssign(ArrayLiteralExp *ae, Expression *val, bool wantRef)
{
assert( ae->type->ty == Tsarray || ae->type->ty == Tarray);
#if DMDV2
Type *desttype = ((TypeArray *)ae->type)->next->toBasetype()->castMod(0);
bool directblk = (val->type->toBasetype()->castMod(0))->equals(desttype);
#else
Type *desttype = ((TypeArray *)ae->type)->next;
bool directblk = (val->type->toBasetype())->equals(desttype);
#endif

bool cow = !(val->op == TOKstructliteral || val->op == TOKarrayliteral
|| val->op == TOKstring);
Expand Down Expand Up @@ -2008,12 +1984,7 @@ Expression *changeArrayLiteralLength(Loc loc, TypeArray *arrayType,

bool isCtfeValueValid(Expression *newval)
{
#if DMDV2
bool isnull = newval->type->ty == Tnull;
#else
bool isnull = false;
#endif
if (isnull || isPointer(newval->type))
if (newval->type->ty == Tnull || isPointer(newval->type))
{
if (newval->op == TOKaddress || newval->op == TOKnull ||
newval->op == TOKstring)
Expand Down

0 comments on commit e1f9b68

Please sign in to comment.