You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Try :ref:`invoking <exec-invocation>` the function :math:`\funcaddr` in :math:`\store` with :ref:`values <syntax-val>` :math:`\val^\ast` as arguments:
314
325
315
326
a. If it succeeds with :ref:`values <syntax-val>` :math:`{\val'}^\ast` as results, then let :math:`\X{result}` be :math:`{\val'}^\ast`.
316
327
317
-
b. Else it has trapped, hence let :math:`\X{result}` be :math:`\ERROR`.
328
+
b. Else if the outcome is an exception with a thrown :ref:`exception <exec-throw_ref>` :math:`\REFEXNADDR~\exnaddr` as the result, then let :math:`\X{result}` be :math:`\ETHROW~\exnaddr`
329
+
330
+
c. Else it has trapped, hence let :math:`\X{result}` be :math:`\ERROR`.
318
331
319
332
2. Return the new store paired with :math:`\X{result}`.
320
333
321
334
.. math::
322
335
~ \\
323
336
\begin{array}{lclll}
324
337
\F{func\_invoke}(S, a, v^\ast) &=& (S', {v'}^\ast) && (\iff\invoke(S, a, v^\ast) \stepto^\ast S'; F; {v'}^\ast) \\
325
-
\F{func\_invoke}(S, a, v^\ast) &=& (S', \ERROR) && (\iff\invoke(S, a, v^\ast) \stepto^\ast S'; F; \result) \\
338
+
\F{func\_invoke}(S, a, v^\ast) &=& (S', \ETHROW~a') && (\iff\invoke(S, a, v^\ast) \stepto^\ast S'; F; \XT[(\REFEXNADDR~a')~\THROWREF] \\
339
+
\F{func\_invoke}(S, a, v^\ast) &=& (S', \ERROR) && (\iff\invoke(S, a, v^\ast) \stepto^\ast S'; F; \TRAP) \\
1. Pre-condition: :math:`\tagaddr` is an allocated :ref:`tag address <syntax-tagaddr>`.
620
+
621
+
2. Let :math:`\exnaddr` be the result of :ref:`allocating an exception instance <syntax-exninst>` in :math:`\store` with :ref:`tag address <syntax-tagaddr>` :math:`\tagaddr` and initialization values :math:`\val^\ast`.
622
+
623
+
3. Return the new store paired with :math:`\exnaddr`.
624
+
625
+
.. math::
626
+
\begin{array}{lcll}
627
+
\F{exn\_alloc}(S, \tagaddr, \val^\ast) &=& (S \compose \{\SEXNS~\exninst\}, |S.\SEXNS|) &
Copy file name to clipboardExpand all lines: document/core/exec/instructions.rst
+9-11
Original file line number
Diff line number
Diff line change
@@ -4030,27 +4030,25 @@ Control Instructions
4030
4030
4031
4031
2. Assert: due to :ref:`validation <valid-throw>`, :math:`F.\AMODULE.\MITAGS[x]` exists.
4032
4032
4033
-
3. Let :math:`a` be the :ref:`tag address <syntax-tagaddr>` :math:`F.\AMODULE.\MITAGS[x]`.
4033
+
3. Let :math:`ta` be the :ref:`tag address <syntax-tagaddr>` :math:`F.\AMODULE.\MITAGS[x]`.
4034
4034
4035
-
4. Assert: due to :ref:`validation <valid-throw>`, :math:`S.\STAGS[a]` exists.
4035
+
4. Assert: due to :ref:`validation <valid-throw>`, :math:`S.\STAGS[ta]` exists.
4036
4036
4037
-
5. Let :math:`\X{ti}` be the :ref:`tag instance <syntax-taginst>` :math:`S.\STAGS[a]`.
4037
+
5. Let :math:`\X{ti}` be the :ref:`tag instance <syntax-taginst>` :math:`S.\STAGS[ta]`.
4038
4038
4039
4039
6. Let :math:`[t^n] \toF [{t'}^\ast]` be the :ref:`tag type <syntax-tagtype>` :math:`\X{ti}.\TAGITYPE`.
4040
4040
4041
4041
7. Assert: due to :ref:`validation <valid-throw>`, there are at least :math:`n` values on the top of the stack.
4042
4042
4043
4043
8. Pop the :math:`n` values :math:`\val^n` from the stack.
4044
4044
4045
-
9. Let :math:`\X{exn}` be the :ref:`exception instance<syntax-exninst>` :math:`\{ \EITAG~a, \EIFIELDS~\val^n \}`.
4045
+
9. Let :math:`\X{ea}` be the :ref:`exception address<syntax-exnaddr>` resulting from :ref:`allocating <alloc-exception>` an exception instance with tag address :math:`ta` and initializer values :math:`\val^n`.
4046
4046
4047
-
10. Let :math:`\X{ea}` be the length of :math:`S.\SEXNS`.
4047
+
10. Let :math:`\X{exn}` be :math:`S.\SEXNS[ea]`
4048
4048
4049
-
11. Append :math:`\X{exn}` to :math:`S.\SEXNS`.
4049
+
11. Push the value :math:`\REFEXNADDR~\X{ea}` to the stack.
4050
4050
4051
-
12. Push the value :math:`\REFEXNADDR~\X{ea}` to the stack.
4052
-
4053
-
13. Execute the instruction |THROWREF|.
4051
+
12. Execute the instruction |THROWREF|.
4054
4052
4055
4053
.. math::
4056
4054
~\\[-1ex]
@@ -4114,13 +4112,13 @@ Control Instructions
4114
4112
4115
4113
a. Let :math:`\catch_1` be the first :ref:`catch clause <syntax-catch>` in :math:`\catch^\ast` and :math:`{\catch'}^\ast` the remaining clauses.
4116
4114
4117
-
b. If :math:`\catch_1` is of the form :math:`\CATCH~x~l` and the :ref:`exception address <syntax-exnaddr>` :math:`a` equals :math:`F.\AMODULE.\MITAGS[x]`, then:
4115
+
b. If :math:`\catch_1` is of the form :math:`\CATCH~x~l` and the :ref:`tag address <syntax-tagaddr>` :math:`a` equals :math:`F.\AMODULE.\MITAGS[x]`, then:
4118
4116
4119
4117
i. Push the values :math:`\X{exn}.\EIFIELDS` to the stack.
4120
4118
4121
4119
ii. Execute the instruction :math:`\BR~l`.
4122
4120
4123
-
c. Else if :math:`\catch_1` is of the form :math:`\CATCHREF~x~l` and the :ref:`exception address <syntax-exnaddr>` :math:`a` equals :math:`F.\AMODULE.\MITAGS[x]`, then:
4121
+
c. Else if :math:`\catch_1` is of the form :math:`\CATCHREF~x~l` and the :ref:`tag address <syntax-tagaddr>` :math:`a` equals :math:`F.\AMODULE.\MITAGS[x]`, then:
4124
4122
4125
4123
i. Push the values :math:`\X{exn}.\EIFIELDS` to the stack.
Copy file name to clipboardExpand all lines: document/core/exec/modules.rst
+26
Original file line number
Diff line number
Diff line change
@@ -170,6 +170,32 @@ are *allocated* in a :ref:`store <syntax-store>` :math:`S`, as defined by the fo
170
170
\end{array}
171
171
172
172
173
+
.. index:: exception, exception instance, exception address, tag address
174
+
.. _alloc-exception:
175
+
176
+
:ref:`Exceptions <syntax-exninst>`
177
+
..................................
178
+
179
+
1. Let :math:`ta` be the :ref:`tag address <syntax-tagaddr>` associated with the exception to allocate and :math:`\EIFIELDS~\val^\ast` be the values to initialize the exception with.
180
+
181
+
2. Let :math:`a` be the first free :ref:`exception address <syntax-exnaddr>` in :math:`S`.
182
+
183
+
3. Let :math:`\exninst` be the :ref:`exception instance <syntax-exninst>` :math:`\{ \EITAG~ta, \EIFIELDS~\val^\ast \}`.
184
+
185
+
4. Append :math:`\exninst` to the |SEXNS| of :math:`S`.
Copy file name to clipboardExpand all lines: document/index.html
+11-2
Original file line number
Diff line number
Diff line change
@@ -82,8 +82,17 @@ <h3>Legacy Extensions</h3>
82
82
<ul>
83
83
<li><p><b>Legacy Exception Handling</b>: defines additional instructions for exception handling that may still be available in some engines and tools, specifically web browsers.</p>
0 commit comments