never executed always true always false
1 module HelVM.HelMA.Automaton.Instruction where
2
3 import HelVM.HelMA.Automaton.Instruction.Extras.TextExtra
4
5 import HelVM.HelMA.Automaton.Instruction.Groups.CFInstruction
6 import HelVM.HelMA.Automaton.Instruction.Groups.LSInstruction
7 import HelVM.HelMA.Automaton.Instruction.Groups.SMInstruction
8
9 import Data.List.Index
10 import qualified Data.Vector as Vector
11
12
13 -- | Types
14
15 data Instruction =
16 ISM !SMInstruction
17 | ILS !LSInstruction
18 | ICF !CFInstruction
19 | End
20 deriving stock (Eq , Read , Show)
21
22 type InstructionList = [Instruction]
23 type InstructionVector = Vector.Vector Instruction
24
25 -- | print
26
27 printIndexedIL :: InstructionList -> Text
28 printIndexedIL il = unlines $ printIndexedI <$> indexed il
29
30 printIndexedI :: (Int , Instruction) -> Text
31 printIndexedI (index , i) = printI i <> " # " <> show index
32
33 printIL :: InstructionList -> Text
34 printIL il = unlines $ printI <$> il
35
36 printI :: Instruction -> Text
37 printI (ISM i) = printSM i
38 printI (ICF i) = printCF i
39 printI (ILS i) = toLowerShow i
40 printI End = toLowerShow End