@@ -24,6 +24,7 @@ import System.FilePath
24import System.Environment
24import System.Environment
25import System.Process
25import System.Process
26import System.Directory
26import System.Directory
27import Control.Monad
28import Control.Monad
28import Control.Monad.State
29import Control.Monad.State
29import Data.List
30import Data.List
@@ -129,6 +130,15 @@ process (Eval t) = do (tm, ty) <- elabVal toplevel False t
129 imp <- impShow
130 imp <- impShow
130 iputStrLn (showImp imp (delab ist tm') ++ " : " ++
131 iputStrLn (showImp imp (delab ist tm') ++ " : " ++
131 showImp imp (delab ist ty'))
132 showImp imp (delab ist ty'))
133+process (ExecVal t) = do (tm, ty) <- elabVal toplevel False t
134+-- (PApp fc (PRef fc (NS (UN "print") ["prelude"]))
136+ (tmpn, tmph) <- liftIO tempfile
137+ liftIO $ hClose tmph
139+ liftIO $ system tmpn
141+ where fc = FC "(input)" 0
132process (Check (PRef _ n))
142process (Check (PRef _ n))
133 = do ctxt <- getContext
143 = do ctxt <- getContext
134 ist <- get
144 ist <- get
@@ -170,10 +180,16 @@ process TTShell = do ist <- get
170 let shst = initState (tt_ctxt ist)
180 let shst = initState (tt_ctxt ist)
171 shst' <- lift $ runShell shst
181 shst' <- lift $ runShell shst
172 return ()
182 return ()
173−process (Execute f) = do compile f
183+process Execute = do (m, _) <- elabVal toplevel False
184+ (PRef (FC "main" 0) (NS (UN "main") ["main"]))
185+ (tmpn, tmph) <- liftIO tempfile
186+ liftIO $ hClose tmph
174− liftIO $ system ("./" ++ f)
188+ liftIO $ system tmpn
175− return ()
189+ return ()
176−process (Compile f) = do compile f
190+process (Compile f) = do (m, _) <- elabVal toplevel False
191+ (PRef (FC "main" 0) (NS (UN "main") ["main"]))
177process (LogLvl i) = setLogLevel i
193process (LogLvl i) = setLogLevel i
178process Metavars = do ist <- get
194process Metavars = do ist <- get
179 let mvs = idris_metavars ist \\ primDefs
195 let mvs = idris_metavars ist \\ primDefs
@@ -202,7 +218,7 @@ help =
202 ([":p",":prove"], "<name>", "Prove a metavariable"),
218 ([":p",":prove"], "<name>", "Prove a metavariable"),
203 ([":a",":addproof"], "", "Add last proof to source file"),
219 ([":a",":addproof"], "", "Add last proof to source file"),
204 ([":c",":compile"], "<filename>", "Compile to an executable <filename>"),
220 ([":c",":compile"], "<filename>", "Compile to an executable <filename>"),
205− ([":exec",":execute"], "<filename>", "Compile to an executable <filename> and run"),
221+ ([":exec",":execute"], "", "Compile to an executable and run"),
206 ([":?",":h",":help"], "", "Display this help text"),
222 ([":?",":h",":help"], "", "Display this help text"),
207 ([":q",":quit"], "", "Exit the Idris system")
223 ([":q",":quit"], "", "Exit the Idris system")