Rename allocator.init to store.string

This commit is contained in:
Rerumu
2022-06-19 05:38:47 -04:00
parent 2f7d7b564c
commit 508ea07aca
4 changed files with 16 additions and 13 deletions
+8 -7
View File
@@ -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
+1 -1
View File
@@ -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 ")?;
}