Merge pull request #20 from carbolymer/master

Expose mutable memory access
This commit is contained in:
Ilya Rezvov
2023-01-09 10:22:22 -07:00
committed by GitHub
2 changed files with 14 additions and 5 deletions
+12 -3
View File
@@ -10,8 +10,11 @@ module Language.Wasm.Interpreter (
ExternalValue(..), ExternalValue(..),
ExportInstance(..), ExportInstance(..),
GlobalInstance(..), GlobalInstance(..),
MemoryInstance(..),
MemoryStore,
Imports, Imports,
HostItem(..), HostItem(..),
Address,
instantiate, instantiate,
invoke, invoke,
invokeExport, invokeExport,
@@ -20,7 +23,8 @@ module Language.Wasm.Interpreter (
emptyImports, emptyImports,
makeHostModule, makeHostModule,
makeMutGlobal, makeMutGlobal,
makeConstGlobal makeConstGlobal,
getMemory
) where ) where
import qualified Data.Map as Map import qualified Data.Map as Map
@@ -1206,4 +1210,9 @@ getGlobalValueByName store ModuleInstance { exports } name =
case globalInst of case globalInst of
GIConst _ v -> return v GIConst _ v -> return v
GIMut _ ref -> readIORef ref 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 cabal-version: 2.2
name: wasm name: wasm
version: 1.1.1 version: 1.1.2
synopsis: WebAssembly Language Toolkit and Interpreter synopsis: WebAssembly Language Toolkit and Interpreter
description: description:
Library for parsing and interpreting WebAssembly, including: Library for parsing and interpreting WebAssembly, including:
@@ -64,7 +64,7 @@ library
, ieee754 >=0.8 && < 0.9 , ieee754 >=0.8 && < 0.9
, mtl >=2.2.1 && < 2.3 , mtl >=2.2.1 && < 2.3
, primitive >=0.7 && < 0.8 , primitive >=0.7 && < 0.8
, text >=1.1 && < 1.3 , text >=1.1 && < 3
, transformers >=0.4 && < 0.6 , transformers >=0.4 && < 0.6
, utf8-string >=1.0 && < 1.1 , utf8-string >=1.0 && < 1.1
, vector >=0.12 && < 0.13 , vector >=0.12 && < 0.13