Merged DMD 2.060 frontend.

Upstream Git tag v2.060 (e8fe11c20249cb9e42538be88c99b74ede4d12e3).
This commit is contained in:
David Nadlinger
2012-08-26 21:10:13 +02:00
parent e03e027002
commit 837ef30fec
85 changed files with 4411 additions and 3780 deletions

View File

@@ -1,5 +1,5 @@
// Copyright (c) 1999-2011 by Digital Mars
// Copyright (c) 1999-2012 by Digital Mars
// All Rights Reserved
// written by Walter Bright
// http://www.digitalmars.com
@@ -142,7 +142,6 @@ Expression *BinExp::arrayOp(Scope *sc)
buf.writestring(type->toBasetype()->nextOf()->toBasetype()->deco);
#endif
size_t namelen = buf.offset;
buf.writeByte(0);
char *name = buf.toChars();
Identifier *ident = Lexer::idPool(name);
@@ -349,7 +348,7 @@ Expression *BinExp::arrayOp(Scope *sc)
Initializer *init = new ExpInitializer(0, new IntegerExp(0, 0, Type::tsize_t));
Dsymbol *d = new VarDeclaration(0, Type::tsize_t, Id::p, init);
Statement *s1 = new ForStatement(0,
new DeclarationStatement(0, d),
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));
@@ -357,7 +356,7 @@ Expression *BinExp::arrayOp(Scope *sc)
// foreach (i; 0 .. p.length)
Statement *s1 = new ForeachRangeStatement(0, TOKforeach,
new Parameter(0, NULL, Id::p, NULL),
new IntegerExp(0, 0, Type::tint32),
new IntegerExp(0, 0, Type::tsize_t),
new ArrayLengthExp(0, new IdentifierExp(0, p->ident)),
new ExpStatement(0, loopbody));
#endif
@@ -413,6 +412,23 @@ Expression *BinExp::arrayOp(Scope *sc)
return e;
}
Expression *BinAssignExp::arrayOp(Scope *sc)
{
//printf("BinAssignExp::arrayOp() %s\n", toChars());
/* Check that the elements of e1 can be assigned to
*/
Type *tn = e1->type->toBasetype()->nextOf();
if (tn && (!tn->isMutable() || !tn->isAssignable()))
{
error("slice %s is not mutable", e1->toChars());
return new ErrorExp();
}
return BinExp::arrayOp(sc);
}
/******************************************
* Construct the identifier for the array operation function,
* and build the argument list to pass to it.