fix list handling, add puketh
This commit is contained in:
parent
cb65a188a8
commit
8fb54ede26
@ -296,11 +296,11 @@ end
|
||||
-- default). used for table
|
||||
-- debugging. table-type keys
|
||||
-- are not legible here
|
||||
function puke(item, indent, seen)
|
||||
function puke(item, indent, seen, hidekey)
|
||||
if (type(item) ~= "table") return tostr(item)
|
||||
|
||||
seen = seen or {}
|
||||
if (seen[item]) return "<<PREV>>"
|
||||
if (seen[item]) return "<<...>>"
|
||||
seen[item] = true
|
||||
|
||||
indent = indent or 0
|
||||
@ -313,20 +313,23 @@ function puke(item, indent, seen)
|
||||
local ret,n = "linked_list <",0
|
||||
item:strip(function(x)
|
||||
n += 1
|
||||
local masked_x = {next="<<...>>"}
|
||||
setmetatable(masked_x, {__index=x})
|
||||
ret ..= pfx..tostr(n)..": "..masked_x
|
||||
ret ..= pfx..tostr(n)..": "..puke(x, indent+1, seen, "next")
|
||||
end)
|
||||
return ret..pfx..">"
|
||||
end
|
||||
|
||||
local ret = "{"
|
||||
for k, v in pairs(item) do
|
||||
ret ..= pfx..tostr(k)..": "..puke(v, indent+1, seen)
|
||||
if (k ~= hidekey) ret ..= pfx..tostr(k)..": "..puke(v, indent+1, seen)
|
||||
end
|
||||
return ret..pfx.."}"
|
||||
end
|
||||
|
||||
-- convenience for debugging
|
||||
function puketh(item)
|
||||
printh(puke(item))
|
||||
end
|
||||
|
||||
function drawgame()
|
||||
cls()
|
||||
clip(0,0,112,128)
|
||||
|
Loading…
Reference in New Issue
Block a user