lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Sven,

Am 10.12.2012 um 22:48 schrieb Sven Olsen:


Hrm.  Well, if you push the function via lua_getglobal, then you're pushing it to the C stack -- so you don't want to use lua_getinfo() to get its name back -- lua_getinfo() references the runtime stack.  

Actually, that's not quite true :)

If you push various C-functions to the stack, then call lua_call, the function that gets executed via lua_call will become part of the runtime stack, while any other functions pushed as arguments will become part of the new C stack. 

I'm interested in the C stack only, because for debugging passing / returning arguments from / to the Lua functions. So I push via C API the Lua function to the C stack and run lua_call, but on some debug runs I will create a output
of the C stack before the lua_call is run, so my stack shows eg

4   number 123
3   string "test"
2   boolean "true"
1   lua function

and on the item 1 it would read the name of the function. In my case the Lua function and the arguments of the function are pushed by the routines on program top, so in the cases there are different Lua function.
If I iterate on a stack (eg above), I would get only the function name back. I can determine that a stack item is a lua function (or a C function) but can I get a reference of the name of the function? I push it also with
a name to the stack, so somewhere must be stored that the item n is a lua function with a name or is the stack item of a lua function a pointer to the a memory block?

Thanks

Phil