Update abbrevation types in the state too.

This makes cgtest82 work, although I'm not very happy with it as a fix. I'd
rather have a way of ensuring the state's definitions are kept up to date when
we change something in the AST.
This commit is contained in:
Adam Sampson 2008-06-10 13:57:01 +00:00
parent 638a3f3c22
commit 02c444be95

View File

@ -27,6 +27,7 @@ import Data.Generics
import qualified AST as A
import CompState
import Control.Monad.State
import Metadata
import Pass
import qualified Properties as Prop
@ -37,6 +38,7 @@ simplifyAbbrevs :: [Pass]
simplifyAbbrevs =
[ removeInitial
, removeResult
, updateAbbrevsInState
]
-- | Rewrite 'InitialAbbrev' into a variable and an assignment.
@ -168,3 +170,15 @@ removeResult
doAbbrevMode A.ResultAbbrev = A.Abbrev
doAbbrevMode s = s
-- | Rewrite abbreviation modes in the state.
updateAbbrevsInState :: Pass
updateAbbrevsInState
= pass "Update INITIAL and RESULT abbreviations in state"
[Prop.initialRemoved, Prop.resultRemoved]
[]
(\v -> get >>= applyDepthM (return . doAbbrevMode) >>= put >> return v)
where
doAbbrevMode :: A.AbbrevMode -> A.AbbrevMode
doAbbrevMode A.InitialAbbrev = A.Original
doAbbrevMode A.ResultAbbrev = A.Abbrev
doAbbrevMode s = s