module Ast.Types where

-- | Source location for better error reporting
data SrcLoc = SrcLoc
  { SrcLoc -> String
srcFile :: String,
    SrcLoc -> Int
srcLine :: Int,
    SrcLoc -> Int
srcCol :: Int
  }
  deriving (Int -> SrcLoc -> ShowS
[SrcLoc] -> ShowS
SrcLoc -> String
(Int -> SrcLoc -> ShowS)
-> (SrcLoc -> String) -> ([SrcLoc] -> ShowS) -> Show SrcLoc
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SrcLoc -> ShowS
showsPrec :: Int -> SrcLoc -> ShowS
$cshow :: SrcLoc -> String
show :: SrcLoc -> String
$cshowList :: [SrcLoc] -> ShowS
showList :: [SrcLoc] -> ShowS
Show, SrcLoc -> SrcLoc -> Bool
(SrcLoc -> SrcLoc -> Bool)
-> (SrcLoc -> SrcLoc -> Bool) -> Eq SrcLoc
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SrcLoc -> SrcLoc -> Bool
== :: SrcLoc -> SrcLoc -> Bool
$c/= :: SrcLoc -> SrcLoc -> Bool
/= :: SrcLoc -> SrcLoc -> Bool
Eq, Eq SrcLoc
Eq SrcLoc
-> (SrcLoc -> SrcLoc -> Ordering)
-> (SrcLoc -> SrcLoc -> Bool)
-> (SrcLoc -> SrcLoc -> Bool)
-> (SrcLoc -> SrcLoc -> Bool)
-> (SrcLoc -> SrcLoc -> Bool)
-> (SrcLoc -> SrcLoc -> SrcLoc)
-> (SrcLoc -> SrcLoc -> SrcLoc)
-> Ord SrcLoc
SrcLoc -> SrcLoc -> Bool
SrcLoc -> SrcLoc -> Ordering
SrcLoc -> SrcLoc -> SrcLoc
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: SrcLoc -> SrcLoc -> Ordering
compare :: SrcLoc -> SrcLoc -> Ordering
$c< :: SrcLoc -> SrcLoc -> Bool
< :: SrcLoc -> SrcLoc -> Bool
$c<= :: SrcLoc -> SrcLoc -> Bool
<= :: SrcLoc -> SrcLoc -> Bool
$c> :: SrcLoc -> SrcLoc -> Bool
> :: SrcLoc -> SrcLoc -> Bool
$c>= :: SrcLoc -> SrcLoc -> Bool
>= :: SrcLoc -> SrcLoc -> Bool
$cmax :: SrcLoc -> SrcLoc -> SrcLoc
max :: SrcLoc -> SrcLoc -> SrcLoc
$cmin :: SrcLoc -> SrcLoc -> SrcLoc
min :: SrcLoc -> SrcLoc -> SrcLoc
Ord)

-- | Enhanced literal values including characters and floating-point numbers
data Literal
  = LInt Integer
  | LFloat Double
  | LDouble Double
  | LChar Char
  | LBool Bool
  | LArray [Literal]
  | LNull
  | LStruct [(String, Literal)]
  deriving (Int -> Literal -> ShowS
[Literal] -> ShowS
Literal -> String
(Int -> Literal -> ShowS)
-> (Literal -> String) -> ([Literal] -> ShowS) -> Show Literal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Literal -> ShowS
showsPrec :: Int -> Literal -> ShowS
$cshow :: Literal -> String
show :: Literal -> String
$cshowList :: [Literal] -> ShowS
showList :: [Literal] -> ShowS
Show, Literal -> Literal -> Bool
(Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool) -> Eq Literal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Literal -> Literal -> Bool
== :: Literal -> Literal -> Bool
$c/= :: Literal -> Literal -> Bool
/= :: Literal -> Literal -> Bool
Eq, Eq Literal
Eq Literal
-> (Literal -> Literal -> Ordering)
-> (Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool)
-> (Literal -> Literal -> Bool)
-> (Literal -> Literal -> Literal)
-> (Literal -> Literal -> Literal)
-> Ord Literal
Literal -> Literal -> Bool
Literal -> Literal -> Ordering
Literal -> Literal -> Literal
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Literal -> Literal -> Ordering
compare :: Literal -> Literal -> Ordering
$c< :: Literal -> Literal -> Bool
< :: Literal -> Literal -> Bool
$c<= :: Literal -> Literal -> Bool
<= :: Literal -> Literal -> Bool
$c> :: Literal -> Literal -> Bool
> :: Literal -> Literal -> Bool
$c>= :: Literal -> Literal -> Bool
>= :: Literal -> Literal -> Bool
$cmax :: Literal -> Literal -> Literal
max :: Literal -> Literal -> Literal
$cmin :: Literal -> Literal -> Literal
min :: Literal -> Literal -> Literal
Ord)

-- | Enhanced type system with size information and qualifiers
-- | TInt: Int with bit width (8, 16, 32, 64)
-- | TFloat: 32-bit float
-- | TDouble: 64-bit float
-- | TArray: Array type with optional size
-- | TTypedef: Type aliases
data Type
  = TInt Int
  | TFloat
  | TDouble
  | TChar
  | TBoolean
  | TVoid
  | TMutable Type
  | TPointer Type
  | TArray Type (Maybe Int)
  | TFunction
      { Type -> Type
returnType :: Type,
        Type -> [Type]
paramTypes :: [Type],
        Type -> Bool
isVariadic :: Bool
      }
  | TStruct
      { Type -> String
structName :: String,
        Type -> [(String, Type)]
fields :: [(String, Type)]
      }
  | TUnion
      { Type -> String
unionName :: String,
        Type -> [(String, Type)]
variants :: [(String, Type)]
      }
  | TTypedef String Type
  | TUnknown
  deriving (Int -> Type -> ShowS
[Type] -> ShowS
Type -> String
(Int -> Type -> ShowS)
-> (Type -> String) -> ([Type] -> ShowS) -> Show Type
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Type -> ShowS
showsPrec :: Int -> Type -> ShowS
$cshow :: Type -> String
show :: Type -> String
$cshowList :: [Type] -> ShowS
showList :: [Type] -> ShowS
Show, Type -> Type -> Bool
(Type -> Type -> Bool) -> (Type -> Type -> Bool) -> Eq Type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Type -> Type -> Bool
== :: Type -> Type -> Bool
$c/= :: Type -> Type -> Bool
/= :: Type -> Type -> Bool
Eq, Eq Type
Eq Type
-> (Type -> Type -> Ordering)
-> (Type -> Type -> Bool)
-> (Type -> Type -> Bool)
-> (Type -> Type -> Bool)
-> (Type -> Type -> Bool)
-> (Type -> Type -> Type)
-> (Type -> Type -> Type)
-> Ord Type
Type -> Type -> Bool
Type -> Type -> Ordering
Type -> Type -> Type
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Type -> Type -> Ordering
compare :: Type -> Type -> Ordering
$c< :: Type -> Type -> Bool
< :: Type -> Type -> Bool
$c<= :: Type -> Type -> Bool
<= :: Type -> Type -> Bool
$c> :: Type -> Type -> Bool
> :: Type -> Type -> Bool
$c>= :: Type -> Type -> Bool
>= :: Type -> Type -> Bool
$cmax :: Type -> Type -> Type
max :: Type -> Type -> Type
$cmin :: Type -> Type -> Type
min :: Type -> Type -> Type
Ord)

-- | Assembly constraint type
data AsmConstraint = AsmConstraint
  { AsmConstraint -> String
outputConstraint :: String,
    AsmConstraint -> [String]
inputConstraints :: [String]
  }
  deriving (Int -> AsmConstraint -> ShowS
[AsmConstraint] -> ShowS
AsmConstraint -> String
(Int -> AsmConstraint -> ShowS)
-> (AsmConstraint -> String)
-> ([AsmConstraint] -> ShowS)
-> Show AsmConstraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AsmConstraint -> ShowS
showsPrec :: Int -> AsmConstraint -> ShowS
$cshow :: AsmConstraint -> String
show :: AsmConstraint -> String
$cshowList :: [AsmConstraint] -> ShowS
showList :: [AsmConstraint] -> ShowS
Show, AsmConstraint -> AsmConstraint -> Bool
(AsmConstraint -> AsmConstraint -> Bool)
-> (AsmConstraint -> AsmConstraint -> Bool) -> Eq AsmConstraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AsmConstraint -> AsmConstraint -> Bool
== :: AsmConstraint -> AsmConstraint -> Bool
$c/= :: AsmConstraint -> AsmConstraint -> Bool
/= :: AsmConstraint -> AsmConstraint -> Bool
Eq, Eq AsmConstraint
Eq AsmConstraint
-> (AsmConstraint -> AsmConstraint -> Ordering)
-> (AsmConstraint -> AsmConstraint -> Bool)
-> (AsmConstraint -> AsmConstraint -> Bool)
-> (AsmConstraint -> AsmConstraint -> Bool)
-> (AsmConstraint -> AsmConstraint -> Bool)
-> (AsmConstraint -> AsmConstraint -> AsmConstraint)
-> (AsmConstraint -> AsmConstraint -> AsmConstraint)
-> Ord AsmConstraint
AsmConstraint -> AsmConstraint -> Bool
AsmConstraint -> AsmConstraint -> Ordering
AsmConstraint -> AsmConstraint -> AsmConstraint
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: AsmConstraint -> AsmConstraint -> Ordering
compare :: AsmConstraint -> AsmConstraint -> Ordering
$c< :: AsmConstraint -> AsmConstraint -> Bool
< :: AsmConstraint -> AsmConstraint -> Bool
$c<= :: AsmConstraint -> AsmConstraint -> Bool
<= :: AsmConstraint -> AsmConstraint -> Bool
$c> :: AsmConstraint -> AsmConstraint -> Bool
> :: AsmConstraint -> AsmConstraint -> Bool
$c>= :: AsmConstraint -> AsmConstraint -> Bool
>= :: AsmConstraint -> AsmConstraint -> Bool
$cmax :: AsmConstraint -> AsmConstraint -> AsmConstraint
max :: AsmConstraint -> AsmConstraint -> AsmConstraint
$cmin :: AsmConstraint -> AsmConstraint -> AsmConstraint
min :: AsmConstraint -> AsmConstraint -> AsmConstraint
Ord)

