From f53eabeed855081fa38e9af5cf7c977915f5213f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 19 Mar 2019 15:31:08 -0300 Subject: Small changes in the header of binary files - LUAC_VERSION is equal to LUA_VERSION_NUM, and it is stored as an int. - 'sizeof(int)' and 'sizeof(size_t)' removed from the header, as the binary format does not depend on these sizes. (It uses its own serialization for unsigned integer values.) --- testes/calls.lua | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'testes') diff --git a/testes/calls.lua b/testes/calls.lua index f5108a47..941493b1 100644 --- a/testes/calls.lua +++ b/testes/calls.lua @@ -397,17 +397,15 @@ assert((function (a) return a end)() == nil) print("testing binary chunks") do - local header = string.pack("c4BBc6BBBBBj", - "\27Lua", -- signature - 5*16 + 4, -- version 5.4 - 0, -- format - "\x19\x93\r\n\x1a\n", -- data - string.packsize("i"), -- sizeof(int) - string.packsize("T"), -- sizeof(size_t) - 4, -- size of instruction - string.packsize("j"), -- sizeof(lua integer) - string.packsize("n"), -- sizeof(lua number) - 0x5678 -- LUAC_INT + local header = string.pack("c4BBBc6BBBj", + "\27Lua", -- signature + (504 >> 7) & 0x7f, (504 & 0x7f) | 0x80, -- version 5.4 (504) + 0, -- format + "\x19\x93\r\n\x1a\n", -- data + 4, -- size of instruction + string.packsize("j"), -- sizeof(lua integer) + string.packsize("n"), -- sizeof(lua number) + 0x5678 -- LUAC_INT -- LUAC_NUM may not have a unique binary representation (padding...) ) local c = string.dump(function () local a = 1; local b = 3; return a+b*3 end) -- cgit v1.2.3-55-g6feb