summaryrefslogtreecommitdiff
path: root/Runtime/Scripting/luax_vm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Scripting/luax_vm.cpp')
-rw-r--r--Runtime/Scripting/luax_vm.cpp76
1 files changed, 0 insertions, 76 deletions
diff --git a/Runtime/Scripting/luax_vm.cpp b/Runtime/Scripting/luax_vm.cpp
deleted file mode 100644
index 4dc7e0c..0000000
--- a/Runtime/Scripting/luax_vm.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#include "luax_internal.h"
-#include "luax_vm.h"
-
-namespace Luax
-{
-
- LuaxVM::VMap LuaxVM::VMs; // 通过线程查找虚拟机,为了方便
-
- LuaxVM* LuaxVM::TryGetVM(global_State* gState)
- {
- auto it = VMs.find(gState);
- if (it != VMs.end())
- return it->second;
- else
- return nullptr;
- }
-
- LuaxVM* LuaxVM::TryGetVM(lua_State* state)
- {
- return TryGetVM(G(state));
- }
-
- LuaxVM::LuaxVM()
- : mStrongRefTable()
- , mWeakRefTable()
- {
- mMainThread = luaL_newstate();
- assert(mMainThread);
- mGlobalState = G(mMainThread);
-
- VMs.insert(std::pair<global_State*, LuaxVM*>(mGlobalState, this));
- }
-
- LuaxVM::~LuaxVM()
- {
- VMs.erase(mGlobalState);
- lua_close(mMainThread);
- }
-
- // 初始化context
- void LuaxVM::Setup()
- {
- LUAX_STATE(mMainThread);
-
- mStrongRefTable.Init(state, "_LUAX_STRONGREF_TABLE");
- mWeakRefTable.Init(state, "_LUAX_WEAKREF_TABLE", "v");
- }
-
- lua_State* LuaxVM::CreateThread()
- {
- lua_State* thread = lua_newthread(mMainThread);
- assert(thread);
- return thread;
- }
-
- lua_State* LuaxVM::GetMainThread()
- {
- return mMainThread;
- }
-
- LuaxState LuaxVM::GetMainState()
- {
- return mMainThread;
- }
-
- LuaxRefTable& LuaxVM::GetStrongRefTable()
- {
- return mStrongRefTable;
- }
-
- LuaxRefTable& LuaxVM::GetWeakRefTable()
- {
- return mWeakRefTable;
- }
-
-} \ No newline at end of file