-
Notifications
You must be signed in to change notification settings - Fork 1
/
dump_sorted_module.nut
68 lines (55 loc) · 1.21 KB
/
dump_sorted_module.nut
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
local dag_system = require_optional("dagor.system")
local argv = dag_system?.argv ?? ::__argv;
local print_table = true;
foreach (a in argv)
if (a == "--dont-print-table")
print_table = false;
local output = []
local function dump_keys(table, prefix, depth)
{
if (depth == 1 && prefix == "globals.")
return;
foreach (k, v in table)
{
local s = prefix + k;
output.append(s);
if (depth < 1 && (type(v) == "table" || type(v) == "class"))
::callee()(v, prefix + k + ".", depth + 1);
}
}
dump_keys(::getroottable(), "", 0);
dump_keys(::getconsttable(), "", 0);
output.sort();
if (print_table)
foreach (s in output) print(".R. " + s + "\n");
try
{
::print(dump_table + "\n");
}
catch (e)
{
return;
}
try
{
local prevOutput = clone output;
output = [];
local table = dump_table();
dump_keys(::getroottable(), "", 0)
dump_keys(::getconsttable(), "", 0)
output.sort();
foreach (s in output)
if (prevOutput.indexof(s) == null)
if (print_table)
print(".A. " + s + "\n");
output = [];
dump_keys(table, "", 0);
foreach (s in output)
if (print_table)
print(".M. " + s + "\n");
}
catch (e)
{
if (print_table)
print(".E. fail to require\n");
}