never executed always true always false
1 module HelVM.HelMA.Automata.Piet.Combiner.CPU (
2 pietPointer,
3 pietSwitch,
4 ) where
5
6 import HelVM.HelMA.Automata.Piet.Types.Memory
7
8 import HelVM.HelMA.Automata.Piet.Types.InstructionMemory
9
10 import HelVM.HelMA.Automaton.Combiner.ALU
11
12 import qualified Data.Sequence as Seq
13
14 pietPointer :: (ALU m (Seq.Seq Int) Int) => Memory -> m Memory
15 pietPointer = modifyIM "pointer" directionPointerIM rotateDirectionPointerIM
16
17 pietSwitch :: (ALU m (Seq.Seq Int) Int) => Memory -> m Memory
18 pietSwitch = modifyIM "switch" codelChooserIM toggleCodelChooserIM
19
20 modifyIM :: (ALU m (Seq.Seq Int) Int, Show a) => Text -> (InstructionMemory -> a) -> (Int -> InstructionMemory -> InstructionMemory) -> Memory -> m Memory
21 modifyIM name getValue f (Memory im s) = logWithPosition (name <> " " <> show (getValue im)) im *> (updateMemory <$> pop1 s) where
22 updateMemory (n, s') = Memory (f n im) s'