on 71bdbbb help sign in
Idris-dev/src/IRTS/CodegenCommon.hs
40 lines 1.7 kB history raw
1module IRTS.CodegenCommon where
3import Idris.Core.TT
4import IRTS.Simplified
5import IRTS.Defunctionalise
6import IRTS.Lang
8import Control.Exception
9import Data.Word
10import System.Environment
12data DbgLevel = NONE | DEBUG | TRACE deriving Eq
13data OutputType = Raw | Object | Executable | MavenProject deriving (Eq, Show)
15environment :: String -> IO (Maybe String)
16environment x = Control.Exception.catch (do e <- getEnv x
17 return (Just e))
18 (\y-> do return (y::SomeException); return Nothing)
20-- Everything which might be needed in a code generator - a CG can choose which
21-- level of Decls to generate code from (simplified, defunctionalised or merely
22-- lambda lifted) and has access to the list of object files, libraries, etc.
24data CodegenInfo = CodegenInfo { outputFile :: String,
25 outputType :: OutputType,
26 targetTriple :: String,
27 targetCPU :: String,
28 optimisation :: Word,
29 includes :: [FilePath],
30 importDirs :: [FilePath],
31 compileObjs :: [String],
32 compileLibs :: [String],
33 compilerFlags :: [String],
34 debugLevel :: DbgLevel,
35 simpleDecls :: [(Name, SDecl)],
36 defunDecls :: [(Name, DDecl)],
37 liftDecls :: [(Name, LDecl)]
38 }
40type CodeGenerator = CodegenInfo -> IO ()