Expose mutable memory access
This commit is contained in:
@@ -10,8 +10,11 @@ module Language.Wasm.Interpreter (
|
||||
ExternalValue(..),
|
||||
ExportInstance(..),
|
||||
GlobalInstance(..),
|
||||
MemoryInstance(..),
|
||||
MemoryStore,
|
||||
Imports,
|
||||
HostItem(..),
|
||||
HostItem(..),
|
||||
Address,
|
||||
instantiate,
|
||||
invoke,
|
||||
invokeExport,
|
||||
@@ -20,7 +23,8 @@ module Language.Wasm.Interpreter (
|
||||
emptyImports,
|
||||
makeHostModule,
|
||||
makeMutGlobal,
|
||||
makeConstGlobal
|
||||
makeConstGlobal,
|
||||
getMemory
|
||||
) where
|
||||
|
||||
import qualified Data.Map as Map
|
||||
@@ -1206,4 +1210,9 @@ getGlobalValueByName store ModuleInstance { exports } name =
|
||||
case globalInst of
|
||||
GIConst _ v -> return v
|
||||
GIMut _ ref -> readIORef ref
|
||||
_ -> error $ "Function with name " ++ show name ++ " was not found in module's exports"
|
||||
_ -> error $ "Function with name " ++ show name ++ " was not found in module's exports"
|
||||
|
||||
-- | Retrieve mutable memory from the 'Store'
|
||||
getMemory :: Store -> Address -> Maybe MemoryInstance
|
||||
getMemory Store{memInstances} address = memInstances !? address
|
||||
|
||||
|
||||
Reference in New Issue
Block a user