Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua equivalent to Python dis()?

In Python you have the ability to view the compiled bytecode of a user-defined function using dis.

Is there a builtin equivalent to this for Lua?

It would really useful!

like image 352
Graphene Avatar asked Oct 06 '10 13:10

Graphene


1 Answers

The luac utility that comes with standard lua can create an assembly listing from Lua source using its -l option. For example, compiling from source on stdin:

C:...> echo a=b | luac -l -

main  (3 instructions, 12 bytes at 00334C30)
0+ params, 2 slots, 0 upvalues, 0 locals, 2 constants, 0 functions
        1       [1]     GETGLOBAL       0 -2    ; b
        2       [1]     SETGLOBAL       0 -1    ; a
        3       [1]     RETURN          0 1
C:...> 
like image 184
RBerteig Avatar answered Sep 22 '22 09:09

RBerteig