Added command line options for occam 2 mobility, and turned it off by default

This commit is contained in:
Neil Brown 2009-03-19 11:38:48 +00:00
parent a995d29c32
commit b970b9df33
3 changed files with 16 additions and 15 deletions

27
Main.hs
View File

@ -67,7 +67,8 @@ optionsNoWarnings =
, Option [] ["mode"] (ReqArg optMode "MODE") "select mode (options: flowgraph, parse, compile, post-c, full)" , Option [] ["mode"] (ReqArg optMode "MODE") "select mode (options: flowgraph, parse, compile, post-c, full)"
, Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")" , Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")"
, Option [] ["sanity-check"] (ReqArg optSanityCheck "SETTING") "internal sanity check (options: on, off)" , Option [] ["sanity-check"] (ReqArg optSanityCheck "SETTING") "internal sanity check (options: on, off)"
, Option [] ["usage-checking"] (ReqArg optUsageChecking "SETTING") "usage checking (EXPERIMENTAL) (options: on, off)" , Option [] ["occam2-mobility"] (ReqArg optClassicOccamMobility "SETTING") "occam2 implicit mobility (EXPERIMENTAL) (options: on, off)"
, Option [] ["usage-checking"] (ReqArg optUsageChecking "SETTING") "usage checking (options: on, off)"
, Option ['v'] ["verbose"] (NoArg $ optVerbose) "be more verbose (use multiple times for more detail)" , Option ['v'] ["verbose"] (NoArg $ optVerbose) "be more verbose (use multiple times for more detail)"
] ]
@ -123,22 +124,22 @@ optPrintHelp _ = dieIO (Nothing, usageInfo "Usage: tock [OPTION...] SOURCEFILE"
optPrintWarningHelp :: OptFunc optPrintWarningHelp :: OptFunc
optPrintWarningHelp _ = dieIO (Nothing, usageInfo "Usage: tock [OPTION...] SOURCEFILE" optionsWarnings) optPrintWarningHelp _ = dieIO (Nothing, usageInfo "Usage: tock [OPTION...] SOURCEFILE" optionsWarnings)
optOnOff :: (String, Bool -> CompState -> CompState) -> String -> OptFunc
optOnOff (n, f) s ps
= do mode <- case s of
"on" -> return True
"off" -> return False
_ -> dieIO (Nothing, "Unknown " ++ n ++ " mode: " ++ s)
return $ f mode ps
optUsageChecking :: String -> OptFunc optUsageChecking :: String -> OptFunc
optUsageChecking s ps optUsageChecking = optOnOff ("usage checking", \m ps -> ps { csUsageChecking = m })
= do usageCheck <- case s of
"on" -> return True
"off" -> return False
_ -> dieIO (Nothing, "Unknown usage checking mode: " ++ s)
return $ ps { csUsageChecking = usageCheck }
optSanityCheck :: String -> OptFunc optSanityCheck :: String -> OptFunc
optSanityCheck s ps optSanityCheck = optOnOff ("sanity checking", \m ps -> ps { csSanityCheck = m })
= do sanityCheck <- case s of
"on" -> return True optClassicOccamMobility :: String -> OptFunc
"off" -> return False optClassicOccamMobility = optOnOff ("occam 2 mobility", \m ps -> ps { csClassicOccamMobility = m })
_ -> dieIO (Nothing, "Unknown sanity checking mode: " ++ s)
return $ ps { csSanityCheck = sanityCheck }
optEnableWarning :: WarningType -> OptFunc optEnableWarning :: WarningType -> OptFunc
optEnableWarning w ps = return $ ps { csEnabledWarnings = Set.insert w (csEnabledWarnings ps) } optEnableWarning w ps = return $ ps { csEnabledWarnings = Set.insert w (csEnabledWarnings ps) }

View File

@ -147,7 +147,7 @@ emptyState = CompState {
, WarnUnknownPreprocessorDirective , WarnUnknownPreprocessorDirective
, WarnUnusedVariable], , WarnUnusedVariable],
-- TODO enable WarnUninitialisedVariable by default -- TODO enable WarnUninitialisedVariable by default
csClassicOccamMobility = True, csClassicOccamMobility = False,
csCurrentFile = "none", csCurrentFile = "none",
csUsedFiles = Set.empty, csUsedFiles = Set.empty,

View File

@ -60,7 +60,7 @@ commonPasses opts = concat $
[pass "Usage checking turned OFF" Prop.agg_namesDone [Prop.parUsageChecked] [pass "Usage checking turned OFF" Prop.agg_namesDone [Prop.parUsageChecked]
return] return]
-- TODO add an implicit mobility pass after these two: -- TODO add an implicit mobility pass after these two:
, enablePassesWhen csClassicOccamMobility [mobiliseArrays, inferDeref] , enablePassesWhen csClassicOccamMobility [mobiliseArrays, inferDeref, implicitMobility]
, simplifyAbbrevs , simplifyAbbrevs
, simplifyComms , simplifyComms
, simplifyExprs , simplifyExprs