Skip to content

Commit 79bce8c

Browse files
committed
make VisitGCRef general to support GC and other state traversals
1 parent 5afab21 commit 79bce8c

File tree

1 file changed

+4
-6
lines changed
  • external-stg-interpreter/lib/Stg/Interpreter/GC

1 file changed

+4
-6
lines changed

external-stg-interpreter/lib/Stg/Interpreter/GC/GCRef.hs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
module Stg.Interpreter.GC.GCRef where
33

44
import Data.Maybe
5-
import Control.Monad.State
5+
import Control.Monad
66
import Foreign.Ptr
77
import qualified Data.IntSet as IntSet
88
import qualified Data.ByteString.Char8 as BS8
99

10-
import Language.Souffle.Compiled (SouffleM)
11-
1210
import Stg.Interpreter.Base
1311

1412
-- HINT: populate datalog database during a traversal
1513

1614
class VisitGCRef a where
17-
visitGCRef :: (GCSymbol -> SouffleM ()) -> a -> SouffleM ()
15+
visitGCRef :: Monad m => (GCSymbol -> m ()) -> a -> m ()
1816

1917
instance VisitGCRef Atom where
2018
visitGCRef action a = visitAtom a action
@@ -122,15 +120,15 @@ data RefNamespace
122120
| NS_StablePointer
123121
| NS_WeakPointer
124122
| NS_Thread
125-
deriving (Show, Read)
123+
deriving (Eq, Ord, Show, Read)
126124

127125
encodeRef :: Int -> RefNamespace -> GCSymbol
128126
encodeRef i ns = GCSymbol $ BS8.pack $ show (ns, i)
129127

130128
decodeRef :: GCSymbol -> (RefNamespace, Int)
131129
decodeRef = read . BS8.unpack . unGCSymbol
132130

133-
visitAtom :: Atom -> (GCSymbol -> SouffleM ()) -> SouffleM ()
131+
visitAtom :: Monad m => Atom -> (GCSymbol -> m ()) -> m ()
134132
visitAtom atom action = case atom of
135133
HeapPtr i -> action $ encodeRef i NS_HeapPtr
136134
Literal{} -> pure ()

0 commit comments

Comments
 (0)