~jojo/Carth

2642b97d08644a183f6e0fcba45d1dbe69662274 — JoJo 1 year, 3 months ago 98f0ad6
when debug, write file ".dbg.gen.ll"
3 files changed, 11 insertions(+), 0 deletions(-)

M carth.cabal
M src/Compile.hs
M src/Pretty.hs
M carth.cabal => carth.cabal +2 -0
@@ 58,12 58,14 @@ library
    , filepath
    , llvm-hs
    , llvm-hs-pure
    , llvm-hs-pretty
    , megaparsec
    , microlens-platform
    , mtl
    , process
    , template-haskell
    , utf8-string
    , prettyprinter
  default-language: Haskell2010

executable carth

M src/Compile.hs => src/Compile.hs +2 -0
@@ 36,6 36,7 @@ import Conf
import qualified Monomorphic
import Codegen
import Err
import Pretty


compile :: FilePath -> CompileConfig -> Monomorphic.Program -> IO ()


@@ 66,6 67,7 @@ handleProgram f file cfg pgm = withContext $ \ctx ->
            layout <- getTargetMachineDataLayout tm
            verbose cfg ("   Generating LLVM")
            amod <- codegen' layout file pgm
            when (getDebug cfg) (writeFile ".dbg.gen.ll" (pretty amod))
            flip
                    catch
                    (\case

M src/Pretty.hs => src/Pretty.hs +7 -0
@@ 7,6 7,9 @@ import Data.List
import Data.Bifunctor
import qualified Data.Set as Set
import Data.Set (Set)
import LLVM.AST (Module)
import LLVM.Pretty ()
import qualified Data.Text.Prettyprint.Doc as Prettyprint

import Misc
import SrcPos


@@ 259,3 262,7 @@ prettyMonoTFun a b =
            M.TFun a' b' -> first (a' :) (f b')
            t -> ([], t)
    in  concat ["(Fun ", pretty a, " ", spcPretty (bParams ++ [bBody]), ")"]


instance Pretty Module where
    pretty' _ = show . Prettyprint.pretty