diff options
author | chai <chaifix@163.com> | 2019-03-29 08:56:55 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-03-29 08:56:55 +0800 |
commit | 62085e1b49ce2d8a630373e410812d5c4a9eecc2 (patch) | |
tree | 5b221e36ff35348aaedc041a2a0513f1d0390ecf /source/3rd-party/Luax/luax_ref.cpp | |
parent | f4c338c63f3456a8eccd56c35e233843687d55be (diff) |
*luax
Diffstat (limited to 'source/3rd-party/Luax/luax_ref.cpp')
-rw-r--r-- | source/3rd-party/Luax/luax_ref.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/source/3rd-party/Luax/luax_ref.cpp b/source/3rd-party/Luax/luax_ref.cpp index 544861d..78596e3 100644 --- a/source/3rd-party/Luax/luax_ref.cpp +++ b/source/3rd-party/Luax/luax_ref.cpp @@ -1,4 +1,4 @@ -#include "luax_runtime.h" +#include "luax_vm.h" #include "luax_ref.h" namespace Luax @@ -23,16 +23,16 @@ namespace Luax { assert(mRefID != LUA_NOREF); - LuaxRuntime& runtime = LuaxRuntime::Get(); - + LuaxVM* vm = LuaxVM::TryGetVM(state); + if (!vm) return false; if (mMode == STRONG_REF) { - LuaxRefTable& table = runtime[state.GetHandle()].strongRefTable; + LuaxRefTable& table = vm->GetStrongRefTable(); table.PushRef(state, mRefID); } else if (mMode == WEAK_REF) { - LuaxRefTable& table = runtime[state.GetHandle()].weakRefTable; + LuaxRefTable& table = vm->GetWeakRefTable(); table.PushRef(state, mRefID); } else @@ -43,15 +43,16 @@ namespace Luax void LuaxRef::SetRef(LuaxState& state, int idx) { - LuaxRuntime& runtime = LuaxRuntime::Get(); + LuaxVM* vm = LuaxVM::TryGetVM(state); + if (!vm) return; if (mMode == STRONG_REF) { - LuaxRefTable& table = runtime[state.GetHandle()].strongRefTable; + LuaxRefTable& table = vm->GetStrongRefTable(); mRefID = table.Ref(state, idx); } else if (mMode == WEAK_REF) { - LuaxRefTable& table = runtime[state.GetHandle()].weakRefTable; + LuaxRefTable& table = vm->GetWeakRefTable(); mRefID = table.Ref(state, idx); } } |