Commit a1705363 by Zachary Snow

unbased-unsized binding nested struct performance fix

parent 7f0c33ab
...@@ -83,7 +83,7 @@ convertModuleItem _ other = convertModuleItem' other ...@@ -83,7 +83,7 @@ convertModuleItem _ other = convertModuleItem' other
determinePortSize :: Identifier -> [ParamBinding] -> [ModuleItem] -> Expr determinePortSize :: Identifier -> [ParamBinding] -> [ModuleItem] -> Expr
determinePortSize portName instanceParams moduleItems = determinePortSize portName instanceParams moduleItems =
step initialMapping moduleItems step (reverse initialMapping) moduleItems
where where
moduleParams = parameterNames moduleItems moduleParams = parameterNames moduleItems
initialMapping = catMaybes $ initialMapping = catMaybes $
...@@ -99,10 +99,10 @@ determinePortSize portName instanceParams moduleItems = ...@@ -99,10 +99,10 @@ determinePortSize portName instanceParams moduleItems =
step :: [(Identifier, Expr)] -> [ModuleItem] -> Expr step :: [(Identifier, Expr)] -> [ModuleItem] -> Expr
step mapping (MIPackageItem (Decl (Param _ _ x e)) : rest) = step mapping (MIPackageItem (Decl (Param _ _ x e)) : rest) =
step (mapping ++ [(x, e)]) rest step ((x, e) : mapping) rest
step mapping (MIPackageItem (Decl (Variable _ t x a _)) : rest) = step mapping (MIPackageItem (Decl (Variable _ t x a _)) : rest) =
if x == portName if x == portName
then substituteExpr mapping size then substituteExpr (reverse mapping) size
else step mapping rest else step mapping rest
where size = BinOp Mul (dimensionsSize a) (DimsFn FnBits $ Left t) where size = BinOp Mul (dimensionsSize a) (DimsFn FnBits $ Left t)
step mapping (_ : rest) = step mapping rest step mapping (_ : rest) = step mapping rest
...@@ -111,6 +111,14 @@ determinePortSize portName instanceParams moduleItems = ...@@ -111,6 +111,14 @@ determinePortSize portName instanceParams moduleItems =
substituteExpr :: [(Identifier, Expr)] -> Expr -> Expr substituteExpr :: [(Identifier, Expr)] -> Expr -> Expr
substituteExpr _ (Ident (':' : x)) = substituteExpr _ (Ident (':' : x)) =
Ident x Ident x
substituteExpr mapping (Dot (Ident x) y) =
case lookup x mapping of
Nothing -> Dot (Ident x) y
Just (Pattern items) ->
case lookup y items of
Just item -> substituteExpr mapping item
Nothing -> Dot (substituteExpr mapping (Pattern items)) y
Just expr -> Dot (substituteExpr mapping expr) y
substituteExpr mapping (Ident x) = substituteExpr mapping (Ident x) =
case lookup x mapping of case lookup x mapping of
Nothing -> Ident x Nothing -> Ident x
......
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