mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 21:11:39 +00:00
- fixed: FxVMFunctionCall::GetDirectFunction did not perform any checks on the function's self pointer and failed to report a mismatch as an error.
- also fixed two places in the code where the above caused some incorrect definitions not to be detected.
This commit is contained in:
parent
ca4888eb3d
commit
74faacd218
5 changed files with 16 additions and 14 deletions
|
@ -419,7 +419,7 @@ bool FxExpression::isConstant() const
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
VMFunction *FxExpression::GetDirectFunction(const VersionInfo &ver)
|
VMFunction *FxExpression::GetDirectFunction(PFunction *callingfunc, const VersionInfo &ver)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -8625,14 +8625,14 @@ bool FxVMFunctionCall::CheckAccessibility(const VersionInfo &ver)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
VMFunction *FxVMFunctionCall::GetDirectFunction(const VersionInfo &ver)
|
VMFunction *FxVMFunctionCall::GetDirectFunction(PFunction *callingfunc, const VersionInfo &ver)
|
||||||
{
|
{
|
||||||
// If this return statement calls a non-virtual function with no arguments,
|
// If this return statement calls a non-virtual function with no arguments,
|
||||||
// then it can be a "direct" function. That is, the DECORATE
|
// then it can be a "direct" function. That is, the DECORATE
|
||||||
// definition can call that function directly without wrapping
|
// definition can call that function directly without wrapping
|
||||||
// it inside VM code.
|
// it inside VM code.
|
||||||
|
|
||||||
if (ArgList.Size() == 0 && !(Function->Variants[0].Flags & VARF_Virtual) && CheckAccessibility(ver))
|
if (ArgList.Size() == 0 && !(Function->Variants[0].Flags & VARF_Virtual) && CheckAccessibility(ver) && CheckFunctionCompatiblity(ScriptPosition, callingfunc, Function))
|
||||||
{
|
{
|
||||||
unsigned imp = Function->GetImplicitArgs();
|
unsigned imp = Function->GetImplicitArgs();
|
||||||
if (Function->Variants[0].ArgFlags.Size() > imp && !(Function->Variants[0].ArgFlags[imp] & VARF_Optional)) return nullptr;
|
if (Function->Variants[0].ArgFlags.Size() > imp && !(Function->Variants[0].ArgFlags[imp] & VARF_Optional)) return nullptr;
|
||||||
|
@ -9558,11 +9558,11 @@ ExpEmit FxSequence::Emit(VMFunctionBuilder *build)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
VMFunction *FxSequence::GetDirectFunction(const VersionInfo &ver)
|
VMFunction *FxSequence::GetDirectFunction(PFunction *func, const VersionInfo &ver)
|
||||||
{
|
{
|
||||||
if (Expressions.Size() == 1)
|
if (Expressions.Size() == 1)
|
||||||
{
|
{
|
||||||
return Expressions[0]->GetDirectFunction(ver);
|
return Expressions[0]->GetDirectFunction(func, ver);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -10544,11 +10544,11 @@ ExpEmit FxReturnStatement::Emit(VMFunctionBuilder *build)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
VMFunction *FxReturnStatement::GetDirectFunction(const VersionInfo &ver)
|
VMFunction *FxReturnStatement::GetDirectFunction(PFunction *func, const VersionInfo &ver)
|
||||||
{
|
{
|
||||||
if (Args.Size() == 1)
|
if (Args.Size() == 1)
|
||||||
{
|
{
|
||||||
return Args[0]->GetDirectFunction(ver);
|
return Args[0]->GetDirectFunction(func, ver);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,7 +324,7 @@ public:
|
||||||
virtual bool isConstant() const;
|
virtual bool isConstant() const;
|
||||||
virtual bool RequestAddress(FCompileContext &ctx, bool *writable);
|
virtual bool RequestAddress(FCompileContext &ctx, bool *writable);
|
||||||
virtual PPrototype *ReturnProto();
|
virtual PPrototype *ReturnProto();
|
||||||
virtual VMFunction *GetDirectFunction(const VersionInfo &ver);
|
virtual VMFunction *GetDirectFunction(PFunction *func, const VersionInfo &ver);
|
||||||
virtual bool CheckReturn() { return false; }
|
virtual bool CheckReturn() { return false; }
|
||||||
virtual int GetBitValue() { return -1; }
|
virtual int GetBitValue() { return -1; }
|
||||||
bool IsNumeric() const { return ValueType->isNumeric(); }
|
bool IsNumeric() const { return ValueType->isNumeric(); }
|
||||||
|
@ -1721,7 +1721,7 @@ public:
|
||||||
~FxVMFunctionCall();
|
~FxVMFunctionCall();
|
||||||
FxExpression *Resolve(FCompileContext&);
|
FxExpression *Resolve(FCompileContext&);
|
||||||
PPrototype *ReturnProto();
|
PPrototype *ReturnProto();
|
||||||
VMFunction *GetDirectFunction(const VersionInfo &ver);
|
VMFunction *GetDirectFunction(PFunction *func, const VersionInfo &ver);
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
bool CheckEmitCast(VMFunctionBuilder *build, bool returnit, ExpEmit ®);
|
bool CheckEmitCast(VMFunctionBuilder *build, bool returnit, ExpEmit ®);
|
||||||
TArray<PType*> &GetReturnTypes() const
|
TArray<PType*> &GetReturnTypes() const
|
||||||
|
@ -1746,7 +1746,7 @@ public:
|
||||||
FxExpression *Resolve(FCompileContext&);
|
FxExpression *Resolve(FCompileContext&);
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
void Add(FxExpression *expr) { if (expr != NULL) Expressions.Push(expr); expr->NeedResult = false; }
|
void Add(FxExpression *expr) { if (expr != NULL) Expressions.Push(expr); expr->NeedResult = false; }
|
||||||
VMFunction *GetDirectFunction(const VersionInfo &ver);
|
VMFunction *GetDirectFunction(PFunction *func, const VersionInfo &ver);
|
||||||
bool CheckReturn();
|
bool CheckReturn();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1953,7 +1953,7 @@ public:
|
||||||
~FxReturnStatement();
|
~FxReturnStatement();
|
||||||
FxExpression *Resolve(FCompileContext&);
|
FxExpression *Resolve(FCompileContext&);
|
||||||
ExpEmit Emit(VMFunctionBuilder *build);
|
ExpEmit Emit(VMFunctionBuilder *build);
|
||||||
VMFunction *GetDirectFunction(const VersionInfo &ver);
|
VMFunction *GetDirectFunction(PFunction *func, const VersionInfo &ver);
|
||||||
bool CheckReturn() { return true; }
|
bool CheckReturn() { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -804,10 +804,12 @@ FFunctionBuildList FunctionBuildList;
|
||||||
|
|
||||||
VMFunction *FFunctionBuildList::AddFunction(PNamespace *gnspc, const VersionInfo &ver, PFunction *functype, FxExpression *code, const FString &name, bool fromdecorate, int stateindex, int statecount, int lumpnum)
|
VMFunction *FFunctionBuildList::AddFunction(PNamespace *gnspc, const VersionInfo &ver, PFunction *functype, FxExpression *code, const FString &name, bool fromdecorate, int stateindex, int statecount, int lumpnum)
|
||||||
{
|
{
|
||||||
auto func = code->GetDirectFunction(ver);
|
auto func = code->GetDirectFunction(functype, ver);
|
||||||
if (func != nullptr)
|
if (func != nullptr)
|
||||||
{
|
{
|
||||||
delete code;
|
delete code;
|
||||||
|
|
||||||
|
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Inventory : Actor native
|
||||||
native void ModifyDropAmount(int dropamount);
|
native void ModifyDropAmount(int dropamount);
|
||||||
native static void PrintPickupMessage (bool localview, String str);
|
native static void PrintPickupMessage (bool localview, String str);
|
||||||
|
|
||||||
States(Actor, Overlay, Weapon, Item)
|
States(Actor)
|
||||||
{
|
{
|
||||||
HideDoomish:
|
HideDoomish:
|
||||||
TNT1 A 1050;
|
TNT1 A 1050;
|
||||||
|
|
|
@ -45,7 +45,7 @@ extend class StateProvider
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
void A_FireAssaultGun()
|
action void A_FireAssaultGun()
|
||||||
{
|
{
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue