git @ Cat's Eye Technologies UampirNexol / 4aa862a
Regularize Condition data type. Chris Pressey 2 months ago
2 changed file(s) with 4 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
33
44 module Language.UampirNexol.Eval where
55
6 import Language.UampirNexol.Type (Location(..))
67 import Language.UampirNexol.State
78 import Language.UampirNexol.Prog
89
2627
2728 -- | Helper to evaluate conditions
2829 evalCond :: Condition -> State -> Bool
29 evalCond Zero s = accumulator s == 0
30 evalCond NonZero s = accumulator s /= 0
30 evalCond (IsSet Z) s = accumulator s == 0
31 evalCond (IsUnset Z) s = accumulator s /= 0
3132 --evalCond Carry s = "C" `elem` map fst (meaningfulLocs s)
3233 --evalCond NonCarry s = "C" `notElem` map fst (meaningfulLocs s)
2020 deriving (Show)
2121
2222 -- | Processor status conditions
23 data Condition =
24 Zero
25 | NonZero
26 -- | Carry
27 -- | NonCarry
23 data Condition = IsSet Location | IsUnset Location
2824 deriving (Show, Eq)
2925
3026 -- | Type checker that ensures programs maintain location type consistency