- actually evaluate the default parameters and store them in the VMFunction.

- disabled the assert in PType::GetRegType. This assert blocks any use to check for types that are incompatible with function parameters.
- pass the default parameter constants to the native functions. At the moment this is not used yet.
- use the function defaults to complete argument lists to script functions.
- fixed all default values that got flagged by the expression evaluator as non-constant. Most were state labels and colors which were defaulted to "". The proper value is null for states and 0 for colors.
- also replaced all "" defaults for names with "none".
This commit is contained in:
Christoph Oelckers 2016-10-27 01:30:34 +02:00
commit 66b1f36e56
12 changed files with 151 additions and 61 deletions

View file

@ -188,13 +188,14 @@ void VMFillParams(VMValue *params, VMFrame *callee, int numparam)
const VMRegisters calleereg(callee);
assert(calleefunc != NULL && !calleefunc->Native);
assert(numparam == calleefunc->NumArgs);
assert(numparam == calleefunc->NumArgs || ((int)calleefunc->Defaults.Size() == numparam));
assert(REGT_INT == 0 && REGT_FLOAT == 1 && REGT_STRING == 2 && REGT_POINTER == 3);
regd = regf = regs = rega = 0;
for (int i = 0; i < numparam; ++i)
for (int i = 0; i < calleefunc->NumArgs; ++i)
{
VMValue &p = params[i];
// get all actual parameters and fill the rest from the defaults.
VMValue &p = i < numparam? params[i] : calleefunc->Defaults[i];
if (p.Type < REGT_STRING)
{
if (p.Type == REGT_INT)