@@ -24,6 +24,7 @@ import System.FilePath
2424import System.Environment
2525import System.Process
2626import System.Directory
27+import System.IO
2728import Control.Monad
2829import Control.Monad.State
2930import Data.List
@@ -129,6 +130,15 @@ process (Eval t) = do (tm, ty) <- elabVal toplevel False t
129130 imp <- impShow
130131 iputStrLn (showImp imp (delab ist tm') ++ " : " ++
131132 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"]))
135+-- [pexp t])
136+ (tmpn, tmph) <- liftIO tempfile
137+ liftIO $ hClose tmph
138+ compile tmpn tm
139+ liftIO $ system tmpn
140+ return ()
141+ where fc = FC "(input)" 0
132142process (Check (PRef _ n))
133143 = do ctxt <- getContext
134144 ist <- get
@@ -170,10 +180,16 @@ process TTShell = do ist <- get
170180 let shst = initState (tt_ctxt ist)
171181 shst' <- lift $ runShell shst
172182 return ()
173−process (Execute f) = do compile f
174− liftIO $ system ("./" ++ f)
175− return ()
176−process (Compile 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
187+ compile tmpn m
188+ liftIO $ system tmpn
189+ return ()
190+process (Compile f) = do (m, _) <- elabVal toplevel False
191+ (PRef (FC "main" 0) (NS (UN "main") ["main"]))
192+ compile f m
177193process (LogLvl i) = setLogLevel i
178194process Metavars = do ist <- get
179195 let mvs = idris_metavars ist \\ primDefs
@@ -202,7 +218,7 @@ help =
202218 ([":p",":prove"], "<name>", "Prove a metavariable"),
203219 ([":a",":addproof"], "", "Add last proof to source file"),
204220 ([":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"),
206222 ([":?",":h",":help"], "", "Display this help text"),
207223 ([":q",":quit"], "", "Exit the Idris system")
208224 ]