- mdl' <- buildModuleT "main" repl
- withContext $ \ctx -> withHostTargetMachine $ \tm ->
- withModuleFromAST ctx mdl' $ \mdl -> do
- let spec = defaultCuratedPassSetSpec { optLevel = Just 3 }
- -- this returns true if the module was modified
- withPassManager spec $ flip runPassManager mdl
- Text.hPutStrLn stderr . ("\n" <>) . ppllvm =<< moduleAST mdl
+ withContext $ \ctx -> withHostTargetMachine $ \tm -> do
+ withExecutionSession $ \exSession ->
+ withSymbolResolver exSession (SymbolResolver symResolver) $ \symResolverPtr ->
+ withObjectLinkingLayer exSession (const $ pure symResolverPtr) $ \linkingLayer ->
+ withIRCompileLayer linkingLayer tm $ \compLayer -> do
+ withModuleKey exSession $ \mdlKey -> do
+ let env = JITEnv ctx compLayer mdlKey
+ ast <- runReaderT (buildModuleT "main" repl) env
+ return ()
+
+-- This can eventually be used to resolve external functions, e.g. a stdlib call
+symResolver :: MangledSymbol -> IO (Either JITSymbolError JITSymbol)
+symResolver sym = undefined