[project @ 2002-02-01 15:18:18 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / CmdLineOpts.lhs
index 6fb17e8..e19c24a 100644 (file)
@@ -26,6 +26,9 @@ module CmdLineOpts (
        dopt_StgToDo,                   -- DynFlags -> [StgToDo]
        dopt_HscLang,                   -- DynFlags -> HscLang
        dopt_OutName,                   -- DynFlags -> String
+       getOpts,                        -- (DynFlags -> [a]) -> IO [a]
+       setLang,
+       getVerbFlag,
 
        -- Manipulating the DynFlags state
        getDynFlags,                    -- IO DynFlags
@@ -63,7 +66,6 @@ module CmdLineOpts (
        opt_NumbersStrict,
        opt_Parallel,
        opt_SMP,
-       opt_NoMonomorphismRestriction,
        opt_RuntimeTypes,
 
        -- optimisation opts
@@ -283,6 +285,7 @@ data DynFlag
    | Opt_AllowOverlappingInstances
    | Opt_AllowUndecidableInstances
    | Opt_AllowIncoherentInstances
+   | Opt_NoMonomorphismRestriction
    | Opt_GlasgowExts
    | Opt_Generics
    | Opt_NoImplicitPrelude 
@@ -383,6 +386,22 @@ dopt_set dfs f = dfs{ flags = f : flags dfs }
 
 dopt_unset :: DynFlags -> DynFlag -> DynFlags
 dopt_unset dfs f = dfs{ flags = filter (/= f) (flags dfs) }
+
+getOpts :: (DynFlags -> [a]) -> IO [a]
+       -- We add to the options from the front, so we need to reverse the list
+getOpts opts = dynFlag opts >>= return . reverse
+
+-- we can only switch between HscC, HscAsmm, and HscILX with dynamic flags 
+-- (-fvia-C, -fasm, -filx respectively).
+setLang l = updDynFlags (\ dfs -> case hscLang dfs of
+                                       HscC   -> dfs{ hscLang = l }
+                                       HscAsm -> dfs{ hscLang = l }
+                                       HscILX -> dfs{ hscLang = l }
+                                       _      -> dfs)
+
+getVerbFlag = do
+   verb <- dynFlag verbosity
+   if verb >= 3  then return  "-v" else return ""
 \end{code}
 
 -----------------------------------------------------------------------------
@@ -540,7 +559,6 @@ opt_DoTickyProfiling                = lookUp  SLIT("-fticky-ticky")
 
 -- language opts
 opt_AllStrict                  = lookUp  SLIT("-fall-strict")
-opt_NoMonomorphismRestriction  = lookUp  SLIT("-fno-monomorphism-restriction")
 opt_DictsStrict                        = lookUp  SLIT("-fdicts-strict")
 opt_IrrefutableTuples          = lookUp  SLIT("-firrefutable-tuples")
 opt_MaxContextReductionDepth   = lookup_def_int "-fcontext-stack" mAX_CONTEXT_REDUCTION_DEPTH
@@ -571,7 +589,7 @@ opt_InPackage                       = case lookup_str "-inpackage=" of
 opt_EmitCExternDecls           = lookUp  SLIT("-femit-extern-decls")
 opt_EnsureSplittableC          = lookUp  SLIT("-fglobalise-toplev-names")
 opt_GranMacros                 = lookUp  SLIT("-fgransim")
-opt_HiVersion                  = read cProjectVersionInt :: Int
+opt_HiVersion                  = read (cProjectVersionInt ++ cProjectPatchLevel) :: Int
 opt_HistorySize                        = lookup_def_int "-fhistory-size" 20
 opt_IgnoreAsserts               = lookUp  SLIT("-fignore-asserts")
 opt_IgnoreIfacePragmas         = lookUp  SLIT("-fignore-interface-pragmas")