From 36de01d9885562444ae2e2a3e0b7e01b3fb8743b Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 30 Mar 2021 14:49:18 -0300 Subject: Changes in cache for function constants In 'lcode.c', when adding constants to the list of constants of a function, integers represent themselves in the cache and floats with integral values get a small delta to avoid collision with integers. (This change avoids creating artificial addresses; the old implementation converted integers to pointers to index the cache.) --- testes/code.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'testes') diff --git a/testes/code.lua b/testes/code.lua index 4e00309f..543743fc 100644 --- a/testes/code.lua +++ b/testes/code.lua @@ -69,6 +69,20 @@ foo = function (f, a) checkKlist(foo, {100000, 100000.0, -100000, -100000.0}) +-- floats x integers +foo = function (t, a) + t[a] = 1; t[a] = 1.0 + t[a] = 1; t[a] = 1.0 + t[a] = 2; t[a] = 2.0 + t[a] = 0; t[a] = 0.0 + t[a] = 1; t[a] = 1.0 + t[a] = 2; t[a] = 2.0 + t[a] = 0; t[a] = 0.0 +end + +checkKlist(foo, {1, 1.0, 2, 2.0, 0, 0.0}) + + -- testing opcodes -- check that 'f' opcodes match '...' -- cgit v1.2.3-55-g6feb