Base.hs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. module Gidl.Types.Base
  2. ( uint8_t
  3. , uint16_t
  4. , uint32_t
  5. , uint64_t
  6. , sint8_t
  7. , sint16_t
  8. , sint32_t
  9. , sint64_t
  10. , bool_t
  11. , float_t
  12. , double_t
  13. , sequence_num_t
  14. , baseTypeEnv
  15. ) where
  16. import Gidl.Types.AST
  17. uint8_t :: Type
  18. uint8_t = PrimType (AtomType (AtomWord Bits8))
  19. uint16_t :: Type
  20. uint16_t = PrimType (AtomType (AtomWord Bits16))
  21. uint32_t :: Type
  22. uint32_t = PrimType (AtomType (AtomWord Bits32))
  23. uint64_t :: Type
  24. uint64_t = PrimType (AtomType (AtomWord Bits64))
  25. sint8_t :: Type
  26. sint8_t = PrimType (AtomType (AtomInt Bits8))
  27. sint16_t :: Type
  28. sint16_t = PrimType (AtomType (AtomInt Bits16))
  29. sint32_t :: Type
  30. sint32_t = PrimType (AtomType (AtomInt Bits32))
  31. sint64_t :: Type
  32. sint64_t = PrimType (AtomType (AtomInt Bits64))
  33. bool_t :: Type
  34. bool_t = PrimType (EnumType "bool_t" Bits8 [("false", 0), ("true", 1)])
  35. float_t :: Type
  36. float_t = PrimType (AtomType AtomFloat)
  37. double_t :: Type
  38. double_t = PrimType (AtomType AtomDouble)
  39. sequence_num_t :: Type
  40. sequence_num_t = PrimType (Newtype "sequence_num_t" (AtomType (AtomWord Bits32)))
  41. baseTypeEnv :: TypeEnv
  42. baseTypeEnv = TypeEnv
  43. [ ( "uint8_t" , uint8_t)
  44. , ( "uint16_t", uint16_t)
  45. , ( "uint32_t", uint32_t)
  46. , ( "uint64_t", uint64_t)
  47. , ( "sint8_t" , sint8_t)
  48. , ( "sint16_t", sint16_t)
  49. , ( "sint32_t", sint32_t)
  50. , ( "sint64_t", sint64_t)
  51. , ( "bool_t" , bool_t)
  52. , ( "float_t" , float_t)
  53. , ( "double_t", double_t)
  54. , ( "sequence_num_t", sequence_num_t)
  55. ]