.
This commit is contained in:
parent
051265ea3a
commit
176b8b32b0
3 changed files with 261 additions and 213 deletions
428
_G.yml
428
_G.yml
|
@ -1,212 +1,236 @@
|
||||||
__root__: &t0x6f478
|
__root__: &t0xfff91348
|
||||||
_VERSION: Lua 5.2
|
_VERSION: Lua 5.1
|
||||||
add_zeros: f0x73838
|
add_zeros: f0xfff9bdb8
|
||||||
assert: f0x1fefc
|
assert: fbuiltin#2
|
||||||
collectgarbage: f0x1f930
|
collectgarbage: fbuiltin#27
|
||||||
dofile: f0x1fe7c
|
copy: f0xfff9be70
|
||||||
dump: f0x78770
|
dofile: fbuiltin#25
|
||||||
error: f0x1f8c0
|
dump: f0xfff91308
|
||||||
getaddr: f0x74c40
|
error: fbuiltin#19
|
||||||
getmetatable: f0x1fe2c
|
gcinfo: fbuiltin#26
|
||||||
ipairs: f0x1fd24
|
getaddr: f0xfff9be58
|
||||||
load: f0x1ff54
|
getfenv: fbuiltin#10
|
||||||
loadfile: f0x1fd80
|
getmetatable: fbuiltin#8
|
||||||
loadstring: f0x1ff54
|
ipairs: fbuiltin#7
|
||||||
mixed_sorter: f0x76c28
|
load: fbuiltin#23
|
||||||
module: f0x6fe20
|
loadfile: fbuiltin#22
|
||||||
next: f0x1f7ac
|
loadstring: fbuiltin#24
|
||||||
opairs: f0x74c88
|
mixed_sorter: f0xfff9bdd0
|
||||||
order_keys: f0x74cd0
|
module: f0xfff93598
|
||||||
pairs: f0x1fd04
|
newproxy: fbuiltin#28
|
||||||
pcall: f0x1fb50
|
next: fbuiltin#4
|
||||||
print: f0x1f66c
|
opairs: f0xfff9be00
|
||||||
rawequal: f0x1f62c
|
order_keys: f0xfff9bde8
|
||||||
rawget: f0x1f598
|
pairs: fbuiltin#5
|
||||||
rawlen: f0x1f5d8
|
pcall: fbuiltin#20
|
||||||
rawset: f0x1f54c
|
print: fbuiltin#29
|
||||||
rawstr: f0x76460
|
rawequal: fbuiltin#14
|
||||||
require: f0x70b00
|
rawget: fbuiltin#12
|
||||||
select: f0x1f444
|
rawset: fbuiltin#13
|
||||||
setmetatable: f0x1fbc0
|
rawstr: f0xfff9be40
|
||||||
strpad: f0x73e60
|
require: f0xfff935d8
|
||||||
tonumber: f0x1f25c
|
select: fbuiltin#16
|
||||||
tostring: f0x1f234
|
setfenv: fbuiltin#11
|
||||||
type: f0x1f1f8
|
setmetatable: fbuiltin#9
|
||||||
unpack: f0x26598
|
strpad: f0xfff9bda0
|
||||||
xpcall: f0x1fa84
|
tonumber: fbuiltin#17
|
||||||
_G: *t0x6f478
|
tostring: fbuiltin#18
|
||||||
arg: &t0x736b8
|
type: fbuiltin#3
|
||||||
"-1": /usr/bin/lua
|
unpack: fbuiltin#15
|
||||||
0: ./run.lua
|
xpcall: fbuiltin#21
|
||||||
bit32: &t0x70190
|
_G: *t0xfff91348
|
||||||
arshift: f0x2022c
|
arg: &t0xfff93728
|
||||||
band: f0x20458
|
"-1": luajit
|
||||||
bnot: f0x20208
|
0: run.lua
|
||||||
bor: f0x204c4
|
bit: &t0xfff962c0
|
||||||
btest: f0x20434
|
arshift: fbuiltin#68
|
||||||
bxor: f0x20478
|
band: fbuiltin#71
|
||||||
extract: f0x203a4
|
bnot: fbuiltin#64
|
||||||
lrotate: f0x20510
|
bor: fbuiltin#72
|
||||||
lshift: f0x20190
|
bswap: fbuiltin#65
|
||||||
replace: f0x20338
|
bxor: fbuiltin#73
|
||||||
rrotate: f0x201c4
|
lshift: fbuiltin#66
|
||||||
rshift: f0x2015c
|
rol: fbuiltin#69
|
||||||
coroutine: &t0x6f998
|
ror: fbuiltin#70
|
||||||
create: f0x20844
|
rshift: fbuiltin#67
|
||||||
resume: f0x20934
|
tobit: fbuiltin#63
|
||||||
running: f0x20824
|
tohex: fbuiltin#74
|
||||||
status: f0x206cc
|
coroutine: &t0xfff92f38
|
||||||
wrap: f0x20888
|
create: fbuiltin#32
|
||||||
yield: f0x20584
|
resume: fbuiltin#34
|
||||||
debug: &t0x717c8
|
running: fbuiltin#31
|
||||||
debug: f0x20e44
|
status: fbuiltin#30
|
||||||
gethook: f0x21470
|
wrap: fbuiltin#36
|
||||||
getinfo: f0x21674
|
yield: fbuiltin#33
|
||||||
getlocal: f0x2132c
|
debug: &t0xfff95d78
|
||||||
getmetatable: f0x20d88
|
debug: fbuiltin#140
|
||||||
getregistry: f0x209fc
|
getfenv: fbuiltin#129
|
||||||
getupvalue: f0x20aac
|
gethook: fbuiltin#139
|
||||||
getuservalue: f0x20e0c
|
getinfo: fbuiltin#131
|
||||||
sethook: f0x2118c
|
getlocal: fbuiltin#132
|
||||||
setlocal: f0x21094
|
getmetatable: fbuiltin#127
|
||||||
setmetatable: f0x20ab4
|
getregistry: fbuiltin#126
|
||||||
setupvalue: f0x20a8c
|
getupvalue: fbuiltin#134
|
||||||
setuservalue: f0x20b58
|
setfenv: fbuiltin#130
|
||||||
traceback: f0x20ff8
|
sethook: fbuiltin#138
|
||||||
upvalueid: f0x20ca0
|
setlocal: fbuiltin#133
|
||||||
upvaluejoin: f0x20cd8
|
setmetatable: fbuiltin#128
|
||||||
io: &t0x70fe8
|
setupvalue: fbuiltin#135
|
||||||
close: f0x21c94
|
traceback: fbuiltin#141
|
||||||
flush: f0x22328
|
upvalueid: fbuiltin#136
|
||||||
input: f0x22a28
|
upvaluejoin: fbuiltin#137
|
||||||
lines: f0x22a44
|
io: &t0xfff942b0
|
||||||
open: f0x22b64
|
close: fbuiltin#107
|
||||||
output: f0x22a0c
|
flush: fbuiltin#110
|
||||||
popen: f0x2238c
|
input: fbuiltin#111
|
||||||
read: f0x222dc
|
lines: fbuiltin#113
|
||||||
stderr: file (0x76e4f9d8)
|
open: fbuiltin#104
|
||||||
stdin: file (0x76e4fc98)
|
output: fbuiltin#112
|
||||||
stdout: file (0x76e4fb38)
|
popen: fbuiltin#105
|
||||||
tmpfile: f0x22c70
|
read: fbuiltin#108
|
||||||
type: f0x22890
|
stderr: file (0x611a2cf0)
|
||||||
write: f0x21ba8
|
stdin: file (0x611a2c10)
|
||||||
math: &t0x72a10
|
stdout: file (0x611a2c80)
|
||||||
abs: f0x22e48
|
tmpfile: fbuiltin#106
|
||||||
acos: f0x234c8
|
type: fbuiltin#114
|
||||||
asin: f0x234a4
|
write: fbuiltin#109
|
||||||
atan: f0x2343c
|
jit: &t0xfff967f0
|
||||||
atan2: f0x23460
|
arch: x86
|
||||||
ceil: f0x23418
|
attach: fbuiltin#146
|
||||||
cos: f0x233d0
|
flush: fbuiltin#144
|
||||||
cosh: f0x233f4
|
off: fbuiltin#143
|
||||||
deg: f0x22e18
|
on: fbuiltin#142
|
||||||
exp: f0x233ac
|
os: POSIX
|
||||||
floor: f0x23030
|
status: fbuiltin#145
|
||||||
fmod: f0x23368
|
version: LuaJIT 2.1.0-beta1
|
||||||
frexp: f0x2332c
|
version_num: 20100
|
||||||
|
opt: &t0xfff96ba8
|
||||||
|
start: fbuiltin#158
|
||||||
|
math: &t0xfff95250
|
||||||
|
abs: fbuiltin#37
|
||||||
|
acos: fbuiltin#47
|
||||||
|
asin: fbuiltin#46
|
||||||
|
atan: fbuiltin#48
|
||||||
|
atan2: fbuiltin#55
|
||||||
|
ceil: fbuiltin#39
|
||||||
|
cos: fbuiltin#44
|
||||||
|
cosh: fbuiltin#50
|
||||||
|
deg: f0xfff95a48
|
||||||
|
exp: fbuiltin#42
|
||||||
|
floor: fbuiltin#38
|
||||||
|
fmod: fbuiltin#57
|
||||||
|
frexp: fbuiltin#52
|
||||||
huge: inf
|
huge: inf
|
||||||
ldexp: f0x232ec
|
ldexp: fbuiltin#58
|
||||||
log: f0x2323c
|
log: fbuiltin#54
|
||||||
log10: f0x232c8
|
log10: fbuiltin#41
|
||||||
max: f0x22fc4
|
max: fbuiltin#60
|
||||||
min: f0x22f58
|
min: fbuiltin#59
|
||||||
modf: f0x231f0
|
mod: fbuiltin#57
|
||||||
|
modf: fbuiltin#53
|
||||||
pi: 3.1415926535898
|
pi: 3.1415926535898
|
||||||
pow: f0x231ac
|
pow: fbuiltin#56
|
||||||
rad: f0x22de8
|
rad: f0xfff95ad8
|
||||||
random: f0x23054
|
random: fbuiltin#61
|
||||||
randomseed: f0x22f3c
|
randomseed: fbuiltin#62
|
||||||
sin: f0x22ef4
|
sin: fbuiltin#43
|
||||||
sinh: f0x22f18
|
sinh: fbuiltin#49
|
||||||
sqrt: f0x22eb4
|
sqrt: fbuiltin#40
|
||||||
tan: f0x22e6c
|
tan: fbuiltin#45
|
||||||
tanh: f0x22e90
|
tanh: fbuiltin#51
|
||||||
os: &t0x70d90
|
os: &t0xfff94770
|
||||||
clock: f0x237d8
|
clock: fbuiltin#121
|
||||||
date: f0x23ac0
|
date: fbuiltin#122
|
||||||
difftime: f0x23758
|
difftime: fbuiltin#124
|
||||||
execute: f0x23714
|
execute: fbuiltin#115
|
||||||
exit: f0x2369c
|
exit: fbuiltin#120
|
||||||
getenv: f0x23670
|
getenv: fbuiltin#119
|
||||||
remove: f0x2363c
|
remove: fbuiltin#116
|
||||||
rename: f0x235ec
|
rename: fbuiltin#117
|
||||||
setlocale: f0x23580
|
setlocale: fbuiltin#125
|
||||||
time: f0x23930
|
time: fbuiltin#123
|
||||||
tmpname: f0x23810
|
tmpname: fbuiltin#118
|
||||||
package: &t0x6fe90
|
package: &t0xfff93288
|
||||||
config: "\
|
config:
|
||||||
/\
|
/
|
||||||
;\
|
;
|
||||||
?\
|
?
|
||||||
!\
|
!
|
||||||
-\
|
-
|
||||||
"
|
cpath: ./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
|
||||||
cpath: /usr/lib/lua/5.2/?.so;/usr/lib/lua/5.2/loadall.so;./?.so
|
loadlib: f0xfff93318
|
||||||
loadlib: f0x27808
|
path: ./?.lua;/usr/local/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua
|
||||||
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: f0xfff93358
|
||||||
searchpath: f0x27ad4
|
seeall: f0xfff93398
|
||||||
seeall: f0x273e0
|
loaded: &t0xfff92480
|
||||||
searchers: *t0x705b0
|
|
||||||
loaded: &t0x6f948
|
|
||||||
extra: true
|
extra: true
|
||||||
_G: *t0x6f478
|
_G: *t0xfff91348
|
||||||
bit32: *t0x70190
|
bit: *t0xfff962c0
|
||||||
coroutine: *t0x6f998
|
coroutine: *t0xfff92f38
|
||||||
debug: *t0x717c8
|
debug: *t0xfff95d78
|
||||||
io: *t0x70fe8
|
io: *t0xfff942b0
|
||||||
math: *t0x72a10
|
jit: *t0xfff967f0
|
||||||
os: *t0x70d90
|
"jit.opt": *t0xfff96ba8
|
||||||
package: *t0x6fe90
|
math: *t0xfff95250
|
||||||
string: *t0x70340
|
os: *t0xfff94770
|
||||||
table: *t0x70b68
|
package: *t0xfff93288
|
||||||
pt: &t0x78948
|
string: *t0xfff94be0
|
||||||
__call: f0x75128
|
table: *t0xfff93638
|
||||||
inner: f0x76d00
|
pt: &t0xfff9be18
|
||||||
outer: f0x74410
|
__call: f0xfff9be88
|
||||||
safekey: f0x77de8
|
inner: f0xfff9bfb0
|
||||||
safeval: f0x6f2d0
|
outer: f0xfff9bff0
|
||||||
write: f0x6f360
|
safekey: f0xfff9beb8
|
||||||
__index: *t0x78948
|
safeval: f0xfff9bed0
|
||||||
__metatable: *t0x78948
|
write: f0xfff9bea0
|
||||||
loaders: &t0x705b0
|
__index: *t0xfff9be18
|
||||||
1: f0x70620
|
__metatable: *t0xfff9be18
|
||||||
2: f0x70648
|
loaders: &t0xfff933d8
|
||||||
3: f0x70670
|
1: f0xfff93428
|
||||||
4: f0x70698
|
2: f0xfff93448
|
||||||
preload: &t0x70720
|
3: f0xfff93468
|
||||||
string: &t0x70340
|
4: f0xfff93488
|
||||||
byte: f0x25234
|
preload: &t0xfff93700
|
||||||
char: f0x24768
|
ffi: f0xfff96c48
|
||||||
dump: f0x254d4
|
"jit.profile": f0xfff96af0
|
||||||
find: f0x25db4
|
"jit.util": f0xfff96b30
|
||||||
format: f0x24890
|
"table.clear": f0xfff93e68
|
||||||
gmatch: f0x2470c
|
"table.new": f0xfff93e28
|
||||||
gsub: f0x25dbc
|
string: &t0xfff94be0
|
||||||
len: f0x2433c
|
byte: fbuiltin#75
|
||||||
lower: f0x2436c
|
char: fbuiltin#76
|
||||||
match: f0x25dac
|
dump: fbuiltin#82
|
||||||
rep: f0x2416c
|
find: fbuiltin#83
|
||||||
reverse: f0x23fb8
|
format: fbuiltin#88
|
||||||
sub: f0x2518c
|
gfind: fbuiltin#86
|
||||||
upper: f0x23ed8
|
gmatch: fbuiltin#86
|
||||||
t: &t0x74a30
|
gsub: fbuiltin#87
|
||||||
|
len: f0xfff94e00
|
||||||
|
lower: fbuiltin#80
|
||||||
|
match: fbuiltin#84
|
||||||
|
rep: fbuiltin#78
|
||||||
|
reverse: fbuiltin#79
|
||||||
|
sub: fbuiltin#77
|
||||||
|
upper: fbuiltin#81
|
||||||
|
t: &t0xfff9a1c0
|
||||||
C: hello
|
C: hello
|
||||||
D: *t0x74a30
|
D: *t0xfff9a1c0
|
||||||
A: &t0x74b78
|
A: &t0xfff9a978
|
||||||
a: beep
|
a: beep
|
||||||
b: boop
|
b: boop
|
||||||
c: burp
|
c: burp
|
||||||
d: *t0x786c0
|
d: *t0xfff9a9a0
|
||||||
B: &t0x786c0
|
B: &t0xfff9a9a0
|
||||||
a: nude
|
a: nude
|
||||||
b: dude
|
b: dude
|
||||||
c: lewd
|
c: lewd
|
||||||
d: *t0x74b78
|
d: *t0xfff9a978
|
||||||
table: &t0x70b68
|
table: &t0xfff93638
|
||||||
concat: f0x2691c
|
concat: fbuiltin#91
|
||||||
insert: f0x26688
|
foreach: f0xfff93b70
|
||||||
maxn: f0x26818
|
foreachi: f0xfff93aa8
|
||||||
pack: f0x26778
|
getn: f0xfff93c00
|
||||||
remove: f0x26498
|
insert: fbuiltin#90
|
||||||
sort: f0x26dec
|
maxn: fbuiltin#89
|
||||||
unpack: f0x26598
|
remove: f0xfff93d90
|
||||||
|
sort: fbuiltin#92
|
||||||
|
|
42
pt.lua
42
pt.lua
|
@ -1,4 +1,4 @@
|
||||||
require('extra')
|
require 'extra'
|
||||||
|
|
||||||
local pt = {}
|
local pt = {}
|
||||||
pt.__index = pt
|
pt.__index = pt
|
||||||
|
@ -19,14 +19,29 @@ function getaddr(t)
|
||||||
return rawstr(t):sub(#type(t) + 3)
|
return rawstr(t):sub(#type(t) + 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pt.__call(pt, t, writer, seen)
|
function copy(t)
|
||||||
|
-- shallow copy
|
||||||
|
if type(t) ~= 'table' then return end
|
||||||
|
local new = {}
|
||||||
|
for key, value in pairs(t) do
|
||||||
|
new[key] = value
|
||||||
|
end
|
||||||
|
return new
|
||||||
|
end
|
||||||
|
|
||||||
|
function pt.__call(pt, args)
|
||||||
-- print a table as semi-valid YAML
|
-- print a table as semi-valid YAML
|
||||||
-- with references to prevent recursion/duplication
|
-- with references to prevent recursion/duplication
|
||||||
|
local t = args.table or args[1]
|
||||||
local self = {}
|
local self = {}
|
||||||
setmetatable(self, pt)
|
setmetatable(self, pt)
|
||||||
self.seen = seen or {}
|
self.seen = copy(args.seen) or {}
|
||||||
|
self.skipped = copy(args.skipped) or {}
|
||||||
|
self.seen_elsewhere = args.seen or {}
|
||||||
|
self.depth = args.depth or 16
|
||||||
|
self.writer = args.writer or io.write
|
||||||
|
self.skeleton = args.skeleton or false
|
||||||
self.queued = {}
|
self.queued = {}
|
||||||
self.writer = writer or io.write
|
|
||||||
self:inner('__root__', t, '')
|
self:inner('__root__', t, '')
|
||||||
return self.seen
|
return self.seen
|
||||||
end
|
end
|
||||||
|
@ -53,22 +68,31 @@ function pt.safeval(v, indent)
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
s = s:find('[\r\n]') and ('\n'..s):gsub('[\r\n]', '\n'..indent..' ') or s
|
s = s:find('[\r\n]') and ('\n'..s):gsub('[\r\n]', '\n'..indent..' ') or s
|
||||||
local safe = ('%q'):format(s)
|
--local safe = ('%q'):format(s)
|
||||||
return s == safe:sub(2, -2) and s or safe
|
--return s == safe:sub(2, -2) and s or safe
|
||||||
|
-- TODO: finish matching valid characters
|
||||||
|
return s:find('[^%w_()[]{}.]') and ('%q'):format(s) or s
|
||||||
end
|
end
|
||||||
|
|
||||||
function pt:inner(k, v, indent)
|
function pt:inner(k, v, indent)
|
||||||
if type(v) ~= 'table' then
|
if type(v) ~= 'table' then
|
||||||
|
if self.skeleton then return end
|
||||||
self:write(indent, pt.safekey(k), ': ')
|
self:write(indent, pt.safekey(k), ': ')
|
||||||
self:write(pt.safeval(v, indent), '\n')
|
self:write(pt.safeval(v, indent), '\n')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local addr = getaddr(v)
|
local addr = getaddr(v)
|
||||||
|
|
||||||
self:write(indent, pt.safekey(k))
|
self:write(indent, pt.safekey(k))
|
||||||
|
|
||||||
|
if #indent > self.depth or self.skipped[addr] then
|
||||||
|
--self.skipped[addr] = true -- TODO: extra logics
|
||||||
|
self:write(': #t', addr, '\n')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if self.seen[addr] or self.queued[addr] then
|
if self.seen[addr] or self.queued[addr] then
|
||||||
self:write(': *t', addr, '\n')
|
self:write(': *t', addr, self.seen_elsewhere[addr] and ' #\n' or '\n')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -90,7 +114,7 @@ function pt:outer(t, indent)
|
||||||
for k,v in opairs(t) do
|
for k,v in opairs(t) do
|
||||||
if type(v) == 'table' then
|
if type(v) == 'table' then
|
||||||
local addr = getaddr(v)
|
local addr = getaddr(v)
|
||||||
if not self.queued[addr] and not self.seen[addr] then
|
if not self.queued[addr] and not self.seen[addr] and not self.skipped[addr] then
|
||||||
self.queued[addr] = true
|
self.queued[addr] = true
|
||||||
ours[k] = v
|
ours[k] = v
|
||||||
else
|
else
|
||||||
|
|
4
run.lua
4
run.lua
|
@ -30,11 +30,11 @@ function dump(t, fn, seen)
|
||||||
local writer = function(...)
|
local writer = function(...)
|
||||||
file:write(...)
|
file:write(...)
|
||||||
end
|
end
|
||||||
seen = pt(t, writer, seen)
|
seen = pt{t, writer=writer, seen=seen}
|
||||||
|
|
||||||
file:close()
|
file:close()
|
||||||
return seen
|
return seen
|
||||||
end
|
end
|
||||||
|
|
||||||
pt(t)
|
pt{t}
|
||||||
dump(_G, '_G.yml')
|
dump(_G, '_G.yml')
|
||||||
|
|
Loading…
Reference in a new issue