mirror of
https://github.com/anoma/juvix.git
synced 2024-12-22 06:11:36 +03:00
efb7f2abd0
Filepaths within a Loc must now be absolute or an error is thrown when mkLoc is called. This Loc is used when displaying errors. This commit uses imaginary absolute file paths in the Core repl and Asm commands in the cases (parsing a single expression for example). Before this fix, the `core {repl, read, eval}` and `asm` commands would crash if it encountered an error when invoked with a relative path, or in the case of a repl when parsing a single expression.
25 lines
1.0 KiB
Haskell
25 lines
1.0 KiB
Haskell
module Commands.Dev.Core.Asm where
|
|
|
|
import AsmInterpreter
|
|
import Commands.Base
|
|
import Commands.Dev.Core.Asm.Options
|
|
import Juvix.Compiler.Asm.Pretty qualified as Asm
|
|
import Juvix.Compiler.Asm.Translation.FromCore qualified as Asm
|
|
import Juvix.Compiler.Core.Pipeline qualified as Core
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
|
import Juvix.Compiler.Core.Translation.Stripped.FromCore qualified as Stripped
|
|
|
|
runCommand :: forall r a. (Members '[Embed IO, App] r, CanonicalProjection a CoreAsmOptions) => a -> Sem r ()
|
|
runCommand opts = do
|
|
inputFile :: Path Abs File <- someBaseToAbs' sinputFile
|
|
s' <- embed (readFile $ toFilePath inputFile)
|
|
tab <- getRight (mapLeft JuvixError (Core.runParserMain inputFile Core.emptyInfoTable s'))
|
|
let tab' = Asm.fromCore $ Stripped.fromCore (Core.toStripped tab)
|
|
if
|
|
| project opts ^. coreAsmPrint ->
|
|
renderStdOut (Asm.ppOutDefault tab' tab')
|
|
| otherwise -> runAsm True tab'
|
|
where
|
|
sinputFile :: SomeBase File
|
|
sinputFile = project opts ^. coreAsmInputFile . pathPath
|