MCPcopy Create free account
hub / github.com/Norbyte/bg3se / GetVariablesInLocal

Method GetVariablesInLocal

BG3Extender/Lua/Debugger/LuaDebugger.cpp:1112–1155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1110 }
1111
1112 ResultCode ContextDebugger::GetVariablesInLocal(lua_State* L, DebuggerGetVariablesRequest const& req)
1113 {
1114 auto top = lua_gettop(L);
1115 try {
1116 if (!PushVariableContext(L, req)) {
1117 return ResultCode::EvalFailed;
1118 }
1119
1120 for (auto const& key : req.Key) {
1121 if (key.Int) {
1122 push(L, *key.Int); // stack: table, key
1123 } else {
1124 push(L, *key.String); // stack: table, key
1125 }
1126
1127 lua_gettable(L, -2); // stack: table, value
1128 lua_remove(L, -2); // stack: value
1129 }
1130
1131 auto retval = lua_absindex(L, -1);
1132 if (IsLuaContainerType(L, retval)) {
1133 LuaValueToEvalResults(L, lua_absindex(L, retval), req);
1134 lua_pop(L, 1);
1135 return ResultCode::Success;
1136 } else {
1137 req.Response->set_error_message("Can only enumerate table or cppobject types");
1138 lua_pop(L, 1);
1139 return ResultCode::EvalFailed;
1140 }
1141
1142 } catch (Exception&) {
1143 auto stackRemaining = lua_gettop(L) - top;
1144 if (stackRemaining > 0) {
1145 req.Response->set_error_message(lua_tostring(L, -1));
1146 lua_pop(L, stackRemaining);
1147 } else {
1148 req.Response->set_error_message("Internal Lua error during evaluation");
1149 }
1150
1151 return ResultCode::EvalFailed;
1152 }
1153
1154 return ResultCode::Success;
1155 }
1156
1157 ResultCode ContextDebugger::GetVariablesInStackFrame(lua_State* L, DebuggerGetVariablesRequest const& req)
1158 {

Callers 1

ContextDebuggerGetVarFunction · 0.80

Calls 3

IsLuaContainerTypeFunction · 0.85
LuaValueToEvalResultsFunction · 0.85
pushFunction · 0.50

Tested by

no test coverage detected