mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-07-10 17:34:09 +02:00
Merge DMD 1.051
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright (c) 1999-2008 by Digital Mars
|
||||
// Copyright (c) 1999-2009 by Digital Mars
|
||||
// All Rights Reserved
|
||||
// written by Walter Bright
|
||||
// http://www.digitalmars.com
|
||||
@@ -31,6 +31,14 @@
|
||||
|
||||
Expression *BinExp::arrayOp(Scope *sc)
|
||||
{
|
||||
//printf("BinExp::arrayOp() %s\n", toChars());
|
||||
|
||||
if (type->toBasetype()->nextOf()->toBasetype()->ty == Tvoid)
|
||||
{
|
||||
error("Cannot perform array operations on void[] arrays");
|
||||
return new ErrorExp();
|
||||
}
|
||||
|
||||
Expressions *arguments = new Expressions();
|
||||
|
||||
/* The expression to generate an array operation for is mangled
|
||||
@@ -288,6 +296,8 @@ Expression *BinExp::arrayOp(Scope *sc)
|
||||
sc->stc = 0;
|
||||
sc->linkage = LINKd;
|
||||
fd->semantic(sc);
|
||||
fd->semantic2(sc);
|
||||
fd->semantic3(sc);
|
||||
sc->pop();
|
||||
// }
|
||||
// else
|
||||
@@ -318,6 +328,17 @@ void Expression::buildArrayIdent(OutBuffer *buf, Expressions *arguments)
|
||||
arguments->shift(this);
|
||||
}
|
||||
|
||||
void CastExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments)
|
||||
{
|
||||
Type *tb = type->toBasetype();
|
||||
if (tb->ty == Tarray || tb->ty == Tsarray)
|
||||
{
|
||||
e1->buildArrayIdent(buf, arguments);
|
||||
}
|
||||
else
|
||||
Expression::buildArrayIdent(buf, arguments);
|
||||
}
|
||||
|
||||
void SliceExp::buildArrayIdent(OutBuffer *buf, Expressions *arguments)
|
||||
{
|
||||
buf->writestring("Slice");
|
||||
@@ -402,6 +423,17 @@ Expression *Expression::buildArrayLoop(Arguments *fparams)
|
||||
return e;
|
||||
}
|
||||
|
||||
Expression *CastExp::buildArrayLoop(Arguments *fparams)
|
||||
{
|
||||
Type *tb = type->toBasetype();
|
||||
if (tb->ty == Tarray || tb->ty == Tsarray)
|
||||
{
|
||||
return e1->buildArrayLoop(fparams);
|
||||
}
|
||||
else
|
||||
return Expression::buildArrayLoop(fparams);
|
||||
}
|
||||
|
||||
Expression *SliceExp::buildArrayLoop(Arguments *fparams)
|
||||
{
|
||||
Identifier *id = Identifier::generateId("p", fparams->dim);
|
||||
@@ -420,6 +452,14 @@ Expression *AssignExp::buildArrayLoop(Arguments *fparams)
|
||||
/* Evaluate assign expressions right to left
|
||||
*/
|
||||
Expression *ex2 = e2->buildArrayLoop(fparams);
|
||||
#if DMDV2
|
||||
/* Need the cast because:
|
||||
* b = c + p[i];
|
||||
* 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());
|
||||
#endif
|
||||
Expression *ex1 = e1->buildArrayLoop(fparams);
|
||||
Argument *param = (Argument *)fparams->data[0];
|
||||
param->storageClass = 0;
|
||||
@@ -488,3 +528,34 @@ X(Or)
|
||||
#undef X
|
||||
|
||||
|
||||
/***********************************************
|
||||
* Test if operand is a valid array op operand.
|
||||
*/
|
||||
|
||||
int Expression::isArrayOperand()
|
||||
{
|
||||
//printf("Expression::isArrayOperand() %s\n", toChars());
|
||||
if (op == TOKslice)
|
||||
return 1;
|
||||
if (type->toBasetype()->ty == Tarray)
|
||||
{
|
||||
switch (op)
|
||||
{
|
||||
case TOKadd:
|
||||
case TOKmin:
|
||||
case TOKmul:
|
||||
case TOKdiv:
|
||||
case TOKmod:
|
||||
case TOKxor:
|
||||
case TOKand:
|
||||
case TOKor:
|
||||
case TOKneg:
|
||||
case TOKtilde:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user