Commit 10feedb1 by Zachary Snow

use the Unique package in a few places

parent a14d0782
......@@ -8,6 +8,7 @@ module Convert.ParamType (convert) where
import Control.Monad.Writer
import Data.Either (isLeft)
import Data.List.Unique (complex)
import Data.Maybe (isJust, isNothing, fromJust)
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
......@@ -32,13 +33,8 @@ convert files =
mapM (collectDescriptionsM collectDescriptionM) files
(files', instancesRaw) = runWriter $ mapM
(mapM $ traverseModuleItemsM $ convertModuleItemM info) files
instances = reverse $ uniq [] instancesRaw
-- TODO: use the unique package
uniq curr [] = curr
uniq curr (x : xs) =
if elem x curr
then uniq curr xs
else uniq (x : curr) xs
instances = uniq instancesRaw
uniq l = l' where (l', _, _) = complex l
-- add type parameter instantiations
files'' = map (concatMap explodeDescription) files'
......@@ -61,7 +57,7 @@ convert files =
explodeDescription other = [other]
-- remove or rewrite source modules that are no longer needed
files''' = map (reverse . uniq [] . concatMap replaceDefault) files''
files''' = map (uniq . concatMap replaceDefault) files''
(usageMapRaw, usedTypedModulesRaw) =
execWriter $ mapM (mapM collectUsageInfoM) files''
usageMap = Map.unionsWith Set.union $ map (uncurry Map.singleton)
......
......@@ -7,6 +7,7 @@
module Convert.Stream (convert) where
import Control.Monad.Writer
import Data.List.Unique (complex)
import Convert.Traverse
import Language.SystemVerilog.AST
......@@ -23,12 +24,7 @@ convertDescription (description @ (Part _ _ _ _ _ _)) =
(description', funcSet) =
runWriter $ traverseModuleItemsM (traverseStmtsM traverseStmtM) description
Part extern kw lifetime name ports items = description'
funcs = reverse $ uniq [] funcSet
uniq curr [] = curr
uniq curr (x : xs) =
if elem x curr
then uniq curr xs
else uniq (x : curr) xs
(funcs, _, _) = complex funcSet
convertDescription other = other
streamerBlock :: Expr -> Expr -> (LHS -> Expr -> Stmt) -> LHS -> Expr -> Stmt
......
resolver: lts-13.17
extra-deps:
- Unique-0.4.7.6
packages:
- .
- .
......@@ -30,7 +30,8 @@ executable sv2v
directory,
filepath,
hashable,
mtl
mtl,
Unique
other-modules:
-- SystemVerilog modules
Language.SystemVerilog
......
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