Added a function to load the Standard LLVM library at runtime.

This commit is contained in:
Samuel Hammersberg 2023-01-24 11:38:33 +01:00
parent 8aaf05bf82
commit fd64a7e669
4 changed files with 19 additions and 3 deletions

View file

@ -32,6 +32,7 @@ executable language
Grammar.Skel
Compiler.Compiler
Compiler.StandardLLVMLibrary
Compiler.TH
Interpreter
hs-source-dirs: src
@ -42,5 +43,6 @@ executable language
, containers
, either
, array
, template-haskell
default-language: GHC2021

View file

@ -1,6 +1,10 @@
{-# LANGUAGE TemplateHaskell #-}
module Compiler.StandardLLVMLibrary where
import Control.Monad
import Language.Haskell.TH
import Compiler.TH
-- $(genCurries 8)
standardLLVMLibrary :: String
standardLLVMLibrary = "
"
standardLLVMLibrary = $(includeStr "src/Compiler/standard_library.ll")

10
src/Compiler/TH.hs Normal file
View file

@ -0,0 +1,10 @@
{-# LANGUAGE TemplateHaskell #-}
module Compiler.TH where
import Control.Monad
import Language.Haskell.TH
import System.IO.Unsafe(unsafePerformIO)
includeStr :: String -> Q Exp
includeStr file = do
let res = unsafePerformIO $ readFile file
[|res|]