2023-05-22 21:18:18 +03:00
|
|
|
module VampIR.Compilation.Base where
|
|
|
|
|
|
|
|
import Base
|
|
|
|
import Core.VampIR.Base (coreVampIRAssertion')
|
|
|
|
import Juvix.Compiler.Core
|
2023-06-21 14:08:19 +03:00
|
|
|
import VampIR.Core.Base (VampirBackend (..), vampirAssertion')
|
2023-05-22 21:18:18 +03:00
|
|
|
|
2023-11-16 18:19:52 +03:00
|
|
|
vampirCompileAssertion :: Path Abs Dir -> Path Abs File -> Path Abs File -> (String -> IO ()) -> Assertion
|
|
|
|
vampirCompileAssertion root' mainFile dataFile step = do
|
2023-05-22 21:18:18 +03:00
|
|
|
step "Translate to JuvixCore"
|
2023-12-06 20:24:59 +03:00
|
|
|
entryPoint <- testDefaultEntryPointIO root' mainFile
|
2023-12-30 22:15:35 +03:00
|
|
|
PipelineResult {..} <- snd <$> testRunIO entryPoint upToStoredCore
|
|
|
|
let tab = computeCombinedInfoTable (_pipelineResult ^. coreResultModule)
|
2023-05-22 21:18:18 +03:00
|
|
|
coreVampIRAssertion' tab toVampIRTransformations mainFile dataFile step
|
2024-06-28 13:15:51 +03:00
|
|
|
vampirAssertion' entryPoint VampirHalo2 tab dataFile step
|
2023-06-15 17:42:58 +03:00
|
|
|
|
|
|
|
vampirCompileErrorAssertion ::
|
2023-11-16 18:19:52 +03:00
|
|
|
Path Abs Dir ->
|
2023-06-15 17:42:58 +03:00
|
|
|
Path Abs File ->
|
|
|
|
(String -> IO ()) ->
|
|
|
|
Assertion
|
2023-11-16 18:19:52 +03:00
|
|
|
vampirCompileErrorAssertion root' mainFile step = do
|
2023-06-15 17:42:58 +03:00
|
|
|
step "Translate to JuvixCore"
|
2023-12-06 20:24:59 +03:00
|
|
|
entryPoint <- testDefaultEntryPointIO root' mainFile
|
2023-12-30 22:15:35 +03:00
|
|
|
r <- testRunIOEither entryPoint upToStoredCore
|
2023-06-15 17:42:58 +03:00
|
|
|
case r of
|
|
|
|
Left _ -> return ()
|
|
|
|
Right res ->
|
2023-12-30 22:15:35 +03:00
|
|
|
let m = snd res ^. pipelineResult . coreResultModule
|
2024-06-28 13:15:51 +03:00
|
|
|
in case run $ runReader entryPoint $ runError @JuvixError $ toVampIR m of
|
2023-06-15 17:42:58 +03:00
|
|
|
Left _ -> return ()
|
|
|
|
Right _ -> assertFailure "no error"
|