File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -895,10 +895,22 @@ data StmTxResult s a =
895
895
| StmTxAborted [SomeTVar s ] SomeException
896
896
897
897
898
- -- | A branch is an alternative of a `OrElse` or a `CatchStm` statement
899
- data BranchStmA s a = OrElseStmA (StmA s a )
900
- | CatchStmA (SomeException -> StmA s a )
901
- | NoOpStmA
898
+ -- | A branch indicates an alternative statment available in the current context.
899
+ -- For example, `OrElse` has two alternative statements, say "left" and "right".
900
+ -- While executing the left statement, `OrElseStmA` branch indicates that the
901
+ -- right branch is still available, in case, left statement fails.
902
+ data BranchStmA s a =
903
+ -- | `OrElse` statement with its 'right' alternative.
904
+ OrElseStmA (StmA s a )
905
+ -- | `CatchStm` statment with 'catch' handler.
906
+ | CatchStmA (SomeException -> StmA s a )
907
+ -- | No op statment is not a part of the STM semantics. It simply
908
+ -- indicates that there are no alternative statements left to be executed.
909
+ -- For example, when running right alternative of the `OrElse` statement
910
+ -- or when running the catch handler of a `CatchStm` statement, there are
911
+ -- alternative statements available. This case is represented by no-op
912
+ -- branch.
913
+ | NoOpStmA
902
914
903
915
data StmStack s b a where
904
916
-- | Executing in the context of a top level 'atomically'.
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ evalTerm !env !heap !allocs term = case term of
319
319
-- Rule XSTM1
320
320
-- M; heap, {} => return P; heap', allocs'
321
321
-- --------------------------------------------------------
322
- -- S[catch M N]; heap, allocs => S[return P]; heap', allocs'
322
+ -- S[catch M N]; heap, allocs => S[return P]; heap', allocs U allocs '
323
323
NfReturn v -> (NfReturn v, heap', allocs <> allocs')
324
324
325
325
-- Rule XSTM2
@@ -771,10 +771,8 @@ shrinkExpr (ExprName (Name _ (TyRepVar _))) = []
771
771
freeNamesTerm :: Term t -> Set NameId
772
772
freeNamesTerm (Return e) = freeNamesExpr e
773
773
freeNamesTerm (Throw e) = freeNamesExpr e
774
- -- A catch handler should actually have an argument, and then the implementation
775
- -- should handle it. But since current implementation of catch never binds the
776
- -- variable, the following implementation is correct as of now. It needs to be
777
- -- tackled once nested exceptions are handled.
774
+ -- The current generator of catch term ignores the argument passed to the
775
+ -- handler.
778
776
-- TODO: Correctly handle free names when the handler also binds a variable.
779
777
freeNamesTerm (Catch t1 t2) = freeNamesTerm t1 <> freeNamesTerm t2
780
778
freeNamesTerm Retry = Set. empty
You can’t perform that action at this time.
0 commit comments