Expose mutable memory access

This commit is contained in:
Mateusz Galazyn
2022-10-22 09:37:50 +02:00
parent c8f1bc9186
commit 3be70781b8
2 changed files with 14 additions and 5 deletions
+12 -3
View File
@@ -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
+2 -2
View File
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: wasm
version: 1.1.1
version: 1.1.2
synopsis: WebAssembly Language Toolkit and Interpreter
description:
Library for parsing and interpreting WebAssembly, including:
@@ -64,7 +64,7 @@ library
, ieee754 >=0.8 && < 0.9
, mtl >=2.2.1 && < 2.3
, primitive >=0.7 && < 0.8
, text >=1.1 && < 1.3
, text >=1.1 && < 3
, transformers >=0.4 && < 0.6
, utf8-string >=1.0 && < 1.1
, vector >=0.12 && < 0.13