diff --git a/src/Analysis/Abstract/Collecting.hs b/src/Analysis/Abstract/Collecting.hs index b515f4fca..fb8a5d7c5 100644 --- a/src/Analysis/Abstract/Collecting.hs +++ b/src/Analysis/Abstract/Collecting.hs @@ -42,15 +42,6 @@ instance ( Effectful m analyzeModule = liftAnalyze analyzeModule --- | Retrieve the local 'Live' set. -askRoots :: (Effectful m, Member (Reader (Live location value)) effects) => m effects (Live location value) -askRoots = raise ask - --- | Run a computation with the given 'Live' set added to the local root set. --- extraRoots :: (Effectful m, Member (Reader (Live location value)) effects, Ord location) => Live location value -> m effects a -> m effects a --- extraRoots roots = raise . local (<> roots) . lower - - -- | Collect any addresses in the heap not rooted in or reachable from the given 'Live' set. gc :: ( Ord location , Foldable (Cell location) diff --git a/src/Control/Abstract/Evaluator.hs b/src/Control/Abstract/Evaluator.hs index 93efc3e87..30c75646e 100644 --- a/src/Control/Abstract/Evaluator.hs +++ b/src/Control/Abstract/Evaluator.hs @@ -27,6 +27,9 @@ module Control.Abstract.Evaluator , modifyHeap , lookupHeap , assign + -- Roots + , askRoots + , extraRoots -- Module tables , getModuleTable , putModuleTable @@ -59,6 +62,7 @@ import Data.Abstract.Environment as Env import Data.Abstract.Exports as Export import Data.Abstract.FreeVariables import Data.Abstract.Heap +import Data.Abstract.Live import Data.Abstract.Module import Data.Abstract.ModuleTable import Data.Abstract.Package @@ -263,6 +267,17 @@ assign :: ( Ord location assign address = modifyHeap . heapInsert address +-- Roots + +-- | Retrieve the local 'Live' set. +askRoots :: (Effectful m, Member (Reader (Live location value)) effects) => m effects (Live location value) +askRoots = raise ask + +-- | Run a computation with the given 'Live' set added to the local root set. +extraRoots :: (Effectful m, Member (Reader (Live location value)) effects, Ord location) => Live location value -> m effects a -> m effects a +extraRoots roots = raiseHandler (local (<> roots)) + + -- Module table -- | Retrieve the table of evaluated modules.