[Git][ghc/ghc][wip/andreask/typedUniqFM] simple-plugin: Update for UniqFM change

Andreas Klebinger gitlab at gitlab.haskell.org
Fri Jun 26 19:02:39 UTC 2020



Andreas Klebinger pushed to branch wip/andreask/typedUniqFM at Glasgow Haskell Compiler / GHC


Commits:
84f64791 by Andreas Klebinger at 2020-06-26T21:01:35+02:00
simple-plugin: Update for UniqFM change

- - - - -


1 changed file:

- testsuite/tests/plugins/simple-plugin/Simple/Plugin.hs


Changes:

=====================================
testsuite/tests/plugins/simple-plugin/Simple/Plugin.hs
=====================================
@@ -46,14 +46,16 @@ findNameBndr target b
 mainPass :: ModGuts -> CoreM ModGuts
 mainPass guts = do
     putMsgS "Simple Plugin Pass Run"
-    (_, anns) <- getAnnotations deserializeWithData guts
-    bindsOnlyPass (mapM (changeBind anns Nothing)) guts
+    (_, anns) <- getAnnotations deserializeWithData guts :: CoreM (ModuleEnv [ReplaceWith], NameEnv [ReplaceWith])
+    -- Var's have the same uniques as their names. Making a cast from NameEnv to VarEnv safe.
+    let anns' = unsafeCastUFMKey anns :: VarEnv [ReplaceWith]
+    bindsOnlyPass (mapM (changeBind anns' Nothing)) guts
 
-changeBind :: UniqFM [ReplaceWith] -> Maybe String -> CoreBind -> CoreM CoreBind
+changeBind :: VarEnv [ReplaceWith] -> Maybe String -> CoreBind -> CoreM CoreBind
 changeBind anns mb_replacement (NonRec b e) = changeBindPr anns mb_replacement b e >>= (return . uncurry NonRec)
 changeBind anns mb_replacement (Rec bes) = liftM Rec $ mapM (uncurry (changeBindPr anns mb_replacement)) bes
 
-changeBindPr :: UniqFM [ReplaceWith] -> Maybe String -> CoreBndr -> CoreExpr -> CoreM (CoreBndr, CoreExpr)
+changeBindPr :: VarEnv [ReplaceWith] -> Maybe String -> CoreBndr -> CoreExpr -> CoreM (CoreBndr, CoreExpr)
 changeBindPr anns mb_replacement b e = do
     case lookupWithDefaultUFM anns [] b of
         [] -> do
@@ -65,7 +67,7 @@ changeBindPr anns mb_replacement b e = do
         _ -> do dflags <- getDynFlags
                 error ("Too many change_anns on one binder:" ++ showPpr dflags b)
 
-changeExpr :: UniqFM [ReplaceWith] -> Maybe String -> CoreExpr -> CoreM CoreExpr
+changeExpr :: VarEnv [ReplaceWith] -> Maybe String -> CoreExpr -> CoreM CoreExpr
 changeExpr anns mb_replacement e = let go = changeExpr anns mb_replacement in case e of
         Lit (LitString _) -> case mb_replacement of
                 Nothing -> return e
@@ -80,5 +82,5 @@ changeExpr anns mb_replacement e = let go = changeExpr anns mb_replacement in ca
         Tick t e -> liftM (Tick t) (go e)
         _ -> return e
 
-changeAlt :: UniqFM [ReplaceWith] -> Maybe String -> CoreAlt -> CoreM CoreAlt
+changeAlt :: VarEnv [ReplaceWith] -> Maybe String -> CoreAlt -> CoreM CoreAlt
 changeAlt anns mb_replacement (con, bs, e) = liftM (\e' -> (con, bs, e')) (changeExpr anns mb_replacement e)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84f647918ce063d0b22b86f1d986ca55e292b822

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/84f647918ce063d0b22b86f1d986ca55e292b822
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200626/472b9297/attachment-0001.html>


More information about the ghc-commits mailing list