local 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 m end 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 + pages end return memory