Add intermediate phase, and a pass to gather declarations

This commit is contained in:
Adam Sampson 2006-09-07 12:41:35 +00:00
parent 15974f8eb6
commit b659d27f1f
5 changed files with 35 additions and 3 deletions

View File

@ -8,9 +8,10 @@ import Parse
import Tree
import Pass
import PhaseSource
import PhaseIntermediate
import PhaseOutput
phaseList = [phaseSource, phaseOutput]
phaseList = [phaseSource, phaseIntermediate, phaseOutput]
doPhases :: [Phase] -> Node -> IO Node
doPhases [] n = do return n

View File

@ -1,6 +1,7 @@
all: fco
fco: Main.hs Parse.hs Tree.hs Pass.hs PhaseSource.hs PhaseOutput.hs BasePasses.hs
fco: Main.hs Parse.hs Tree.hs Pass.hs BasePasses.hs \
PhaseSource.hs PhaseIntermediate.hs PhaseOutput.hs
ghc -o fco --make Main
BasePasses.hs: Tree.hs make-passthrough.py

26
fco/PhaseIntermediate.hs Normal file
View File

@ -0,0 +1,26 @@
-- Intermediate passes
module PhaseIntermediate (phaseIntermediate) where
import Tree
import Pass
import BasePasses
phaseIntermediate
= (Phase "Intermediate mangling"
[basePassOc, basePassInt]
[
("Gather declarations", gatherDecls)
])
gatherDecls :: Pass
gatherDecls next top node
= case node of
OcDecl d c -> let c' = top c
d' = top d
in
case c' of
IntDeclSet ds cs -> IntDeclSet (d':ds) cs
_ -> IntDeclSet [d'] c'
_ -> next node

View File

@ -8,7 +8,7 @@ import BasePasses
phaseOutput
= (Phase "C output"
[basePassOc, basePassC]
[basePassOc, basePassInt, basePassC]
[
("Convert expressions", convExpressions)
])

View File

@ -139,6 +139,10 @@ data Node =
| OcName String
-- }}} END
-- {{{ BEGIN basePassInt
| IntDeclSet [Node] Node
-- }}} END
-- {{{ BEGIN basePassC
| CCode String
-- }}} END