-hscRecomp dflags finder summary maybe_checked_iface output_filename
- core_cmds stg_cmds hst hit pit pcs_ch
- = do {
- -- what target are we shooting for?
- let toInterp = dopt_HscLang dflags == HscInterpreted
- this_mod = ms_mod summary
- ;
- -- PARSE
- maybe_parsed <- myParseModule dflags summary;
- case maybe_parsed of {
- Nothing -> return (HscFail pcs_ch);
- Just rdr_module -> do {
-
- -- RENAME
- show_pass dflags "Renamer";
- (pcs_rn, maybe_rn_result)
- <- renameModule dflags finder hit hst pcs_ch this_mod rdr_module;
- case maybe_rn_result of {
- Nothing -> return (HscFail pcs_rn);
- Just (new_iface, rn_hs_decls) -> do {
-
- -- TYPECHECK
- show_pass dflags "Typechecker";
- maybe_tc_result
- <- typecheckModule dflags this_mod pcs_rn hst hit rn_hs_decls;
- case maybe_tc_result of {
- Nothing -> return (HscFail pcs_rn);
- Just tc_result -> do {
-
- let pcs_tc = tc_pcs tc_result
- env_tc = tc_env tc_result
- binds_tc = tc_binds tc_result
- local_insts = tc_insts tc_result
- ;
- -- DESUGAR, SIMPLIFY, TIDY-CORE
- -- We grab the the unfoldings at this point.
- (tidy_binds, orphan_rules, foreign_stuff)
- <- dsThenSimplThenTidy dflags this_mod tc_result core_cmds
- ;
- -- CONVERT TO STG
- (stg_binds, oa_tidy_binds, cost_centre_info, top_level_ids)
- <- myCoreToStg dflags this_mod tidy_binds stg_cmds
- ;
- -- cook up a new ModDetails now we (finally) have all the bits
- let new_details = mkModDetails env_tc local_insts tidy_binds
- top_level_ids orphan_rules
- ;
- -- and possibly create a new ModIface
- let maybe_final_iface
- = completeIface maybe_checked_iface new_iface new_details
- ;
-
- -- Write the interface file
- writeIface finder maybe_final_iface
- ;
-
- -- do the rest of code generation/emission
- (maybe_ibinds, maybe_stub_h_filename, maybe_stub_c_filename)
- <- restOfCodeGeneration dflags toInterp summary
- cost_centre_info foreign_stuff tc_env stg_binds oa_tidy_binds
- ;
- -- and the answer is ...
- return (HscOK new_details maybe_final_iface
- maybe_stub_h_filename maybe_stub_c_filename
- maybe_ibinds pcs_tc)
- }}}}}}}
-
-
-myParseModule dflags summary
+hscRecomp ghci_mode dflags location maybe_checked_iface hst hit pcs_ch
+ = do {
+ ; when (verbosity dflags >= 1) $
+ hPutStr stderr "compilation IS required";
+ -- mode -v1 tries to keep everything on one line
+ when (verbosity dflags > 1) $
+ hPutStrLn stderr "";
+
+ -- what target are we shooting for?
+ ; let toInterp = dopt_HscLang dflags == HscInterpreted
+
+ -------------------
+ -- PARSE
+ -------------------
+ ; maybe_parsed <- myParseModule dflags
+ (unJust "hscRecomp:hspp" (ml_hspp_file location))
+ ; case maybe_parsed of {
+ Nothing -> return (HscFail pcs_ch);
+ Just rdr_module -> do {
+ ; let this_mod = mkHomeModule (hsModuleName rdr_module)
+
+ -------------------
+ -- RENAME
+ -------------------
+ ; (pcs_rn, maybe_rn_result)
+ <- renameModule dflags hit hst pcs_ch this_mod rdr_module
+ ; case maybe_rn_result of {
+ Nothing -> return (HscFail pcs_rn);
+ Just (print_unqualified, (is_exported, new_iface, rn_hs_decls)) -> do {
+
+ -------------------
+ -- TYPECHECK
+ -------------------
+ ; maybe_tc_result <- typecheckModule dflags pcs_rn hst new_iface
+ print_unqualified rn_hs_decls
+ ; case maybe_tc_result of {
+ Nothing -> return (HscFail pcs_rn);
+ Just (pcs_tc, tc_result) -> do {
+
+ ; let env_tc = tc_env tc_result
+
+ -------------------
+ -- DESUGAR
+ -------------------
+ ; (ds_binds, ds_rules, foreign_stuff)
+ <- deSugar dflags pcs_tc hst this_mod print_unqualified tc_result
+
+ -------------------
+ -- SIMPLIFY, TIDY-CORE
+ -------------------
+ -- We grab the the unfoldings at this point.
+ ; (pcs_simpl, tidy_binds, orphan_rules)
+ <- simplThenTidy dflags pcs_tc hst this_mod is_exported ds_binds ds_rules
+
+ -------------------
+ -- BUILD THE NEW ModDetails AND ModIface
+ -------------------
+ ; let new_details = mkModDetails env_tc tidy_binds orphan_rules
+ ; final_iface <- mkFinalIface ghci_mode dflags location
+ maybe_checked_iface new_iface new_details
+
+ -------------------
+ -- CONVERT TO STG
+ -------------------
+ ; (stg_binds, cost_centre_info)
+ <- myCoreToStg dflags this_mod tidy_binds
+
+ -------------------
+ -- COMPLETE CODE GENERATION
+ -------------------
+ ; (maybe_stub_h_filename, maybe_stub_c_filename, maybe_ibinds)
+ <- restOfCodeGeneration dflags toInterp this_mod
+ (map ideclName (hsModuleImports rdr_module))
+ cost_centre_info foreign_stuff env_tc stg_binds tidy_binds
+ hit (pcs_PIT pcs_simpl)
+
+ -- and the answer is ...
+ ; return (HscRecomp pcs_simpl new_details final_iface
+ maybe_stub_h_filename maybe_stub_c_filename
+ maybe_ibinds)
+ }}}}}}}
+
+
+
+mkFinalIface ghci_mode dflags location maybe_old_iface new_iface new_details
+ = case completeIface maybe_old_iface new_iface new_details of
+ (new_iface, Nothing) -- no change in the interfacfe
+ -> do when (dopt Opt_D_dump_hi_diffs dflags)
+ (printDump (text "INTERFACE UNCHANGED"))
+ dumpIfSet_dyn dflags Opt_D_dump_hi
+ "UNCHANGED FINAL INTERFACE" (pprIface new_iface)
+ return new_iface
+ (new_iface, Just sdoc_diffs)
+ -> do dumpIfSet_dyn dflags Opt_D_dump_hi_diffs "INTERFACE HAS CHANGED"
+ sdoc_diffs
+ dumpIfSet_dyn dflags Opt_D_dump_hi "NEW FINAL INTERFACE"
+ (pprIface new_iface)
+ -- Write the interface file
+ when (ghci_mode /= Interactive)
+ (writeIface (unJust "hscRecomp:hi" (ml_hi_file location))
+ new_iface)
+ return new_iface
+
+
+myParseModule dflags src_filename