From: Matthijs Kooijman Date: Thu, 16 Apr 2009 08:00:14 +0000 (+0200) Subject: Support binding the scrutinee of a Case expression. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=commitdiff_plain;h=a879bbd83d5ce95e0d05aa117819edf88bc8f6d4 Support binding the scrutinee of a Case expression. --- diff --git a/Flatten.hs b/Flatten.hs index 74b3232..8c4c7ab 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -268,11 +268,12 @@ flattenExpr binds expr@(Case scrut b _ alts) = do -- TODO: Special casing for higher order functions -- Flatten the scrutinee (_, res) <- flattenExpr binds scrut + -- Put the scrutinee in the BindMap + let binds' = (b, Left res) : binds case alts of - -- TODO include b in the binds list - [alt] -> flattenSingleAltCaseExpr binds res b alt + [alt] -> flattenSingleAltCaseExpr binds' res b alt -- Reverse the alternatives, so the __DEFAULT alternative ends up last - otherwise -> flattenMultipleAltCaseExpr binds res b (reverse alts) + otherwise -> flattenMultipleAltCaseExpr binds' res b (reverse alts) where flattenSingleAltCaseExpr :: BindMap