Implemented implicit 'protected' inheritance in virtual functions

This commit is contained in:
ZZYZX 2017-03-05 01:24:22 +02:00 committed by Christoph Oelckers
commit 7cbabfb0d4
5 changed files with 25 additions and 23 deletions

View file

@ -705,10 +705,8 @@ do_double: if (inexact)
class VMFunction
{
public:
bool Native;
bool Final = false; // cannot be overridden
bool Unsafe = false; // Contains references to class fields that are unsafe for psp and item state calls.
bool FuncConst = false; // [ZZ] readonly function
bool Unsafe = false;
int VarFlags = 0; // [ZZ] this replaces 5+ bool fields
int BarrierSide = 0; // [ZZ] FScopeBarrier::Side
BYTE ImplicitArgs = 0; // either 0 for static, 1 for method or 3 for action
unsigned VirtualIndex = ~0u;
@ -718,7 +716,7 @@ public:
class PPrototype *Proto;
VMFunction(FName name = NAME_None) : Native(false), ImplicitArgs(0), Name(name), Proto(NULL)
VMFunction(FName name = NAME_None) : ImplicitArgs(0), Name(name), Proto(NULL)
{
AllFunctions.Push(this);
}
@ -942,9 +940,10 @@ class VMNativeFunction : public VMFunction
public:
typedef int (*NativeCallType)(VMValue *param, TArray<VMValue> &defaultparam, int numparam, VMReturn *ret, int numret);
VMNativeFunction() : NativeCall(NULL) { Native = true; }
VMNativeFunction(NativeCallType call) : NativeCall(call) { Native = true; }
VMNativeFunction(NativeCallType call, FName name) : VMFunction(name), NativeCall(call) { Native = true; }
// 8 is VARF_Native.
VMNativeFunction() : NativeCall(NULL) { VarFlags = 8; }
VMNativeFunction(NativeCallType call) : NativeCall(call) { VarFlags = 8; }
VMNativeFunction(NativeCallType call, FName name) : VMFunction(name), NativeCall(call) { VarFlags = 8; }
// Return value is the number of results.
NativeCallType NativeCall;

View file

@ -22,7 +22,7 @@ static int Exec(VMFrameStack *stack, const VMOP *pc, VMReturn *ret, int numret)
const FVoidObj *konsta;
const VM_ATAG *konstatag;
if (f->Func != NULL && !f->Func->Native)
if (f->Func != NULL && !(f->Func->VarFlags & VARF_Native))
{
sfunc = static_cast<VMScriptFunction *>(f->Func);
konstd = sfunc->KonstD;
@ -679,7 +679,7 @@ begin:
#endif
FillReturns(reg, f, returns, pc+1, C);
if (call->Native)
if (call->VarFlags & VARF_Native)
{
try
{
@ -736,7 +736,7 @@ begin:
{
VMFunction *call = (VMFunction *)ptr;
if (call->Native)
if (call->VarFlags & VARF_Native)
{
try
{
@ -1966,7 +1966,7 @@ static void SetReturn(const VMRegisters &reg, VMFrame *frame, VMReturn *ret, VM_
const void *src;
VMScriptFunction *func = static_cast<VMScriptFunction *>(frame->Func);
assert(func != NULL && !func->Native);
assert(func != NULL && !(func->VarFlags & VARF_Native));
assert((regtype & ~REGT_KONST) == ret->RegType);
switch (regtype & REGT_TYPE)

View file

@ -48,7 +48,6 @@ TArray<VMFunction *> VMFunction::AllFunctions;
VMScriptFunction::VMScriptFunction(FName name)
{
Native = false;
Name = name;
LineInfo = nullptr;
Code = NULL;
@ -438,7 +437,7 @@ int VMFrameStack::Call(VMFunction *func, VMValue *params, int numparams, VMRetur
bool allocated = false;
try
{
if (func->Native)
if (func->VarFlags & VARF_Native)
{
return static_cast<VMNativeFunction *>(func)->NativeCall(params, func->DefaultArgs, numparams, results, numresults);
}