- generate register type info for the parameter lists of all functions.

Currently used for loading parameters into registers.
For checking parameters of native functions some more work is needed to get the info to the function. Currently it doesn't receive the function descriptor.
This commit is contained in:
Christoph Oelckers 2018-11-18 17:10:55 +01:00
commit a981737855
11 changed files with 84 additions and 46 deletions

View file

@ -193,17 +193,20 @@ void VMFillParams(VMValue *params, VMFrame *callee, int numparam)
const VMRegisters calleereg(callee);
assert(calleefunc != NULL && !(calleefunc->VarFlags & VARF_Native));
assert(numparam == calleefunc->NumArgs || ((int)calleefunc->DefaultArgs.Size() == calleefunc->NumArgs));
assert(numparam == 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)
const uint8_t *reginfo = calleefunc->RegTypes;
assert(reginfo != nullptr);
for (int i = 0; i < calleefunc->NumArgs; ++i, reginfo++)
{
// get all actual parameters and fill the rest from the defaults.
VMValue &p = i < numparam? params[i] : calleefunc->DefaultArgs[i];
if (p.Type < REGT_STRING)
// copy all parameters to the local registers.
VMValue &p = params[i];
assert(*reginfo == p.Type);
if (*reginfo < REGT_STRING)
{
if (p.Type == REGT_INT)
if (*reginfo == REGT_INT)
{
calleereg.d[regd++] = p.i;
}
@ -212,13 +215,13 @@ void VMFillParams(VMValue *params, VMFrame *callee, int numparam)
calleereg.f[regf++] = p.f;
}
}
else if (p.Type == REGT_STRING)
else if (*reginfo == REGT_STRING)
{
calleereg.s[regs++] = p.s();
}
else
{
assert(p.Type == REGT_POINTER);
assert(*reginfo == REGT_POINTER);
calleereg.a[rega++] = p.a;
}
}