MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / pushglobalfuncname

Function pushglobalfuncname

lib/lua/src/lauxlib.c:79–98  ·  view source on GitHub ↗

** Search for a name for a function in all loaded modules */

Source from the content-addressed store, hash-verified

77** Search for a name for a function in all loaded modules
78*/
79static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
80 int top = lua_gettop(L);
81 lua_getinfo(L, "f", ar); /* push function */
82 lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
83 luaL_checkstack(L, 6, "not enough stack"); /* slots for 'findfield' */
84 if (findfield(L, top + 1, 2)) {
85 const char *name = lua_tostring(L, -1);
86 if (strncmp(name, LUA_GNAME ".", 3) == 0) { /* name start with '_G.'? */
87 lua_pushstring(L, name + 3); /* push name without prefix */
88 lua_remove(L, -2); /* remove original name */
89 }
90 lua_copy(L, -1, top + 1); /* copy name to proper place */
91 lua_settop(L, top + 1); /* remove table "loaded" and name copy */
92 return 1;
93 }
94 else {
95 lua_settop(L, top); /* remove function and global table */
96 return 0;
97 }
98}
99
100
101static void pushfuncname (lua_State *L, lua_Debug *ar) {

Callers 2

pushfuncnameFunction · 0.85
luaL_argerrorFunction · 0.85

Calls 8

lua_gettopFunction · 0.85
lua_getinfoFunction · 0.85
lua_getfieldFunction · 0.85
luaL_checkstackFunction · 0.85
findfieldFunction · 0.85
lua_pushstringFunction · 0.85
lua_copyFunction · 0.85
lua_settopFunction · 0.85

Tested by

no test coverage detected