Rename allocator.init to store.string
This commit is contained in:
@@ -504,6 +504,8 @@ do
|
||||
store_byte(memory.data, addr, value)
|
||||
end
|
||||
|
||||
local store_i8 = store.i32_n8
|
||||
|
||||
function store.i32_n16(memory, addr, value)
|
||||
store_byte(memory.data, addr, value)
|
||||
store_byte(memory.data, addr + 1, bit_rshift(value, 8))
|
||||
@@ -533,14 +535,9 @@ do
|
||||
store_i32(memory, addr + 4, data_2)
|
||||
end
|
||||
|
||||
function allocator.new(min, max)
|
||||
return { min = min, max = max, data = {} }
|
||||
end
|
||||
function store.string(memory, offset, data, len)
|
||||
len = len or #data
|
||||
|
||||
local store_i8 = store.i32_n8
|
||||
|
||||
function allocator.init(memory, offset, data)
|
||||
local len = #data
|
||||
local rem = len % 4
|
||||
|
||||
for i = 1, len - rem, 4 do
|
||||
@@ -556,6 +553,10 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function allocator.new(min, max)
|
||||
return { min = min, max = max, data = {} }
|
||||
end
|
||||
|
||||
function allocator.grow(memory, num)
|
||||
local old = memory.min
|
||||
local new = old + num
|
||||
|
||||
@@ -213,7 +213,7 @@ fn write_data_list(wasm: &Module, type_info: &TypeInfo, w: &mut dyn Write) -> Re
|
||||
|
||||
write!(w, "\"")?;
|
||||
|
||||
write!(w, "rt.allocator.init(target, offset, data)")?;
|
||||
write!(w, "rt.store.string(target, offset, data)")?;
|
||||
|
||||
write!(w, "end ")?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user