Model virtual machine ADT
This commit is contained in:
@@ -24,7 +24,8 @@ executable MVM
|
|||||||
main-is: Main.hs
|
main-is: Main.hs
|
||||||
|
|
||||||
-- Modules included in this executable, other than Main.
|
-- Modules included in this executable, other than Main.
|
||||||
-- other-modules:
|
other-modules:
|
||||||
|
VirtualMachine
|
||||||
|
|
||||||
-- LANGUAGE extensions used by modules in this package.
|
-- LANGUAGE extensions used by modules in this package.
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
|
|||||||
20
app/VirtualMachine.hs
Normal file
20
app/VirtualMachine.hs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
module VirtualMachine (
|
||||||
|
VM(..),
|
||||||
|
empty
|
||||||
|
)
|
||||||
|
where
|
||||||
|
|
||||||
|
import qualified Data.Sequence as S
|
||||||
|
|
||||||
|
data VM = VM { pc :: Int
|
||||||
|
, fp :: Int
|
||||||
|
, stack :: S.Seq Int
|
||||||
|
, halt :: Bool
|
||||||
|
} deriving (Show, Eq)
|
||||||
|
|
||||||
|
empty :: VM
|
||||||
|
empty = VM { pc = -1
|
||||||
|
, fp = -1
|
||||||
|
, stack = S.empty
|
||||||
|
, halt = False
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user