| 
2 | 2 | module Stg.Interpreter.GC.GCRef where  | 
3 | 3 | 
 
  | 
4 | 4 | import Data.Maybe  | 
5 |  | -import Control.Monad.State  | 
 | 5 | +import Control.Monad  | 
6 | 6 | import Foreign.Ptr  | 
7 | 7 | import qualified Data.IntSet as IntSet  | 
8 | 8 | import qualified Data.ByteString.Char8 as BS8  | 
9 | 9 | 
 
  | 
10 |  | -import Language.Souffle.Compiled (SouffleM)  | 
11 |  | - | 
12 | 10 | import Stg.Interpreter.Base  | 
13 | 11 | 
 
  | 
14 | 12 | -- HINT: populate datalog database during a traversal  | 
15 | 13 | 
 
  | 
16 | 14 | class VisitGCRef a where  | 
17 |  | - visitGCRef :: (GCSymbol -> SouffleM ()) -> a -> SouffleM ()  | 
 | 15 | + visitGCRef :: Monadm=>(GCSymbol -> m ()) -> a -> m ()  | 
18 | 16 | 
 
  | 
19 | 17 | instance VisitGCRef Atom where  | 
20 | 18 |  visitGCRef action a = visitAtom a action  | 
@@ -122,15 +120,15 @@ data RefNamespace  | 
122 | 120 |  | NS_StablePointer  | 
123 | 121 |  | NS_WeakPointer  | 
124 | 122 |  | NS_Thread  | 
125 |  | - deriving (Show, Read)  | 
 | 123 | + deriving (Eq, Ord, Show, Read)  | 
126 | 124 | 
 
  | 
127 | 125 | encodeRef :: Int -> RefNamespace -> GCSymbol  | 
128 | 126 | encodeRef i ns = GCSymbol $ BS8.pack $ show (ns, i)  | 
129 | 127 | 
 
  | 
130 | 128 | decodeRef :: GCSymbol -> (RefNamespace, Int)  | 
131 | 129 | decodeRef = read . BS8.unpack . unGCSymbol  | 
132 | 130 | 
 
  | 
133 |  | -visitAtom :: Atom -> (GCSymbol -> SouffleM ()) -> SouffleM ()  | 
 | 131 | +visitAtom :: Monadm=>Atom -> (GCSymbol -> m ()) -> m ()  | 
134 | 132 | visitAtom atom action = case atom of  | 
135 | 133 |  HeapPtr i -> action $ encodeRef i NS_HeapPtr  | 
136 | 134 |  Literal{} -> pure ()  | 
 | 
0 commit comments