-- | Assembly dialect
data AsmDialect = Intel | ATT deriving (Int -> AsmDialect -> ShowS
[AsmDialect] -> ShowS
AsmDialect -> String
(Int -> AsmDialect -> ShowS)
-> (AsmDialect -> String)
-> ([AsmDialect] -> ShowS)
-> Show AsmDialect
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AsmDialect -> ShowS
showsPrec :: Int -> AsmDialect -> ShowS
$cshow :: AsmDialect -> String
show :: AsmDialect -> String
$cshowList :: [AsmDialect] -> ShowS
showList :: [AsmDialect] -> ShowS
Show, AsmDialect -> AsmDialect -> Bool
(AsmDialect -> AsmDialect -> Bool)
-> (AsmDialect -> AsmDialect -> Bool) -> Eq AsmDialect
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AsmDialect -> AsmDialect -> Bool
== :: AsmDialect -> AsmDialect -> Bool
$c/= :: AsmDialect -> AsmDialect -> Bool
/= :: AsmDialect -> AsmDialect -> Bool
Eq, Eq AsmDialect
Eq AsmDialect
-> (AsmDialect -> AsmDialect -> Ordering)
-> (AsmDialect -> AsmDialect -> Bool)
-> (AsmDialect -> AsmDialect -> Bool)
-> (AsmDialect -> AsmDialect -> Bool)
-> (AsmDialect -> AsmDialect -> Bool)
-> (AsmDialect -> AsmDialect -> AsmDialect)
-> (AsmDialect -> AsmDialect -> AsmDialect)
-> Ord AsmDialect
AsmDialect -> AsmDialect -> Bool
AsmDialect -> AsmDialect -> Ordering
AsmDialect -> AsmDialect -> AsmDialect
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: AsmDialect -> AsmDialect -> Ordering
compare :: AsmDialect -> AsmDialect -> Ordering
$c< :: AsmDialect -> AsmDialect -> Bool
< :: AsmDialect -> AsmDialect -> Bool
$c<= :: AsmDialect -> AsmDialect -> Bool
<= :: AsmDialect -> AsmDialect -> Bool
$c> :: AsmDialect -> AsmDialect -> Bool
> :: AsmDialect -> AsmDialect -> Bool
$c>= :: AsmDialect -> AsmDialect -> Bool
>= :: AsmDialect -> AsmDialect -> Bool
$cmax :: AsmDialect -> AsmDialect -> AsmDialect
max :: AsmDialect -> AsmDialect -> AsmDialect
$cmin :: AsmDialect -> AsmDialect -> AsmDialect
min :: AsmDialect -> AsmDialect -> AsmDialect
Ord)

-- | Assembly expression type
data AsmExpr = AsmExpr
  { AsmExpr -> String
asmCode :: String,
    AsmExpr -> AsmConstraint
asmConstraints :: AsmConstraint,
    AsmExpr -> [Expr]
asmArgs :: [Expr],
    AsmExpr -> [Type]
asmParameters :: [Type],
    AsmExpr -> Type
asmReturnType :: Type,
    AsmExpr -> Bool
asmSideEffects :: Bool,
    AsmExpr -> Bool
asmAlignStack :: Bool,
    AsmExpr -> AsmDialect
asmDialect :: AsmDialect
  }
  deriving (Int -> AsmExpr -> ShowS
[AsmExpr] -> ShowS
AsmExpr -> String
(Int -> AsmExpr -> ShowS)
-> (AsmExpr -> String) -> ([AsmExpr] -> ShowS) -> Show AsmExpr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AsmExpr -> ShowS
showsPrec :: Int -> AsmExpr -> ShowS
$cshow :: AsmExpr -> String
show :: AsmExpr -> String
$cshowList :: [AsmExpr] -> ShowS
showList :: [AsmExpr] -> ShowS
Show, AsmExpr -> AsmExpr -> Bool
(AsmExpr -> AsmExpr -> Bool)
-> (AsmExpr -> AsmExpr -> Bool) -> Eq AsmExpr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AsmExpr -> AsmExpr -> Bool
== :: AsmExpr -> AsmExpr -> Bool
$c/= :: AsmExpr -> AsmExpr -> Bool
/= :: AsmExpr -> AsmExpr -> Bool
Eq, Eq AsmExpr
Eq AsmExpr
-> (AsmExpr -> AsmExpr -> Ordering)
-> (AsmExpr -> AsmExpr -> Bool)
-> (AsmExpr -> AsmExpr -> Bool)
-> (AsmExpr -> AsmExpr -> Bool)
-> (AsmExpr -> AsmExpr -> Bool)
-> (AsmExpr -> AsmExpr -> AsmExpr)
-> (AsmExpr -> AsmExpr -> AsmExpr)
-> Ord AsmExpr
AsmExpr -> AsmExpr -> Bool
AsmExpr -> AsmExpr -> Ordering
AsmExpr -> AsmExpr -> AsmExpr
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: AsmExpr -> AsmExpr -> Ordering
compare :: AsmExpr -> AsmExpr -> Ordering
$c< :: AsmExpr -> AsmExpr -> Bool
< :: AsmExpr -> AsmExpr -> Bool
$c<= :: AsmExpr -> AsmExpr -> Bool
<= :: AsmExpr -> AsmExpr -> Bool
$c> :: AsmExpr -> AsmExpr -> Bool
> :: AsmExpr -> AsmExpr -> Bool
$c>= :: AsmExpr -> AsmExpr -> Bool
>= :: AsmExpr -> AsmExpr -> Bool
$cmax :: AsmExpr -> AsmExpr -> AsmExpr
max :: AsmExpr -> AsmExpr -> AsmExpr
$cmin :: AsmExpr -> AsmExpr -> AsmExpr
min :: AsmExpr -> AsmExpr -> AsmExpr
Ord)

