Fixed test runnable/arrayop

This commit is contained in:
Alexey Prokhin 2010-12-14 14:38:46 +03:00
parent f8bf67dc6e
commit e48d0f6b79
2 changed files with 22 additions and 6 deletions

View file

@ -353,10 +353,10 @@ Expression *BinExp::arrayOp(Scope *sc)
fd = new FuncDeclaration(0, 0, Lexer::idPool(name), STCundefined, ftype); fd = new FuncDeclaration(0, 0, Lexer::idPool(name), STCundefined, ftype);
fd->fbody = fbody; fd->fbody = fbody;
fd->protection = PROTpublic; fd->protection = PROTpublic;
fd->linkage = LINKd; fd->linkage = LINKd;
// special attention for array ops // special attention for array ops
fd->isArrayOp = true; fd->isArrayOp = true;
sc->module->importedFrom->members->push(fd); sc->module->importedFrom->members->push(fd);

View file

@ -424,13 +424,29 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
LLSmallVector<unsigned, 10> attrptr(n, 0); LLSmallVector<unsigned, 10> attrptr(n, 0);
std::vector<DValue*> argvals;
if (dfnval && dfnval->func->isArrayOp) {
// slightly different approach for array operators
for (int i=n-1; i>=0; --i) {
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
assert(fnarg);
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
argvals.insert(argvals.begin(), argval);
}
} else {
for (int i=0; i<n; ++i) {
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
assert(fnarg);
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
argvals.push_back(argval);
}
}
// do formal params // do formal params
int beg = argiter-argbegin; int beg = argiter-argbegin;
for (int i=0; i<n; i++) for (int i=0; i<n; i++)
{ {
Parameter* fnarg = Parameter::getNth(tf->parameters, i); DValue* argval = argvals.at(i);
assert(fnarg);
DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
#if 0 #if 0
if (Logger::enabled()) { if (Logger::enabled()) {