Skip to content

Instantly share code, notes, and snippets.

@creationix
Created April 20, 2016 02:11
Show Gist options
  • Save creationix/1d52c2723279105f2b0ccfdd0298a3fb to your computer and use it in GitHub Desktop.
Save creationix/1d52c2723279105f2b0ccfdd0298a3fb to your computer and use it in GitHub Desktop.
luajit -ble 'local a = 1;function b() return a + 1; end;return b()'
-- BYTECODE -- 0x41ab0238:1-1
0001 UGET 0 0 ; a
0002 ADDVN 0 0 0 ; 1
0003 RET1 0 2
-- BYTECODE -- 0x41aa48b8:0-1
0001 KSHORT 0 1
0002 FNEW 1 0 ; 0x41ab0238:1
0003 GSET 1 1 ; "b"
0004 GGET 1 1 ; "b"
0005 UCLO 0 => 0006
0006 => CALLT 1 1
@daurnimator
Copy link

 $ echo 'local a=1; (function()a=a+1 end)();return a' | luac -l -l -p -

main <stdin:0,0> (5 instructions at 0xb48790)
0+ params, 2 slots, 1 upvalue, 1 local, 1 constant, 1 function
    1   [1] LOADK       0 -1    ; 1
    2   [1] CLOSURE     1 0 ; 0xb48a60
    3   [1] CALL        1 1 1
    4   [1] RETURN      0 2
    5   [1] RETURN      0 1
constants (1) for 0xb48790:
    1   1
locals (1) for 0xb48790:
    0   a   2   6
upvalues (1) for 0xb48790:
    0   _ENV    1   0

function <stdin:1,1> (4 instructions at 0xb48a60)
0 params, 2 slots, 1 upvalue, 0 locals, 1 constant, 0 functions
    1   [1] GETUPVAL    0 0 ; a
    2   [1] ADD         0 0 -1  ; - 1
    3   [1] SETUPVAL    0 0 ; a
    4   [1] RETURN      0 1
constants (1) for 0xb48a60:
    1   1
locals (0) for 0xb48a60:
upvalues (1) for 0xb48a60:
    0   a   1   0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment