aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-19 10:53:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-19 10:53:18 -0300
commit9b37a4695ebf50b37b5b4fb279ae948f23b5b6a0 (patch)
tree2a6b0f6c1c2eb962bb383175eb0a67ea81a4564d /lopcodes.c
parent1e0c73d5b643707335b06abd2546a83d9439d14c (diff)
downloadlua-9b37a4695ebf50b37b5b4fb279ae948f23b5b6a0.tar.gz
lua-9b37a4695ebf50b37b5b4fb279ae948f23b5b6a0.tar.bz2
lua-9b37a4695ebf50b37b5b4fb279ae948f23b5b6a0.zip
New semantics for the integer 'for' loop
The numerical 'for' loop over integers now uses a precomputed counter to control its number of iteractions. This change eliminates several weird cases caused by overflows (wrap-around) in the control variable. (It also ensures that every integer loop halts.) Also, the special opcodes for the usual case of step==1 were removed. (The new code is already somewhat complex for the usual case, but efficient.)
Diffstat (limited to 'lopcodes.c')
-rw-r--r--lopcodes.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/lopcodes.c b/lopcodes.c
index 3f0d551a..c35a0aaf 100644
--- a/lopcodes.c
+++ b/lopcodes.c
@@ -93,8 +93,6 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
93 ,opmode(0, 1, 0, 0, iABC) /* OP_RETURN */ 93 ,opmode(0, 1, 0, 0, iABC) /* OP_RETURN */
94 ,opmode(0, 0, 0, 0, iABC) /* OP_RETURN0 */ 94 ,opmode(0, 0, 0, 0, iABC) /* OP_RETURN0 */
95 ,opmode(0, 0, 0, 0, iABC) /* OP_RETURN1 */ 95 ,opmode(0, 0, 0, 0, iABC) /* OP_RETURN1 */
96 ,opmode(0, 0, 0, 1, iABx) /* OP_FORLOOP1 */
97 ,opmode(0, 0, 0, 1, iABx) /* OP_FORPREP1 */
98 ,opmode(0, 0, 0, 1, iABx) /* OP_FORLOOP */ 96 ,opmode(0, 0, 0, 1, iABx) /* OP_FORLOOP */
99 ,opmode(0, 0, 0, 1, iABx) /* OP_FORPREP */ 97 ,opmode(0, 0, 0, 1, iABx) /* OP_FORPREP */
100 ,opmode(0, 0, 0, 0, iABx) /* OP_TFORPREP */ 98 ,opmode(0, 0, 0, 0, iABx) /* OP_TFORPREP */