aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-11-07 14:42:05 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-11-07 14:42:05 -0200
commit7f6f70853c8a2730fca2e95d5968ad52cf470bda (patch)
tree948147a9cf6a5c5eb34232e7547c310eb06eadea /lopcodes.h
parentb8fed93215a23a3f443c5b0126f0de1725771b44 (diff)
downloadlua-7f6f70853c8a2730fca2e95d5968ad52cf470bda.tar.gz
lua-7f6f70853c8a2730fca2e95d5968ad52cf470bda.tar.bz2
lua-7f6f70853c8a2730fca2e95d5968ad52cf470bda.zip
To-be-closed variable in 'for' loop separated from the state
The variable to be closed in a generic 'for' loop now is the 4th value produced in the loop initialization, instead of being the loop state (the 2nd value produced). That allows a loop to use a state with a '__toclose' metamethod but do not close it. (As an example, 'f:lines()' might use the file 'f' as a state for the loop, but it should not close the file when the loop ends.)
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/lopcodes.h b/lopcodes.h
index 5a38f767..7bb83a1e 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -279,9 +279,9 @@ OP_FORLOOP,/* A Bx R(A)+=R(A+2);
279 if R(A) <?= R(A+1) then { pc-=Bx; R(A+3)=R(A) } */ 279 if R(A) <?= R(A+1) then { pc-=Bx; R(A+3)=R(A) } */
280OP_FORPREP,/* A Bx R(A)-=R(A+2); pc+=Bx */ 280OP_FORPREP,/* A Bx R(A)-=R(A+2); pc+=Bx */
281 281
282OP_TFORPREP,/* A Bx create upvalue A; pc+=Bx */ 282OP_TFORPREP,/* A Bx create upvalue for R(A + 3); pc+=Bx */
283OP_TFORCALL,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); */ 283OP_TFORCALL,/* A C R(A+4), ... ,R(A+3+C) := R(A)(R(A+1), R(A+2)); */
284OP_TFORLOOP,/* A Bx if R(A+1) ~= nil then { R(A)=R(A+1); pc -= Bx } */ 284OP_TFORLOOP,/* A Bx if R(A+2) ~= nil then { R(A)=R(A+2); pc -= Bx } */
285 285
286OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ 286OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
287 287