Skip to content

Commit

Permalink
bytecode reference update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dibyendu Majumdar committed Dec 4, 2016
1 parent e049c9a commit a2a3658
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions readthedocs/lua_bytecode_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ More examples

x=function() y() end

Produces::

function <stdin:1,1> (3 instructions at 000000CECB2BE040)
0 params, 2 slots, 1 upvalue, 0 locals, 1 constant, 0 functions
1 [1] GETTABUP 0 0 -1 ; _ENV "y"
Expand All @@ -259,6 +261,8 @@ In line [2], the call has zero parameters (field B is 1), zero results are retai

x=function() z(1,2,3) end

Generates::

function <stdin:1,1> (6 instructions at 000000CECB2D7BC0)
0 params, 4 slots, 1 upvalue, 0 locals, 4 constants, 0 functions
1 [1] GETTABUP 0 0 -1 ; _ENV "z"
Expand All @@ -282,6 +286,8 @@ Lines [1] to [4] loads the function reference and the arguments in order, then l

x=function() local p,q,r,s = z(y()) end

Produces::

function <stdin:1,1> (5 instructions at 000000CECB2D6CC0)
0 params, 4 slots, 1 upvalue, 4 locals, 2 constants, 0 functions
1 [1] GETTABUP 0 0 -1 ; _ENV "z"
Expand All @@ -305,6 +311,8 @@ has a field C of 0, meaning multiple return values are accepted. These return va

x=function() print(string.char(64)) end

Leads to::

function <stdin:1,1> (7 instructions at 000000CECB2D6220)
0 params, 3 slots, 1 upvalue, 0 locals, 4 constants, 0 functions
1 [1] GETTABUP 0 0 -1 ; _ENV "print"
Expand Down Expand Up @@ -351,8 +359,9 @@ An '``OP_TAILCALL``' is used only for one specific return style, described above

::

> function y() return x('foo', 'bar') end
> ravi.dumplua(y)
function y() return x('foo', 'bar') end

Generates::

function <stdin:1,1> (6 instructions at 000000C3C24DE4A0)
0 params, 3 slots, 1 upvalue, 0 locals, 3 constants, 0 functions
Expand Down

0 comments on commit a2a3658

Please sign in to comment.