Skip to content

Commit

Permalink
Pass initial simplifier cache to performRewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
geo2a committed Aug 5, 2024
1 parent 24b8126 commit 10f6b18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
5 changes: 2 additions & 3 deletions booster/library/Booster/JsonRpc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ respond stateVar request =
unsupported
(Left other, _) ->
pure . Left . RpcError.backendError $ RpcError.Aborted (Text.pack . constructorName $ other)
(Right newPattern, _simplifierCache) -> do
-- FIXME do not throw away @simplifierCache@, pass it to performRewrite somehow
(Right newPattern, simplifierCache) -> do
logger <- getLogger
prettyModifiers <- getPrettyModifiers
let rewriteConfig =
Expand All @@ -197,7 +196,7 @@ respond stateVar request =
}

result <-
performRewrite rewriteConfig newPattern
performRewrite rewriteConfig simplifierCache newPattern
SMT.finaliseSolver solver
stop <- liftIO $ getTime Monotonic
pure $ execResponse (duration req.logTiming start stop) req result substitution unsupported
Expand Down
19 changes: 10 additions & 9 deletions booster/library/Booster/Pattern/Rewrite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,10 @@ performRewrite ::
forall io.
LoggerMIO io =>
RewriteConfig ->
SimplifierCache ->
Pattern ->
io (Natural, Seq (RewriteTrace ()), RewriteResult Pattern)
performRewrite rewriteConfig pat = do
performRewrite rewriteConfig initialCache pat = do
(rr, RewriteStepsState{counter, traces}) <-
flip runStateT rewriteStart $ doSteps False pat
pure (counter, traces, rr)
Expand All @@ -722,6 +723,14 @@ performRewrite rewriteConfig pat = do
, terminalLabels
} = rewriteConfig

rewriteStart :: RewriteStepsState
rewriteStart =
RewriteStepsState
{ counter = 0
, traces = mempty
, simplifierCache = initialCache
}

logDepth = withContext CtxDepth . logMessage

depthReached n = maybe False (n >=) mbMaxDepth
Expand Down Expand Up @@ -919,11 +928,3 @@ data RewriteStepsState = RewriteStepsState
, traces :: !(Seq (RewriteTrace ()))
, simplifierCache :: SimplifierCache
}

rewriteStart :: RewriteStepsState
rewriteStart =
RewriteStepsState
{ counter = 0
, traces = mempty
, simplifierCache = mempty
}

0 comments on commit 10f6b18

Please sign in to comment.