summaryrefslogtreecommitdiff
path: root/src/Language/Fiddle/Internal/UnitInterface.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-10-11 18:45:34 -0600
committerJosh Rahm <joshuarahm@gmail.com>2024-10-11 18:45:34 -0600
commitda0d596946cf21e2f275dd03b40c0a6c0824f66b (patch)
tree517763d8d0613dc0f1b138eb2434a2a709383227 /src/Language/Fiddle/Internal/UnitInterface.hs
parent6ce692d61e8486c103a8492b0ec372858b29de50 (diff)
downloadfiddle-da0d596946cf21e2f275dd03b40c0a6c0824f66b.tar.gz
fiddle-da0d596946cf21e2f275dd03b40c0a6c0824f66b.tar.bz2
fiddle-da0d596946cf21e2f275dd03b40c0a6c0824f66b.zip
Change 'Expression' to use numbers with units.
This helps to catch bugs in the compiler, specifically ones related to mixing up bits and bytes.
Diffstat (limited to 'src/Language/Fiddle/Internal/UnitInterface.hs')
-rw-r--r--src/Language/Fiddle/Internal/UnitInterface.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Language/Fiddle/Internal/UnitInterface.hs b/src/Language/Fiddle/Internal/UnitInterface.hs
index c5cbc2c..2a538eb 100644
--- a/src/Language/Fiddle/Internal/UnitInterface.hs
+++ b/src/Language/Fiddle/Internal/UnitInterface.hs
@@ -8,6 +8,7 @@ import GHC.Generics
import Language.Fiddle.Internal.Scopes (Scope)
import qualified Language.Fiddle.Internal.Scopes as Scopes
import Language.Fiddle.Types (SourceSpan)
+import Language.Fiddle.Internal.UnitNumbers
data InternalDirectiveExpression
= InternalDirectiveExpressionNumber String
@@ -93,7 +94,7 @@ data ExportedLocationDecl where
{ -- | Metadata associated with the location.
exportedLocationMetadata :: Metadata,
-- | The value of the location as an integer.
- exportedLocationValue :: Integer
+ exportedLocationValue :: N Address
} ->
ExportedLocationDecl
deriving (Show, Eq, Ord, Generic, FromJSON, ToJSON)
@@ -105,7 +106,7 @@ data ExportedBitsDecl where
{ -- | Metadata associated with the bits declaration.
exportedBitsDeclMetadata :: Metadata,
-- | The size of the bits in this declaration.
- exportedBitsDeclSizeBits :: Word32
+ exportedBitsDeclSizeBits :: N Bits
} ->
ExportedBitsDecl
deriving (Show, Eq, Ord, Generic, FromJSON, ToJSON)
@@ -117,7 +118,7 @@ data ExportedTypeDecl where
{ -- | Metadata associated with the type declaration.
exportedTypeDeclMetadata :: Metadata,
-- | The size of the type in bytes.
- exportedTypeDeclSizeBytes :: Word32
+ exportedTypeDeclSizeBytes :: N Bytes
} ->
ExportedTypeDecl
deriving (Show, Eq, Ord, Generic, FromJSON, ToJSON)
@@ -127,7 +128,7 @@ data ReferencedObjectType where
{objectTypeReference :: String} -> ReferencedObjectType
ArrayObjectType ::
{ arrayObjectTypeType :: ReferencedObjectType,
- arryObjecttTypeNumber :: Word32
+ arryObjecttTypeNumber :: N Unitless
} ->
ReferencedObjectType
deriving (Show, Eq, Ord, Generic, FromJSON, ToJSON)
@@ -139,7 +140,7 @@ data ExportedObjectDecl where
{ -- | Metadata associated with the object declaration.
exportedObjectDeclMetadata :: Metadata,
-- | The memory location of the object.
- exportedObjectDeclLocation :: Integer,
+ exportedObjectDeclLocation :: N Address,
-- | The type of the object as a string.
exportedObjectDeclType :: ReferencedObjectType
} ->