lua-users home
lua-l archive

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


Hi, list!

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):

    label "A"
    command-1
    if condition-1 then goto label "B"
    goto label "A"
    label "B"
    command-2

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)?

TIA,
Alexander.