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
|
||||
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user