From: Matthijs Kooijman Date: Sun, 21 Jun 2009 11:37:04 +0000 (+0200) Subject: Add cloneVar function to clone a Var. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=7a315b7e40f3cb5e4e705c87953a89b2e858b325;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add cloneVar function to clone a Var. --- diff --git a/NormalizeTools.hs b/NormalizeTools.hs index 817dd51..82da086 100644 --- a/NormalizeTools.hs +++ b/NormalizeTools.hs @@ -43,6 +43,13 @@ mkInternalVar str ty = do let name = Name.mkInternalName uniq occname SrcLoc.noSrcSpan return $ Var.mkLocalIdVar name ty IdInfo.vanillaIdInfo +cloneVar :: Var.Var -> TransformMonad Var.Var +cloneVar v = do + uniq <- mkUnique + -- Swap out the unique, and reset the IdInfo (I'm not 100% sure what it + -- contains, but vannillaIdInfo is always correct, since it means "no info"). + return $ Var.lazySetVarIdInfo (Var.setVarUnique v uniq) IdInfo.vanillaIdInfo + -- Apply the given transformation to all expressions in the given expression, -- including the expression itself. everywhere :: (String, Transform) -> Transform