MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / DisplayFunction54

Function DisplayFunction54

emmy_debugger/src/debugger/emmy_debugger.cpp:292–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290
291#ifndef EMMY_USE_LUA_SOURCE
292void DisplayFunction54(Idx<Variable> variable, lua_State *L, int index, lua_Debug_54 &ar) {
293 if (ar.what == nullptr) {
294 return;
295 }
296 std::string what = ar.what;
297 if (what == "Lua") {
298 auto paramNum = ar.nparams > 10 ? 10 : ar.nparams;
299 std::string showValue = "function(";
300 lua_pushvalue(L, index);
301 for (auto i = 0; i != paramNum; i++) {
302 auto paramIndex = i + 1;
303 auto paramName = lua_getlocal(L, nullptr, paramIndex);
304 if (paramName) {
305 showValue.append(paramName);
306 if (paramIndex != paramNum) {
307 showValue.append(", ");
308 }
309 }
310 }
311 showValue.push_back(')');
312 variable->value = showValue;
313 variable->valueType = 9;
314 variable->valueTypeName = "function";
315 // ptr
316 auto ptr = variable.GetArena()->Alloc();
317 ptr->nameType = LUA_TSTRING;
318 ptr->valueType = LUA_TFUNCTION;
319 ptr->name = "pointer";
320 ptr->value = ToPointer(L, index);
321
322 // source
323 if (ar.source) {
324 std::string sourceText = ar.source;
325 if (!sourceText.empty() && sourceText.front() == '@') {
326 sourceText = sourceText.substr(1);
327 }
328 auto source = variable.GetArena()->Alloc();
329 source->nameType = LUA_TSTRING;
330 source->valueType = LUA_TSTRING;
331 source->name = "source";
332 source->value = sourceText.append(":").append(std::to_string(ar.linedefined));
333 }
334 } else if (what == "C") {
335 variable->value = "C " + ToPointer(L, index);
336 } else {
337 variable->value = ToPointer(L, index);
338 return;
339 }
340}
341
342void DisplayFunction(Idx<Variable> variable, lua_State *L, int index) {
343 lua_Debug ar{};

Callers 1

DisplayFunctionFunction · 0.85

Calls 7

ToPointerFunction · 0.85
push_backMethod · 0.80
AllocMethod · 0.80
GetArenaMethod · 0.80
lua_pushvalueFunction · 0.50
lua_getlocalFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected