diff options
author | Zubin Duggal <zubin.duggal@gmail.com> | 2021-10-21 17:39:41 +0530 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2021-10-21 17:58:34 +0530 |
commit | 95b25a0fa66cb7eda4bc54ba3cce3d9fc73c8262 (patch) | |
tree | c3b26ba54590cd6f4c666fa2f0592b39faa2b3bb | |
parent | 1c4078db07df370e5ba48268c980e3ff5145e111 (diff) | |
download | haskell-95b25a0fa66cb7eda4bc54ba3cce3d9fc73c8262.tar.gz |
Rename `ms_hspp_file` to `ms_hspp_file_loc` and change itswip/backpack-errs
type to a `RealSrcLoc` to accomodate backpack
-rw-r--r-- | compiler/GHC/Driver/Backpack.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Driver/Main.hs | 8 | ||||
-rw-r--r-- | compiler/GHC/Driver/Make.hs | 2 | ||||
-rw-r--r-- | compiler/GHC/Driver/Pipeline.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Driver/Pipeline/Execute.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Unit/Module/ModSummary.hs | 11 |
6 files changed, 12 insertions, 20 deletions
diff --git a/compiler/GHC/Driver/Backpack.hs b/compiler/GHC/Driver/Backpack.hs index b5b8da12f7..098c7350fd 100644 --- a/compiler/GHC/Driver/Backpack.hs +++ b/compiler/GHC/Driver/Backpack.hs @@ -797,7 +797,7 @@ summariseRequirement pn mod_name = do }), hpm_src_files = [] }), - ms_hspp_file = BackpackFile real_loc, + ms_hspp_file_loc = real_loc, ms_hspp_opts = dflags, ms_hspp_buf = Nothing } @@ -897,7 +897,7 @@ hsModuleToModSummary pn hsc_src modname ms_mod = this_mod, ms_hsc_src = hsc_src, ms_location = location, - ms_hspp_file = BackpackFile real_loc, + ms_hspp_file_loc = real_loc, ms_hspp_opts = dflags, ms_hspp_buf = Nothing, ms_srcimps = map convImport src_idecls, diff --git a/compiler/GHC/Driver/Main.hs b/compiler/GHC/Driver/Main.hs index 15ddec68e2..8020630ae9 100644 --- a/compiler/GHC/Driver/Main.hs +++ b/compiler/GHC/Driver/Main.hs @@ -399,9 +399,7 @@ hscParse' mod_summary {-# SCC "Parser" #-} withTiming logger (text "Parser"<+>brackets (ppr $ ms_mod mod_summary)) (const ()) $ do - let src_filename = case ms_hspp_file mod_summary of - PreprocessedFile f -> f - BackpackFile _ -> pprPanic "hscParse" (text "Can't parse backpack interface file:" <+> ppr mod_summary) + let src_filename = unpackFS $ srcLocFile $ ms_hspp_file_loc mod_summary maybe_src_buf = ms_hspp_buf mod_summary -------------------------- Parser ---------------- @@ -544,9 +542,7 @@ hsc_typecheck keep_rn mod_summary mb_rdr_module = do mod_name = moduleName outer_mod outer_mod' = mkHomeModule home_unit mod_name inner_mod = homeModuleNameInstantiation home_unit mod_name - real_loc = realSrcLocSpan $ case ms_hspp_file mod_summary of - PreprocessedFile src_filename -> mkRealSrcLoc (mkFastString src_filename) 1 1 - BackpackFile loc -> loc + real_loc = realSrcLocSpan $ ms_hspp_file_loc mod_summary keep_rn' = gopt Opt_WriteHie dflags || keep_rn massert (isHomeModule home_unit outer_mod) tc_result <- if hsc_src == HsigFile && not (isHoleModule inner_mod) diff --git a/compiler/GHC/Driver/Make.hs b/compiler/GHC/Driver/Make.hs index 5acdf963d0..e50276d5f2 100644 --- a/compiler/GHC/Driver/Make.hs +++ b/compiler/GHC/Driver/Make.hs @@ -2018,7 +2018,7 @@ makeNewModSummary hsc_env MakeNewModSummary{..} = do { ms_mod = nms_mod , ms_hsc_src = nms_hsc_src , ms_location = nms_location - , ms_hspp_file = PreprocessedFile pi_hspp_fn + , ms_hspp_file_loc = mkRealSrcLoc (mkFastString pi_hspp_fn) 1 1 , ms_hspp_opts = pi_local_dflags , ms_hspp_buf = Just pi_hspp_buf , ms_parsed_mod = Nothing diff --git a/compiler/GHC/Driver/Pipeline.hs b/compiler/GHC/Driver/Pipeline.hs index a0d0f4665b..8a97c06d3d 100644 --- a/compiler/GHC/Driver/Pipeline.hs +++ b/compiler/GHC/Driver/Pipeline.hs @@ -250,9 +250,7 @@ compileOne' mHscMessage where lcl_dflags = ms_hspp_opts summary location = ms_location summary input_fn = expectJust "compile:hs" (ml_hs_file location) - input_fnpp = case ms_hspp_file summary of - PreprocessedFile f -> text f - BackpackFile loc -> text "backpack instantiation:" <+> ppr (ms_mod summary) <+> ppr loc + input_fnpp = ppr $ ms_hspp_file_loc summary mod_graph = hsc_mod_graph hsc_env0 needsLinker = needsTemplateHaskellOrQQ mod_graph isDynWay = hasWay (ways lcl_dflags) WayDyn diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs index 6c3f9e0ed0..f635da932d 100644 --- a/compiler/GHC/Driver/Pipeline/Execute.hs +++ b/compiler/GHC/Driver/Pipeline/Execute.hs @@ -81,6 +81,7 @@ import Data.Version import GHC.Utils.Panic import GHC.Unit.Module.Env import GHC.Driver.Env.KnotVars +import GHC.Data.FastString newtype HookedUse a = HookedUse { runHookedUse :: (Hooks, PhaseHook) -> IO a } deriving (Functor, Applicative, Monad, MonadIO, MonadThrow, MonadCatch) via (ReaderT (Hooks, PhaseHook) IO) @@ -671,7 +672,7 @@ runHscPhase pipe_env hsc_env0 input_fn src_flavour = do let mod_summary = ModSummary { ms_mod = mod, ms_hsc_src = src_flavour, - ms_hspp_file = PreprocessedFile input_fn, + ms_hspp_file_loc = mkRealSrcLoc (mkFastString input_fn) 1 1, ms_hspp_opts = dflags, ms_hspp_buf = hspp_buf, ms_location = location, diff --git a/compiler/GHC/Unit/Module/ModSummary.hs b/compiler/GHC/Unit/Module/ModSummary.hs index 9d6199f632..cb0e0760f4 100644 --- a/compiler/GHC/Unit/Module/ModSummary.hs +++ b/compiler/GHC/Unit/Module/ModSummary.hs @@ -5,7 +5,6 @@ -- (ModuleGraph) module GHC.Unit.Module.ModSummary ( ExtendedModSummary (..) - , PreprocessedFile(..) , extendModSummaryNoDeps , ModSummary (..) , ms_unitid @@ -97,8 +96,10 @@ data ModSummary ms_parsed_mod :: Maybe HsParsedModule, -- ^ The parsed, nonrenamed source, if we have it. This is also -- used to support "inline module syntax" in Backpack files. - ms_hspp_file :: PreprocessedFile, - -- ^ Filename of preprocessed source file + ms_hspp_file_loc :: RealSrcLoc, + -- ^ Filename of preprocessed source file with the location + -- The location doesn't always start at line 1, column 1, for + -- example for backpack ms_hspp_opts :: DynFlags, -- ^ Cached flags from @OPTIONS@, @INCLUDE@ and @LANGUAGE@ -- pragmas in the modules source code @@ -106,10 +107,6 @@ data ModSummary -- ^ The actual preprocessed source, if we have it } -data PreprocessedFile - = PreprocessedFile FilePath -- ^ This is a regular haskell file that has been preprocessed - | BackpackFile RealSrcLoc -- ^ There is no preprocessed source since we are instantiating a backpack signature at this location - ms_unitid :: ModSummary -> UnitId ms_unitid = toUnitId . moduleUnit . ms_mod |