packages feed

uhc-light-1.1.7.0: src/UHC/Light/Compiler/EHC/CompilePhase/Run.hs

module UHC.Light.Compiler.EHC.CompilePhase.Run
( cpRunCoreRun )
where
import UHC.Light.Compiler.EHC.Common
import UHC.Light.Compiler.EHC.CompileUnit
import UHC.Light.Compiler.EHC.CompileRun
import Data.Maybe
import Control.Monad.State
import Control.Exception
import UHC.Light.Compiler.Core.ToCoreRun
import UHC.Light.Compiler.CoreRun.Run
import UHC.Light.Compiler.CoreRun.Run.Val.RunExplStk as RE

{-# LINE 41 "src/ehc/EHC/CompilePhase/Run.chs" #-}
-- | Run CoreRun.
-- TBD: fix dependence on whole program linked
cpRunCoreRun :: HsName -> EHCompilePhase ()
cpRunCoreRun modNm = do
    cr <- get
    let (ecu,_,opts,_) = crBaseInfo modNm cr
        mbCore = ecuMbCore ecu
    cpMsg modNm VerboseNormal "Run Core"
    when (isJust mbCore) $ do
      let mod = cmod2CoreRun $ fromJust mbCore
      res <- liftIO $ catch
        (runCoreRun opts [] mod $ cmodRun opts mod)
        (\(e :: SomeException) -> hFlush stdout >> (return $ Left $ strMsg $ "cpRunCoreRun: " ++ show e))
      either (\e -> cpSetLimitErrsWhen 1 "Run Core(Run) errors" [e])
             (\_ -> return ())
             res