Programs are now actually compiled all the way through.
This commit is contained in:
parent
e0c78f5783
commit
e500c70529
3 changed files with 29 additions and 36 deletions
|
|
@ -51,6 +51,7 @@ executable language
|
|||
, hspec
|
||||
, QuickCheck
|
||||
, directory
|
||||
, process
|
||||
|
||||
default-language: GHC2021
|
||||
|
||||
|
|
@ -83,5 +84,6 @@ Test-suite language-testsuite
|
|||
, hspec
|
||||
, QuickCheck
|
||||
, process
|
||||
, bytestring
|
||||
|
||||
default-language: GHC2021
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
module Compiler where
|
||||
module Compiler (compile) where
|
||||
|
||||
import Grammar.ErrM (Err)
|
||||
import System.Exit (exitFailure, exitSuccess)
|
||||
|
|
@ -13,15 +13,10 @@ import System.Process.Extra (CreateProcess (..),
|
|||
--spawnWait s = spawnCommand s >>= \s >>= waitForProcess
|
||||
|
||||
optimize :: String -> IO String
|
||||
optimize prg = do
|
||||
result <- readCreateProcess (shell "opt --O3") prg
|
||||
putStrLn result
|
||||
optimize = readCreateProcess (shell "opt --O3 -S")
|
||||
|
||||
compileClang :: String -> IO String
|
||||
compileClang = readCreateProcess (shell "clang -x ir -o hello_world -")
|
||||
|
||||
-- (Just hin, Just hout, _, _) <- createProcess (proc "opt" ["--O3"]){ std_in = CreatePipe, std_out = CreatePipe }
|
||||
-- hSetBuffering hin NoBuffering
|
||||
-- hPutStrLn hin prg
|
||||
-- hFlush hin
|
||||
--bytes <- hGetContents hout
|
||||
--putStrLn bytes
|
||||
pure ""
|
||||
compile :: String -> IO String
|
||||
compile s = optimize s >>= compileClang
|
||||
|
|
|
|||
46
src/Main.hs
46
src/Main.hs
|
|
@ -2,32 +2,29 @@
|
|||
|
||||
module Main where
|
||||
|
||||
import Codegen.Codegen (generateCode)
|
||||
import Data.Bool (bool)
|
||||
import GHC.IO.Handle.Text (hPutStrLn)
|
||||
import Grammar.ErrM (Err)
|
||||
import Grammar.Par (myLexer, pProgram)
|
||||
import Grammar.Print (printTree)
|
||||
import Codegen.Codegen (generateCode)
|
||||
import Data.Bool (bool)
|
||||
import GHC.IO.Handle.Text (hPutStrLn)
|
||||
import Grammar.ErrM (Err)
|
||||
import Grammar.Par (myLexer, pProgram)
|
||||
import Grammar.Print (printTree)
|
||||
|
||||
import Monomorphizer.Monomorphizer (monomorphize)
|
||||
import Monomorphizer.Monomorphizer (monomorphize)
|
||||
|
||||
import Control.Monad (when)
|
||||
import Data.List.Extra (isSuffixOf)
|
||||
import Control.Monad (when)
|
||||
import Data.List.Extra (isSuffixOf)
|
||||
|
||||
import Compiler (optimize)
|
||||
import Renamer.Renamer (rename)
|
||||
import System.Directory (
|
||||
createDirectory,
|
||||
doesPathExist,
|
||||
getDirectoryContents,
|
||||
removeDirectoryRecursive,
|
||||
setCurrentDirectory,
|
||||
)
|
||||
import System.Environment (getArgs)
|
||||
import System.Exit (exitFailure, exitSuccess)
|
||||
import System.IO (stderr)
|
||||
import System.Process.Extra (spawnCommand, waitForProcess)
|
||||
import TypeChecker.TypeChecker (typecheck)
|
||||
import Compiler (compile)
|
||||
import Renamer.Renamer (rename)
|
||||
import System.Directory (createDirectory, doesPathExist,
|
||||
getDirectoryContents,
|
||||
removeDirectoryRecursive,
|
||||
setCurrentDirectory)
|
||||
import System.Environment (getArgs)
|
||||
import System.Exit (exitFailure, exitSuccess)
|
||||
import System.IO (stderr)
|
||||
import System.Process.Extra (spawnCommand, waitForProcess)
|
||||
import TypeChecker.TypeChecker (typecheck)
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
|
|
@ -67,8 +64,7 @@ main' debug s = do
|
|||
writeFile "output/llvm.ll" generatedCode
|
||||
debugDotViz
|
||||
|
||||
optimize generatedCode
|
||||
|
||||
compile generatedCode
|
||||
-- interpred <- fromInterpreterErr $ interpret lifted
|
||||
-- putStrLn "\n-- interpret"
|
||||
-- print interpred
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue