10 import qualified CoreSyn
11 import qualified CoreUtils
12 import qualified HscTypes
13 import qualified Outputable
17 import CLasH.Utils.GhcTools
18 import CLasH.Utils.Pretty
20 listBindings :: FilePath -> [FilePath] -> IO [()]
21 listBindings libdir filenames = do
22 (cores,_,_,_,_) <- loadModules libdir filenames bogusFinder bogusFinder bogusFinder
23 let binds = concat $ map (CoreSyn.flattenBinds . HscTypes.cm_binds) cores
24 mapM (listBinding) binds
26 bogusFinder = (\x -> return $ Nothing)
28 listBinding :: (CoreSyn.CoreBndr, CoreSyn.CoreExpr) -> IO ()
29 listBinding (b, e) = do
32 putStr "\nType of Binder: \n"
33 putStr $ Outputable.showSDoc $ Outputable.ppr $ Var.varType b
34 putStr "\n\nExpression: \n"
37 putStr $ Outputable.showSDoc $ Outputable.ppr e
38 putStr "\n\nType of Expression: \n"
39 putStr $ Outputable.showSDoc $ Outputable.ppr $ CoreUtils.exprType e
42 -- | Show the core structure of the given binds in the given file.
43 listBind :: FilePath -> [FilePath] -> String -> IO ()
44 listBind libdir filenames name = do
45 (_,corebind,_,coreexpr,_) <- loadModules libdir filenames bindFinder bindFinder exprFinder
46 listBinding (Maybe.fromJust $ head corebind, Maybe.fromJust $ head coreexpr)
48 bindFinder = findBind (hasVarName name)
49 exprFinder = findExpr (hasVarName name)