-restOfCodeGeneration dflags toInterp this_mod imported_module_names cost_centre_info
- foreign_stuff env_tc stg_binds oa_tidy_binds
- hit pit -- these last two for mapping ModNames to Modules
- | toInterp
- = do (ibinds,itbl_env)
- <- stgBindsToInterpSyn dflags (map fst stg_binds)
- local_tycons local_classes
- return (Nothing, Nothing, Just (ibinds,itbl_env))
-
- | otherwise
- = do -------------------------- Code generation -------------------------------
- -- _scc_ "CodeGen"
- abstractC <- codeGen dflags this_mod imported_modules
- cost_centre_info fe_binders
- local_tycons stg_binds
-
- -------------------------- Code output -------------------------------
- -- _scc_ "CodeOutput"
- (maybe_stub_h_name, maybe_stub_c_name)
- <- codeOutput dflags this_mod local_tycons
- oa_tidy_binds stg_binds
- c_code h_code abstractC
-
- return (maybe_stub_h_name, maybe_stub_c_name, Nothing)
- where
- local_tycons = typeEnvTyCons env_tc
- local_classes = typeEnvClasses env_tc
- imported_modules = map mod_name_to_Module imported_module_names
- (fe_binders,h_code,c_code) = foreign_stuff
-
- mod_name_to_Module :: ModuleName -> Module
- mod_name_to_Module nm
- = let str_mi = case lookupModuleEnvByName hit nm of
- Just mi -> mi
- Nothing -> case lookupModuleEnvByName pit nm of
- Just mi -> mi
- Nothing -> barf nm
- in mi_module str_mi
- barf nm = pprPanic "mod_name_to_Module: no hst or pst mapping for"
- (ppr nm)
-
-
-dsThenSimplThenTidy dflags pcs hst this_mod print_unqual is_exported tc_result
- = do -------------------------- Desugaring ----------------
- showPass dflags "DeSugar"
- -- _scc_ "DeSugar"
- (desugared, rules, h_code, c_code, fe_binders)
- <- deSugar dflags pcs hst this_mod print_unqual tc_result
-
- -------------------------- Main Core-language transformations ----------------
- -- _scc_ "Core2Core"
- (simplified, orphan_rules)
- <- core2core dflags pcs hst is_exported desugared rules
-
- -- Do the final tidy-up
- showPass dflags "TidyCore"
- (tidy_binds, tidy_orphan_rules)
- <- tidyCorePgm dflags this_mod simplified orphan_rules
-
- return (tidy_binds, tidy_orphan_rules, (fe_binders,h_code,c_code))
-
-
-myCoreToStg dflags this_mod tidy_binds