55 lines
1.6 KiB
Haskell
55 lines
1.6 KiB
Haskell
module Language.Elna.Backend.Intermediate
|
|
( Operand(..)
|
|
, Quadruple(..)
|
|
, Label(..)
|
|
, Variable(..)
|
|
) where
|
|
|
|
import Data.Int (Int32)
|
|
import Data.Word (Word32)
|
|
import Data.Text (Text)
|
|
import qualified Data.Text as Text
|
|
|
|
newtype Label = Label { unLabel :: Text }
|
|
deriving Eq
|
|
|
|
instance Show Label
|
|
where
|
|
show (Label label) = '.' : Text.unpack label
|
|
|
|
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 -}
|
|
| LessOrEqualQuadruple (Operand v) (Operand v) Label
|
|
| GreaterOrEqualQuadruple (Operand v) (Operand v) Label
|
|
| GreaterQuadruple (Operand v) (Operand v) Label
|
|
| LessQuadruple (Operand v) (Operand v) Label
|
|
| NonEqualQuadruple (Operand v) (Operand v) Label
|
|
| EqualQuadruple (Operand v) (Operand v) Label
|
|
| LabelQuadruple Label
|
|
deriving (Eq, Show)
|