Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Add prose for exiting a CAUGHTadm block. #227

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Changes from all commits
Commits
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
25 changes: 20 additions & 5 deletions document/core/exec/instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3039,17 +3039,32 @@ Throwing an exception with :ref:`tag address <syntax-tagaddr>` :math:`a`

.. _exec-caughtadm:

Holding a caught exception with |CAUGHTadm|
...........................................
Exiting a |CAUGHTadm|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Exiting a |CAUGHTadm|
Exiting a catch clause |CAUGHTadm|

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made PR #240 with this and the other changes requested.

.....................

When the |END| of a |CAUGHTadm|, is reached without a jump, exception, or trap, then the following steps are performed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
When the |END| of a |CAUGHTadm|, is reached without a jump, exception, or trap, then the following steps are performed.
When the |END| of a catch clause |CAUGHTadm| is reached without a jump, exception, or trap, then the following steps are performed.


1. Let :math:`\val^\ast` be the values on the top of the stack.

2. Pop the values :math:`\val^\ast` from the stack.

3. Assert: due to :ref:`validation <valid-instr-seq>`, an administrative instruction :math:`\CAUGHTadm\{a~\val_0^\ast\}` is now on the top of the stack.

4. Pop the |CAUGHTadm| from the stack.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. Pop the |CAUGHTadm| from the stack.
4. Pop the catch clause |CAUGHTadm| from the stack.


5. Push :math:`\val^\ast` back to the stack.
Comment on lines +3047 to +3055
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other similar sections ('Exiting an exception handler' and 'Exiting instr with label L') use val^m. Is there any reason we use val^* here? For example, our 'Exiting an exception handler' section's prose is:

Exiting an exception handler                                                     
............................                                                     

When the end of a :ref:`try <syntax-try>` instruction is reached without a jump, exception, or trap, then the following steps are performed.

1. Let :math:`m` be the number of values on the top of the stack.

2. Pop the values :math:`\val^m` from the stack.

3. Assert: due to :ref:`validation <valid-instr-seq>`, the handler :math:`H` is now on the top of the stack.

4. Pop the handler from the stack.

5. Push :math:`\val^m` back to the stack.

6. Jump to the position after the |END| of the administrative instruction associated with the handler :math:`H`.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aheejin "Exiting instr with label L" uses val^m because it's relevant to the rule, in that labels are of the form label_m. Since caught does not have such a subscript, I used *, and I think it should be the same for "Exiting an exception handler".
So I would be more inclined to change to val^* in "Exiting an exception handler" and leaving this val* here as it is, but I would go with whatever you prefer. WDYT?


6. Jump to the position after the |END| of the administrative instruction associated with the |CAUGHTadm| instruction.

.. todo::
Add prose describing the administrative |CAUGHTadm| execution step.

.. math::
\begin{array}{rcl}
\CAUGHTadm\{a~\val^n\}~\val^m~\END &\stepto& \val^m
\CAUGHTadm\{a~\val_0^\ast\}~\val^\ast~\END &\stepto& \val^\ast
\end{array}

.. note::
An exception can only be rethrown from the scope of the |CAUGHTadm| administrative instruction holding it, i.e., from the scope of the |CATCH| or |CATCHALL| block of a :ref:`try-catch <syntax-try-catch>` instruction that caught it. Upon exit from a |CAUGHTadm|, the exception it holds is discarded.


.. index:: ! call, function, function instance, label, frame

Expand Down