mirror of
https://github.com/anoma/juvix.git
synced 2024-12-25 08:34:10 +03:00
23 lines
807 B
Haskell
23 lines
807 B
Haskell
|
module Compilation.Base where
|
||
|
|
||
|
import Base
|
||
|
import Data.HashMap.Strict qualified as HashMap
|
||
|
import Juvix.Compiler.Builtins (iniState)
|
||
|
import Juvix.Compiler.Core.Data.InfoTable qualified as Core
|
||
|
import Juvix.Compiler.Core.Translation.FromInternal.Data qualified as Core
|
||
|
import Juvix.Compiler.Pipeline
|
||
|
|
||
|
compileAssertion ::
|
||
|
Path Abs File ->
|
||
|
Path Abs File ->
|
||
|
(String -> IO ()) ->
|
||
|
Assertion
|
||
|
compileAssertion mainFile _ step = do
|
||
|
step "Translate to JuvixCore"
|
||
|
cwd <- getCurrentDir
|
||
|
let entryPoint = defaultEntryPoint cwd mainFile
|
||
|
tab <- (^. Core.coreResultTable) . snd <$> runIO' iniState entryPoint upToCore
|
||
|
case (tab ^. Core.infoMain) >>= ((tab ^. Core.identContext) HashMap.!?) of
|
||
|
Just _ -> return ()
|
||
|
Nothing -> assertFailure ("No main function registered in: " <> toFilePath mainFile)
|