Skip to content

Commit 4bce8d3

Browse files
committed
saw-core: Redefine field accessor 'scTermF' as a normal function.
This makes it so that client code can't break the SharedContext abstraction by updating the 'scTermF' field.
1 parent df3b7f9 commit 4bce8d3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

saw-core/src/SAWCore/SharedTerm.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ insertTFM tf x tfm =
374374
-- then do another lookup for hash-consing the Constant term.
375375
data SharedContext = SharedContext
376376
{ scModuleMap :: IORef ModuleMap
377-
, scTermF :: TermF Term -> IO Term
377+
, scAppCache :: AppCacheRef
378378
, scDisplayNameEnv :: IORef DisplayNameEnv
379379
, scURIEnv :: IORef (Map URI VarIndex)
380380
, scGlobalEnv :: IORef (HashMap Ident Term)
@@ -726,9 +726,9 @@ emptyAppCache :: AppCache
726726
emptyAppCache = emptyTFM
727727

728728
-- | Return term for application using existing term in cache if it is available.
729-
getTerm :: AppCacheRef -> TermF Term -> IO Term
730-
getTerm cache termF =
731-
modifyMVar cache $ \s -> do
729+
scTermF :: SharedContext -> TermF Term -> IO Term
730+
scTermF sc termF =
731+
modifyMVar (scAppCache sc) $ \s -> do
732732
case lookupTFM termF s of
733733
Just term -> return (s, term)
734734
Nothing -> do
@@ -2567,7 +2567,7 @@ mkSharedContext = do
25672567
ur <- newIORef Map.empty
25682568
return SharedContext {
25692569
scModuleMap = mod_map_ref
2570-
, scTermF = getTerm cr
2570+
, scAppCache = cr
25712571
, scNextVarIndex = vr
25722572
, scDisplayNameEnv = dr
25732573
, scURIEnv = ur

0 commit comments

Comments
 (0)