summaryrefslogtreecommitdiff
path: root/ghc
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-08-05 11:32:17 +0200
committerSylvain Henry <sylvain@haskus.fr>2020-08-13 09:49:56 -0400
commitffc0d578ea22de02a68c64c094602701e65d8895 (patch)
tree168171a5fb54632f5f4fdd1130a31ed730248e73 /ghc
parentcf97889a38edc3314a7b61e6e0b6e6d0f434c8a2 (diff)
downloadhaskell-ffc0d578ea22de02a68c64c094602701e65d8895.tar.gz
Add HomeUnit type
Since Backpack the "home unit" is much more involved than what it was before (just an identifier obtained with `-this-unit-id`). Now it is used in conjunction with `-component-id` and `-instantiated-with` to configure module instantiations and to detect if we are type-checking an indefinite unit or compiling a definite one. This patch introduces a new HomeUnit datatype which is much easier to understand. Moreover to make GHC support several packages in the same instances, we will need to handle several HomeUnits so having a dedicated (documented) type is helpful. Finally in #14335 we will also need to handle the case where we have no HomeUnit at all because we are only loading existing interfaces for plugins which live in a different space compared to units used to produce target code. Several functions will have to be refactored to accept "Maybe HomeUnit" parameters instead of implicitly querying the HomeUnit fields in DynFlags. Having a dedicated type will make this easier. Bump haddock submodule
Diffstat (limited to 'ghc')
-rw-r--r--ghc/GHCi/UI.hs14
1 files changed, 6 insertions, 8 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 7cef2dd423..948cc74a71 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -57,10 +57,8 @@ import GHC.Hs
import GHC.Driver.Types ( tyThingParent_maybe, handleFlagWarnings, getSafeMode, hsc_IC,
setInteractivePrintName, hsc_dflags, msObjFilePath, runInteractiveHsc,
hsc_dynLinker, hsc_interp, emptyModBreaks )
-import GHC.Unit.Module
+import GHC.Unit
import GHC.Types.Name
-import GHC.Unit.State ( unitIsTrusted, unsafeLookupUnit, unsafeLookupUnitId,
- listVisibleModuleNames, pprFlag, preloadUnits )
import GHC.Iface.Syntax ( showToHeader )
import GHC.Core.Ppr.TyThing
import GHC.Builtin.Names
@@ -2363,13 +2361,13 @@ isSafeModule m = do
mname = GHC.moduleNameString $ GHC.moduleName m
packageTrusted dflags md
- | isHomeModule dflags md = True
+ | isHomeModule (mkHomeUnitFromFlags dflags) md = True
| otherwise = unitIsTrusted $ unsafeLookupUnit (unitState dflags) (moduleUnit md)
tallyPkgs dflags deps | not (packageTrustOn dflags) = (S.empty, S.empty)
| otherwise = S.partition part deps
- where part pkg = unitIsTrusted $ unsafeLookupUnitId pkgstate pkg
- pkgstate = unitState dflags
+ where part pkg = unitIsTrusted $ unsafeLookupUnitId unit_state pkg
+ unit_state = unitState dflags
-----------------------------------------------------------------------------
-- :browse
@@ -4316,8 +4314,8 @@ wantInterpretedModuleName :: GHC.GhcMonad m => ModuleName -> m Module
wantInterpretedModuleName modname = do
modl <- lookupModuleName modname
let str = moduleNameString modname
- dflags <- getDynFlags
- unless (isHomeModule dflags modl) $
+ home_unit <- mkHomeUnitFromFlags <$> getDynFlags
+ unless (isHomeModule home_unit modl) $
throwGhcException (CmdLineError ("module '" ++ str ++ "' is from another package;\nthis command requires an interpreted module"))
is_interpreted <- GHC.moduleIsInterpreted modl
when (not is_interpreted) $