Skip to content

Commit c90608f

Browse files
committed
Revert context extension notation
1 parent 6299fc3 commit c90608f

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

document/core/syntax/conventions.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,13 @@ The following conventions are adopted in defining grammar rules for abstract syn
4141

4242

4343

44+
.. _notation-epsilon:
45+
.. _notation-length:
46+
.. _notation-index:
4447
.. _notation-slice:
4548
.. _notation-replace:
4649
.. _notation-record:
50+
.. _notation-project:
4751
.. _notation-concat:
4852
.. _notation-compose:
4953

document/core/valid/conventions.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,18 @@ More concretely, contexts are defined as :ref:`records <notation-record>` :math:
6464
\end{array}
6565
\end{array}
6666
67+
.. _notation-extend:
68+
6769
In addition to field access written :math:`C.\K{field}` the following notation is adopted for manipulating contexts:
6870

6971
* When spelling out a context, empty fields are omitted.
7072

71-
* The notation :math:`\K{field}\,A^\ast, C` denotes the same context as :math:`C` but with the elements :math:`A^\ast` prepended to its :math:`\K{field}` component sequence.
73+
* :math:`C,\K{field}\,A^\ast` denotes the same context as :math:`C` but with the elements :math:`A^\ast` prepended to its :math:`\K{field}` component sequence.
7274

7375
.. note::
74-
The notation for context extension is only used in situations where the original :math:`C.\K{field}` is either empty
75-
or :math:`\K{field}` is :math:`\K{labels}`.
76-
It is reversed from usual conventions because it *prepends* not *appends*, in accordance with the use of relative indexing to look up a label in the context's label list.
76+
We use :ref:`indexing notation <notation-index>` like :math:`C.\CLABELS[i]` to look up indices in their respective :ref:`index space <syntax-index>` in the context.
77+
Context extension notation :math:`C,\K{field}\,A` is primarily used to locally extend *relative* index spaces, such as :ref:`label indices <syntax-labelidx>`.
78+
Accordingly, the notation is defined to append at the *front* of the respective sequence, introducing a new relative index :math:`0` and shifting the existing ones.
7779

7880

7981
.. _valid-notation-textual:

document/core/valid/instructions.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,14 @@ Control Instructions
477477

478478
.. math::
479479
\frac{
480-
\CLABELS\,[t^?], C \vdashinstrseq \instr^\ast : [] \to [t^?]
480+
C,\CLABELS\,[t^?] \vdashinstrseq \instr^\ast : [] \to [t^?]
481481
}{
482482
C \vdashinstr \BLOCK~[t^?]~\instr^\ast~\END : [] \to [t^?]
483483
}
484484
485485
.. note::
486+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
487+
486488
The fact that the nested instruction sequence :math:`\instr^\ast` must have type :math:`[] \to [t^?]` implies that it cannot access operands that have been pushed on the stack before the block was entered.
487489
This may be generalized in future versions of WebAssembly.
488490

@@ -501,12 +503,14 @@ Control Instructions
501503

502504
.. math::
503505
\frac{
504-
\CLABELS\,[], C \vdashinstrseq \instr^\ast : [] \to [t^?]
506+
C,\CLABELS\,[] \vdashinstrseq \instr^\ast : [] \to [t^?]
505507
}{
506508
C \vdashinstr \LOOP~[t^?]~\instr^\ast~\END : [] \to [t^?]
507509
}
508510
509511
.. note::
512+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
513+
510514
The fact that the nested instruction sequence :math:`\instr^\ast` must have type :math:`[] \to [t^?]` implies that it cannot access operands that have been pushed on the stack before the loop was entered.
511515
This may be generalized in future versions of WebAssembly.
512516

@@ -528,14 +532,16 @@ Control Instructions
528532

529533
.. math::
530534
\frac{
531-
\CLABELS\,[t^?], C \vdashinstrseq \instr_1^\ast : [] \to [t^?]
535+
C,\CLABELS\,[t^?] \vdashinstrseq \instr_1^\ast : [] \to [t^?]
532536
\qquad
533-
\CLABELS\,[t^?], C \vdashinstrseq \instr_2^\ast : [] \to [t^?]
537+
C,\CLABELS\,[t^?] \vdashinstrseq \instr_2^\ast : [] \to [t^?]
534538
}{
535539
C \vdashinstr \IF~[t^?]~\instr_1^\ast~\ELSE~\instr_2^\ast~\END : [\I32] \to [t^?]
536540
}
537541
538542
.. note::
543+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
544+
539545
The fact that the nested instruction sequence :math:`\instr^\ast` must have type :math:`[] \to [t^?]` implies that it cannot access operands that have been pushed on the stack before the conditional was entered.
540546
This may be generalized in future versions of WebAssembly.
541547

@@ -559,6 +565,8 @@ Control Instructions
559565
}
560566
561567
.. note::
568+
The :ref:`label index <syntax-labelidx>` space in the :ref:`context <context>` :math:`C` contains the most recent label first, so that :math:`C.\CLABELS[l]` performs a relative lookup as expected.
569+
562570
The |BR| instruction is :ref:`stack-polymorphic <polymorphism>`.
563571

564572

@@ -580,6 +588,9 @@ Control Instructions
580588
C \vdashinstr \BRIF~l : [t^?~\I32] \to [t^?]
581589
}
582590
591+
.. note::
592+
The :ref:`label index <syntax-labelidx>` space in the :ref:`context <context>` :math:`C` contains the most recent label first, so that :math:`C.\CLABELS[l]` performs a relative lookup as expected.
593+
583594

584595
.. _valid-br_table:
585596

@@ -608,6 +619,8 @@ Control Instructions
608619
}
609620
610621
.. note::
622+
The :ref:`label index <syntax-labelidx>` space in the :ref:`context <context>` :math:`C` contains the most recent label first, so that :math:`C.\CLABELS[l_i]` performs a relative lookup as expected.
623+
611624
The |BRTABLE| instruction is :ref:`stack-polymorphic <polymorphism>`.
612625

613626

document/core/valid/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Functions :math:`\func` are classified by :ref:`function types <syntax-functype>
4242
\frac{
4343
C.\CTYPES[x] = [t_1^\ast] \to [t_2^?]
4444
\qquad
45-
\CLOCALS\,t_1^\ast~t^\ast,\CLABELS~[t_2^?],\CRETURN~[t_2^?], C \vdashexpr \expr : [t_2^?]
45+
C,\CLOCALS\,t_1^\ast~t^\ast,\CLABELS~[t_2^?],\CRETURN~[t_2^?] \vdashexpr \expr : [t_2^?]
4646
}{
4747
C \vdashfunc \{ \FTYPE~x, \FLOCALS~t^\ast, \FBODY~\expr \} : [t_1^\ast] \to [t_2^?]
4848
}

0 commit comments

Comments
 (0)