lua-users home
lua-l archive

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


The luac -l annotation indicates the FORPREP instruction jumps to the PC of the loops FORLOOP instruction when it actually jumps to the instruction following it. It's possible the comment is meant to indicate that the loop spans between the two instructions but in that case using the same 'to <PC>' format as the JMP and FORLOOP instructions is rather confusing.

For example:

% echo 'goto next; ::next:: local print=print; for i=1,0,1 do print(i) end' | luac -l -

main <stdin:0,0> (12 instructions at 0x55f66c6b7ae0)
0+ params, 7 slots, 1 upvalue, 5 locals, 1 constant, 0 functions
1 [1] VARARGPREP 0
2 [1] JMP       0 ; to 3  -- A jump target
3 [1] GETTABUP 0 0 0 ; _ENV "print"
4 [1] LOADI     1 1
5 [1] LOADI     2 0
6 [1] LOADI     3 1
7 [1] FORPREP   1 3 ; to 11  -- not a jump target, actually jumps to instruction 12.
8 [1] MOVE     5 0
9 [1] MOVE     6 4
10 [1] CALL     5 2 1 ; 1 in 0 out
11 [1] FORLOOP   1 4 ; to 8  -- A jump target
12 [1] RETURN   1 1 1 ; 0 out


-Alex