diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-19 10:53:18 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-19 10:53:18 -0300 |
commit | 9b37a4695ebf50b37b5b4fb279ae948f23b5b6a0 (patch) | |
tree | 2a6b0f6c1c2eb962bb383175eb0a67ea81a4564d /testes/code.lua | |
parent | 1e0c73d5b643707335b06abd2546a83d9439d14c (diff) | |
download | lua-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 'testes/code.lua')
-rw-r--r-- | testes/code.lua | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/testes/code.lua b/testes/code.lua index 834ff5e2..128ca2cb 100644 --- a/testes/code.lua +++ b/testes/code.lua | |||
@@ -303,9 +303,9 @@ check(function (x) return x & 2.0 end, 'LOADF', 'BAND', 'RETURN1') | |||
303 | 303 | ||
304 | -- basic 'for' loops | 304 | -- basic 'for' loops |
305 | check(function () for i = -10, 10.5 do end end, | 305 | check(function () for i = -10, 10.5 do end end, |
306 | 'LOADI', 'LOADK', 'LOADI', 'FORPREP1', 'FORLOOP1', 'RETURN0') | 306 | 'LOADI', 'LOADK', 'LOADI', 'FORPREP', 'FORLOOP', 'RETURN0') |
307 | check(function () for i = 0xfffffff, 10.0, 1 do end end, | 307 | check(function () for i = 0xfffffff, 10.0, 1 do end end, |
308 | 'LOADK', 'LOADF', 'LOADI', 'FORPREP1', 'FORLOOP1', 'RETURN0') | 308 | 'LOADK', 'LOADF', 'LOADI', 'FORPREP', 'FORLOOP', 'RETURN0') |
309 | 309 | ||
310 | -- bug in constant folding for 5.1 | 310 | -- bug in constant folding for 5.1 |
311 | check(function () return -nil end, 'LOADNIL', 'UNM', 'RETURN1') | 311 | check(function () return -nil end, 'LOADNIL', 'UNM', 'RETURN1') |