mirror of
https://github.com/anoma/juvix.git
synced 2024-12-15 01:52:11 +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.
21 lines
966 B
Haskell
21 lines
966 B
Haskell
module Commands.Dev.Core.Strip where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Core.Strip.Options
|
|
import Juvix.Compiler.Core.Pipeline qualified as Core
|
|
import Juvix.Compiler.Core.Pretty 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 Core.Options, CanonicalProjection a CoreStripOptions) => a -> Sem r ()
|
|
runCommand opts = do
|
|
inputFile :: Path Abs File <- someBaseToAbs' sinputFile
|
|
s' <- embed (readFile $ toFilePath inputFile)
|
|
(tab, _) <- getRight (mapLeft JuvixError (Core.runParser inputFile Core.emptyInfoTable s'))
|
|
let tab' = Stripped.fromCore (Core.toStripped tab)
|
|
unless (project opts ^. coreStripNoPrint) $ do
|
|
renderStdOut (Core.ppOut opts tab')
|
|
where
|
|
sinputFile :: SomeBase File
|
|
sinputFile = project opts ^. coreStripInputFile . pathPath
|