X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FUtils%2FCore%2FCoreTools.hs;h=094b70294ceabcca23e722df69c98e93e1bd85db;hb=a533335368e252544db4f68ee03e0e7b7255eae5;hp=3ba262251c54131b6028b216e7ff248bc09eb18d;hpb=2290559dd61c1cb5f16ef8fe3fc0fecccc29e792;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git "a/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" "b/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" index 3ba2622..094b702 100644 --- "a/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" +++ "b/c\316\273ash/CLasH/Utils/Core/CoreTools.hs" @@ -299,17 +299,19 @@ hasStateType expr = case getType expr of Just ty -> isStateType ty --- | Flattens nested non-recursive lets into a single list of bindings. The --- expression passed does not have to be a let expression, if it isn't an --- empty list of bindings is returned. +-- | Flattens nested lets into a single list of bindings. The expression +-- passed does not have to be a let expression, if it isn't an empty list of +-- bindings is returned. flattenLets :: CoreSyn.CoreExpr -- ^ The expression to flatten. -> ([Binding], CoreSyn.CoreExpr) -- ^ The bindings and resulting expression. -flattenLets (CoreSyn.Let (CoreSyn.NonRec bndr expr) res) = - ((bndr, expr):bindings, res') +flattenLets (CoreSyn.Let binds expr) = + (bindings ++ bindings', expr') where -- Recursively flatten the contained expression - (bindings, res') = flattenLets res + (bindings', expr') =flattenLets expr + -- Flatten our own bindings to remove the Rec / NonRec constructors + bindings = CoreSyn.flattenBinds [binds] flattenLets expr = ([], expr) -- | Create bunch of nested non-recursive let expressions from the given