2023-03-14 18:24:07 +03:00
|
|
|
module Commands.Dev.Core.Compile where
|
2023-01-09 20:21:30 +03:00
|
|
|
|
|
|
|
import Commands.Base
|
2023-03-14 18:24:07 +03:00
|
|
|
import Commands.Dev.Core.Compile.Base
|
2023-01-09 20:21:30 +03:00
|
|
|
import Commands.Dev.Core.Compile.Options
|
|
|
|
import Juvix.Compiler.Core.Data.InfoTable qualified as Core
|
|
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
2023-02-01 14:04:05 +03:00
|
|
|
|
2023-03-14 18:24:07 +03:00
|
|
|
runCommand :: forall r. (Members '[Embed IO, App] r) => CompileOptions -> Sem r ()
|
2023-01-09 20:21:30 +03:00
|
|
|
runCommand opts = do
|
|
|
|
file <- getFile
|
|
|
|
s <- embed (readFile (toFilePath file))
|
2023-01-26 14:55:06 +03:00
|
|
|
tab <- getRight (mapLeft JuvixError (Core.runParserMain file Core.emptyInfoTable s))
|
2023-03-14 18:24:07 +03:00
|
|
|
let arg = PipelineArg opts file tab
|
2023-02-01 14:04:05 +03:00
|
|
|
case opts ^. compileTarget of
|
2023-03-14 18:24:07 +03:00
|
|
|
TargetWasm32Wasi -> runCPipeline arg
|
|
|
|
TargetNative64 -> runCPipeline arg
|
|
|
|
TargetGeb -> runGebPipeline arg
|
|
|
|
TargetCore -> return ()
|
|
|
|
TargetAsm -> runAsmPipeline arg
|
2023-01-09 20:21:30 +03:00
|
|
|
where
|
|
|
|
getFile :: Sem r (Path Abs File)
|
|
|
|
getFile = someBaseToAbs' (opts ^. compileInputFile . pathPath)
|