projects
/
matthijs
/
master-project
/
cλash.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
33091be
)
Add getConstructorFieldLabel accessor function.
author
Matthijs Kooijman
<matthijs@stdin.nl>
Wed, 16 Jun 2010 10:39:58 +0000
(12:39 +0200)
committer
Matthijs Kooijman
<matthijs@stdin.nl>
Wed, 16 Jun 2010 10:39:58 +0000
(12:39 +0200)
clash/CLasH/VHDL/VHDLTools.hs
patch
|
blob
|
history
diff --git
a/clash/CLasH/VHDL/VHDLTools.hs
b/clash/CLasH/VHDL/VHDLTools.hs
index 0ac3015e3f512533371a150f3d047de00e50da44..a70036ef33b56ff60816390b43505b7f7fcb6e77 100644
(file)
--- a/
clash/CLasH/VHDL/VHDLTools.hs
+++ b/
clash/CLasH/VHDL/VHDLTools.hs
@@
-581,6
+581,17
@@
getFieldLabels ::
-> [AST.VHDLId] -- ^ The labels
getFieldLabels htype dc_i = ((map mkVHDLBasicId) . (map fst)) (getFields htype dc_i)
-> [AST.VHDLId] -- ^ The labels
getFieldLabels htype dc_i = ((map mkVHDLBasicId) . (map fst)) (getFields htype dc_i)
+-- Finds the field label for the constructor field, if any.
+getConstructorFieldLabel ::
+ HType
+ -> Maybe AST.VHDLId
+getConstructorFieldLabel (AggrType _ (Just con) _) =
+ Just $ mkVHDLBasicId (fst con)
+getConstructorFieldLabel (AggrType _ Nothing _) =
+ Nothing
+getConstructorFieldLabel htype =
+ error $ "Can't get constructor field label from non-aggregate HType: " ++ show htype
+
mktydecl :: (AST.VHDLId, Maybe (Either AST.TypeDef AST.SubtypeIn)) -> Maybe AST.PackageDecItem
mytydecl (_, Nothing) = Nothing
mktydecl (ty_id, Just (Left ty_def)) = Just $ AST.PDITD $ AST.TypeDec ty_id ty_def
mktydecl :: (AST.VHDLId, Maybe (Either AST.TypeDef AST.SubtypeIn)) -> Maybe AST.PackageDecItem
mytydecl (_, Nothing) = Nothing
mktydecl (ty_id, Just (Left ty_def)) = Just $ AST.PDITD $ AST.TypeDec ty_id ty_def