lua-users home
lua-l archive

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


I have been making progress with this. The initial LLVM backend
support is now in.
I am looking for tests I could add - so far the simple tests I have
created appear to work.

For the curious, here is what the bytecode looks like:

> function try_deferred()
>>   defer print'deferred' end
>> end
> ravi.dumplua(try_deferred)

function <stdin:1,3> (3 instructions at 000002442A3EEB30)
0 params, 2 slots, 1 upvalue, 1 local, 0 constants, 1 function
        1       [2]     DEFER           0
        2       [2]     CLOSURE         0 0     ; 000002442A3EEE60
        3       [3]     RETURN          0 1
constants (0) for 000002442A3EEB30:
locals (1) for 000002442A3EEB30:
        0       (deferred function)     3       4
upvalues (1) for 000002442A3EEB30:
        0       _ENV    0       0

function <stdin:2,2> (4 instructions at 000002442A3EEE60)
0 params, 2 slots, 1 upvalue, 0 locals, 2 constants, 0 functions
        1       [2]     GETTABUP_SK     0 0 -1  ; _ENV "print"
        2       [2]     LOADK           1 -2    ; "deferred"
        3       [2]     CALL            0 2 1
        4       [2]     RETURN          0 1
constants (2) for 000002442A3EEE60:
        1       "print"
        2       "deferred"
locals (0) for 000002442A3EEE60:
upvalues (1) for 000002442A3EEE60:
        0       _ENV    0       0

On Sun, 6 Oct 2019 at 18:46, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
>
> On Sun, 6 Oct 2019 at 01:52, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> > BTW syntax of defer could be simplified by omitting the 'function()'.
> >
>
> This is now committed. So we can simply write:
>
> function x()
>    defer print('exited') end
> end
>
> Credit for this idea goes to Daurnimator:
> http://lua-users.org/lists/lua-l/2019-06/msg00280.html
>
> > The JIT backends are not yet fully updated.
> >
> > Anyway, if anyone wants to try out, the branch is 'defer'.
> >
> > https://github.com/dibyendumajumdar/ravi/tree/defer
> >