Commit c0b8ba17 by Zachary Snow

simplify interface port type representation

parent 7f79147c
...@@ -260,8 +260,8 @@ convertDescription parts (Part attrs extern Module lifetime name ports items) = ...@@ -260,8 +260,8 @@ convertDescription parts (Part attrs extern Module lifetime name ports items) =
collectDecl _ = return () collectDecl _ = return ()
extractModportInfo :: Type -> Maybe Identifier extractModportInfo :: Type -> Maybe Identifier
extractModportInfo (InterfaceT "" Nothing []) = Just "" extractModportInfo (InterfaceT "" "" []) = Just ""
extractModportInfo (InterfaceT interfaceName (Just modportName) []) = extractModportInfo (InterfaceT interfaceName modportName []) =
if isInterface interfaceName if isInterface interfaceName
then Just modportName then Just modportName
else Nothing else Nothing
......
...@@ -798,7 +798,7 @@ traverseSinglyNestedTypesM mapper = tm ...@@ -798,7 +798,7 @@ traverseSinglyNestedTypesM mapper = tm
tm (IntegerAtom kw sg ) = return $ IntegerAtom kw sg tm (IntegerAtom kw sg ) = return $ IntegerAtom kw sg
tm (NonInteger kw ) = return $ NonInteger kw tm (NonInteger kw ) = return $ NonInteger kw
tm (TypeOf expr ) = return $ TypeOf expr tm (TypeOf expr ) = return $ TypeOf expr
tm (InterfaceT x my r) = return $ InterfaceT x my r tm (InterfaceT x y r) = return $ InterfaceT x y r
tm (Enum t vals r) = do tm (Enum t vals r) = do
t' <- mapper t t' <- mapper t
return $ Enum t' vals r return $ Enum t' vals r
......
...@@ -49,7 +49,7 @@ data Type ...@@ -49,7 +49,7 @@ data Type
| Enum Type [Item] [Range] | Enum Type [Item] [Range]
| Struct Packing [Field] [Range] | Struct Packing [Field] [Range]
| Union Packing [Field] [Range] | Union Packing [Field] [Range]
| InterfaceT Identifier (Maybe Identifier) [Range] | InterfaceT Identifier Identifier [Range]
| TypeOf Expr | TypeOf Expr
| UnpackedType Type [Range] -- used internally | UnpackedType Type [Range] -- used internally
deriving (Eq, Ord) deriving (Eq, Ord)
...@@ -63,8 +63,8 @@ instance Show Type where ...@@ -63,8 +63,8 @@ instance Show Type where
show (IntegerVector kw sg rs) = printf "%s%s%s" (show kw) (showPadBefore sg) (showRanges rs) show (IntegerVector kw sg rs) = printf "%s%s%s" (show kw) (showPadBefore sg) (showRanges rs)
show (IntegerAtom kw sg ) = printf "%s%s" (show kw) (showPadBefore sg) show (IntegerAtom kw sg ) = printf "%s%s" (show kw) (showPadBefore sg)
show (NonInteger kw ) = printf "%s" (show kw) show (NonInteger kw ) = printf "%s" (show kw)
show (InterfaceT x my r) = x ++ yStr ++ (showRanges r) show (InterfaceT x y r) = x ++ yStr ++ (showRanges r)
where yStr = maybe "" ("."++) my where yStr = if null y then "" else '.' : y
show (Enum t vals r) = printf "enum %s{%s}%s" tStr (commas $ map showVal vals) (showRanges r) show (Enum t vals r) = printf "enum %s{%s}%s" tStr (commas $ map showVal vals) (showRanges r)
where where
tStr = showPad t tStr = showPad t
...@@ -104,7 +104,7 @@ typeRanges typ = ...@@ -104,7 +104,7 @@ typeRanges typ =
Enum t v rs -> (Enum t v, rs) Enum t v rs -> (Enum t v, rs)
Struct p l rs -> (Struct p l, rs) Struct p l rs -> (Struct p l, rs)
Union p l rs -> (Union p l, rs) Union p l rs -> (Union p l, rs)
InterfaceT x my rs -> (InterfaceT x my, rs) InterfaceT x y rs -> (InterfaceT x y, rs)
Alias xx rs -> (Alias xx, rs) Alias xx rs -> (Alias xx, rs)
PSAlias ps xx rs -> (PSAlias ps xx, rs) PSAlias ps xx rs -> (PSAlias ps xx, rs)
CSAlias ps pm xx rs -> (CSAlias ps pm xx, rs) CSAlias ps pm xx rs -> (CSAlias ps pm xx, rs)
......
...@@ -661,7 +661,7 @@ PortDeclTokens(delim) :: { [DeclToken] } ...@@ -661,7 +661,7 @@ PortDeclTokens(delim) :: { [DeclToken] }
| GenericInterfaceDecl delim { $1 } | GenericInterfaceDecl delim { $1 }
| AttributeInstance PortDeclTokens(delim) {% posInject \p -> DTAttr p $1 : $2 } | AttributeInstance PortDeclTokens(delim) {% posInject \p -> DTAttr p $1 : $2 }
GenericInterfaceDecl :: { [DeclToken] } GenericInterfaceDecl :: { [DeclToken] }
: "interface" Identifier {% posInject \p -> [DTType p (\Unspecified -> InterfaceT "" Nothing), DTIdent p $2] } : "interface" Identifier {% posInject \p -> [DTType p (\Unspecified -> InterfaceT "" ""), DTIdent p $2] }
VariablePortIdentifiers :: { [(Identifier, Expr)] } VariablePortIdentifiers :: { [(Identifier, Expr)] }
: VariablePortIdentifier { [$1] } : VariablePortIdentifier { [$1] }
......
...@@ -434,7 +434,7 @@ takeLifetime (DTLifetime _ l : rest) = (Just l, rest) ...@@ -434,7 +434,7 @@ takeLifetime (DTLifetime _ l : rest) = (Just l, rest)
takeLifetime rest = (Nothing, rest) takeLifetime rest = (Nothing, rest)
takeType :: [DeclToken] -> ([Range] -> Type, [DeclToken]) takeType :: [DeclToken] -> ([Range] -> Type, [DeclToken])
takeType (DTIdent _ a : DTDot _ b : rest) = (InterfaceT a (Just b), rest) takeType (DTIdent _ a : DTDot _ b : rest) = (InterfaceT a b , rest)
takeType (DTType _ tf : DTSigning _ sg : rest) = (tf sg , rest) takeType (DTType _ tf : DTSigning _ sg : rest) = (tf sg , rest)
takeType (DTType _ tf : rest) = (tf Unspecified , rest) takeType (DTType _ tf : rest) = (tf Unspecified , rest)
takeType (DTSigning _ sg : rest) = (Implicit sg , rest) takeType (DTSigning _ sg : rest) = (Implicit sg , rest)
......
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