- fixed potentially incomplete list of argument flags for virtual function

https://forum.zdoom.org/viewtopic.php?t=63450
This commit is contained in:
alexey.lysiuk 2019-02-01 18:22:12 +02:00 committed by Christoph Oelckers
parent b1c508fa6c
commit 5e9001e7bc
1 changed files with 13 additions and 1 deletions

View File

@ -2767,6 +2767,8 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
}
}
VMFunction *newfunc = nullptr;
if (!(f->Flags & ZCC_Native))
{
if (f->Body == nullptr)
@ -2779,7 +2781,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
auto code = ConvertAST(c->Type(), f->Body);
if (code != nullptr)
{
FunctionBuildList.AddFunction(OutNamespace, mVersion, sym, code, FStringf("%s.%s", c->Type()->TypeName.GetChars(), FName(f->Name).GetChars()), false, -1, 0, Lump);
newfunc = FunctionBuildList.AddFunction(OutNamespace, mVersion, sym, code, FStringf("%s.%s", c->Type()->TypeName.GetChars(), FName(f->Name).GetChars()), false, -1, 0, Lump);
}
}
}
@ -2859,6 +2861,16 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
sym->Variants[0].Implementation->DefaultArgs = parentfunc->Variants[0].Implementation->DefaultArgs;
sym->Variants[0].ArgFlags = parentfunc->Variants[0].ArgFlags;
}
// Update argument flags for VM function if needed as their list could be incomplete
// At the moment of function creation, arguments with default values were not copied yet from the parent function
if (newfunc != nullptr && sym->Variants[0].ArgFlags.Size() != newfunc->ArgFlags.Size())
{
for (unsigned i = newfunc->ArgFlags.Size(), count = sym->Variants[0].ArgFlags.Size(); i < count; ++i)
{
newfunc->ArgFlags.Push(sym->Variants[0].ArgFlags[i]);
}
}
}
}
else