@@ -17,6 +17,7 @@ function table_clone (target)
17
17
return dest ;
18
18
end
19
19
20
+ -- say debug_get("l") in the repl to find the innermost "l" variable
20
21
function debug_get (var )
21
22
local i = 1
22
23
while true do
@@ -31,14 +32,39 @@ function debug_get (var)
31
32
end
32
33
end
33
34
35
+ function debug_flat (obj )
36
+ local out = {}
37
+ for k , v in pairs (obj ) do
38
+ -- flatten Storage info into the result
39
+ if k == " Storage" then
40
+ for ks , vs in pairs (v ) do
41
+ -- for P6opaque, merge all per-class attribute lists together
42
+ if type (ks ) == " table" then
43
+ for kss , vss in pairs (vs ) do
44
+ out [kss ] = vss
45
+ end
46
+ else
47
+ out [ks ] = vs
48
+ end
49
+ end
50
+ else
51
+ out [k ] = v
52
+ end
53
+ end
54
+ return out
55
+ end
56
+
34
57
function table_desc (target )
35
58
if (type (target ) == " nil" ) then
36
59
print (" table_desc target was nil" );
37
60
elseif (type (target ) ~= " table" ) then
38
61
print (" table_desc target wasn't a table; it was a " .. type (target ));
39
62
else
40
63
print (" table_desc : " .. tostring (target ));
41
- for k ,v in pairs (target ) do print (k .. " : " .. tostring (v )) end
64
+ keys = {}
65
+ for k ,_ in pairs (target ) do table.insert (keys , k ) end
66
+ table.sort (keys , function (k1 , k2 ) return tostring (k1 ) < tostring (k2 ) end )
67
+ for _ ,k in ipairs (keys ) do print (" " .. tostring (k ) .. " : " .. tostring (target [k ])) end
42
68
end
43
69
end
44
70
0 commit comments