on a87f69e help sign in
Idris-dev/src/IRTS/CodegenCommon.hs
39 lines 1.6 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 includes :: [FilePath],
29 importDirs :: [FilePath],
30 compileObjs :: [String],
31 compileLibs :: [String],
32 compilerFlags :: [String],
33 debugLevel :: DbgLevel,
34 simpleDecls :: [(Name, SDecl)],
35 defunDecls :: [(Name, DDecl)],
36 liftDecls :: [(Name, LDecl)]
37 }
39type CodeGenerator = CodegenInfo -> IO ()