mapM processBind binds
modFuncs nameFlatFunction
modFuncs VHDL.createEntity
+ -- Extract the library units generated from all the functions in the
+ -- session.
+ funcs <- getFuncs
+ let units = concat $ map VHDL.getLibraryUnits funcs
return $ AST.DesignFile
[]
- []
+ units
findBind :: [CoreBind] -> String -> Maybe CoreBind
findBind binds lookfor =
fs <- State.gets funcs -- Get the funcs element from the session
return $ Map.lookup hsfunc fs
+-- | Gets all functions from the current session
+getFuncs :: VHDLState [(HsFunction, FuncData)]
+getFuncs = do
+ fs <- State.gets funcs -- Get the funcs element from the session
+ return $ Map.toList fs
+
-- | Sets the FlatFunction for the given HsFunction in the given setting.
setFlatFunc :: HsFunction -> FlatFunction -> VHDLState ()
setFlatFunc hsfunc flatfunc = do
-- TODO: This doesn't work for functions with multiple signatures!
mkVHDLId $ hsFuncName hsfunc
+getLibraryUnits ::
+ (HsFunction, FuncData) -- | A function from the session
+ -> [AST.LibraryUnit] -- | The library units it generates
+
+getLibraryUnits (hsfunc, fdata) =
+ case entity fdata of
+ Nothing -> []
+ Just ent -> case ent_decl ent of
+ Nothing -> []
+ Just decl -> [AST.LUEntity decl]
-- | The VHDL Bit type
bit_ty :: AST.TypeMark