-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkonstantdecompiler.lua
More file actions
15000 lines (14966 loc) · 435 KB
/
Copy pathkonstantdecompiler.lua
File metadata and controls
15000 lines (14966 loc) · 435 KB
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Saved by UniversalSynSaveInstance https://discord.gg/wx4ThpAsmw
local l_select_0 = select;
local function v6(v1, v2, ...)
local v3, v4 = {
...
}, l_select_0("#", ...);
for v5 = v2, v2 + v4 - 1 do
v1[v5] = v3[v5 - v2 + 1];
end;
end;
local l_getscriptbytecode_0 = getscriptbytecode;
local l_getscripthash_0 = getscripthash;
local _ = getgenv;
local l_rconsoleprint_0 = rconsoleprint;
local v14 = Vector3 or {
new = function(v11, v12, v13)
return {
X = v11,
Y = v12,
Z = v13
};
end
};
local v15 = nil;
local v16 = nil;
local v17 = {};
local function v21()
if v16 == "vanilla" then
v15 = function(v18)
return v18;
end;
elseif v16 == "mul227" then
v15 = function(v19)
return v19 * 227;
end;
else
error("Invalid opcode_encoding_type");
end;
for v20 = 0, 255 do
v17[v15(v20)] = v20;
end;
end;
local v22 = {
use_proto_debugnames = true,
show_proto_line_defined = true,
show_proto_upvalues = true,
show_proto_constants = true,
inline_table_initialization = true,
table_string_key_shortening = true,
table_dict_key_semicolons = true,
table_array_value_semicolons = false,
always_use_table_keys = false,
use_compound_assignment = true,
exact_argument_names = false,
string_quotes_behavior = "single char, single quotes",
do_tonumber_nan = true,
do_while_1 = false,
show_nil_definitions = true,
smart_var_level = 3,
smart_var_usage_analysis = true,
smart_var_extensive_prefixes = false,
mark_upvalues = "extra",
mark_setglobal = true,
mark_reads_and_writes = false,
minify_if_statements = true,
assume_if_else = true,
prefix_error = "KONSTANTERROR",
prefix_warning = "KONSTANTWARNING",
prefix_information = "KONSTANTINFO"
};
local v23 = if task then task.wait else nil;
local v24 = {
[0] = "nil",
[1] = "boolean",
[2] = "number",
[3] = "string",
[4] = "import",
[5] = "table",
[6] = "function",
[7] = "vector"
};
local l_clock_0 = os.clock;
local v26 = elapsedTime or l_clock_0;
local v27 = v26();
local v28 = game ~= nil;
local v29 = l_rconsoleprint_0 or print;
local function v33(v30, v31, v32)
if v26() - v27 >= 0.016666666666666666 then
v29("[" .. v30 .. "/" .. v31 .. "] " .. string.format("%.1f", math.floor(v30 / v31 * 1000 + 0.5) / 10) .. "% done with func `" .. (v32 or "<main>") .. "`");
if v23 and v28 then
v23();
end;
v27 = v26();
end;
end;
local function v43()
return {
start_times = {},
end_times = {},
completed_benchmarks = {},
start_benchmark = function(_, _)
end,
end_benchmark = function(_, _)
end,
get_benchmark_time = function(_, _)
return 0;
end,
print_benchmark_time = function(_, _)
end,
print_all_times = function(_)
end
};
end;
local v44 = buffer.create(8);
local function _(v45)
return (bit32.band(bit32.rshift(v45, 8), 255));
end;
local function _(v47)
return (bit32.band(bit32.rshift(v47, 16), 255));
end;
local function _(v49)
return (bit32.band(bit32.rshift(v49, 24), 255));
end;
local function _(v51)
return (bit32.band(bit32.rshift(v51, 16), 65535));
end;
local function _(v53)
buffer.writeu16(v44, 0, (bit32.band(bit32.rshift(v53, 16), 65535)));
return (buffer.readi16(v44, 0));
end;
local function _(v55)
return (bit32.rshift(v55, 8));
end;
local function _(v57)
buffer.writeu32(v44, 0, (bit32.rshift(v57, 8)));
return (bit32.rshift(buffer.readi32(v44, 1), 16));
end;
local function _(v59)
return (bit32.band(v59, 255));
end;
local v61 = {
A = true,
a = true,
E = true,
e = true,
I = true,
i = true,
O = true,
o = true,
U = true,
u = true
};
local function _(v62)
return string.format("%X", v62);
end;
local v64 = {};
for v65 = 0, 255 do
v64[v65] = string.format("%.2X", v65);
end;
local v66 = buffer.create(2);
local v67 = {};
for v68 = 0, 255 do
buffer.writestring(v66, 0, v64[v68]);
v67[v68] = buffer.readu16(v66, 0);
end;
local v69 = {};
for v70 = 0, 255 do
v69[v70] = bit32.bor(bit32.lrotate(v67[v70], 16), 30812);
end;
local function _(v71)
return v64[v71];
end;
local function _(v73)
return string.format("%.4X", v73);
end;
local function _(v75)
return v64[bit32.rshift(v75, 24)] .. v64[bit32.band(bit32.rrotate(v75, 16), 255)] .. v64[bit32.band(bit32.rrotate(v75, 8), 255)] .. v64[bit32.band(v75, 255)];
end;
local function _(v77)
assert(v77);
return v77;
end;
local function _(v79, v80)
table.clear(v79);
for v81, v82 in pairs(v80) do
v79[v81] = v82;
end;
end;
local function v89(v84, v85)
if #v85 > 8 then
return table.move(v85, 1, #v85, 1, table.clone(v84));
else
local v86 = table.clone(v84);
for _, v88 in ipairs(v85) do
table.insert(v86, v88);
end;
return v86;
end;
end;
local function _(v90, v91)
local v92 = table.clone(v90);
for v93 in pairs(v91) do
v92[v93] = true;
end;
return v92;
end;
local function _(v95, v96, v97)
local v98 = table.find(v95, v96);
assert(v98);
if v97 == nil then
table.remove(v95, v98);
else
v95[v98] = v97;
end;
assert(not table.find(v95, v96));
end;
local function _(v100, v101, v102)
for v103 = #v100, 1, -1 do
if v100[v103] == v101 then
if v102 == nil then
table.remove(v100, v103);
return;
else
v100[v103] = v102;
return;
end;
end;
end;
end;
local function v109(v105)
local v106 = table.clone(v105);
for v107, v108 in pairs(v106) do
if type(v108) == "table" then
v106[v107] = table.clone(v108);
end;
end;
return v106;
end;
local function _(v110, v111)
local v112 = v110[v111];
if v112 then
return v112;
else
local v113 = {};
v110[v111] = v113;
return v113;
end;
end;
local function _(v115)
assert(#v115 > 0);
end;
local function _(v117, v118)
local v119 = table.create(v117, v118);
if v118 then
v119[0] = v118;
return v119;
else
v119[0] = nil;
return v119;
end;
end;
local v121 = {};
local function _(v122, v123, v124)
local v125 = v122[v123];
if v125 then
return v125[v124];
else
return nil;
end;
end;
local function _(v127, v128, v129, v130)
local v131 = v127[v128];
if v131 then
v131[v129] = v130;
return;
else
v127[v128] = {
[v129] = v130
};
return;
end;
end;
local _ = function(v133, v134)
for _, v136 in ipairs(v133) do
if table.find(v134, v136) then
return v136;
end;
end;
return nil;
end;
local function _()
v121 = {};
end;
local function v139(v140, v141, v142)
local v143 = v121[v140];
local v144 = if v143 then v143[v141] else nil;
if v144 then
return v144;
else
local v145 = v142 or {};
for v146, v147 in v140 do
if type(v146) == "table" then
if not v145[v146] then
v145[v146] = true;
if v146 == v141 then
local l_v121_0 = v121;
local v149 = l_v121_0[v140];
if v149 then
v149[v141] = true;
else
l_v121_0[v140] = {
[v141] = true
};
end;
return true;
elseif v139(v147, v141, v145) then
local l_v121_1 = v121;
local v151 = l_v121_1[v140];
if v151 then
v151[v141] = true;
else
l_v121_1[v140] = {
[v141] = true
};
end;
return true;
end;
end;
elseif type(v147) == "table" and not v145[v147] then
v145[v147] = true;
if v147 == v141 then
local l_v121_2 = v121;
local v153 = l_v121_2[v140];
if v153 then
v153[v141] = true;
else
l_v121_2[v140] = {
[v141] = true
};
end;
return true;
elseif v139(v147, v141, v145) then
local l_v121_3 = v121;
local v155 = l_v121_3[v140];
if v155 then
v155[v141] = true;
else
l_v121_3[v140] = {
[v141] = true
};
end;
return true;
end;
end;
end;
v143 = v121;
local v156 = v143[v140];
if v156 then
v156[v141] = false;
else
v143[v140] = {
[v141] = false
};
end;
return false;
end;
end;
local function _(v157, v158)
if v158 then
return {
beginning = v157,
ending = v158
};
else
return {
beginning = v157,
ending = v157
};
end;
end;
local function _(v160)
return v160.ending - v160.beginning + 1;
end;
local function _(v162, v163)
local v164 = false;
if v162.beginning == v163.beginning then
v164 = v162.ending == v163.ending;
end;
return v164;
end;
local function _(v166)
return (("range<%*:%*>"):format(v166.beginning, v166.ending));
end;
local function _(v168, v169, v170)
local v171 = false;
if v169 <= v168 then
v171 = v168 <= v170;
end;
return v171;
end;
local function _(v173, v174)
local l_beginning_0 = v174.beginning;
local l_ending_0 = v174.ending;
local v177 = false;
if l_beginning_0 <= v173 then
v177 = v173 <= l_ending_0;
end;
return v177;
end;
local v179 = nil;
local v180 = nil;
local v181 = nil;
local function _(v182)
local v183 = v180[v182];
if not v183 then
error((("Unknown opname %*"):format(v182)));
end;
return v183;
end;
local function _(v185)
return v181[v185];
end;
local v187 = {
"LOADB",
"JUMP",
"JUMPBACK",
"JUMPIF",
"JUMPIFNOT",
"JUMPIFEQ",
"JUMPIFLE",
"JUMPIFLT",
"JUMPIFNOTEQ",
"JUMPIFNOTLE",
"JUMPIFNOTLT",
"FORNPREP",
"FORNLOOP",
"FORGLOOP",
"FORGPREP",
"FORGPREP_INEXT",
"DEP_FORGLOOP_INEXT",
"FORGPREP_NEXT",
"JUMPX",
"JUMPXEQKNIL",
"JUMPXEQKB",
"JUMPXEQKN",
"JUMPXEQKS",
"DEP_JUMPIFEQK",
"DEP_JUMPIFNOTEQK"
};
local v188 = nil;
local v189 = nil;
local function v212(v190)
v21();
local v191 = nil;
if v190 >= 4 and v190 <= 6 then
local v192 = {
opname = "DEP_JUMPIFEQK",
aux = false
};
local v193 = {
opname = "SUBRK",
aux = false
};
local v194 = {
opname = "DEP_JUMPIFNOTEQK",
aux = false
};
local v195 = {
opname = "DIVRK",
aux = false
};
local v196 = {
opname = "DEP_FORGLOOP_INEXT",
aux = false
};
local v197 = {
opname = "FASTCALL3",
aux = true
};
v191 = {
{
opname = "NOP",
aux = false
},
{
opname = "BREAK",
aux = false
},
{
opname = "LOADNIL",
aux = false
},
{
opname = "LOADB",
aux = false
},
{
opname = "LOADN",
aux = false
},
{
opname = "LOADK",
aux = false
},
{
opname = "MOVE",
aux = false
},
{
opname = "GETGLOBAL",
aux = true
},
{
opname = "SETGLOBAL",
aux = true
},
{
opname = "GETUPVAL",
aux = false
},
{
opname = "SETUPVAL",
aux = false
},
{
opname = "CLOSEUPVALS",
aux = false
},
{
opname = "GETIMPORT",
aux = true
},
{
opname = "GETTABLE",
aux = false
},
{
opname = "SETTABLE",
aux = false
},
{
opname = "GETTABLEKS",
aux = true
},
{
opname = "SETTABLEKS",
aux = true
},
{
opname = "GETTABLEN",
aux = false
},
{
opname = "SETTABLEN",
aux = false
},
{
opname = "NEWCLOSURE",
aux = false
},
{
opname = "NAMECALL",
aux = true
},
{
opname = "CALL",
aux = false
},
{
opname = "RETURN",
aux = false
},
{
opname = "JUMP",
aux = false
},
{
opname = "JUMPBACK",
aux = false
},
{
opname = "JUMPIF",
aux = false
},
{
opname = "JUMPIFNOT",
aux = false
},
{
opname = "JUMPIFEQ",
aux = true
},
{
opname = "JUMPIFLE",
aux = true
},
{
opname = "JUMPIFLT",
aux = true
},
{
opname = "JUMPIFNOTEQ",
aux = true
},
{
opname = "JUMPIFNOTLE",
aux = true
},
{
opname = "JUMPIFNOTLT",
aux = true
},
{
opname = "ADD",
aux = false
},
{
opname = "SUB",
aux = false
},
{
opname = "MUL",
aux = false
},
{
opname = "DIV",
aux = false
},
{
opname = "MOD",
aux = false
},
{
opname = "POW",
aux = false
},
{
opname = "ADDK",
aux = false
},
{
opname = "SUBK",
aux = false
},
{
opname = "MULK",
aux = false
},
{
opname = "DIVK",
aux = false
},
{
opname = "MODK",
aux = false
},
{
opname = "POWK",
aux = false
},
{
opname = "AND",
aux = false
},
{
opname = "OR",
aux = false
},
{
opname = "ANDK",
aux = false
},
{
opname = "ORK",
aux = false
},
{
opname = "CONCAT",
aux = false
},
{
opname = "NOT",
aux = false
},
{
opname = "MINUS",
aux = false
},
{
opname = "LENGTH",
aux = false
},
{
opname = "NEWTABLE",
aux = true
},
{
opname = "DUPTABLE",
aux = false
},
{
opname = "SETLIST",
aux = true
},
{
opname = "FORNPREP",
aux = false
},
{
opname = "FORNLOOP",
aux = false
},
{
opname = "FORGLOOP",
aux = true
},
{
opname = "FORGPREP_INEXT",
aux = false
},
v196,
{
opname = "FORGPREP_NEXT",
aux = false
},
{
opname = "NATIVECALL",
aux = false
},
{
opname = "GETVARARGS",
aux = false
},
{
opname = "DUPCLOSURE",
aux = false
},
{
opname = "PREPVARARGS",
aux = false
},
{
opname = "LOADKX",
aux = false
},
{
opname = "JUMPX",
aux = false
},
{
opname = "FASTCALL",
aux = false
},
{
opname = "COVERAGE",
aux = false
},
{
opname = "CAPTURE",
aux = false
},
v193,
v195,
{
opname = "FASTCALL1",
aux = false
},
{
opname = "FASTCALL2",
aux = true
},
{
opname = "FASTCALL2K",
aux = true
},
{
opname = "FORGPREP",
aux = false
},
{
opname = "JUMPXEQKNIL",
aux = true
},
{
opname = "JUMPXEQKB",
aux = true
},
{
opname = "JUMPXEQKN",
aux = true
},
{
opname = "JUMPXEQKS",
aux = true
},
{
opname = "IDIV",
aux = false
},
{
opname = "IDIVK",
aux = false
},
{
opname = "COUNT",
aux = false
}
};
if v190 < 1 then
local v198 = table.find(v191, v193);
assert(v198);
v191[v198] = v192;
v198 = table.find(v191, v195);
assert(v198);
v191[v198] = v194;
end;
if v190 >= 6 then
local v199 = table.find(v191, v196);
assert(v199);
v191[v199] = v197;
end;
elseif v190 >= 16 then
error((("Luau version %* not supported. You likely didn't input Luau bytecode, or the bytecode was encoded. No encoding is supported."):format(v190)));
else
error((("Luau version %* not supported."):format(v190)));
end;
v179 = {};
for v200, v201 in ipairs(v191) do
local l_aux_0 = v201.aux;
v179[v200] = {
opname = v201.opname,
aux = l_aux_0,
opcode = -1,
real_opcode = -1,
size = l_aux_0 and 2 or 1
};
end;
for v203, v204 in ipairs(v179) do
local v205 = v203 - 1;
v204.real_opcode = v205;
v204.opcode = bit32.band(v15(v205), 255);
end;
v180 = {};
v181 = {};
for _, v207 in pairs(v179) do
v180[v207.opname] = v207;
v181[v207.opcode] = v207;
end;
v188 = {};
v189 = {};
for _, v209 in pairs(v187) do
if v180[v209] then
local v210 = v180[v209];
if not v210 then
error((("Unknown opname %*"):format(v209)));
end;
local l_v210_0 = v210;
v188[v209] = true;
v189[l_v210_0.opcode] = true;
end;
end;
end;
local _ = {
LOADB = true,
JUMP = true,
JUMPBACK = true,
JUMPX = true
};
local v214 = {
addition = "+=",
subtraction = "-=",
multiplication = "*=",
division = "/=",
["floor division"] = "//=",
exponentiation = "^=",
concatenation = "..=",
modulus = "%="
};
local v215 = {
[">"] = "<=",
["<="] = ">",
["<"] = ">=",
[">="] = "<",
["=="] = "~=",
["~="] = "==",
exist = "not exist",
["not exist"] = "exist"
};
local v216 = {
[">"] = "<",
["<"] = ">",
["<="] = ">=",
[">="] = "<=",
["=="] = "==",
["~="] = "~=",
exist = "not exist",
["not exist"] = "exist"
};
local v217 = {
["end"] = true,
["if"] = true,
["local"] = true,
["else"] = true,
["elseif"] = true,
["function"] = true,
["break"] = true,
["then"] = true,
["and"] = true,
["or"] = true,
["repeat"] = true,
["until"] = true,
["for"] = true,
["do"] = true,
["in"] = true,
["nil"] = true,
["true"] = true,
["false"] = true,
["not"] = true,
["return"] = true
};
local v218 = {
["for"] = true
};
local v219 = {
call = true,
varargs = true
};
local v220 = {
[0] = "<none>";
"assert",
"math.abs",
"math.acos",
"math.asin",
"math.atan2",
"math.atan",
"math.ceil",
"math.cosh",
"math.cos",
"math.deg",
"math.exp",
"math.floor",
"math.fmod",
"math.frexp",
"math.ldexp",
"math.log10",
"math.log",
"math.max",
"math.min",
"math.modf",
"math.pow",
"math.rad",
"math.sinh",
"math.sin",
"math.sqrt",
"math.tanh",
"math.tan",
"bit32.arshift",
"bit32.band",
"bit32.bnot",
"bit32.bor",
"bit32.bxor",
"bit32.btest",
"bit32.extract",
"bit32.lrotate",
"bit32.lshift",
"bit32.replace",
"bit32.rrotate",
"bit32.rshift",
"type",
"string.byte",
"string.char",
"string.len",
"typeof",
"string.sub",
"math.clamp",
"math.sign",
"math.round",
"rawset",
"rawget",
"rawequal",
"table.insert",
"table.unpack",
"vector",
"bit32.countlz",
"bit32.countrz",
"select.vararg",
"rawlen",
"bit32.extractk",
"getmetatable",
"setmetatable",
"tonumber",
"tostring",
"bit32.byteswap",
"buffer.readi8",
"buffer.readu8",