1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-05 22:46:08 +03:00
juvix/app/Commands/Dev/Asm/Run.hs

18 lines
590 B
Haskell
Raw Normal View History

2022-09-29 18:44:55 +03:00
module Commands.Dev.Asm.Run where
import AsmInterpreter
2022-09-29 18:44:55 +03:00
import Commands.Base
import Commands.Dev.Asm.Run.Options
import Juvix.Compiler.Asm.Translation.FromSource qualified as Asm
runCommand :: forall r. (Members '[Embed IO, App] r) => AsmRunOptions -> Sem r ()
2022-09-29 18:44:55 +03:00
runCommand opts = do
afile :: Path Abs File <- fromAppPathFile file
s <- readFile (toFilePath afile)
2022-12-20 15:05:40 +03:00
case Asm.runParser (toFilePath afile) s of
2022-09-29 18:44:55 +03:00
Left err -> exitJuvixError (JuvixError err)
Right tab -> runAsm (not (opts ^. asmRunNoValidate)) tab
2022-09-29 18:44:55 +03:00
where
file :: AppPath File
file = opts ^. asmRunInputFile