1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 04:51:57 +03:00

Run nondeterminism locally in flow-sensitive analysis.

This commit is contained in:
Rob Rix 2018-10-26 13:03:14 -04:00
parent f0925ad0cf
commit 66d5a1dfe8

View File

@ -89,10 +89,13 @@ convergingModules :: ( AbstractValue term address value m
, Member (Env address) sig
, Member (State (Heap address value)) sig
, Carrier sig m
, Effect sig
)
=> Open (Module term -> Evaluator term address value m address)
convergingModules recur m = do
c <- getConfiguration (moduleBody m)
=> (Module (Either prelude term) -> Evaluator term address value (AltC Maybe (Eff m)) address)
-> (Module (Either prelude term) -> Evaluator term address value m address)
convergingModules recur m@(Module _ (Left _)) = raiseHandler runNonDet (recur m) >>= maybeM empty
convergingModules recur m@(Module _ (Right term)) = do
c <- getConfiguration term
-- Convergence here is predicated upon an Eq instance, not α-equivalence
cache <- converge lowerBound (\ prevCache -> isolateCache $ do
putHeap (configurationHeap c)
@ -104,8 +107,7 @@ convergingModules recur m = do
-- that it doesn't "leak" to the calling context and diverge (otherwise this
-- would never complete). We dont need to use the values, so we 'gather' the
-- nondeterministic values into @()@.
-- FIXME: do we actually need to gather here?
withOracle prevCache (recur m))
withOracle prevCache (raiseHandler runNonDet (recur m)))
address =<< maybe empty scatter (cacheLookup c cache)
-- | Iterate a monadic action starting from some initial seed until the results converge.