mirror of
https://github.com/lua/lua.git
synced 2025-07-10 18:00:52 +00:00
Details
In the generic for loop, it is simpler for OP_TFORLOOP to use the same 'ra' as OP_TFORCALL. Moreover, the internal names of the loop temporaries "(for ...)" don't need to leak internal details (even because the numerical for loop doesn't have a fixed role for each of its temporaries).
This commit is contained in:
parent
3d296304ef
commit
be8445d7e4
3 changed files with 13 additions and 13 deletions
|
@ -427,10 +427,12 @@ do -- testing closing file in line iteration
|
|||
-- get the to-be-closed variable from a loop
|
||||
local function gettoclose (lv)
|
||||
lv = lv + 1
|
||||
for i = 1, math.maxinteger do
|
||||
local stvar = 0 -- to-be-closed is 4th state variable in the loop
|
||||
for i = 1, 1000 do
|
||||
local n, v = debug.getlocal(lv, i)
|
||||
if n == "(for toclose)" then
|
||||
return v
|
||||
if n == "(for state)" then
|
||||
stvar = stvar + 1
|
||||
if stvar == 4 then return v end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue