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.)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user