Skip to content

Commit 00f10c1

Browse files
committed
Commit improved table_desc and new debug_flat used to debug missing Mu
1 parent ef39dd4 commit 00f10c1

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

lua/runtime/Init.lua

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function table_clone (target)
1717
return dest;
1818
end
1919

20+
-- say debug_get("l") in the repl to find the innermost "l" variable
2021
function debug_get (var)
2122
local i = 1
2223
while true do
@@ -31,14 +32,39 @@ function debug_get (var)
3132
end
3233
end
3334

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+
3457
function table_desc (target)
3558
if (type(target) == "nil") then
3659
print("table_desc target was nil");
3760
elseif (type(target) ~= "table") then
3861
print("table_desc target wasn't a table; it was a " .. type(target));
3962
else
4063
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
4268
end
4369
end
4470

0 commit comments

Comments
 (0)