-- | Enhanced expression nodes
-- | StructAccess: For accessing struct fields
-- | ArrayAccess: For array indexing
data Expr
  = Lit SrcLoc Literal
  | Var SrcLoc String Type
  | Function
      { Expr -> SrcLoc
funcLoc :: SrcLoc,
        Expr -> String
funcName :: String,
        Expr -> Type
funcType :: Type,
        Expr -> [String]
funcParams :: [String],
        Expr -> Expr
funcBody :: Expr
      }
  | ForeignFunction
      { funcLoc :: SrcLoc,
        funcName :: String,
        funcType :: Type
      }
  | Declaration
      { Expr -> SrcLoc
declLoc :: SrcLoc,
        Expr -> String
declName :: String,
        Expr -> Type
declType :: Type,
        Expr -> Maybe Expr
declInit :: Maybe Expr
      }
  | Assignment
      { Expr -> SrcLoc
assignLoc :: SrcLoc,
        Expr -> Expr
assignTarget :: Expr,
        Expr -> Expr
assignValue :: Expr
      }
  | Call
      { Expr -> SrcLoc
callLoc :: SrcLoc,
        Expr -> Expr
callFunc :: Expr,
        Expr -> [Expr]
callArgs :: [Expr]
      }
  | If
      { Expr -> SrcLoc
ifLoc :: SrcLoc,
        Expr -> Expr
ifCond :: Expr,
        Expr -> Expr
ifThen :: Expr,
        Expr -> Maybe Expr
ifElse :: Maybe Expr
      }
  | While
      { Expr -> SrcLoc
whileLoc :: SrcLoc,
        Expr -> Expr
whileCond :: Expr,
        Expr -> Expr
whileBody :: Expr
      }
  | From
      { Expr -> SrcLoc
fromLoc :: SrcLoc,
        Expr -> Expr
fromStart :: Expr,
        Expr -> Expr
fromEnd :: Expr,
        Expr -> Expr
fromStep :: Expr,
        Expr -> Expr
fromVar :: Expr,
        Expr -> Expr
fromBody :: Expr
      }
  | Block [Expr]
  | Return SrcLoc (Maybe Expr)
  | Break SrcLoc
  | Continue SrcLoc
  | Op SrcLoc Operation Expr Expr
  | UnaryOp SrcLoc UnaryOperation Expr
  | StructAccess SrcLoc Expr Expr
  | ArrayAccess SrcLoc Expr Expr
  | Cast SrcLoc Type Expr
  | Assembly
      { Expr -> SrcLoc
asmLoc :: SrcLoc,
        Expr -> AsmExpr
asmExpr :: AsmExpr
      }
  deriving (Int -> Expr -> ShowS
[Expr] -> ShowS
Expr -> String
(Int -> Expr -> ShowS)
-> (Expr -> String) -> ([Expr] -> ShowS) -> Show Expr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Expr -> ShowS
showsPrec :: Int -> Expr -> ShowS
$cshow :: Expr -> String
show :: Expr -> String
$cshowList :: [Expr] -> ShowS
showList :: [Expr] -> ShowS
Show, Expr -> Expr -> Bool
(Expr -> Expr -> Bool) -> (Expr -> Expr -> Bool) -> Eq Expr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Expr -> Expr -> Bool
== :: Expr -> Expr -> Bool
$c/= :: Expr -> Expr -> Bool
/= :: Expr -> Expr -> Bool
Eq, Eq Expr
Eq Expr
-> (Expr -> Expr -> Ordering)
-> (Expr -> Expr -> Bool)
-> (Expr -> Expr -> Bool)
-> (Expr -> Expr -> Bool)
-> (Expr -> Expr -> Bool)
-> (Expr -> Expr -> Expr)
-> (Expr -> Expr -> Expr)
-> Ord Expr
Expr -> Expr -> Bool
Expr -> Expr -> Ordering
Expr -> Expr -> Expr
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Expr -> Expr -> Ordering
compare :: Expr -> Expr -> Ordering
$c< :: Expr -> Expr -> Bool
< :: Expr -> Expr -> Bool
$c<= :: Expr -> Expr -> Bool
<= :: Expr -> Expr -> Bool
$c> :: Expr -> Expr -> Bool
> :: Expr -> Expr -> Bool
$c>= :: Expr -> Expr -> Bool
>= :: Expr -> Expr -> Bool
$cmax :: Expr -> Expr -> Expr
max :: Expr -> Expr -> Expr
$cmin :: Expr -> Expr -> Expr
min :: Expr -> Expr -> Expr
Ord)

-- | Enhanced operations including bitwise operations
data Operation
  = Add
  | Sub
  | Mul
  | Div
  | Mod
  | BitAnd
  | BitOr
  | BitXor
  | BitShl
  | BitShr
  | Lt
  | Gt
  | Lte
  | Gte
  | Eq
  | Ne
  | And
  | Or
  deriving (Int -> Operation -> ShowS
[Operation] -> ShowS
Operation -> String
(Int -> Operation -> ShowS)
-> (Operation -> String)
-> ([Operation] -> ShowS)
-> Show Operation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Operation -> ShowS
showsPrec :: Int -> Operation -> ShowS
$cshow :: Operation -> String
show :: Operation -> String
$cshowList :: [Operation] -> ShowS
showList :: [Operation] -> ShowS
Show, Operation -> Operation -> Bool
(Operation -> Operation -> Bool)
-> (Operation -> Operation -> Bool) -> Eq Operation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Operation -> Operation -> Bool
== :: Operation -> Operation -> Bool
$c/= :: Operation -> Operation -> Bool
/= :: Operation -> Operation -> Bool
Eq, Eq Operation
Eq Operation
-> (Operation -> Operation -> Ordering)
-> (Operation -> Operation -> Bool)
-> (Operation -> Operation -> Bool)
-> (Operation -> Operation -> Bool)
-> (Operation -> Operation -> Bool)
-> (Operation -> Operation -> Operation)
-> (Operation -> Operation -> Operation)
-> Ord Operation
Operation -> Operation -> Bool
Operation -> Operation -> Ordering
Operation -> Operation -> Operation
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Operation -> Operation -> Ordering
compare :: Operation -> Operation -> Ordering
$c< :: Operation -> Operation -> Bool
< :: Operation -> Operation -> Bool
$c<= :: Operation -> Operation -> Bool
<= :: Operation -> Operation -> Bool
$c> :: Operation -> Operation -> Bool
> :: Operation -> Operation -> Bool
$c>= :: Operation -> Operation -> Bool
>= :: Operation -> Operation -> Bool
$cmax :: Operation -> Operation -> Operation
max :: Operation -> Operation -> Operation
$cmin :: Operation -> Operation -> Operation
min :: Operation -> Operation -> Operation
Ord)

