- fixed: A VM function's NumArgs value needs to count stack arguments, not logical ones, meaning that for vectors each element needs to count separately.
- renamed VMFunction::Defaults to DefaultArgs to make searching easier. - let ZCCCompiler process vector defaults for function parameters.
This commit is contained in:
parent
06ec6318a9
commit
9eeb56212b
7 changed files with 54 additions and 17 deletions
|
|
@ -643,7 +643,7 @@ public:
|
|||
bool Native;
|
||||
BYTE ImplicitArgs = 0; // either 0 for static, 1 for method or 3 for action
|
||||
FName Name;
|
||||
TArray<VMValue> Defaults;
|
||||
TArray<VMValue> DefaultArgs;
|
||||
|
||||
class PPrototype *Proto;
|
||||
|
||||
|
|
|
|||
|
|
@ -722,7 +722,13 @@ void FFunctionBuildList::Build()
|
|||
// Emit code
|
||||
item.Code->Emit(&buildit);
|
||||
buildit.MakeFunction(sfunc);
|
||||
sfunc->NumArgs = item.Func->Variants[0].Proto->ArgumentTypes.Size();
|
||||
sfunc->NumArgs = 0;
|
||||
// NumArgs for the VMFunction must be the amount of stack elements, which can differ from the amount of logical function arguments if vectors are in the list.
|
||||
// For the VM a vector is 2 or 3 args, depending on size.
|
||||
for (auto s : item.Func->Variants[0].Proto->ArgumentTypes)
|
||||
{
|
||||
sfunc->NumArgs += s->GetRegCount();
|
||||
}
|
||||
|
||||
if (dump != nullptr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -188,14 +188,14 @@ void VMFillParams(VMValue *params, VMFrame *callee, int numparam)
|
|||
const VMRegisters calleereg(callee);
|
||||
|
||||
assert(calleefunc != NULL && !calleefunc->Native);
|
||||
assert(numparam == calleefunc->NumArgs || ((int)calleefunc->Defaults.Size() == calleefunc->NumArgs));
|
||||
assert(numparam == calleefunc->NumArgs || ((int)calleefunc->DefaultArgs.Size() == calleefunc->NumArgs));
|
||||
assert(REGT_INT == 0 && REGT_FLOAT == 1 && REGT_STRING == 2 && REGT_POINTER == 3);
|
||||
|
||||
regd = regf = regs = rega = 0;
|
||||
for (int i = 0; i < calleefunc->NumArgs; ++i)
|
||||
{
|
||||
// get all actual parameters and fill the rest from the defaults.
|
||||
VMValue &p = i < numparam? params[i] : calleefunc->Defaults[i];
|
||||
VMValue &p = i < numparam? params[i] : calleefunc->DefaultArgs[i];
|
||||
if (p.Type < REGT_STRING)
|
||||
{
|
||||
if (p.Type == REGT_INT)
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ begin:
|
|||
FillReturns(reg, f, returns, pc+1, C);
|
||||
if (call->Native)
|
||||
{
|
||||
numret = static_cast<VMNativeFunction *>(call)->NativeCall(stack, reg.param + f->NumParam - B, call->Defaults, B, returns, C);
|
||||
numret = static_cast<VMNativeFunction *>(call)->NativeCall(stack, reg.param + f->NumParam - B, call->DefaultArgs, B, returns, C);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -588,7 +588,7 @@ begin:
|
|||
|
||||
if (call->Native)
|
||||
{
|
||||
return static_cast<VMNativeFunction *>(call)->NativeCall(stack, reg.param + f->NumParam - B, call->Defaults, B, ret, numret);
|
||||
return static_cast<VMNativeFunction *>(call)->NativeCall(stack, reg.param + f->NumParam - B, call->DefaultArgs, B, ret, numret);
|
||||
}
|
||||
else
|
||||
{ // FIXME: Not a true tail call
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ int VMFrameStack::Call(VMFunction *func, VMValue *params, int numparams, VMRetur
|
|||
{
|
||||
if (func->Native)
|
||||
{
|
||||
return static_cast<VMNativeFunction *>(func)->NativeCall(this, params, func->Defaults, numparams, results, numresults);
|
||||
return static_cast<VMNativeFunction *>(func)->NativeCall(this, params, func->DefaultArgs, numparams, results, numresults);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue