whilestat
function · lua · boundary
- Address
0x6fcfd0· 364 bytes, up to0x6fd13b- Meaning
- Compiles a while loop, moving the condition's code after the body
- 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.
| function | name | decided by |
|---|---|---|
0x6fcfd0 | whilestat | luaK_jump (0x6fcfee), constant made true (0x6fd00a), luaK_goiffalse (0x6fd022), 100 (0x6fd03b), copy (0x6fd06d), luaK_code loop (0x6fd0f1), luaK_patchlist (0x6fd126) |
0x6fe260 | repeatstat | luaK_getlabel (0x6fe272), block (0x6fe28f), until (0x6fe2a1), cond (0x6fe2ab), luaK_patchlist of the false list (0x6fe2b9) |
0x6fe2d0 | cond | expr (0x6fe2d6), nil made false (0x6fe2db), luaK_goiftrue (0x6fe2eb), tail jmp to luaK_patchtohere (0x6fe2f8) |
0x6fe300 | forstat | str_checkname (0x6fe325), = to fornum (0x6fe352), , or in to forlist (0x6fe35b), `=' or `in' expected (0x6fe341) |
0x6fe380 | fornum | three locals (0x6fe390..0x6fe3ac), three exp1 (0x6fe3bf, 0x6fe3d2, 0x6fe3e9), step 1.0 (0x6fe3f0..0x6fe40a), OP_SUB (0x6fe42c), forbody (0x6fe444) |
0x6fe450 | exp1 | expr (0x6fe45d), kind kept (0x6fe465), luaK_exp2nextreg (0x6fe46b) |
0x6fe480 | forbody | do (0x6fe49f), block (0x6fe4ba), OP_FORLOOP (0x6fe4e0) or OP_TFORLOOP (0x6fe4f8), luaK_fixline (0x6fe504), luaK_patchlist (0x6fe520) |
0x6fe540 | forlist | two locals (0x6fe55e, 0x6fe56c), names (0x6fe5a1), in (0x6fe5bd), adjust_assign (0x6fe5db), luaK_checkstack 3 (0x6fe5e7), OP_TFORPREP (0x6fe5fc) |
0x6fe6a0 | ifstat | test_then_block (0x6fe6ba, 0x6fe6e9), elseif (0x6fe6bf), else (0x6fe6f7), end (0x6fe752) |
0x6fe760 | test_then_block | next (0x6fe766), cond (0x6fe76f), then (0x6fe77b), tail jmp to block (0x6fe784) |
The derivation is in the doc.
Callers 1
- statement lua
Callees 15
- next lua
- check_match lua
- block lua
- enterblock lua
- leaveblock lua
- check lua
- expr lua
- luaX_syntaxerror lua
- luaK_jump lua
- luaK_getlabel lua
- luaK_patchlist lua
- luaK_patchtohere lua
- luaK_concat lua
- luaK_goiffalse lua
- luaK_code lua
Calls and jumps by a bare address, from tables/calls.tsv.