Commit 10feedb1 by Zachary Snow

use the Unique package in a few places

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