1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
--- lam.dump --- dump raw lua values
local m = {}
local type = require("type")
function m.dump (x, lvl)
lvl = lvl or 0
local space = string.rep(" ", lvl*4)
local out = {}
if type.luatype(x) == "table" then
local sub = {}
for k, v in pairs(x) do
if v == x then
v = "self"
elseif type.lamtype(v) == "environment" then
v = tostring(v)
else
v = m.dump(v, lvl+1)
end
table.insert(sub,
string.format("\n%s[%s] = %s,", space, k, v))
end
table.insert(out,
string.format("\n%s{%s\n%s}",
space, table.concat(sub), space))
else
table.insert(out, tostring(x))
end
return table.concat(out)
end
--------
return m
|