~jojo/Carth

0827c3a92bacaccc97ec9c84e8f02c1deffe7a2a — JoJo 1 year, 5 months ago 5618dd7
Prefix debug files (like out.ll) with ".dbg." to make invisible

Also gitignore them
3 files changed, 7 insertions(+), 6 deletions(-)

M .gitignore
M app/Main.hs
M src/Compile.hs
M .gitignore => .gitignore +2 -1
@@ 2,4 2,5 @@
carth.cabal
*~
examples/out.*
examples/out
\ No newline at end of file
examples/out
.dbg.*
\ No newline at end of file

M app/Main.hs => app/Main.hs +3 -3
@@ 37,7 37,7 @@ compileFile f cfg = do
parse :: FilePath -> IO Ast.Program
parse f = Parse.parse f >>= \case
    Left e -> putStrLn (formatParseErr e) >> abort f
    Right p -> writeFile "out.parsed" (pretty p) $> p
    Right p -> writeFile ".dbg.out.parsed" (pretty p) $> p
  where
    formatParseErr e =
        let ss = lines e in (unlines ((head ss ++ " Error:") : tail ss))


@@ 45,10 45,10 @@ parse f = Parse.parse f >>= \case
typecheck' :: FilePath -> Ast.Program -> IO DesugaredAst.Program
typecheck' f p = case typecheck p of
    Left e -> TypeErr.printErr e >> abort f
    Right p -> writeFile "out.checked" (show p) $> p
    Right p -> writeFile ".dbg.out.checked" (show p) $> p

monomorphize' :: DesugaredAst.Program -> IO MonoAst.Program
monomorphize' p = do
    let p' = monomorphize p
    writeFile "out.mono" (show p')
    writeFile ".dbg.out.mono" (show p')
    pure p'

M src/Compile.hs => src/Compile.hs +2 -2
@@ 34,7 34,7 @@ compile f cfg pgm = withContext $ \c -> withHostTargetMachinePIC $ \t -> do
    layout <- getTargetMachineDataLayout t
    putStrLn ("   Generating LLVM")
    let mod = codegen layout f pgm
    writeFile "out.dbgll" (pretty mod)
    writeFile ".dbg.out.dbgll" (pretty mod)
    withModuleFromAST c mod (compileModule t cfg)

compileModule :: TargetMachine -> CompileConfig -> Module -> IO ()


@@ 43,7 43,7 @@ compileModule t cfg m = do
    let binfile = fromMaybe "out" (outfile cfg)
        llfile = replaceExtension binfile "ll"
        ofile = replaceExtension binfile "o"
    writeLLVMAssemblyToFile' llfile m
    writeLLVMAssemblyToFile' (".dbg." ++ llfile) m
    verify m
    writeObjectToFile t (File ofile) m
    putStrLn ("   Linking")