Mercurial > projects > ldc
diff dmd/constfold.c @ 717:a26b0c5d5942
Merged DMD 1.036.
Improved comments a little in the runtime source code.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Wed, 22 Oct 2008 17:06:17 +0200 |
parents | 50383e476c7e |
children | 6dcab994ddc3 |
line wrap: on
line diff
--- a/dmd/constfold.c Wed Oct 22 15:35:46 2008 +0200 +++ b/dmd/constfold.c Wed Oct 22 17:06:17 2008 +0200 @@ -1297,6 +1297,8 @@ { Expression *e = EXP_CANT_INTERPRET; Loc loc = e1->loc; Type *t; + Type *t1 = e1->type->toBasetype(); + Type *t2 = e2->type->toBasetype(); //printf("Cat(e1 = %s, e2 = %s)\n", e1->toChars(), e2->toChars()); @@ -1442,6 +1444,31 @@ else e->type = type; } + else if (e1->op == TOKarrayliteral && e2->op == TOKnull && + t1->nextOf()->equals(t2->nextOf())) + { + e = e1; + goto L3; + } + else if (e1->op == TOKnull && e2->op == TOKarrayliteral && + t1->nextOf()->equals(t2->nextOf())) + { + e = e2; + L3: + // Concatenate the array with null + ArrayLiteralExp *es = (ArrayLiteralExp *)e; + + es = new ArrayLiteralExp(es->loc, (Expressions *)es->elements->copy()); + e = es; + + if (type->toBasetype()->ty == Tsarray) + { + e->type = new TypeSArray(t1->nextOf(), new IntegerExp(loc, es->elements->dim, Type::tindex)); + e->type = e->type->semantic(loc, NULL); + } + else + e->type = type; + } else if ((e1->op == TOKarrayliteral || e1->op == TOKnull) && e1->type->toBasetype()->nextOf()->equals(e2->type)) {