LUA_GETINFO(3) | Library Functions Manual | LUA_GETINFO(3) |
lua_getinfo
—
returns information about a specific function or function
invocation, function indicator [- (0|1), + Pq 0|1|2 , m]
#include
<lua.h>
int
lua_getinfo
(lua_State
*L, const char
*what, lua_Debug
*ar);
lua_getinfo
()
returns information about a specific function or function invocation.
To get information about a function invocation, the parameter ar must be a valid activation record that was filled by a previous call to lua_getstack or given as argument to a hook (see lua_Hook(3)).
To get information about a function you push it onto the stack and
start the what string with the character '>'. (In that case,
lua_getinfo
pops the function in the top of the
stack.) For instance, to know in which line a function
f was defined, you can write the following code:
lua_Debug ar; lua_getfield(L, LUA_GLOBALSINDEX, "f"); /* get global 'f' */ lua_getinfo(L, ">S", &ar); printf("%d\n", ar.linedefined);
Each character in the string what selects some fields of the structure ar to be filled or a value to be pushed on the stack:
Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes, Lua 5.1 Reference Manual.
The lua_getinfo
() manual page is based on
Lua Reference Manual 5.1 and was created by Sergey Bronnikov.
July 19, 2022 | Debian |