2023-01-09 20:21:30 +03:00
|
|
|
module AsmInterpreter where
|
|
|
|
|
|
|
|
import App
|
|
|
|
import CommonOptions
|
|
|
|
import Juvix.Compiler.Asm.Data.InfoTable qualified as Asm
|
|
|
|
import Juvix.Compiler.Asm.Extra qualified as Asm
|
|
|
|
import Juvix.Compiler.Asm.Interpreter qualified as Asm
|
|
|
|
import Juvix.Compiler.Asm.Pretty qualified as Asm
|
|
|
|
import Juvix.Compiler.Asm.Transformation.Validate qualified as Asm
|
|
|
|
|
Update CI to install Smoke, Github actions, and Makefile fixes (#1735)
This PR adds some maintenance at different levels to the CI config, the
Make file, and formatting.
- Most of the actions used by the CI related to haskell, ormolu, hlint
and pre-commit have been updated because Github requires NodeJS 16. This
change removes all the old warnings related to nodeJs.
In the case of ormolu, the new version makes us format some files that
were not formatted before, similarly with hlint.
- The CI has been updated to use the latest version of the Smoke testing
framework, which introduced installation of the dependencies for Linux
(libicu66) and macOS (icu4c) in the CI. In the case of macOS, the CI
uses a binary for smoke. For Linux, we use stack to build smoke from the
source. The source here is in a fork of [the official Smoke
repo](https://github.com/SamirTalwar/smoke). Such includes some
features/changes that are not yet in the official repo.
- The Makefile runs the ormolu and hlint targets using as a path for the
binaries the environment variables ORMOLU and HLINT. Thus, export those
variables in your environment before running `make check,` `make format`
or `make hlint`. Otherwise, the Makefile will use the binaries provided
by `stack`.
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-01-24 13:50:23 +03:00
|
|
|
runAsm :: forall r. (Members '[Embed IO, App] r) => Bool -> Asm.InfoTable -> Sem r ()
|
2023-01-09 20:21:30 +03:00
|
|
|
runAsm bValidate tab =
|
|
|
|
let v = if bValidate then Asm.validate' tab else Nothing
|
|
|
|
in case v of
|
|
|
|
Just err ->
|
|
|
|
exitJuvixError (JuvixError err)
|
|
|
|
Nothing ->
|
|
|
|
case tab ^. Asm.infoMainFunction of
|
|
|
|
Just sym -> do
|
|
|
|
r <- doRun tab (Asm.getFunInfo tab sym)
|
|
|
|
case r of
|
|
|
|
Left err ->
|
|
|
|
exitJuvixError (JuvixError err)
|
|
|
|
Right Asm.ValVoid ->
|
|
|
|
return ()
|
|
|
|
Right val -> do
|
|
|
|
renderStdOut (Asm.ppOut (Asm.defaultOptions tab) val)
|
|
|
|
embed (putStrLn "")
|
|
|
|
Nothing ->
|
|
|
|
exitMsg (ExitFailure 1) "no 'main' function"
|
|
|
|
where
|
|
|
|
doRun ::
|
|
|
|
Asm.InfoTable ->
|
|
|
|
Asm.FunctionInfo ->
|
|
|
|
Sem r (Either Asm.AsmError Asm.Val)
|
|
|
|
doRun tab' funInfo =
|
|
|
|
embed $ Asm.catchRunErrorIO (Asm.runCodeIO tab' funInfo)
|