MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaV_execute

Function luaV_execute

src/Chain/libraries/glua/lvm.cpp:959–1740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

957 } \
958}
959void luaV_execute(lua_State *L)
960{
961 if (L->force_stopping)
962 return;
963 CallInfo *ci = L->ci;
964 LClosure *cl;
965 TValue *k;
966 StkId base;
967 ci->callstatus |= CIST_FRESH; /* fresh invocation of 'luaV_execute" */
968newframe: /* reentry point when frame changes (call/return) */
969 lua_assert(ci == L->ci);
970 cl = clLvalue(ci->func); /* local reference to function's closure */
971 k = cl->p->k; /* local reference to function's constant table */
972 base = ci->u.l.base; /* local copy of function's base */
973
974 int insts_limit = thinkyoung::lua::lib::get_lua_state_value(L, INSTRUCTIONS_LIMIT_LUA_STATE_MAP_KEY).int_value;
975 int *stopped_pointer = thinkyoung::lua::lib::get_lua_state_value(L, LUA_STATE_STOP_TO_RUN_IN_LVM_STATE_MAP_KEY).int_pointer_value;
976 if (nullptr == stopped_pointer)
977 {
978 thinkyoung::lua::lib::notify_lua_state_stop(L);
979 thinkyoung::lua::lib::resume_lua_state_running(L);
980 stopped_pointer = thinkyoung::lua::lib::get_lua_state_value(L, LUA_STATE_STOP_TO_RUN_IN_LVM_STATE_MAP_KEY).int_pointer_value;
981 }
982 int has_insts_limit = insts_limit > 0 ? 1 : 0;
983 int *insts_executed_count = thinkyoung::lua::lib::get_lua_state_value(L, INSTRUCTIONS_EXECUTED_COUNT_LUA_STATE_MAP_KEY).int_pointer_value;
984 if (nullptr == insts_executed_count)
985 {
986 insts_executed_count = static_cast<int*>(lua_malloc(L, sizeof(int)));
987 *insts_executed_count = 0;
988 GluaStateValue lua_state_value_of_exected_count;
989 lua_state_value_of_exected_count.int_pointer_value = insts_executed_count;
990 thinkyoung::lua::lib::set_lua_state_value(L, INSTRUCTIONS_EXECUTED_COUNT_LUA_STATE_MAP_KEY, lua_state_value_of_exected_count, LUA_STATE_VALUE_INT_POINTER);
991 }
992 if (*insts_executed_count < 0)
993 *insts_executed_count = 0;
994
995 lua_getglobal(L, "last_return");
996 bool use_last_return = true; // lua_istable(L, -1);
997 lua_pop(L, 1);
998
999 int last_debug_line_in_file = -1;
1000
1001 /* main loop of interpreter */
1002 for (;;) {
1003 while (L->bytecode_debugger_opened && remote_debugger && remote_debugger->is_pausing_lvm())
1004 {
1005 std::this_thread::sleep_for(std::chrono::seconds(1));
1006 }
1007 // TODO: 添加断点调试, 外部socket设置文件名,断点位置(字节码指令offset)列表,继续/暂停等
1008 if(L->bytecode_debugger_opened)
1009 {
1010 // TODO
1011 if(!remote_debugger)
1012 {
1013 remote_debugger = new glua::debugger::LRemoteDebugger();
1014 }
1015 L->debugger_pausing = false;
1016

Callers 3

luaD_callFunction · 0.85
unrollFunction · 0.85
resumeFunction · 0.85

Calls 15

get_lua_state_valueFunction · 0.85
notify_lua_state_stopFunction · 0.85
resume_lua_state_runningFunction · 0.85
lua_mallocFunction · 0.85
set_lua_state_valueFunction · 0.85
lua_getglobalFunction · 0.85
sleep_forFunction · 0.85
luaG_traceexecFunction · 0.85
is_pausing_lvmMethod · 0.80
start_asyncMethod · 0.80
debugger_source_linesMethod · 0.80

Tested by

no test coverage detected