Skip to content

Commit

Permalink
fileCounter + ReaderT
Browse files Browse the repository at this point in the history
  • Loading branch information
d-xo authored and msooseth committed Sep 13, 2023
1 parent a82d280 commit 28912be
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/EVM/Solvers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import Control.Concurrent.Chan (Chan, newChan, writeChan, readChan)
import Control.Concurrent (forkIO, killThread)
import Control.Monad
import Control.Monad.State.Strict
import Control.Monad.Reader
import Data.Char (isSpace)
import Data.Map (Map)
import Data.IORef
import Data.Map qualified as Map
import Data.Maybe (fromMaybe, isJust, fromJust)
import Data.Text qualified as TS
Expand Down Expand Up @@ -103,7 +105,7 @@ withSolvers solver count timeout cont = do
taskQueue <- newChan
availableInstances <- newChan
forM_ instances (writeChan availableInstances)
orchestrateId <- forkIO $ orchestrate taskQueue availableInstances
orchestrateId <- forkIO $ orchestrate taskQueue availableInstances 0

-- run continuation with task queue
res <- cont (SolverGroup taskQueue)
Expand All @@ -113,14 +115,14 @@ withSolvers solver count timeout cont = do
killThread orchestrateId
pure res
where
orchestrate :: Chan Task -> Chan SolverInstance -> IO b
orchestrate queue avail = do
orchestrate :: Chan Task -> Chan SolverInstance -> Int -> IO b
orchestrate queue avail fileCounter = do
task <- readChan queue
inst <- readChan avail
_ <- forkIO $ runTask task inst avail
orchestrate queue avail
_ <- forkIO $ runTask task inst avail fileCounter
orchestrate queue avail (fileCounter + 1)

runTask (Task smt2@(SMT2 cmds (RefinementEqs refineEqs) cexvars) r debugFName) inst availableInstances = do
runTask (Task smt2@(SMT2 cmds (RefinementEqs refineEqs) cexvars) r debugFName) inst availableInstances fileCounter = do
writeSMT2File smt2 debugFName ("abstracted")
-- reset solver and send all lines of provided script
out <- sendScript inst (SMT2 ("(reset)" : cmds) mempty mempty)
Expand Down Expand Up @@ -284,7 +286,7 @@ sendScript solver (SMT2 cmds _ _) = do
"success" -> go cs
e -> pure $ Left $ "Solver returned an error:\n" <> e <> "\nwhile sending the following line: " <> c

checkCommand :: SolverInstance -> Text -> IO ()
checkCommand :: SolverInstance -> Text -> ReaderT Text IO ()
checkCommand inst cmd = do
res <- sendCommand inst cmd

Check failure on line 291 in src/EVM/Solvers.hs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

• Couldn't match type ‘IO’ with ‘ReaderT Text IO’
case res of
Expand Down

0 comments on commit 28912be

Please sign in to comment.