Merge pull request #5578 from edolstra/call-functor

Call functors with both arguments at once
This commit is contained in:
Eelco Dolstra 2021-11-16 23:39:12 +01:00 committed by GitHub
commit b191213b8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1406,13 +1406,15 @@ void EvalState::callFunction(Value & fun, size_t nrArgs, Value * * args, Value &
}
else if (vCur.type() == nAttrs && (functor = vCur.attrs->get(sFunctor))) {
/* 'vCur" may be allocated on the stack of the calling
/* 'vCur' may be allocated on the stack of the calling
function, but for functors we may keep a reference, so
heap-allocate a copy and use that instead. */
Value * args2[] = {allocValue()};
Value * args2[] = {allocValue(), args[0]};
*args2[0] = vCur;
/* !!! Should we use the attr pos here? */
callFunction(*functor->value, 1, args2, vCur, pos);
callFunction(*functor->value, 2, args2, vCur, pos);
nrArgs--;
args++;
}
else