dear pesky plumbers
This commit is contained in:
parent
ab2b4a4dff
commit
62866ee36c
5 changed files with 377 additions and 1 deletions
199
!_G.yml
Normal file
199
!_G.yml
Normal file
|
@ -0,0 +1,199 @@
|
|||
__root__: &t0xc4e478
|
||||
_VERSION: "Lua 5.2"
|
||||
add_zeros: f0xc56f38
|
||||
assert: f0x1fefc
|
||||
collectgarbage: f0x1f930
|
||||
dofile: f0x1fe7c
|
||||
dump: f0xc578c0
|
||||
error: f0x1f8c0
|
||||
getaddr: f0xc53f00
|
||||
getmetatable: f0x1fe2c
|
||||
ipairs: f0x1fd24
|
||||
load: f0x1ff54
|
||||
loadfile: f0x1fd80
|
||||
loadstring: f0x1ff54
|
||||
mixed_sorter: f0xc56ef0
|
||||
module: f0xc4ee20
|
||||
next: f0x1f7ac
|
||||
opairs: f0xc53630
|
||||
order_keys: f0xc56ea8
|
||||
pairs: f0x1fd04
|
||||
pcall: f0x1fb50
|
||||
print: f0x1f66c
|
||||
rawequal: f0x1f62c
|
||||
rawget: f0x1f598
|
||||
rawlen: f0x1f5d8
|
||||
rawset: f0x1f54c
|
||||
rawstr: f0xc56e60
|
||||
require: f0xc4fb00
|
||||
select: f0x1f444
|
||||
setmetatable: f0x1fbc0
|
||||
strpad: f0xc52890
|
||||
tonumber: f0x1f25c
|
||||
tostring: f0x1f234
|
||||
type: f0x1f1f8
|
||||
unpack: f0x26598
|
||||
xpcall: f0x1fa84
|
||||
_G: *t0xc4e478
|
||||
arg: &t0xc526b8
|
||||
"-1": "/usr/bin/lua"
|
||||
0: "./run.lua"
|
||||
bit32: &t0xc4f190
|
||||
arshift: f0x2022c
|
||||
band: f0x20458
|
||||
bnot: f0x20208
|
||||
bor: f0x204c4
|
||||
btest: f0x20434
|
||||
bxor: f0x20478
|
||||
extract: f0x203a4
|
||||
lrotate: f0x20510
|
||||
lshift: f0x20190
|
||||
replace: f0x20338
|
||||
rrotate: f0x201c4
|
||||
rshift: f0x2015c
|
||||
coroutine: &t0xc4e998
|
||||
create: f0x20844
|
||||
resume: f0x20934
|
||||
running: f0x20824
|
||||
status: f0x206cc
|
||||
wrap: f0x20888
|
||||
yield: f0x20584
|
||||
debug: &t0xc507c8
|
||||
debug: f0x20e44
|
||||
gethook: f0x21470
|
||||
getinfo: f0x21674
|
||||
getlocal: f0x2132c
|
||||
getmetatable: f0x20d88
|
||||
getregistry: f0x209fc
|
||||
getupvalue: f0x20aac
|
||||
getuservalue: f0x20e0c
|
||||
sethook: f0x2118c
|
||||
setlocal: f0x21094
|
||||
setmetatable: f0x20ab4
|
||||
setupvalue: f0x20a8c
|
||||
setuservalue: f0x20b58
|
||||
traceback: f0x20ff8
|
||||
upvalueid: f0x20ca0
|
||||
upvaluejoin: f0x20cd8
|
||||
io: &t0xc4ffe8
|
||||
close: f0x21c94
|
||||
flush: f0x22328
|
||||
input: f0x22a28
|
||||
lines: f0x22a44
|
||||
open: f0x22b64
|
||||
output: f0x22a0c
|
||||
popen: f0x2238c
|
||||
read: f0x222dc
|
||||
stderr: "file (0x76ee69d8)"
|
||||
stdin: "file (0x76ee6c98)"
|
||||
stdout: "file (0x76ee6b38)"
|
||||
tmpfile: f0x22c70
|
||||
type: f0x22890
|
||||
write: f0x21ba8
|
||||
math: &t0xc51a10
|
||||
abs: f0x22e48
|
||||
acos: f0x234c8
|
||||
asin: f0x234a4
|
||||
atan: f0x2343c
|
||||
atan2: f0x23460
|
||||
ceil: f0x23418
|
||||
cos: f0x233d0
|
||||
cosh: f0x233f4
|
||||
deg: f0x22e18
|
||||
exp: f0x233ac
|
||||
floor: f0x23030
|
||||
fmod: f0x23368
|
||||
frexp: f0x2332c
|
||||
huge: inf
|
||||
ldexp: f0x232ec
|
||||
log: f0x2323c
|
||||
log10: f0x232c8
|
||||
max: f0x22fc4
|
||||
min: f0x22f58
|
||||
modf: f0x231f0
|
||||
pi: 3.1415926535898
|
||||
pow: f0x231ac
|
||||
rad: f0x22de8
|
||||
random: f0x23054
|
||||
randomseed: f0x22f3c
|
||||
sin: f0x22ef4
|
||||
sinh: f0x22f18
|
||||
sqrt: f0x22eb4
|
||||
tan: f0x22e6c
|
||||
tanh: f0x22e90
|
||||
os: &t0xc4fd90
|
||||
clock: f0x237d8
|
||||
date: f0x23ac0
|
||||
difftime: f0x23758
|
||||
execute: f0x23714
|
||||
exit: f0x2369c
|
||||
getenv: f0x23670
|
||||
remove: f0x2363c
|
||||
rename: f0x235ec
|
||||
setlocale: f0x23580
|
||||
time: f0x23930
|
||||
tmpname: f0x23810
|
||||
package: &t0xc4ee90
|
||||
config: "\
|
||||
/\
|
||||
;\
|
||||
?\
|
||||
!\
|
||||
-\
|
||||
"
|
||||
cpath: "/usr/lib/lua/5.2/?.so;/usr/lib/lua/5.2/loadall.so;./?.so"
|
||||
loadlib: f0x27808
|
||||
path: "/usr/share/lua/5.2/?.lua;/usr/share/lua/5.2/?/init.lua;/usr/lib/lua/5.2/?.lua;/usr/lib/lua/5.2/?/init.lua;./?.lua"
|
||||
searchpath: f0x27ad4
|
||||
seeall: f0x273e0
|
||||
searchers: *t0xc4f5b0
|
||||
loaded: &t0xc4e948
|
||||
extra: true
|
||||
_G: *t0xc4e478
|
||||
bit32: *t0xc4f190
|
||||
coroutine: *t0xc4e998
|
||||
debug: *t0xc507c8
|
||||
io: *t0xc4ffe8
|
||||
math: *t0xc51a10
|
||||
os: *t0xc4fd90
|
||||
package: *t0xc4ee90
|
||||
string: *t0xc4f340
|
||||
table: *t0xc4fb68
|
||||
pt: &t0xc56a90
|
||||
__call: f0xc52a58
|
||||
inner: f0xc55c50
|
||||
outer: f0xc55ce8
|
||||
safekey: f0xc57890
|
||||
safeval: f0xc578a8
|
||||
write: f0xc56f08
|
||||
__index: *t0xc56a90
|
||||
__metatable: *t0xc56a90
|
||||
loaders: &t0xc4f5b0
|
||||
1: f0xc4f620
|
||||
2: f0xc4f648
|
||||
3: f0xc4f670
|
||||
4: f0xc4f698
|
||||
preload: &t0xc4f720
|
||||
string: &t0xc4f340
|
||||
byte: f0x25234
|
||||
char: f0x24768
|
||||
dump: f0x254d4
|
||||
find: f0x25db4
|
||||
format: f0x24890
|
||||
gmatch: f0x2470c
|
||||
gsub: f0x25dbc
|
||||
len: f0x2433c
|
||||
lower: f0x2436c
|
||||
match: f0x25dac
|
||||
rep: f0x2416c
|
||||
reverse: f0x23fb8
|
||||
sub: f0x2518c
|
||||
upper: f0x23ed8
|
||||
table: &t0xc4fb68
|
||||
concat: f0x2691c
|
||||
insert: f0x26688
|
||||
maxn: f0x26818
|
||||
pack: f0x26778
|
||||
remove: f0x26498
|
||||
sort: f0x26dec
|
||||
unpack: f0x26598
|
1
.dummy
1
.dummy
|
@ -1 +0,0 @@
|
|||
.
|
38
extra.lua
Executable file
38
extra.lua
Executable file
|
@ -0,0 +1,38 @@
|
|||
function strpad(num, count, pad)
|
||||
num = tostring(num)
|
||||
return (pad:rep(count)..num):sub(#num)
|
||||
end
|
||||
|
||||
function add_zeros(num, count)
|
||||
return strpad(num, count - 1, '0')
|
||||
end
|
||||
|
||||
function mixed_sorter(a, b)
|
||||
a = type(a) == 'number' and add_zeros(a, 16) or tostring(a)
|
||||
b = type(b) == 'number' and add_zeros(b, 16) or tostring(b)
|
||||
return a < b
|
||||
end
|
||||
|
||||
-- loosely based on http://lua-users.org/wiki/SortedIteration
|
||||
-- the original didn't make use of closures for who knows why
|
||||
function order_keys(t)
|
||||
local oi = {}
|
||||
for key in pairs(t) do
|
||||
table.insert(oi, key)
|
||||
end
|
||||
table.sort(oi, mixed_sorter)
|
||||
return oi
|
||||
end
|
||||
|
||||
function opairs(t, cache)
|
||||
local oi = cache and cache[t] or order_keys(t)
|
||||
if cache then
|
||||
cache[t] = oi
|
||||
end
|
||||
local i = 0
|
||||
return function()
|
||||
i = i + 1
|
||||
local key = oi[i]
|
||||
if key then return key, t[key] end
|
||||
end
|
||||
end
|
118
pt.lua
Executable file
118
pt.lua
Executable file
|
@ -0,0 +1,118 @@
|
|||
require('extra')
|
||||
|
||||
local pt = {}
|
||||
pt.__index = pt
|
||||
setmetatable(pt, pt)
|
||||
|
||||
function rawstr(v)
|
||||
if v == nil then return 'nil' end
|
||||
local mt = getmetatable(v)
|
||||
local ts = mt and rawget(mt, '__tostring')
|
||||
if not ts then return tostring(v) end
|
||||
mt.__tostring = nil
|
||||
local s = tostring(v)
|
||||
mt.__tostring = ts
|
||||
return s
|
||||
end
|
||||
|
||||
function getaddr(t)
|
||||
return rawstr(t):sub(#type(t) + 3)
|
||||
end
|
||||
|
||||
function pt.__call(pt, t, writer, seen)
|
||||
-- print a table as semi-valid YAML
|
||||
-- with references to prevent recursion/duplication
|
||||
local self = {}
|
||||
setmetatable(self, pt)
|
||||
self.seen = seen or {}
|
||||
self.queued = {}
|
||||
self.writer = writer or io.write
|
||||
self:inner('__root__', t, '')
|
||||
return self.seen
|
||||
end
|
||||
|
||||
function pt:write(...)
|
||||
self.writer(...)
|
||||
end
|
||||
|
||||
function pt.safekey(k)
|
||||
if type(k) == 'table' then
|
||||
return 't'..getaddr(k)
|
||||
end
|
||||
local s = tostring(k)
|
||||
s = s:gsub('[\r\n]', '')
|
||||
return s:find('[^%w_]') and ('%q'):format(s) or s
|
||||
end
|
||||
|
||||
function pt.safeval(v, indent)
|
||||
if type(v) == 'function' then
|
||||
return 'f'..getaddr(v)
|
||||
end
|
||||
local s = tostring(v)
|
||||
if type(v) == 'number' then
|
||||
return s
|
||||
end
|
||||
s = s:find('[\r\n]') and ('\n'..s):gsub('[\r\n]', '\n'..indent..' ') or s
|
||||
return s:find('[^%w_]') and ('%q'):format(s) or s
|
||||
end
|
||||
|
||||
function pt:inner(k, v, indent)
|
||||
if type(v) ~= 'table' then
|
||||
self:write(indent, pt.safekey(k), ': ')
|
||||
self:write(pt.safeval(v, indent), '\n')
|
||||
return
|
||||
end
|
||||
|
||||
local addr = getaddr(v)
|
||||
|
||||
self:write(indent, pt.safekey(k))
|
||||
if self.seen[addr] or self.queued[addr] then
|
||||
self:write(': *t', addr, '\n')
|
||||
return
|
||||
end
|
||||
|
||||
self.seen[addr] = true
|
||||
|
||||
self:write(': &t', addr, '\n')
|
||||
self:outer(v, indent..' ')
|
||||
end
|
||||
|
||||
function pt:outer(t, indent)
|
||||
if type(t) ~= "table" then
|
||||
self:write(indent, pt.safeval(t, indent), '\n')
|
||||
return
|
||||
end
|
||||
|
||||
local ours = {}
|
||||
local not_ours = {}
|
||||
|
||||
for k,v in opairs(t) do
|
||||
if type(v) == 'table' then
|
||||
local addr = getaddr(v)
|
||||
if not self.queued[addr] and not self.seen[addr] then
|
||||
self.queued[addr] = true
|
||||
ours[k] = v
|
||||
else
|
||||
not_ours[k] = v
|
||||
end
|
||||
else
|
||||
self:inner(k, v, indent)
|
||||
end
|
||||
end
|
||||
|
||||
for k,v in opairs(not_ours) do
|
||||
self:inner(k, v, indent)
|
||||
end
|
||||
|
||||
for k,v in opairs(ours) do
|
||||
self.queued[getaddr(v)] = nil
|
||||
self:inner(k, v, indent)
|
||||
end
|
||||
|
||||
local mt = getmetatable(t)
|
||||
if mt ~= nil then
|
||||
self:inner('__metatable', mt, indent)
|
||||
end
|
||||
end
|
||||
|
||||
return pt
|
22
run.lua
Executable file
22
run.lua
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/lua
|
||||
local pt = require('pt')
|
||||
|
||||
function dump(t, fn, seen)
|
||||
if t == nil then return end
|
||||
|
||||
local file = io.open(fn, "w")
|
||||
if not file then
|
||||
io.write("Failed opening ", fn, "\n")
|
||||
return
|
||||
end
|
||||
|
||||
local writer = function(...)
|
||||
file:write(...)
|
||||
end
|
||||
seen = pt(t, writer, seen)
|
||||
|
||||
file:close()
|
||||
return seen
|
||||
end
|
||||
|
||||
dump(_G, '!_G.yml')
|
Loading…
Reference in a new issue