[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] LuacExplain
- From: Mooffie <mooffie@...>
- Date: Tue, 6 Oct 2015 15:44:32 +0300
On 10/6/15, Dirk Laurie <email@example.com> wrote:
> 2015-10-06 12:03 GMT+02:00 Mooffie <firstname.lastname@example.org>:
>> 'luacexplain' is a small program that enhances the output of "luac
>> -l", and especially of "luac -l -l":
>> 1  ADD 2 0 1
>> ;; R(A) := RK(B) + RK(C)
>> ;; 2<?a> 0<b> 1<c>
> Would not
> ;; a := b + c
> also be possible, and even more friendly?
The Lua code I gave ("a = b + c") is deceivingly easy to
"disassemble", but that's usually not the case: one line of Lua code
corresponds to several VM instructions with possible use of temporary
registers. There'd be absolutely no value in inventing extra layer of
"friendly" notation to represent such code: my tool is intended for
users who want to learn about the VM, not to learn some awkward
abstraction on top.
'luacexplain' is not supposed to be a disassembler. It's merely a
reading-aid for lac's output. A "thin layer". It's an educational
tool. It was not at all my intention to free the user from his
responsibility to study the preliminaries (like the section
"Instruction anatomy" in your nice document, Dirk) -- on the contrary.
Admittedly, the string "2<?a> 0<b> 1<c>" could look noisy at first,
but one gets used to it.
Another reason why I don't need a "more friendly" notation is the way
I use 'luacexplain'. My editor launches it on a key press, jumping
directly to the line I stand on, and I can navigate the source code
while browsing luacexplain's output in-sync. Here's a screenshot:
So, as one sees, I already know what the code is supposed to do. If
'luacexplain' needed a feature it'd be interlacing the Lua source code
in the output. But my editor (as everybody's should) already provides
a comfortable solution so such feature is not on my horizon.