forked from GitHub/haskell-wasm
start interpreter
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
|
||||
module Language.Wasm.Interpreter (
|
||||
instantiate
|
||||
) where
|
||||
|
||||
import qualified Data.Map as Map
|
||||
import qualified Data.Text.Lazy as TL
|
||||
|
||||
import Data.Vector (Vector)
|
||||
import qualified Data.Vector as Vector
|
||||
import Data.IORef (IORef)
|
||||
import Data.Array.IO (IOArray, newArray, readArray, writeArray)
|
||||
import Data.Word (Word32, Word64)
|
||||
|
||||
import Language.Wasm.Structure
|
||||
|
||||
data Value =
|
||||
VI32 Word32
|
||||
| VI62 Word64
|
||||
| VF32 Float
|
||||
| VF64 Double
|
||||
|
||||
type Address = Int
|
||||
|
||||
data Ref a = Imported TL.Text TL.Text | Local a
|
||||
|
||||
type TableInstance = Vector (Maybe Address)
|
||||
|
||||
type MemoryInstance = IOArray Int Word32
|
||||
|
||||
data GlobalInstance = GConst Value | GMut (IORef Value)
|
||||
|
||||
data ModuleInstance = ModuleInstance {
|
||||
types :: Vector FuncType,
|
||||
functions :: Vector (Ref Function),
|
||||
tables :: Vector (Ref TableInstance),
|
||||
mems :: Vector (Ref MemoryInstance),
|
||||
globals :: Vector (Ref Global),
|
||||
exports :: Map.Map TL.Text ExportDesc
|
||||
}
|
||||
|
||||
instantiate :: Module -> ModuleInstance
|
||||
instantiate mod = undefined
|
||||
@@ -30,6 +30,7 @@ library
|
||||
, transformers >=0.4 && <0.6
|
||||
, utf8-string >=1.0
|
||||
, cereal >= 0.5
|
||||
, vector >= 0.12
|
||||
build-tools:
|
||||
alex >=3.1.3
|
||||
, happy >=1.9.4
|
||||
@@ -39,6 +40,7 @@ library
|
||||
Language.Wasm.Structure
|
||||
Language.Wasm.Binary
|
||||
Language.Wasm.Validate
|
||||
Language.Wasm.Interpreter
|
||||
Language.Wasm
|
||||
other-modules:
|
||||
Paths_wasm
|
||||
|
||||
Reference in New Issue
Block a user