[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Lua code generation vs. goto
- From: "Alexander Gladysh" <agladysh@...>
- Date: Fri, 25 Jul 2008 13:25:00 +0400
I have some "buisiness" logic editing tool with back-end which
generates Lua script. (Users no not have direct access to Lua code,
only to UI constructs.)
I'm writing the generator now, and I've come to that I need to emulate
unconditional jumps in Lua. (Note that I want to generate sources
useable by plain unpatched Lua, so neither Metalua tricks, nor direct
bytecode generation are not an option.)
My code generator sees data flow roughly as follows (pseudo-representation):
if condition-1 then goto label "B"
goto label "A"
That is, unconditonal jumps may be both up and down on command flow.
I think I'd have to settle with generating of intermediate
representation of command flow (table-array of command data) and
interpretation of them in micro-VM. But this is kind of defeats the
purpose of the code generator -- that is to keep overhead from stuff
not directly needed for the job as low as possible.
Is there some trick that would allow me to emulate unconditional jumps
in plain Lua (even if it kind of hard to implement)?