Something went wrong. Try again.
quick and dirty pure lua webassembly interpreter
Something went wrong. Try again.
1234567891011121314151617181920212223242526local memory = {}
local constants = require("constants")
memory.Memory = { pages = 0, maxpages = -1,}
function memory.Memory:new(pages) local m = {} setmetatable(m, {__index = self}) m:grow(pages) return mend
function memory.Memory:grow(pages) local initStart = self.pages * constants.WASM_PAGE_SIZE local initEnd = ((self.pages + pages) * constants.WASM_PAGE_SIZE) - 1 for i = initStart, initEnd do self[i] = 0 end self.pages = self.pages + pagesend
return memory