-- | Unary operations
-- | Not: Logical not
-- | BitNot: Bitwise not
-- | Deref: Pointer dereference
-- | AddrOf: Address-of operator
-- | PreInc: Pre-increment
-- | PreDec: Pre-decrement
-- | PostInc: Post-increment
-- | PostDec: Post-decrement
data UnaryOperation
  = Not
  | BitNot
  | Deref
  | AddrOf
  | PreInc
  | PreDec
  | PostInc
  | PostDec
  deriving (Int -> UnaryOperation -> ShowS
[UnaryOperation] -> ShowS
UnaryOperation -> String
(Int -> UnaryOperation -> ShowS)
-> (UnaryOperation -> String)
-> ([UnaryOperation] -> ShowS)
-> Show UnaryOperation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UnaryOperation -> ShowS
showsPrec :: Int -> UnaryOperation -> ShowS
$cshow :: UnaryOperation -> String
show :: UnaryOperation -> String
$cshowList :: [UnaryOperation] -> ShowS
showList :: [UnaryOperation] -> ShowS
Show, UnaryOperation -> UnaryOperation -> Bool
(UnaryOperation -> UnaryOperation -> Bool)
-> (UnaryOperation -> UnaryOperation -> Bool) -> Eq UnaryOperation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UnaryOperation -> UnaryOperation -> Bool
== :: UnaryOperation -> UnaryOperation -> Bool
$c/= :: UnaryOperation -> UnaryOperation -> Bool
/= :: UnaryOperation -> UnaryOperation -> Bool
Eq, Eq UnaryOperation
Eq UnaryOperation
-> (UnaryOperation -> UnaryOperation -> Ordering)
-> (UnaryOperation -> UnaryOperation -> Bool)
-> (UnaryOperation -> UnaryOperation -> Bool)
-> (UnaryOperation -> UnaryOperation -> Bool)
-> (UnaryOperation -> UnaryOperation -> Bool)
-> (UnaryOperation -> UnaryOperation -> UnaryOperation)
-> (UnaryOperation -> UnaryOperation -> UnaryOperation)
-> Ord UnaryOperation
UnaryOperation -> UnaryOperation -> Bool
UnaryOperation -> UnaryOperation -> Ordering
UnaryOperation -> UnaryOperation -> UnaryOperation
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UnaryOperation -> UnaryOperation -> Ordering
compare :: UnaryOperation -> UnaryOperation -> Ordering
$c< :: UnaryOperation -> UnaryOperation -> Bool
< :: UnaryOperation -> UnaryOperation -> Bool
$c<= :: UnaryOperation -> UnaryOperation -> Bool
<= :: UnaryOperation -> UnaryOperation -> Bool
$c> :: UnaryOperation -> UnaryOperation -> Bool
> :: UnaryOperation -> UnaryOperation -> Bool
$c>= :: UnaryOperation -> UnaryOperation -> Bool
>= :: UnaryOperation -> UnaryOperation -> Bool
$cmax :: UnaryOperation -> UnaryOperation -> UnaryOperation
max :: UnaryOperation -> UnaryOperation -> UnaryOperation
$cmin :: UnaryOperation -> UnaryOperation -> UnaryOperation
min :: UnaryOperation -> UnaryOperation -> UnaryOperation
Ord)

-- | Program representation with global scope information
-- | globals: Global variables and functions
-- | types: Type definitions
-- | sourceFile: Source file name
data Program = Program
  { Program -> [(String, Expr)]
globals :: [(String, Expr)],
    Program -> [(String, Type)]
types :: [(String, Type)],
    Program -> String
sourceFile :: String
  }
  deriving (Int -> Program -> ShowS
[Program] -> ShowS
Program -> String
(Int -> Program -> ShowS)
-> (Program -> String) -> ([Program] -> ShowS) -> Show Program
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Program -> ShowS
showsPrec :: Int -> Program -> ShowS
$cshow :: Program -> String
show :: Program -> String
$cshowList :: [Program] -> ShowS
showList :: [Program] -> ShowS
Show, Program -> Program -> Bool
(Program -> Program -> Bool)
-> (Program -> Program -> Bool) -> Eq Program
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Program -> Program -> Bool
== :: Program -> Program -> Bool
$c/= :: Program -> Program -> Bool
/= :: Program -> Program -> Bool
Eq)