Get number constant reading working
This commit is contained in:
parent
5aa1a031fa
commit
283be71809
13
readbc.lua
13
readbc.lua
|
|
@ -1,6 +1,8 @@
|
||||||
-- module for reading serialized lua bytecode
|
-- module for reading serialized lua bytecode
|
||||||
|
|
||||||
local bit = require('bit')
|
local bit = require('bit')
|
||||||
|
local lunaclib = require('lunaclib')
|
||||||
|
local u64_to_num = lunaclib.u64_to_num
|
||||||
|
|
||||||
local HEADER_MAGIC = {27, string.byte('L'), string.byte('J')}
|
local HEADER_MAGIC = {27, string.byte('L'), string.byte('J')}
|
||||||
local FLAG_STRIP = 0x02
|
local FLAG_STRIP = 0x02
|
||||||
|
|
@ -125,7 +127,16 @@ local function read_proto(fp)
|
||||||
local bcins = read_u32n(fp, numbc)
|
local bcins = read_u32n(fp, numbc)
|
||||||
local uvdata = read_u16n(fp, numuv)
|
local uvdata = read_u16n(fp, numuv)
|
||||||
-- local kgc
|
-- local kgc
|
||||||
-- local numkn
|
local num = {}
|
||||||
|
for i = 1, numkn do
|
||||||
|
local x = read_uleb128(fp)
|
||||||
|
if bit.band(x, 1) == 1 then
|
||||||
|
local y = read_uleb128(fp)
|
||||||
|
num[i] = u64_to_num(x, y)
|
||||||
|
else
|
||||||
|
num[i] = (x/2)-1
|
||||||
|
end
|
||||||
|
end
|
||||||
-- local debug = fp:read(debugLen)
|
-- local debug = fp:read(debugLen)
|
||||||
|
|
||||||
-- TODO: remove when reading of kgc, numkn and debug is implemented
|
-- TODO: remove when reading of kgc, numkn and debug is implemented
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
local num = 2^15+1
|
||||||
|
local num64 = 2^32
|
||||||
|
local fp = 0.75
|
||||||
Loading…
Reference in New Issue