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

Function addreturn

third-party/lua-5.3.5/src/lua.c:332–344  ·  view source on GitHub ↗

** Try to compile line on the stack as 'return ;'; on return, stack ** has either compiled chunk or original line (if compilation failed). */

Source from the content-addressed store, hash-verified

330** has either compiled chunk or original line (if compilation failed).
331*/
332static int addreturn (lua_State *L) {
333 const char *line = lua_tostring(L, -1); /* original line */
334 const char *retline = lua_pushfstring(L, "return %s;", line);
335 int status = luaL_loadbuffer(L, retline, strlen(retline), "=stdin");
336 if (status == LUA_OK) {
337 lua_remove(L, -2); /* remove modified line */
338 if (line[0] != '\0') /* non empty? */
339 lua_saveline(L, line); /* keep history */
340 }
341 else
342 lua_pop(L, 2); /* pop result from 'luaL_loadbuffer' and modified line */
343 return status;
344}
345
346
347/*

Callers 1

loadlineFunction · 0.70

Calls 4

luaL_loadbufferFunction · 0.85
lua_savelineFunction · 0.85
lua_pushfstringFunction · 0.70
lua_removeFunction · 0.50

Tested by

no test coverage detected