Skip to content
Browse files

+ Binding closure convert to compiler

  • Loading branch information...
1 parent ff0d164 commit 486ad2b0b253a8724d2316e6ceef130974d20aa6 @Averethel committed Mar 12, 2013
Showing with 16 additions and 3 deletions.
  1. +11 −0 ClosureConvert.hs
  2. +5 −3 Compiler.hs
View
11 ClosureConvert.hs
@@ -0,0 +1,11 @@
+module ClosureConvert (
+ ClosureConvert.closureConvert,
+ Program(..)
+) where
+ import ClosureConvert.CSyntax
+ import ClosureConvert.ClosureConvert
+
+ import KNormal.KSyntax
+
+ closureConvert :: KExpr -> IO Program
+ closureConvert = ClosureConvert.ClosureConvert.closureConvert []
View
8 Compiler.hs
@@ -1,6 +1,7 @@
module Compiler (compile) where
import AlphaConvert
import BetaReduce
+ import ClosureConvert
import ConstantsFold
import EliminateDefinitions
import Inline
@@ -10,7 +11,7 @@ module Compiler (compile) where
import Syntax
import TypeInference
- compiler :: Integer -> Expr -> IO KExpr
+ compiler :: Integer -> Expr -> IO Program
compiler t e0 = do
let e1 = compilePatternMatching e0
let e2 = convertToKNormal e1
@@ -19,9 +20,10 @@ module Compiler (compile) where
let e5 = letFlatten e4
e6 <- inline t e5
let e7 = constantsFold e6
- eliminateDefinitions e7
+ e8 <- eliminateDefinitions e7
+ closureConvert e8
- compile :: Integer -> Expr -> IO (Either String KExpr)
+ compile :: Integer -> Expr -> IO (Either String Program)
compile inlineTreshold expr = case typeOfExpression emptyEnv expr of
Left er -> return $ Left er
Right _ -> do

0 comments on commit 486ad2b

Please sign in to comment.
Something went wrong with that request. Please try again.