mirror of https://github.com/zachjs/sv2v.git
removed enum complex type cast hack
This commit is contained in:
parent
710da1a62f
commit
d7b36a033b
|
|
@ -33,8 +33,10 @@ convertDescription (description @ (Part _ _ _ _)) =
|
|||
where
|
||||
enumPairs = concat $ map (uncurry enumVals) $ Set.toList enums
|
||||
enumItems = map (\(x, v) -> MIDecl $ Localparam (Implicit []) x v) enumPairs
|
||||
(Part kw name ports items, enums) = runWriter $
|
||||
traverseModuleItemsM (traverseTypesM traverseType) description
|
||||
(Part kw name ports items, enums) =
|
||||
runWriter $ traverseModuleItemsM (traverseTypesM traverseType) $
|
||||
traverseModuleItems (traverseExprs traverseExpr) $
|
||||
description
|
||||
traverseType :: Type -> Writer Enums Type
|
||||
traverseType (Enum t v r) = do
|
||||
() <- tell $ Set.singleton (t, v)
|
||||
|
|
@ -42,6 +44,11 @@ convertDescription (description @ (Part _ _ _ _)) =
|
|||
let (tf, rs) = typeRanges baseType
|
||||
return $ tf (rs ++ r)
|
||||
traverseType other = return other
|
||||
-- drop any enum type casts in favor of implicit conversion from the
|
||||
-- converted type
|
||||
traverseExpr :: Expr -> Expr
|
||||
traverseExpr (Cast (Enum _ _ _) e) = e
|
||||
traverseExpr other = other
|
||||
convertDescription other = other
|
||||
|
||||
enumVals :: Maybe Type -> [(Identifier, Maybe Expr)] -> [(Identifier, Expr)]
|
||||
|
|
|
|||
|
|
@ -380,14 +380,8 @@ traverseTypesM mapper item =
|
|||
types <- mapM fullMapper $ map fst fields
|
||||
let idents = map snd fields
|
||||
return $ Struct p (zip types idents) r
|
||||
exprMapper (Cast t e) = do
|
||||
t' <- fullMapper t
|
||||
-- TODO HACK: If the cast type is no longer "simple", we just drop
|
||||
-- the case altogether. This probably doesn't work great in all
|
||||
-- cases.
|
||||
return $ if elem ' ' (show t')
|
||||
then e
|
||||
else Cast t' e
|
||||
exprMapper (Cast t e) =
|
||||
fullMapper t >>= \t' -> return $ Cast t' e
|
||||
exprMapper other = return other
|
||||
declMapper (Parameter t x e) =
|
||||
fullMapper t >>= \t' -> return $ Parameter t' x e
|
||||
|
|
|
|||
Loading…
Reference in New Issue