Fix array op argument evaluation order regression.

Fixes DMD testcase 'arrayop'.
This commit is contained in:
David Nadlinger
2013-06-14 17:02:41 +02:00
parent 9dc387aa91
commit 349305cd1d
2 changed files with 7 additions and 1 deletions

View File

@@ -255,7 +255,10 @@ ArrayOp *buildArrayOp(Identifier *ident, BinExp *exp, Scope *sc, Loc loc)
Parameters *fparams = new Parameters();
Expression *loopbody = exp->buildArrayLoop(fparams);
if (isDruntimeArrayOp(ident))
{
op->cFunc = FuncDeclaration::genCfunc(fparams, exp->type, ident);
op->cFunc->isArrayOp = 2;
}
#else
if (isDruntimeArrayOp(ident))
op->cFunc = FuncDeclaration::genCfunc(exp->type, ident);

View File

@@ -513,7 +513,10 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
std::vector<DValue*> argvals;
argvals.reserve(n);
if (dfnval && dfnval->func->isArrayOp) {
// slightly different approach for array operators
// For array ops, the druntime implementation signatures are crafted
// specifically such that the evaluation order is as expected with
// the strange DMD reverse parameter passing order. Thus, we need
// to actually build the arguments right-to-left for them.
for (int i=n-1; i>=0; --i) {
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
assert(fnarg);