Fixed codegen bug, added prelude option, created lambda calc
This commit is contained in:
parent
c98166392b
commit
762a6aef9b
3 changed files with 76 additions and 1 deletions
|
|
@ -320,7 +320,7 @@ emitECased t e cases = do
|
|||
emit $ Label lbl_failPos
|
||||
emitCases rt ty label stackPtr vs (Branch (PEnum (Ident "True$Bool"), t) exp) = do
|
||||
emitCases rt ty label stackPtr vs (Branch (PLit $ LInt 1, t) exp)
|
||||
emitCases rt ty label stackPtr vs (Branch (PEnum (Ident "False$Bool"), _) exp) = do
|
||||
emitCases rt ty label stackPtr vs (Branch (PEnum (Ident "False$Bool"), t) exp) = do
|
||||
emitCases rt ty label stackPtr vs (Branch (PLit (LInt 0), t) exp)
|
||||
emitCases rt ty label stackPtr vs br@(Branch (PEnum consId, _) exp) = do
|
||||
emit $ Comment "Penum"
|
||||
|
|
|
|||
12
src/Main.hs
12
src/Main.hs
|
|
@ -58,6 +58,7 @@ 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 ['p'] ["disable-prelude"] (NoArg disablePrelude) "Do not include the prelude"
|
||||
, Option [] ["help"] (NoArg enableHelp) "Print this help message"
|
||||
]
|
||||
|
||||
|
|
@ -68,6 +69,7 @@ initOpts =
|
|||
, debug = False
|
||||
, gc = True
|
||||
, typechecker = Nothing
|
||||
, preludeOpt = True
|
||||
}
|
||||
|
||||
enableHelp :: Options -> Options
|
||||
|
|
@ -79,6 +81,9 @@ enableDebug opts = opts{debug = True}
|
|||
disableGC :: Options -> Options
|
||||
disableGC opts = opts{gc = False}
|
||||
|
||||
disablePrelude :: Options -> Options
|
||||
disablePrelude opts = opts{preludeOpt = False}
|
||||
|
||||
chooseTypechecker :: String -> Options -> Options
|
||||
chooseTypechecker s options = options{typechecker = tc}
|
||||
where
|
||||
|
|
@ -92,6 +97,7 @@ data Options = Options
|
|||
, debug :: Bool
|
||||
, gc :: Bool
|
||||
, typechecker :: Maybe TypeChecker
|
||||
, preludeOpt :: Bool
|
||||
}
|
||||
|
||||
main' :: Options -> String -> IO ()
|
||||
|
|
@ -184,4 +190,10 @@ prelude =
|
|||
".- : Int -> Int -> Int"
|
||||
, ".- x y = 0"
|
||||
, "\n"
|
||||
, ".== : Int -> Int -> Bool"
|
||||
, ".== a b = case a < b of"
|
||||
, " False => case b < a of"
|
||||
, " False => True"
|
||||
, " _ => False"
|
||||
, " False => False"
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue