benilla-re systems structs docs

fornum

function · lua · boundary

Address
0x6fe380 · 208 bytes, up to 0x6fe44f
Meaning
Compiles a numeric for loop's control locals, start, limit and step
Confidence
verified, proof one
Finding
lua/compiler#loops-and-conditionals

Finding: Loops and conditionals in lua: the compiler

whilestat compiles the condition first, copies its code out (at most 100 instructions, else `while' condition too complex), compiles the body and puts the condition's code after it, so the loop runs one jump per pass. repeatstat jumps back while the until condition is false. fornum makes three hidden locals, (for limit) and (for step) after the variable, with a step of 1 when none is given, and subtracts the step from the start before the loop. forlist makes (for generator) and (for state) and emits OP_TFORPREP. ifstat chains elseif and else.

functionnamedecided by
0x6fcfd0whilestatluaK_jump (0x6fcfee), constant made true (0x6fd00a), luaK_goiffalse (0x6fd022), 100 (0x6fd03b), copy (0x6fd06d), luaK_code loop (0x6fd0f1), luaK_patchlist (0x6fd126)
0x6fe260repeatstatluaK_getlabel (0x6fe272), block (0x6fe28f), until (0x6fe2a1), cond (0x6fe2ab), luaK_patchlist of the false list (0x6fe2b9)
0x6fe2d0condexpr (0x6fe2d6), nil made false (0x6fe2db), luaK_goiftrue (0x6fe2eb), tail jmp to luaK_patchtohere (0x6fe2f8)
0x6fe300forstatstr_checkname (0x6fe325), = to fornum (0x6fe352), , or in to forlist (0x6fe35b), `=' or `in' expected (0x6fe341)
0x6fe380fornumthree locals (0x6fe390..0x6fe3ac), three exp1 (0x6fe3bf, 0x6fe3d2, 0x6fe3e9), step 1.0 (0x6fe3f0..0x6fe40a), OP_SUB (0x6fe42c), forbody (0x6fe444)
0x6fe450exp1expr (0x6fe45d), kind kept (0x6fe465), luaK_exp2nextreg (0x6fe46b)
0x6fe480forbodydo (0x6fe49f), block (0x6fe4ba), OP_FORLOOP (0x6fe4e0) or OP_TFORLOOP (0x6fe4f8), luaK_fixline (0x6fe504), luaK_patchlist (0x6fe520)
0x6fe540forlisttwo locals (0x6fe55e, 0x6fe56c), names (0x6fe5a1), in (0x6fe5bd), adjust_assign (0x6fe5db), luaK_checkstack 3 (0x6fe5e7), OP_TFORPREP (0x6fe5fc)
0x6fe6a0ifstattest_then_block (0x6fe6ba, 0x6fe6e9), elseif (0x6fe6bf), else (0x6fe6f7), end (0x6fe752)
0x6fe760test_then_blocknext (0x6fe766), cond (0x6fe76f), then (0x6fe77b), tail jmp to block (0x6fe784)

The derivation is in the doc.

Callers 1

Callees 11

Calls and jumps by a bare address, from tables/calls.tsv.