Commit e9d62e01 by Zachary Snow

unify type range splitting

parent aea2975d
......@@ -125,6 +125,7 @@ traverseDeclM decl = do
isRangeable :: Type -> Bool
isRangeable IntegerAtom{} = False
isRangeable NonInteger{} = False
isRangeable TypeOf{} = False
isRangeable _ = True
traverseGenItemM :: GenItem -> Scoper Type GenItem
......
......@@ -86,19 +86,6 @@ traverseTypeM (Alias st rs1) = do
details <- lookupElemM st
return $ case details of
Nothing -> Alias st rs1
Just (_, _, typ) -> case typ of
Net kw sg rs2 -> Net kw sg $ rs1 ++ rs2
Implicit sg rs2 -> Implicit sg $ rs1 ++ rs2
IntegerVector kw sg rs2 -> IntegerVector kw sg $ rs1 ++ rs2
Enum t v rs2 -> Enum t v $ rs1 ++ rs2
Struct p l rs2 -> Struct p l $ rs1 ++ rs2
Union p l rs2 -> Union p l $ rs1 ++ rs2
InterfaceT x my rs2 -> InterfaceT x my $ rs1 ++ rs2
Alias xx rs2 -> Alias xx $ rs1 ++ rs2
PSAlias ps xx rs2 -> PSAlias ps xx $ rs1 ++ rs2
CSAlias ps pm xx rs2 -> CSAlias ps pm xx $ rs1 ++ rs2
UnpackedType t rs2 -> UnpackedType t $ rs1 ++ rs2
IntegerAtom kw sg -> nullRange (IntegerAtom kw sg) rs1
NonInteger kw -> nullRange (NonInteger kw ) rs1
TypeOf expr -> nullRange (TypeOf expr) rs1
Just (_, _, typ) -> tf $ rs1 ++ rs2
where (tf, rs2) = typeRanges typ
traverseTypeM other = return other
......@@ -24,7 +24,6 @@ module Language.SystemVerilog.AST.Type
, ChargeStrength (..)
, pattern UnknownType
, typeRanges
, nullRange
, elaborateIntegerAtom
) where
......@@ -101,20 +100,22 @@ instance Ord (Signing -> [Range] -> Type) where
compare tf1 tf2 = compare (tf1 Unspecified) (tf2 Unspecified)
typeRanges :: Type -> ([Range] -> Type, [Range])
typeRanges (Alias xx rs) = (Alias xx , rs)
typeRanges (PSAlias ps xx rs) = (PSAlias ps xx , rs)
typeRanges (CSAlias ps pm xx rs) = (CSAlias ps pm xx , rs)
typeRanges (Net kw sg rs) = (Net kw sg, rs)
typeRanges (Implicit sg rs) = (Implicit sg, rs)
typeRanges (IntegerVector kw sg rs) = (IntegerVector kw sg, rs)
typeRanges (IntegerAtom kw sg ) = (nullRange $ IntegerAtom kw sg, [])
typeRanges (NonInteger kw ) = (nullRange $ NonInteger kw , [])
typeRanges (Enum t v r) = (Enum t v, r)
typeRanges (Struct p l r) = (Struct p l, r)
typeRanges (Union p l r) = (Union p l, r)
typeRanges (InterfaceT x my r) = (InterfaceT x my, r)
typeRanges (TypeOf expr) = (UnpackedType $ TypeOf expr, [])
typeRanges (UnpackedType t rs) = (UnpackedType t, rs)
typeRanges typ =
case typ of
Net kw sg rs -> (Net kw sg, rs)
Implicit sg rs -> (Implicit sg, rs)
IntegerVector kw sg rs -> (IntegerVector kw sg, rs)
Enum t v rs -> (Enum t v, rs)
Struct p l rs -> (Struct p l, rs)
Union p l rs -> (Union p l, rs)
InterfaceT x my rs -> (InterfaceT x my, rs)
Alias xx rs -> (Alias xx, rs)
PSAlias ps xx rs -> (PSAlias ps xx, rs)
CSAlias ps pm xx rs -> (CSAlias ps pm xx, rs)
UnpackedType t rs -> (UnpackedType t, rs)
IntegerAtom kw sg -> (nullRange $ IntegerAtom kw sg, [])
NonInteger kw -> (nullRange $ NonInteger kw , [])
TypeOf expr -> (nullRange $ TypeOf expr, [])
nullRange :: Type -> ([Range] -> Type)
nullRange t [] = t
......
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