Cleared up a couple of remaining uses of SYB

This commit is contained in:
Neil Brown 2009-04-18 21:25:48 +00:00
parent 48018a0acf
commit a05facb7ad
2 changed files with 10 additions and 7 deletions

View File

@ -36,7 +36,7 @@ import Control.Monad.Reader
import Control.Monad.State
import Data.Array.IArray
import qualified Data.Foldable as F
import Data.Generics hiding (GT)
import Data.Generics (Data, Typeable)
import Data.Int
import Data.List
import qualified Data.Map as Map
@ -46,6 +46,7 @@ import qualified Data.Traversable as T
import qualified AST as A
import CompState
import Data.Generics.Polyplate.Schemes
import Errors
import Metadata
import Omega
@ -561,7 +562,7 @@ makeEquations accesses bound
reps' :: [Var]
reps' = map (Var . A.Variable emptyMeta) reps
vs :: [Var]
vs = map Var $ listify (const True :: A.Variable -> Bool) e
vs = map Var $ listifyDepth (const True :: A.Variable -> Bool) e
-- | A front-end to the setIndexVar' function
setIndexVar :: A.Variable -> Int -> [FlattenedExp] -> [FlattenedExp]

View File

@ -19,9 +19,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
module UsageCheckUtils (Decl(..), emptyVars, flattenParItems, foldUnionVars, getVarProcCall, getVarProc, labelUsageFunctions, mapUnionVars, ParItems(..), processVarW, transformParItems, UsageLabel(..), Var(..), Vars(..), vars) where
import Control.Applicative
import Control.Monad.State
import Control.Monad.Writer (tell)
import qualified Data.Foldable as F
import Data.Generics hiding (GT)
import Data.Generics (Data, Typeable)
import Data.List
import qualified Data.Map as Map
import Data.Maybe
@ -30,6 +31,7 @@ import qualified Data.Traversable as T
import qualified AST as A
import CompState
import Data.Generics.Polyplate.Schemes
import Errors
import FlowGraph
import Metadata
@ -227,13 +229,13 @@ getVarExpList (A.IntrinsicFunctionCallList _ _ es) = foldUnionVars $ map getVarE
getVarExpList (A.AllocChannelBundle {}) = emptyVars
getVarExp :: A.Expression -> Vars
getVarExp = everything unionVars (emptyVars `mkQ` getVarExp')
getVarExp e = execState (applyBottomUpM getVarExp' e) emptyVars
where
--Only need to deal with the two cases where we can see an A.Variable directly;
--the generic recursion will take care of nested expressions, and even the expressions used as subscripts
getVarExp' :: A.Expression -> Vars
getVarExp' (A.ExprVariable _ v) = processVarR v
getVarExp' _ = emptyVars
getVarExp' :: A.Expression -> State Vars A.Expression
getVarExp' e@(A.ExprVariable _ v) = modify (unionVars $ processVarR v) >> return e
getVarExp' e = return e
getVarSpec :: A.Specification -> Vars
getVarSpec (A.Specification _ n st) = get st