+hscFileCheck hsc_env msg_act hspp_file = do {
+ -------------------
+ -- PARSE
+ -------------------
+ ; maybe_parsed <- myParseModule (hsc_dflags hsc_env) hspp_file
+
+ ; case maybe_parsed of {
+ Left err -> do { msg_act (unitBag err, emptyBag) ;
+ ; return HscFail ;
+ };
+ Right rdr_module -> hscBufferTypecheck hsc_env rdr_module msg_act
+ }}
+
+
+-- Perform static/dynamic checks on the source code in a StringBuffer
+-- This is a temporary solution: it'll read in interface files lazily, whereas
+-- we probably want to use the compilation manager to load in all the modules
+-- in a project.
+hscBufferCheck :: HscEnv -> StringBuffer -> MessageAction -> IO HscResult
+hscBufferCheck hsc_env buffer msg_act = do
+ let loc = mkSrcLoc (mkFastString "*edit*") 1 0
+ showPass (hsc_dflags hsc_env) "Parser"
+ case unP parseModule (mkPState buffer loc (hsc_dflags hsc_env)) of
+ PFailed span err -> do
+ msg_act (emptyBag, unitBag (mkPlainErrMsg span err))
+ return HscFail
+ POk _ rdr_module -> do
+ hscBufferTypecheck hsc_env rdr_module msg_act
+
+hscBufferTypecheck hsc_env rdr_module msg_act = do
+ (tc_msgs, maybe_tc_result) <- _scc_ "Typecheck-Rename"
+ tcRnModule hsc_env rdr_module
+ msg_act tc_msgs
+ case maybe_tc_result of
+ Nothing -> return (HscChecked rdr_module Nothing)
+ -- space leak on rdr_module!
+ Just r -> return (HscChecked rdr_module (Just r))
+
+
+hscBackEnd dflags
+ ModGuts{ -- This is the last use of the ModGuts in a compilation.
+ -- From now on, we just use the bits we need.
+ mg_module = this_mod,
+ mg_binds = core_binds,
+ mg_types = type_env,
+ mg_dir_imps = dir_imps,
+ mg_foreign = foreign_stubs,
+ mg_deps = dependencies } = do {
+
+ -------------------
+ -- PREPARE FOR CODE GENERATION
+ -- Do saturation and convert to A-normal form
+ prepd_binds <- _scc_ "CorePrep"
+ corePrepPgm dflags core_binds type_env;
+
+ case dopt_HscLang dflags of