Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CESK machine to track environments through new Suspended state #1928

Merged
merged 54 commits into from
Jun 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
058c3fd
CESK suspend state
byorgey Jun 7, 2024
8ad3fe4
suspend primitive
byorgey Jun 7, 2024
db57d1a
remove RobotContext and turn it into Env
byorgey Jun 7, 2024
ba95254
remove VResult + F*Env
byorgey Jun 8, 2024
5a5a8ad
turn def into syntax sugar for let
byorgey Jun 8, 2024
49a595e
remove Module and ProcessedTerm
byorgey Jun 9, 2024
807a50b
fill in type annotations on binders
byorgey Jun 10, 2024
20b82bb
split up Requirements module
byorgey Jun 12, 2024
935e370
fix machine stepping for new Env
byorgey Jun 11, 2024
93e4fb3
automatically insert suspend calls
byorgey Jun 13, 2024
c5f5fb5
fix test + benchmark suites
byorgey Jun 13, 2024
bca7a23
fix FromJSON Syntax instance
byorgey Jun 14, 2024
845a824
replace undefined in Step.Const
byorgey Jun 14, 2024
03e19a9
fix unit test suite
byorgey Jun 14, 2024
94a7809
get unit tests building
byorgey Jun 14, 2024
01e0f44
fix unused var analysis
byorgey Jun 14, 2024
fa83471
reinstate CPower requirement; 21/333 failing
byorgey Jun 14, 2024
6abdc0c
fix code size scoring test; 16/333 failing
byorgey Jun 14, 2024
4ab7947
fix infinite type error message that changed slightly; 15/333 failing
byorgey Jun 14, 2024
1655828
reinstate typechecking context stack entries for def/let; 9/333 failing
byorgey Jun 14, 2024
08ad198
fix pretty-printing for consecutive defs; 8/333 failing
byorgey Jun 14, 2024
98948f2
cabal gild
byorgey Jun 14, 2024
bfb21f2
fourmolu
byorgey Jun 14, 2024
9b575ce
apply hlint suggestions
byorgey Jun 14, 2024
413b6d2
fix tydef
byorgey Jun 14, 2024
5615c29
refactor and fix CESK initialization code
byorgey Jun 14, 2024
09ba197
fix remaining XXX
byorgey Jun 14, 2024
8e5b587
recreate it variable
byorgey Jun 14, 2024
e34adb2
tests for #681 and #1032
byorgey Jun 14, 2024
2e3c4f8
special case for insertSuspend noop
byorgey Jun 14, 2024
0826fc1
fix type of it variable when using type alias
byorgey Jun 14, 2024
6646432
fix requirements checking for definitions
byorgey Jun 14, 2024
75fb8fe
fix requirements checking during type checking for let
byorgey Jun 14, 2024
0b30679
fix run command
byorgey Jun 15, 2024
ec35222
remove debugging code
byorgey Jun 15, 2024
8d579e0
restore base Env after an exception bubbles to top level
byorgey Jun 15, 2024
b289b61
properly handle suspend with more continuation remaining
byorgey Jun 15, 2024
e2b1b3b
Remove last XXX comment
byorgey Jun 15, 2024
17e5500
add tests with nested def/tydef
byorgey Jun 15, 2024
ee45a19
fourmolu
byorgey Jun 15, 2024
a9874b7
remove redundant import
byorgey Jun 15, 2024
5e1b6e4
fix benchmark suite
byorgey Jun 15, 2024
d99bf2e
bugfix: exceptions must terminate atomic blocks
byorgey Jun 15, 2024
ee570e0
fix docspec test
byorgey Jun 16, 2024
cd56578
properly add binding when Suspended meets FBind
byorgey Jun 16, 2024
0e065d5
delete stray files
byorgey Jun 16, 2024
2d34d4b
improve comments
byorgey Jun 16, 2024
5c8c979
report explicit type annotations after checking instead of expanded v…
byorgey Jun 16, 2024
92487b4
more comments, ensure def has command type, and properly make let loc…
byorgey Jun 16, 2024
e330c51
bug fix: free vars in scope of tydef were being ignored; add minimal …
byorgey Jun 16, 2024
e763af8
fix Ctrl-C so it doesn't lose all definitions in scope
byorgey Jun 17, 2024
6cab7ec
fix filterTCStack
byorgey Jun 18, 2024
a8e263a
remove unnecessary change
byorgey Jun 18, 2024
328afae
fix import
byorgey Jun 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
bugfix: exceptions must terminate atomic blocks
  • Loading branch information
byorgey committed Jun 19, 2024
commit d99bf2e8af6fac0a1a623544679e26b92b6174f2
11 changes: 5 additions & 6 deletions src/swarm-engine/Swarm/Game/Step.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
-- See <https://github.com/swarm-game/swarm/issues/495>.
module Swarm.Game.Step where

import Debug.Trace

import Control.Applicative (Applicative (..))
import Control.Carrier.Error.Either (ErrorC, runError)
import Control.Carrier.State.Lazy
Expand Down Expand Up @@ -497,7 +495,6 @@ tickRobotRec r = do
stepRobot :: HasGameStepState sig m => Robot -> m Robot
stepRobot r = do
(r', cesk') <- runState (r & activityCounts . tickStepBudget -~ 1) (stepCESK (r ^. machine))
-- sendIO $ appendFile "out.txt" (prettyString cesk' ++ "\n")
t <- use $ temporal . ticks

isCreative <- use creativeMode
Expand Down Expand Up @@ -775,9 +772,7 @@ stepCESK cesk = case cesk of
-- Otherwise, if we're suspended with nothing else left to do,
-- return the machine unchanged (but throw away the rest of the
-- continuation stack).
Suspended v e s k -> do
traceM ("Suspended killing stack: " ++ show k)
return $ Suspended v e s []
Suspended v e s _ -> return $ Suspended v e s []
------------------------------------------------------------
-- Exception handling
------------------------------------------------------------
Expand All @@ -791,6 +786,10 @@ stepCESK cesk = case cesk of
-- it appropriately.
Up exn s [] -> handleException exn s Nothing
Up exn s (FRestoreEnv e : _) -> handleException exn s (Just e)
-- If an atomic block threw an exception, we should terminate it.
Up exn s (FFinishAtomic : k) -> do
runningAtomic .= False
return $ Up exn s k
-- If we are raising a catchable exception up the continuation
-- stack and come to a Try frame, force and then execute the associated catch
-- block.
Expand Down