summaryrefslogtreecommitdiff
path: root/compiler/GHC/Driver
diff options
context:
space:
mode:
authorFendor <power.walross@gmail.com>2020-09-03 17:30:29 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-01 18:35:33 -0400
commitd2cfad96831edbe50aeddaefc1a3b0fb0dd73bc2 (patch)
tree0362d38396a11ae053908f54734f190a49195978 /compiler/GHC/Driver
parente393f213f5ccff4fd6034d5294e51aa5a2720890 (diff)
downloadhaskell-d2cfad96831edbe50aeddaefc1a3b0fb0dd73bc2.tar.gz
Add mainModuleNameIs and demote mainModIs
Add `mainModuleNameIs` to DynFlags and demote `mainModIs` to function which uses the homeUnit from DynFlags it is created from.
Diffstat (limited to 'compiler/GHC/Driver')
-rw-r--r--compiler/GHC/Driver/Session.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs
index a5df52d2b2..f54e38c682 100644
--- a/compiler/GHC/Driver/Session.hs
+++ b/compiler/GHC/Driver/Session.hs
@@ -41,7 +41,7 @@ module GHC.Driver.Session (
dynamicTooMkDynamicDynFlags,
dynamicOutputFile,
sccProfilingEnabled,
- DynFlags(..),
+ DynFlags(..), mainModIs,
FlagSpec(..),
HasDynFlags(..), ContainsDynFlags(..),
RtsOptsEnabled(..),
@@ -240,7 +240,7 @@ import GHC.Unit.Parser
import GHC.Unit.Module
import {-# SOURCE #-} GHC.Driver.Plugins
import {-# SOURCE #-} GHC.Driver.Hooks
-import GHC.Builtin.Names ( mAIN )
+import GHC.Builtin.Names ( mAIN_NAME )
import {-# SOURCE #-} GHC.Unit.State (UnitState, emptyUnitState, UnitDatabase)
import GHC.Driver.Phases ( Phase(..), phaseInputExt )
import GHC.Driver.Flags
@@ -514,7 +514,7 @@ data DynFlags = DynFlags {
historySize :: Int, -- ^ Simplification history size
importPaths :: [FilePath],
- mainModIs :: Module,
+ mainModuleNameIs :: ModuleName,
mainFunIs :: Maybe String,
reductionDepth :: IntWithInf, -- ^ Typechecker maximum stack depth
solverIterations :: IntWithInf, -- ^ Number of iterations in the constraints solver
@@ -1188,7 +1188,7 @@ defaultDynFlags mySettings llvmConfig =
ghcHeapSize = Nothing,
importPaths = ["."],
- mainModIs = mAIN,
+ mainModuleNameIs = mAIN_NAME,
mainFunIs = Nothing,
reductionDepth = treatZeroAsInf mAX_REDUCTION_DEPTH,
solverIterations = treatZeroAsInf mAX_SOLVER_ITERATIONS,
@@ -1665,6 +1665,9 @@ lang_set dflags lang =
extensionFlags = flattenExtensionFlags lang (extensions dflags)
}
+mainModIs :: DynFlags -> Module
+mainModIs dflags = mkHomeModule (mkHomeUnitFromFlags dflags) (mainModuleNameIs dflags)
+
-- | Set the Haskell language standard to use
setLanguage :: Language -> DynP ()
setLanguage l = upd (`lang_set` Just l)
@@ -4505,10 +4508,10 @@ setMainIs arg
| not (null main_fn) && isLower (head main_fn)
-- The arg looked like "Foo.Bar.baz"
= upd $ \d -> d { mainFunIs = Just main_fn,
- mainModIs = mkModule mainUnit (mkModuleName main_mod) }
+ mainModuleNameIs = mkModuleName main_mod }
| isUpper (head arg) -- The arg looked like "Foo" or "Foo.Bar"
- = upd $ \d -> d { mainModIs = mkModule mainUnit (mkModuleName arg) }
+ = upd $ \d -> d { mainModuleNameIs = mkModuleName arg }
| otherwise -- The arg looked like "baz"
= upd $ \d -> d { mainFunIs = Just arg }