mirror of
https://github.com/anoma/juvix.git
synced 2025-01-01 12:06:57 +03:00
65176a333d
- refactor `--target` into subcommands for `dev tree compile`. - prepend `App` to all `CompileTarget` constructors to avoid name clashes with `Target`. - parameterize compile options type with the input kind. The input kind indicates the expected file extension of the input file. If the input file is a .juvix file, then it is optional, otherwise it is mandatory. - Add `AppError MegaparsecError` instance and simplify some related code.
31 lines
1.1 KiB
Haskell
31 lines
1.1 KiB
Haskell
module Commands.Dev.Core.Compile where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Core.Compile.Base
|
|
import Commands.Dev.Core.Compile.Options
|
|
import Juvix.Compiler.Core.Data.Module qualified as Core
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
|
|
|
runCommand :: forall r. (Members '[EmbedIO, App, TaggedLock] r) => CompileOptions -> Sem r ()
|
|
runCommand opts = do
|
|
file <- getMainFile (Just (opts ^. compileInputFile))
|
|
s <- readFile file
|
|
tab <- getRight (Core.runParserMain file defaultModuleId mempty s)
|
|
let arg =
|
|
PipelineArg
|
|
{ _pipelineArgOptions = opts,
|
|
_pipelineArgModule = Core.moduleFromInfoTable tab
|
|
}
|
|
case opts ^. compileTarget of
|
|
AppTargetWasm32Wasi -> runCPipeline arg
|
|
AppTargetNative64 -> runCPipeline arg
|
|
AppTargetGeb -> runGebPipeline arg
|
|
AppTargetVampIR -> runVampIRPipeline arg
|
|
AppTargetCore -> return ()
|
|
AppTargetAsm -> runAsmPipeline arg
|
|
AppTargetReg -> runRegPipeline arg
|
|
AppTargetTree -> runTreePipeline arg
|
|
AppTargetAnoma -> runAnomaPipeline arg
|
|
AppTargetCasm -> runCasmPipeline arg
|
|
AppTargetCairo -> runCairoPipeline arg
|