Updated the monomorphizer to the new tree.
This commit is contained in:
parent
3c2cb1a713
commit
b1209b3353
4 changed files with 34 additions and 40 deletions
|
|
@ -1,8 +1,5 @@
|
||||||
posMul: _Int - > _Int - > _Int;
|
add : Int -> Int -> Int ;
|
||||||
posMul a b = a + b; {
|
add x y = x + y;
|
||||||
-
|
|
||||||
case b of {
|
main : Int ;
|
||||||
0 => 0;
|
main = add 4 6 ;
|
||||||
_ => a + posMul a(b - 1)
|
|
||||||
}; -
|
|
||||||
}
|
|
||||||
|
|
|
||||||
27
src/Main.hs
27
src/Main.hs
|
|
@ -2,25 +2,22 @@
|
||||||
|
|
||||||
module Main where
|
module Main where
|
||||||
|
|
||||||
-- import Codegen.Codegen (generateCode)
|
import Codegen.Codegen (generateCode)
|
||||||
import GHC.IO.Handle.Text (hPutStrLn)
|
import GHC.IO.Handle.Text (hPutStrLn)
|
||||||
import Grammar.ErrM (Err)
|
import Grammar.ErrM (Err)
|
||||||
import Grammar.Par (myLexer, pProgram)
|
import Grammar.Par (myLexer, pProgram)
|
||||||
import Grammar.Print (printTree)
|
import Grammar.Print (printTree)
|
||||||
|
|
||||||
-- import Monomorphizer.Monomorphizer (monomorphize)
|
import Monomorphizer.Monomorphizer (monomorphize)
|
||||||
|
|
||||||
import Control.Monad (when)
|
import Control.Monad (when)
|
||||||
import Data.List.Extra (isSuffixOf)
|
import Data.List.Extra (isSuffixOf)
|
||||||
|
|
||||||
import Renamer.Renamer (rename)
|
import Renamer.Renamer (rename)
|
||||||
import System.Directory (
|
import System.Directory (createDirectory, doesPathExist,
|
||||||
createDirectory,
|
|
||||||
doesPathExist,
|
|
||||||
getDirectoryContents,
|
getDirectoryContents,
|
||||||
removeDirectoryRecursive,
|
removeDirectoryRecursive,
|
||||||
setCurrentDirectory,
|
setCurrentDirectory)
|
||||||
)
|
|
||||||
import System.Environment (getArgs)
|
import System.Environment (getArgs)
|
||||||
import System.Exit (exitFailure, exitSuccess)
|
import System.Exit (exitFailure, exitSuccess)
|
||||||
import System.IO (stderr)
|
import System.IO (stderr)
|
||||||
|
|
@ -50,18 +47,18 @@ main' debug s = do
|
||||||
typechecked <- fromTypeCheckerErr $ typecheck renamed
|
typechecked <- fromTypeCheckerErr $ typecheck renamed
|
||||||
printToErr $ printTree typechecked
|
printToErr $ printTree typechecked
|
||||||
|
|
||||||
-- printToErr "\n-- Lambda Lifter --"
|
printToErr "\n-- Lambda Lifter --"
|
||||||
-- let lifted = lambdaLift typechecked
|
-- let lifted = lambdaLift typechecked
|
||||||
-- printToErr $ printTree lifted
|
-- printToErr $ printTree lifted
|
||||||
--
|
--
|
||||||
-- printToErr "\n -- Printing compiler output to stdout --"
|
printToErr "\n -- Printing compiler output to stdout --"
|
||||||
-- compiled <- fromCompilerErr $ generateCode (monomorphize typechecked)
|
compiled <- fromCompilerErr $ generateCode (monomorphize typechecked)
|
||||||
-- putStrLn compiled
|
putStrLn compiled
|
||||||
|
|
||||||
-- check <- doesPathExist "output"
|
check <- doesPathExist "output"
|
||||||
-- when check (removeDirectoryRecursive "output")
|
when check (removeDirectoryRecursive "output")
|
||||||
-- createDirectory "output"
|
createDirectory "output"
|
||||||
-- writeFile "output/llvm.ll" compiled
|
writeFile "output/llvm.ll" compiled
|
||||||
-- if debug then debugDotViz else putStrLn compiled
|
-- if debug then debugDotViz else putStrLn compiled
|
||||||
|
|
||||||
-- interpred <- fromInterpreterErr $ interpret lifted
|
-- interpred <- fromInterpreterErr $ interpret lifted
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ monoAbsType (GA.TVar _v) = error "NOT POLYMORHPIC TYPES"
|
||||||
monoAbsType (GA.TAll _v _t) = error "NOT ALL TYPES"
|
monoAbsType (GA.TAll _v _t) = error "NOT ALL TYPES"
|
||||||
monoAbsType (GA.TEVar _v) = error "I DONT KNOW WHAT THIS IS"
|
monoAbsType (GA.TEVar _v) = error "I DONT KNOW WHAT THIS IS"
|
||||||
monoAbsType (GA.TFun t1 t2) = M.TFun (monoAbsType t1) (monoAbsType t2)
|
monoAbsType (GA.TFun t1 t2) = M.TFun (monoAbsType t1) (monoAbsType t2)
|
||||||
monoAbsType (GA.TIndexed _) = error "NOT INDEXED TYPES"
|
monoAbsType (GA.TData _ _) = error "NOT INDEXED TYPES"
|
||||||
|
|
||||||
monoType :: T.Type -> M.Type
|
monoType :: T.Type -> M.Type
|
||||||
monoType (T.TAll _ t) = monoType t
|
monoType (T.TAll _ t) = monoType t
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module Monomorphizer.MonomorphizerIr (module Monomorphizer.MonomorphizerIr, module RE, module GA) where
|
module Monomorphizer.MonomorphizerIr (module Monomorphizer.MonomorphizerIr, module RE, module GA) where
|
||||||
|
|
||||||
import Grammar.Abs (Ident (..), Init (..), UIdent)
|
import Grammar.Abs (Ident (..), UIdent)
|
||||||
import qualified Grammar.Abs as GA (Ident (..), Init (..))
|
import qualified Grammar.Abs as GA (Ident (..))
|
||||||
import qualified TypeChecker.TypeCheckerIr as RE
|
import qualified TypeChecker.TypeCheckerIr as RE
|
||||||
|
|
||||||
type Id = (Ident, Type)
|
type Id = (Ident, Type)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue