elna/lib/Language/Elna/Types.hs

30 lines
604 B
Haskell
Raw Normal View History

2024-07-29 07:26:47 +02:00
module Language.Elna.Types
( Type(..)
, addressByteSize
2024-07-29 07:26:47 +02:00
, booleanType
, intType
) where
import Data.Text (Text)
import Data.Word (Word32)
import Language.Elna.Location (showArrayType)
addressByteSize :: Int
addressByteSize = 4
2024-07-29 07:26:47 +02:00
data Type
= PrimitiveType Text Int
2024-07-29 07:26:47 +02:00
| ArrayType Word32 Type
deriving Eq
instance Show Type
where
show (PrimitiveType typeName _) = show typeName
2024-07-29 07:26:47 +02:00
show (ArrayType elementCount typeName) = showArrayType elementCount typeName
intType :: Type
intType = PrimitiveType "int" 4
2024-07-29 07:26:47 +02:00
booleanType :: Type
booleanType = PrimitiveType "boolean" 1