@@ -24,6 +24,11 @@ import Idris.ElabDecls
2424import Idris.Primitives
2525import Idris.Imports
2626import Idris.Error
27+
28+import RTS.BCParser
29+import RTS.Bytecode
30+import RTS.Assembler
31+
2732import Paths_idris
2833
2934-- Main program reads command line options, parses the main program, and gets
@@ -40,6 +45,8 @@ runIdris opts =
4045 let output = opt getOutput opts
4146 let ibcsubdir = opt getIBCSubDir opts
4247 let importdirs = opt getImportDir opts
48+ let bcs = opt getBC opts
49+
4350 when (Ver `elem` opts) $ liftIO showver
4451 when (Usage `elem` opts) $ liftIO usage
4552 when (ShowIncs `elem` opts) $ liftIO showIncs
@@ -48,6 +55,10 @@ runIdris opts =
4855 setVerbose runrepl
4956 when (Verbose `elem` opts) $ setVerbose True
5057 mapM_ makeOption opts
58+ -- if we have the --bytecode flag, drop into the bytecode assembler
59+ case bcs of
60+ [] -> return ()
61+ xs -> liftIO $ mapM_ bcAsm xs
5162 case ibcsubdir of
5263 [] -> setIBCSubDir ""
5364 (d:_) -> setIBCSubDir d
@@ -77,6 +88,10 @@ getFile :: Opt -> Maybe String
7788getFile (Filename str) = Just str
7889getFile _ = Nothing
7990
91+getBC :: Opt -> Maybe String
92+getBC (BCAsm str) = Just str
93+getBC _ = Nothing
94+
8095getOutput :: Opt -> Maybe String
8196getOutput (Output str) = Just str
8297getOutput _ = Nothing
@@ -108,22 +123,23 @@ showIncs = do dir <- getDataDir
108123
109124parseArgs :: [String] -> IO [Opt]
110125parseArgs [] = return []
111−parseArgs ("--log":lvl:ns) = liftM (OLogging (read lvl) : ) (parseArgs ns)
112−parseArgs ("--noprelude":ns) = liftM (NoPrelude : ) (parseArgs ns)
113−parseArgs ("--check":ns) = liftM (NoREPL : ) (parseArgs ns)
114−parseArgs ("-o":n:ns) = liftM (\x -> NoREPL : Output n : x) (parseArgs ns)
115−parseArgs ("--typecase":ns) = liftM (TypeCase : ) (parseArgs ns)
116−parseArgs ("--typeintype":ns) = liftM (TypeInType : ) (parseArgs ns)
117−parseArgs ("--nocoverage":ns) = liftM (NoCoverage : ) (parseArgs ns)
126+parseArgs ("--log":lvl:ns) = liftM (OLogging (read lvl) : ) (parseArgs ns)
127+parseArgs ("--noprelude":ns) = liftM (NoPrelude : ) (parseArgs ns)
128+parseArgs ("--check":ns) = liftM (NoREPL : ) (parseArgs ns)
129+parseArgs ("-o":n:ns) = liftM (\x -> NoREPL : Output n : x) (parseArgs ns)
130+parseArgs ("--typecase":ns) = liftM (TypeCase : ) (parseArgs ns)
131+parseArgs ("--typeintype":ns) = liftM (TypeInType : ) (parseArgs ns)
132+parseArgs ("--nocoverage":ns) = liftM (NoCoverage : ) (parseArgs ns)
118133parseArgs ("--errorcontext":ns) = liftM (ErrContext : ) (parseArgs ns)
119−parseArgs ("--help":ns) = liftM (Usage : ) (parseArgs ns)
120−parseArgs ("--link":ns) = liftM (ShowLibs : ) (parseArgs ns)
121−parseArgs ("--include":ns) = liftM (ShowIncs : ) (parseArgs ns)
122−parseArgs ("--version":ns) = liftM (Ver : ) (parseArgs ns)
123−parseArgs ("--verbose":ns) = liftM (Verbose : ) (parseArgs ns)
124−parseArgs ("--ibcsubdir":n:ns) = liftM (IBCSubDir n : ) (parseArgs ns)
125−parseArgs ("-i":n:ns) = liftM (ImportDir n : ) (parseArgs ns)
126−parseArgs (n:ns) = liftM (Filename n : ) (parseArgs ns)
134+parseArgs ("--help":ns) = liftM (Usage : ) (parseArgs ns)
135+parseArgs ("--link":ns) = liftM (ShowLibs : ) (parseArgs ns)
136+parseArgs ("--include":ns) = liftM (ShowIncs : ) (parseArgs ns)
137+parseArgs ("--version":ns) = liftM (Ver : ) (parseArgs ns)
138+parseArgs ("--verbose":ns) = liftM (Verbose : ) (parseArgs ns)
139+parseArgs ("--ibcsubdir":n:ns) = liftM (IBCSubDir n : ) (parseArgs ns)
140+parseArgs ("-i":n:ns) = liftM (ImportDir n : ) (parseArgs ns)
141+parseArgs ("--bytecode":n:ns) = liftM (\x -> NoREPL : BCAsm n : x) (parseArgs ns)
142+parseArgs (n:ns) = liftM (Filename n : ) (parseArgs ns)
127143
128144ver = showVersion version
129145