Add intermediate phase, and a pass to gather declarations
This commit is contained in:
parent
15974f8eb6
commit
b659d27f1f
|
@ -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
|
||||
|
|
|
@ -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
26
fco/PhaseIntermediate.hs
Normal 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
|
||||
|
|
@ -8,7 +8,7 @@ import BasePasses
|
|||
|
||||
phaseOutput
|
||||
= (Phase "C output"
|
||||
[basePassOc, basePassC]
|
||||
[basePassOc, basePassInt, basePassC]
|
||||
[
|
||||
("Convert expressions", convExpressions)
|
||||
])
|
||||
|
|
|
@ -139,6 +139,10 @@ data Node =
|
|||
| OcName String
|
||||
-- }}} END
|
||||
|
||||
-- {{{ BEGIN basePassInt
|
||||
| IntDeclSet [Node] Node
|
||||
-- }}} END
|
||||
|
||||
-- {{{ BEGIN basePassC
|
||||
| CCode String
|
||||
-- }}} END
|
||||
|
|
Loading…
Reference in New Issue
Block a user