elna/lib/Language/Elna/Backend/Intermediate.hs
2024-10-06 18:09:08 +02:00

47 lines
1.3 KiB
Haskell

module Language.Elna.Backend.Intermediate
( Operand(..)
, Quadruple(..)
{- , Label(..) -}
, Variable(..)
) where
import Data.Int (Int32)
import Data.Word (Word32)
import Data.Text (Text)
newtype Variable = TempVariable Word32 -- | Variable Text
deriving Eq
instance Show Variable
where
-- show (Variable variable) = '$' : Text.unpack variable
show (TempVariable variable) = '$' : show variable
data Operand v
= IntOperand Int32
| VariableOperand v
deriving (Eq, Show)
data Quadruple v
= StartQuadruple
| StopQuadruple
| ParameterQuadruple (Operand v)
| CallQuadruple Text Word32
| AddQuadruple (Operand v) (Operand v) v
| SubtractionQuadruple (Operand v) (Operand v) v
| NegationQuadruple (Operand v) v
| ProductQuadruple (Operand v) (Operand v) v
| DivisionQuadruple (Operand v) (Operand v) v
{-| GoToQuadruple Label
| AssignQuadruple Operand Variable
| ArrayQuadruple Variable Operand Variable
| ArrayAssignQuadruple Operand Operand Variable
| EqualQuadruple Operand Operand Label
| NonEqualQuadruple Operand Operand Label
| LessQuadruple Operand Operand Label
| GreaterQuadruple Operand Operand Label
| LessOrEqualQuadruple Operand Operand Label
| GreaterOrEqualQuadruple Operand Operand Label
| LabelQuadruple Label -}
deriving (Eq, Show)