Commit d2cfad96 authored by fendor's avatar fendor Committed by Marge Bot
Browse files

Add mainModuleNameIs and demote mainModIs

Add `mainModuleNameIs` to DynFlags and demote
`mainModIs` to function which uses the homeUnit from DynFlags
it is created from.
parent e393f213
......@@ -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 }
......
......@@ -34,7 +34,7 @@ fingerprintDynFlags :: DynFlags -> Module
-> IO Fingerprint
fingerprintDynFlags dflags@DynFlags{..} this_mod nameio =
let mainis = if mainModIs == this_mod then Just mainFunIs else Nothing
let mainis = if mainModIs dflags == this_mod then Just mainFunIs else Nothing
-- see #5878
-- pkgopts = (homeUnit home_unit, sort $ packageFlags dflags)
safeHs = setSafeMode safeHaskell
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment