debug.getinfo()
#!/usr/bin/env lua debug.debug()
で、
lua_debug> print(debug.getinfo(math.abs)) table: 0x8050a40 lua_debug> table.foreach(debug.getinfo(math.abs), function(k,v) print(k,v); return nil; end) source =[C] what C func function: 0x804f5f0 short_src [C] currentline -1 namewhat linedefined -1 nups 0 lua_debug> function foo() print("foo"); end lua_debug> table.foreach(debug.getinfo(foo), function(k,v) print(k,v); return nil; end) source function foo() print("foo"); end what Lua func function: 0x804c5b0 name foo nups 0 currentline -1 namewhat global linedefined 1 short_src [string "function foo() print("foo"); end..."]
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio > table.foreach(debug.getinfo(math.abs), function(k,v) print(k,v); return nil; end) source =[C] what C func function: 0x804f5f0 short_src [C] currentline -1 namewhat linedefined -1 nups 0 > function foo() print("foo"); end > table.foreach(debug.getinfo(foo), function(k,v) print(k,v); return nil; end) source =stdin what Lua func function: 0x805b5c8 name foo nups 0 currentline -1 namewhat global linedefined 1 short_src stdin > print(debug.getinfo(1,"n").name) nil > print(debug.getinfo(math.abs).source) =[C] > table.foreach(debug.getinfo(print), function(k,v) print(k,v); return nil; end)source =[C] what C func function: 0x804d218 name print nups 0 currentline -1 namewhat global linedefined -1 short_src [C]