+import VHDLTypes
+import FlattenTypes
+import TranslatorTypes
+
+-- | Create an entity for a given function
+createEntity ::
+ HsFunction -- | The function signature
+ -> FuncData -- | The function data collected so far
+ -> FuncData -- | The modified function data
+
+createEntity hsfunc fdata =
+ let func = flatFunc fdata in
+ case func of
+ -- Skip (builtin) functions without a FlatFunction
+ Nothing -> fdata
+ -- Create an entity for all other functions
+ Just flatfunc ->
+
+ let
+ s = sigs flatfunc
+ a = args flatfunc
+ r = res flatfunc
+ args' = map (fmap (mkMap s)) a
+ res' = fmap (mkMap s) r
+ entity' = Entity args' res' Nothing
+ in
+ fdata { entity = Just entity' }
+ where
+ mkMap :: Eq id => [(id, SignalInfo)] -> id -> AST.VHDLId
+ mkMap sigmap id =
+ mkVHDLId nm
+ where
+ info = Maybe.fromMaybe
+ (error $ "Signal not found in the name map? This should not happen!")
+ (lookup id sigmap)
+ nm = Maybe.fromMaybe
+ (error $ "Signal not named? This should not happen!")
+ (name info)
+
+
+
+
+