Module Debug
Manipulation of upvalues and locals.
Module Status: Work in progress.
Usage:
local Debug = require('__eradicators-library__/erlib/lua/Debug')()
Section
TOO_DEEP | This unique empty table is used as a value by Debug.get_upvalue_tree to signal that the real value was not retrieved because the depth limit has been reached. |
get_upvalue_tree(obj[, depth=2[, include_everything=true]]) | __!WARNING! Unfinished. |
Section
- TOO_DEEP
-
This unique empty table is used as a value by Debug.get_upvalue_tree to signal
that the real value was not retrieved because the depth limit has been reached.
Usage:
if value == Debug.TOO_DEEP then --[[ignore value]] end
- get_upvalue_tree(obj[, depth=2[, include_everything=true]])
-
!WARNING! Unfinished. Only use for testing.
Recursively explores the upvalues of a function or table.
Parameters:
- obj function or table the starting point of the exploration
- depth NaturalNumber The maximum deepth to explore. Any values deeper than this will instead be replaced with Debug.TOO_DEEP. There is no protection against infinite loops so be careful not to set it too high. (default 2)
- include_everything boolean Should numbers, strings etc be in the output table? If false then only functions and tables will be included. (default true)
Returns:
-
table or nil
A table of upvalues. Any value that would be a function is
replaced by a table {__f=TheFunction,__up={The,Up,Values}}.
Usage:
local a,b,three = 'a','b',3 local d = {a,b} local f1 = function() return a,b end local f2 = function() return f1,three,d end print( erlib.Hydra.lines( erlib.Debug.get_upvalue_tree({k1=f1,k2=f2},3,false) ,{indentlevel=5} ) ) > { > k1 = { > __f = function()end, > __up = { > a = "a", > b = "b" > } > }, > k2 = { > __f = function()end, > __up = { > d = { > {}, -- Debug.TOO_DEEP > 0 --[[ self.k2.__up.d[1] ]] > }, > f1 = { > __f = 0 --[[ self.k1.__f ]], > __up = { > a = 0 --[[ self.k2.__up.d[1] ]], > b = 0 --[[ self.k2.__up.d[1] ]] > } > }, > three = 3 > } > } > }