Only generate the self==stateowner check inside action functions

This commit is contained in:
Marisa Heit 2016-10-01 21:47:15 -05:00
parent 51ffd6d9c6
commit 944ae2bc09
4 changed files with 8 additions and 4 deletions

View file

@ -288,7 +288,7 @@ static void FinishThingdef()
if (func == nullptr) if (func == nullptr)
{ {
VMFunctionBuilder buildit; VMFunctionBuilder buildit(true);
assert(tcall->Proto != nullptr); assert(tcall->Proto != nullptr);

View file

@ -3373,7 +3373,7 @@ FxExpression *FxClassMember::Resolve(FCompileContext &ctx)
ExpEmit FxClassMember::Emit(VMFunctionBuilder *build) ExpEmit FxClassMember::Emit(VMFunctionBuilder *build)
{ {
if (~membervar->Flags & VARF_Native) if (build->IsActionFunc && ~membervar->Flags & VARF_Native)
{ // Check if this is a user-defined variable. { // Check if this is a user-defined variable.
// As of right now, FxClassMember is only ever used with FxSelf. // As of right now, FxClassMember is only ever used with FxSelf.
// This very user variable was defined in stateowner so if // This very user variable was defined in stateowner so if

View file

@ -6,7 +6,7 @@
// //
//========================================================================== //==========================================================================
VMFunctionBuilder::VMFunctionBuilder() VMFunctionBuilder::VMFunctionBuilder(bool selfcheck)
{ {
NumIntConstants = 0; NumIntConstants = 0;
NumFloatConstants = 0; NumFloatConstants = 0;
@ -14,6 +14,7 @@ VMFunctionBuilder::VMFunctionBuilder()
NumStringConstants = 0; NumStringConstants = 0;
MaxParam = 0; MaxParam = 0;
ActiveParam = 0; ActiveParam = 0;
IsActionFunc = selfcheck;
} }
//========================================================================== //==========================================================================

View file

@ -23,7 +23,7 @@ public:
friend class VMFunctionBuilder; friend class VMFunctionBuilder;
}; };
VMFunctionBuilder(); VMFunctionBuilder(bool checkself = false);
~VMFunctionBuilder(); ~VMFunctionBuilder();
VMScriptFunction *MakeFunction(); VMScriptFunction *MakeFunction();
@ -60,6 +60,9 @@ public:
// Track available registers. // Track available registers.
RegAvailability Registers[4]; RegAvailability Registers[4];
// For use by DECORATE's self/stateowner sanitizer.
bool IsActionFunc;
private: private:
struct AddrKonst struct AddrKonst
{ {