X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=NormalizeTools.hs;h=193af61edc717571bccfd9def970f142e7c8c7e6;hb=56c7e95a268187a0dd4aea1fa9e669755247c79b;hp=91e5b4526bbd272ff95b020b8a010f2040b55e4f;hpb=e184a93a2d3c19afdade23ec707a000652a5dcbc;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/NormalizeTools.hs b/NormalizeTools.hs index 91e5b45..193af61 100644 --- a/NormalizeTools.hs +++ b/NormalizeTools.hs @@ -23,6 +23,7 @@ import qualified SrcLoc import qualified Type import qualified IdInfo import qualified CoreUtils +import qualified CoreSubst import Outputable ( showSDoc, ppr, nest ) -- Local imports @@ -140,3 +141,9 @@ mkUnique = Trans.lift $ do let (us', us'') = UniqSupply.splitUniqSupply us putA tsUniqSupply us' return $ UniqSupply.uniqFromSupply us'' + +-- Replace each of the binders given with the coresponding expressions in the +-- given expression. +substitute :: [(CoreBndr, CoreExpr)] -> CoreExpr -> CoreExpr +substitute replace expr = CoreSubst.substExpr subs expr + where subs = foldl (\s (b, e) -> CoreSubst.extendIdSubst s b e) CoreSubst.emptySubst replace