-- | Types representation during the analysis process.
module Analyzer.AnalyzedType where

import MaybeVoid (MaybeVoid)

-- | Type representation during the analysis process.
data Type
  = -- | 32-bit/64-bit (depending on the machine) integer type.
    TInt
  | -- | Boolean type.
    TBool
  | -- | String type.
    TString
  | -- | Array type, it contains the length of the array and its elements type.
    TArray Type Int
  | -- | Function type, see 'FunctionType'.
    TFunction FunctionType
  | -- | Null type.
    TNil
  deriving (Int -> Type -> ShowS
[Type] -> ShowS
Type -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Type] -> ShowS
$cshowList :: [Type] -> ShowS
show :: Type -> String
$cshow :: Type -> String
showsPrec :: Int -> Type -> ShowS
$cshowsPrec :: Int -> Type -> ShowS
Show, Type -> Type -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Type -> Type -> Bool
$c/= :: Type -> Type -> Bool
== :: Type -> Type -> Bool
$c== :: Type -> Type -> Bool
Eq)

-- | Function type,
-- it contains the result of the function (which can be @void@ if the result is equal to 'Nothing')
-- and its parameters types.
data FunctionType = FunctionType {FunctionType -> [Type]
parameters :: [Type], FunctionType -> MaybeVoid Type
returnType :: MaybeVoid Type}
  deriving (Int -> FunctionType -> ShowS
[FunctionType] -> ShowS
FunctionType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FunctionType] -> ShowS
$cshowList :: [FunctionType] -> ShowS
show :: FunctionType -> String
$cshow :: FunctionType -> String
showsPrec :: Int -> FunctionType -> ShowS
$cshowsPrec :: Int -> FunctionType -> ShowS
Show, FunctionType -> FunctionType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionType -> FunctionType -> Bool
$c/= :: FunctionType -> FunctionType -> Bool
== :: FunctionType -> FunctionType -> Bool
$c== :: FunctionType -> FunctionType -> Bool
Eq)