+ let do_recomp = dopt Opt_RecompChecking dflags
+ source_unchanged = isJust maybe_old_linkable && do_recomp
+ hsc_env' = hsc_env { hsc_dflags = dflags' }
+ object_filename = ml_obj_file location
+
+ let getStubLinkable False = return []
+ getStubLinkable True
+ = do stub_o <- compileStub dflags' this_mod location
+ return [ DotO stub_o ]
+
+ handleBatch (HscNoRecomp, iface, details)
+ = ASSERT (isJust maybe_old_linkable)
+ return (CompOK details iface maybe_old_linkable)
+ handleBatch (HscRecomp hasStub, iface, details)
+ | isHsBoot src_flavour
+ = return (CompOK details iface Nothing)
+ | otherwise
+ = do stub_unlinked <- getStubLinkable hasStub
+ (hs_unlinked, unlinked_time) <-
+ case hsc_lang of
+ HscNothing
+ -> return ([], ms_hs_date mod_summary)
+ -- We're in --make mode: finish the compilation pipeline.
+ _other
+ -> do runPipeline StopLn dflags (output_fn,Nothing) Persistent
+ (Just location)
+ -- The object filename comes from the ModLocation
+ o_time <- getModificationTime object_filename
+ return ([DotO object_filename], o_time)
+ let linkable = LM unlinked_time this_mod
+ (hs_unlinked ++ stub_unlinked)
+ return (CompOK details iface (Just linkable))
+
+ handleInterpreted (InteractiveNoRecomp, iface, details)
+ = ASSERT (isJust maybe_old_linkable)
+ return (CompOK details iface maybe_old_linkable)
+ handleInterpreted (InteractiveRecomp hasStub comp_bc, iface, details)
+ = do stub_unlinked <- getStubLinkable hasStub
+ let hs_unlinked = [BCOs comp_bc]
+ unlinked_time = ms_hs_date mod_summary
+ -- Why do we use the timestamp of the source file here,
+ -- rather than the current time? This works better in
+ -- the case where the local clock is out of sync
+ -- with the filesystem's clock. It's just as accurate:
+ -- if the source is modified, then the linkable will
+ -- be out of date.
+ let linkable = LM unlinked_time this_mod
+ (hs_unlinked ++ stub_unlinked)
+ return (CompOK details iface (Just linkable))
+
+ let runCompiler compiler handle
+ = do mbResult <- compiler hsc_env' mod_summary
+ source_unchanged old_iface
+ (Just (mod_index, nmods))
+ case mbResult of
+ Nothing -> return CompErrs
+ Just result -> handle result