[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Querying Lua stack for function information
- From: Jonathan Murphy <nuclearfriend@...>
- Date: Tue, 12 May 2009 12:21:45 +1000
Hi all, I've been attempting to draw some information about functions that reside on the stack frame (just for debugging purposes). I have a function that I gleamed from an online resource (can't remember where) that looks like this: http://rafb.net/p/dYZsjE83.html.
But I really want to handle the LUA_TFUNCTION type, and possibly print out if the function is a cfunc or luafunc. If it's a luafunc I'd also like to know it's name.
I've tried to use lua_getstack and lua_getinfo, something along the lines of:
case LUA_TFUNCTION:
lua_Debug ar;
lua_getstack(luaState, i - 1, &ar);
lua_getinfo(luaState, ">Sn", &ar);
break;
But I think getinfo would pop the function, which wasn't much help when I wanted to query the stack without modifying it.
Any suggestions?