mirror of
https://github.com/CPunch/LuaPytecode.git
synced 2024-12-22 06:10:03 +00:00
updated example
This commit is contained in:
parent
9bdeecc601
commit
97c558956e
33
README.md
33
README.md
@ -10,15 +10,30 @@ chunk = lc.compileC("test.lua")
|
|||||||
|
|
||||||
print("\n===== [[Disassembly]] =====\n")
|
print("\n===== [[Disassembly]] =====\n")
|
||||||
|
|
||||||
for z in chunk['INSTRUCTIONS']:
|
def dis_chunk(chunk):
|
||||||
i = chunk['INSTRUCTIONS'][z]
|
print("==== [[" + str(chunk['NAME']) + "]] ====\n")
|
||||||
if (i['TYPE'] == "ABC"):
|
for z in chunk['PROTOTYPES']:
|
||||||
print(luac.lua_opcode_names[i['OPCODE']], i['A'], i['B'], i['C'])
|
print("** decoding proto\n")
|
||||||
elif (i['TYPE'] == "ABx"):
|
dis_chunk(chunk['PROTOTYPES'][z])
|
||||||
if (i['OPCODE'] == 1 or i['OPCODE'] == 5):
|
|
||||||
print(luac.lua_opcode_names[i['OPCODE']], i['A'], -i['Bx']-1, chunk['CONSTANTS'][i['Bx']]['DATA'])
|
print("\n==== [[" + str(chunk['NAME']) + "'s constants]] ====\n")
|
||||||
else:
|
for z in chunk['CONSTANTS']:
|
||||||
print(luac.lua_opcode_names[i['OPCODE']], i['A'], -i['Bx']-1)
|
i = chunk['CONSTANTS'][z]
|
||||||
|
print(str(z) + ": " + str(i['DATA']))
|
||||||
|
|
||||||
|
print("\n==== [[" + str(chunk['NAME']) + "'s dissassembly]] ====\n")
|
||||||
|
|
||||||
|
for z in chunk['INSTRUCTIONS']:
|
||||||
|
i = chunk['INSTRUCTIONS'][z]
|
||||||
|
if (i['TYPE'] == "ABC"):
|
||||||
|
print(luac.lua_opcode_names[i['OPCODE']], i['A'], i['B'], i['C'])
|
||||||
|
elif (i['TYPE'] == "ABx"):
|
||||||
|
if (i['OPCODE'] == 1 or i['OPCODE'] == 5):
|
||||||
|
print(luac.lua_opcode_names[i['OPCODE']], i['A'], -i['Bx']-1, chunk['CONSTANTS'][i['Bx']]['DATA'])
|
||||||
|
else:
|
||||||
|
print(luac.lua_opcode_names[i['OPCODE']], i['A'], -i['Bx']-1)
|
||||||
|
|
||||||
|
dis_chunk(chunk)
|
||||||
```
|
```
|
||||||
|
|
||||||
or just parse lua bytecode
|
or just parse lua bytecode
|
||||||
|
Loading…
Reference in New Issue
Block a user