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:
parent
638a3f3c22
commit
02c444be95
|
@ -27,6 +27,7 @@ import Data.Generics
|
||||||
|
|
||||||
import qualified AST as A
|
import qualified AST as A
|
||||||
import CompState
|
import CompState
|
||||||
|
import Control.Monad.State
|
||||||
import Metadata
|
import Metadata
|
||||||
import Pass
|
import Pass
|
||||||
import qualified Properties as Prop
|
import qualified Properties as Prop
|
||||||
|
@ -37,6 +38,7 @@ simplifyAbbrevs :: [Pass]
|
||||||
simplifyAbbrevs =
|
simplifyAbbrevs =
|
||||||
[ removeInitial
|
[ removeInitial
|
||||||
, removeResult
|
, removeResult
|
||||||
|
, updateAbbrevsInState
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | Rewrite 'InitialAbbrev' into a variable and an assignment.
|
-- | Rewrite 'InitialAbbrev' into a variable and an assignment.
|
||||||
|
@ -168,3 +170,15 @@ removeResult
|
||||||
doAbbrevMode A.ResultAbbrev = A.Abbrev
|
doAbbrevMode A.ResultAbbrev = A.Abbrev
|
||||||
doAbbrevMode s = s
|
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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user