- always pass complete argument lists in the VM.

This commit is contained in:
Christoph Oelckers 2018-11-16 22:43:12 +01:00
parent 16053c7cdb
commit 95ab1da6a0
2 changed files with 32 additions and 0 deletions

View file

@ -9127,6 +9127,31 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build)
{ {
count += EmitParameter(build, ArgList[i], ScriptPosition, &tempstrings); count += EmitParameter(build, ArgList[i], ScriptPosition, &tempstrings);
} }
// Complete the parameter list from the defaults.
auto &defaults = Function->Variants[0].Implementation->DefaultArgs;
for (unsigned i = count; i < defaults.Size(); i++)
{
FxConstant *constant;
switch (defaults[i].Type)
{
default:
case REGT_INT:
constant = new FxConstant(defaults[i].i, ScriptPosition);
break;
case REGT_FLOAT:
constant = new FxConstant(defaults[i].f, ScriptPosition);
break;
case REGT_POINTER:
constant = new FxConstant(defaults[i].a, ScriptPosition);
break;
case REGT_STRING:
constant = new FxConstant(defaults[i].s(), ScriptPosition);
break;
}
count += EmitParameter(build, constant, ScriptPosition, &tempstrings);
delete constant;
}
ArgList.DeleteAndClear(); ArgList.DeleteAndClear();
ArgList.ShrinkToFit(); ArgList.ShrinkToFit();

View file

@ -501,6 +501,13 @@ public:
isresolved = true; isresolved = true;
} }
FxConstant(void *state, const FScriptPosition &pos) : FxExpression(EFX_Constant, pos)
{
value.pointer = state;
ValueType = value.Type = TypeVoidPtr;
isresolved = true;
}
FxConstant(const FScriptPosition &pos) : FxExpression(EFX_Constant, pos) FxConstant(const FScriptPosition &pos) : FxExpression(EFX_Constant, pos)
{ {
value.pointer = nullptr; value.pointer = nullptr;