Added an option to disable the garbage collector (this feature is not implemented fully yet.).

This commit is contained in:
Samuel Hammersberg 2023-04-28 14:22:02 +02:00
parent 38b88d36b5
commit ddffe7913c
2 changed files with 13 additions and 1 deletions

View file

@ -26,4 +26,10 @@ hmd FILE:
cabal run language -- -d -t hm {{FILE}}
bid FILE:
cabal run language -- -d -t bi {{FILE}}
cabal run language -- -d -t bi {{FILE}}
hmdm FILE:
cabal run language -- -d -t hm -m {{FILE}}
bidm FILE:
cabal run language -- -d -t bi -m {{FILE}}

View file

@ -65,6 +65,7 @@ flags :: [OptDescr (Options -> Options)]
flags =
[ Option ['d'] ["debug"] (NoArg enableDebug) "Print debug messages."
, Option ['t'] ["type-checker"] (ReqArg chooseTypechecker "bi/hm") "Choose type checker. Possible options are bi and hm"
, Option ['m'] ["disable-gc"] (NoArg disableGC) "Disables the garbage collector and uses malloc instead."
, Option [] ["help"] (NoArg enableHelp) "Print this help message"
]
@ -73,6 +74,7 @@ initOpts =
Options
{ help = False
, debug = False
, gc = True
, typechecker = Nothing
}
@ -82,6 +84,9 @@ enableHelp opts = opts{help = True}
enableDebug :: Options -> Options
enableDebug opts = opts{debug = True}
disableGC :: Options -> Options
disableGC opts = opts{gc = False}
chooseTypechecker :: String -> Options -> Options
chooseTypechecker s options = options{typechecker = tc}
where
@ -93,6 +98,7 @@ chooseTypechecker s options = options{typechecker = tc}
data Options = Options
{ help :: Bool
, debug :: Bool
, gc :: Bool
, typechecker :: Maybe TypeChecker
}