-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdecompile3.lua
243 lines (220 loc) · 3.95 KB
/
decompile3.lua
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
local bc = require "luavm.bytecode"
local decompiler = require "luavm.decompiler3"
serpent = require "serpent"
local function testFunc()
print("Hello, World!", x+4)
if y then
print("y is set!")
end
local i = 0
while i < 10 and w do
if i == 5 or i == 5 then
print('FIVE!')
end
if math.deg(math.pi) == 180 then
print("PI == 180")
end
i = i+1
print("i is", i)
end
if i > 4 and j or n == 4 then
return 0
end
if q > p or r < n and f > 4 then
return 1
end
for i=1, 10 do
print(i)
end
return 5
end
-- not on and widgetPowerLevel > 0
--[[
0 {"getglobal", dest = 0, index = 0}
1 {"condop", "test", invert = true, target = 0}
2 {"jump", to = 8}
3 {"getglobal", dest = 0, index = 1}
4 {"condop", "<", invert = false, lhs = 258, rhs = 0}
5 {"jump", to = 8}
6 {"loadk", dest = 0, kst = 3}
7 {"return", base = 0, count = 1}
]]
-- not on and widgetPowerLevel > 0
-- not (on and widgetPowerLevel > 0)
--[[
0 {"getglobal", dest = 0, index = 0}
1 {"condop", "test", invert = false, target = 0}
2 {"jump", to = 6}
3 {"getglobal", dest = 0, index = 1}
4 {"condop", "<", invert = true, lhs = 258, rhs = 0}
5 {"jump", to = 8}
6 {"loadk", dest = 0, kst = 3}
7 {"return", base = 0, count = 1}
]]
-- on or widgetPowerLevel > 0
-- a or b > 0
--[[
0 {"getglobal", dest = 0, index = 0}
1 {"condop", "test", invert = false, target = 0}
2 {"jump", to = 6}
3 {"getglobal", dest = 0, index = 1}
4 {"condop", "<", invert = true, lhs = 258, rhs = 0}
5 {"jump", to = 8}
6 {"loadk", dest = 0, kst = 3}
7 {"return", base = 0, count = 1}
]]
-- a or b
--[[
8 {"getglobal", dest = 0, index = 4}
9 {"condop", "test", invert = true, target = 0}
10 {"jump", to = 14}
11 {"getglobal", dest = 0, index = 5}
12 {"condop", "test", invert = false, target = 0}
13 {"jump", to = 19}
]]
--
local function testFunc()
if not (on and widgetPowerLevel > 0) then
return not (on and widgetPowerLevel > 0)
end
if a or b then
return a or b
end
if a and (b and c or d) or e then
print("!")
end
if i > 4 and j or n == 4 then
print("!!!")
end
if q > p or r < n and f > 4 then
print("!!")
end
return a > a and (b > b and c or d) or e
end
local function testFunc1()
while true do
print("Hey")
if j > 2 then
print("Bye")
break
end
end
print("!")
return a > 0 and b > 0
end
local function testFunc1()
for i, v in pairs(_G) do
print(i, v)
end
for i=1, 10 do
print(i)
end
end
local function testFunc1()
while true do
while true do
print("!")
break
end
print("!!")
end
end
local function testFunc1()
if j then
print("J!")
return j
elseif q then
print("Q!")
if m then
print("BUT M!")
end
return q
else
print("?!")
return false
end
print("!")
return true
end
local function testFunc1()
if g > 3 then
print("!")
else
g = 3
end
repeat
print("jk")
until not kidding
end
local function testFunc1()
local g, s = 3, 0
while g > 0 do
local n = g * g
s = s + n
g = g - 1
end
if s > 4 then
local q = s * s
s = q * 0.5
end
return s, s * s, s * s * s
end
local function testFunc1()
local q = 3
do
local g = 3
local function x()
g = 4
end
q = 4
end
return q
end
local function testFunc()
local x = {}
x.x = 5
x.y = 3
return x
end
local dump = string.dump(testFunc)
--local dump = io.open(..., "rb"):read("*a")
local chunk = bc.load(dump) --.functionPrototypes[1]
local decoded = decompiler.decoder.native().decodeChunk(chunk)
for i=0, decoded.last do
print(i, serpent.line(decoded[i]))
end
bc.dump(chunk)
local source = decompiler.core.decompile(decoded, chunk, {
asFunction = true
})
print()
for i=1, #source do
print(source[i])
end
--[[x = 3
w = true
testFunc();
(function()
local L_0, L_1
print("Hello, World!", x+4)
L_0 = y
if L_0 then
print("y is set!")
end
L_0 = 0
while L_0<10 and w do
if L_0==5 or L_0==5 then
print("FIVE!")
end
L_1 = math.deg(math.pi)
if L_1==180 then
print("PI == 180")
end
L_0 = L_0+1
print("i is", L_0)
end
if 4<L_0 and j or n==4 then
return 0
end
return 5
end)()]]