Commit 737791ae by Zachary Snow

expose nested type traversal

parent a9f502a6
......@@ -55,7 +55,7 @@ traverseDescriptionM (orig @ (Part extern kw lifetime name ports items)) = do
runner f = execWriter $ collectModuleItemsM f orig
usedPIs = Set.unions $ map runner $
[ collectStmtsM collectSubroutinesM
, collectTypesM collectTypenamesM
, collectTypesM $ collectNestedTypesM collectTypenamesM
, collectExprsM $ collectNestedExprsM collectIdentsM
]
traverseDescriptionM other = return other
......@@ -82,10 +82,6 @@ collectIdentsM _ = return ()
-- writes down aliased typenames
collectTypenamesM :: Type -> Writer Idents ()
collectTypenamesM (Alias _ x _) = tell $ Set.singleton x
collectTypenamesM (Enum (Just t) _ _) = collectTypenamesM t
collectTypenamesM (Struct _ fields _) = do
_ <- mapM collectTypenamesM $ map fst fields
return ()
collectTypenamesM _ = return ()
-- returns the "name" of a package item, if it has one
......
......@@ -47,6 +47,9 @@ module Convert.Traverse
, traverseDeclsM'
, traverseDecls'
, collectDeclsM'
, traverseNestedTypesM
, traverseNestedTypes
, collectNestedTypesM
, traverseTypesM
, traverseTypes
, collectTypesM
......@@ -796,6 +799,11 @@ traverseNestedTypesM mapper = fullMapper
let idents = map snd fields
return $ Union p (zip types idents) r
traverseNestedTypes :: Mapper Type -> Mapper Type
traverseNestedTypes = unmonad traverseNestedTypesM
collectNestedTypesM :: Monad m => CollectorM m Type -> CollectorM m Type
collectNestedTypesM = collectify traverseNestedTypesM
traverseTypesM :: Monad m => MapperM m Type -> MapperM m ModuleItem
traverseTypesM mapper item =
miMapper item >>=
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment