MCPcopy Create free account
hub / github.com/DFHack/dfhack / pushglobalfuncname

Function pushglobalfuncname

depends/lua/src/lauxlib.c:73–91  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

71** Search for a name for a function in all loaded modules
72*/
73static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
74 int top = lua_gettop(L);
75 lua_getinfo(L, "f", ar); /* push function */
76 lua_getfield(L, LUA_REGISTRYINDEX, LUA_LOADED_TABLE);
77 if (findfield(L, top + 1, 2)) {
78 const char *name = lua_tostring(L, -1);
79 if (strncmp(name, "_G.", 3) == 0) { /* name start with '_G.'? */
80 lua_pushstring(L, name + 3); /* push name without prefix */
81 lua_remove(L, -2); /* remove original name */
82 }
83 lua_copy(L, -1, top + 1); /* move name to proper place */
84 lua_pop(L, 2); /* remove pushed values */
85 return 1;
86 }
87 else {
88 lua_settop(L, top); /* remove function and global table */
89 return 0;
90 }
91}
92
93
94static void pushfuncname (lua_State *L, lua_Debug *ar) {

Callers 2

pushfuncnameFunction · 0.85
luaL_argerrorFunction · 0.85

Calls 7

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

Tested by

no test coverage detected