Copyright | (c) Sebastian Galkin 2018 |
---|---|
License | GPL-3 |
Safe Haskell | None |
Language | Haskell2010 |
Functions to evaluate a compiled Brainfuck program.
- type MachineType = Machine (Vector Int8)
- eval :: (PrimMonad m, MachineIO m) => Program Optimized -> m MachineType
- evalWith :: (PrimMonad m, MachineIO m) => VMOptions -> Program Optimized -> m MachineType
- evalWithIO :: VMOptions -> Program Optimized -> IO MachineType
- evalWithMachine :: forall m. (PrimMonad m, MachineIO m) => VMOptions -> MachineType -> Program Optimized -> m MachineType
- emptyMachine :: MachineType
- mkMachine :: Word -> MachineType
- data VMOptions = VMOptions {}
- defaultVMOptions :: VMOptions
- unsafeParse :: [String] -> IO VMOptions
- parse :: IO VMOptions
- parsePure :: [String] -> ParserResult VMOptions
Documentation
type MachineType = Machine (Vector Int8) Source #
An alias for a Machine
in which memory is an unboxed vector of bytes.
evalWith :: (PrimMonad m, MachineIO m) => VMOptions -> Program Optimized -> m MachineType Source #
Evaluate the given program returning the end state of the Machine
. The evaluation can
happen in any PrimMonad
for which we can do I/O. The reason to use PrimState
is that
we will use mutable vectors for the evaluation. VMOptions
are used to tune the details
of the VM, like available memory, verbosity, etc.
evalWithIO :: VMOptions -> Program Optimized -> IO MachineType Source #
Evaluate the given program returning the end state of the Machine
. The evaluation
happens in IO, so Input/Output is done to the console.
evalWithMachine :: forall m. (PrimMonad m, MachineIO m) => VMOptions -> MachineType -> Program Optimized -> m MachineType Source #
Evaluate the given program returning the end state of the Machine
. The evaluation can
happen in any PrimMonad
for which we can do I/O. The reason to use PrimState
is that
we will use mutable vectors for the evaluation. VMOptions
are used to tune the details
of the VM, like memory available, verbosity, etc. The evaluation starts with the specified
MachineType
, so the memory and initial pointer can be configured before running.
emptyMachine :: MachineType Source #
A VM Machine
with the default memory available.
mkMachine :: Word -> MachineType Source #
Create a new machine with the given memory
Command line arguments for the VM evaluator.
VMOptions | |
|
defaultVMOptions :: VMOptions Source #
Default configuration for the VM.