lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


'luacexplain' is a small program that enhances the output of "luac
-l", and especially of "luac -l -l":

    https://github.com/mooffie/luacexplain

It's intended for whoever wants to understand Lua VM's instructions
(or "opcodes") better.

After every VM instruction it prints a pseudo-code line describing the
instruction, and a more friendly representation of the operands.

Let's have an example.

First, a plain vanilla luac invocation:

    $ echo "local b,c; local a = b+c" | luac -l -l -p -
    ...
    1   [1]   ADD   2 0 1
    ...

And now with piping it through 'luacexplain':

    $ echo "local b,c; local a = b+c" | luac -l -l -p - | luacexplain
    ...
    1   [1]   ADD   2 0 1
                           ;; R(A) := RK(B) + RK(C)
                           ;; 2<?a> 0<b> 1<c>

The "R(A) := RK(B) + RK(C)" line is the pseudo-code (the README.md
gives links to texts explaining its conventions). The "2<?a> 0<b>
1<c>" is simply "2 0 1" (the A-B-C operands) with the variable names
printed in angle brackets after every operand.