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
Copy file name to clipboardExpand all lines: document/core/valid/conventions.rst
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -64,16 +64,18 @@ More concretely, contexts are defined as :ref:`records <notation-record>` :math:
64
64
\end{array}
65
65
\end{array}
66
66
67
+
.. _notation-extend:
68
+
67
69
In addition to field access written :math:`C.\K{field}` the following notation is adopted for manipulating contexts:
68
70
69
71
* When spelling out a context, empty fields are omitted.
70
72
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.
72
74
73
75
.. 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.
C \vdashinstr\BLOCK~[t^?]~\instr^\ast~\END : [] \to [t^?]
483
483
}
484
484
485
485
.. note::
486
+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
487
+
486
488
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.
487
489
This may be generalized in future versions of WebAssembly.
C \vdashinstr\LOOP~[t^?]~\instr^\ast~\END : [] \to [t^?]
507
509
}
508
510
509
511
.. note::
512
+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
513
+
510
514
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.
511
515
This may be generalized in future versions of WebAssembly.
C \vdashinstr\IF~[t^?]~\instr_1^\ast~\ELSE~\instr_2^\ast~\END : [\I32] \to [t^?]
536
540
}
537
541
538
542
.. note::
543
+
The :ref:`notation <notation-extend>` :math:`C,\CLABELS\,[t^?]` inserts the new label type at index :math:`0`, shifting all others.
544
+
539
545
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.
540
546
This may be generalized in future versions of WebAssembly.
541
547
@@ -559,6 +565,8 @@ Control Instructions
559
565
}
560
566
561
567
.. 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
+
562
570
The |BR| instruction is :ref:`stack-polymorphic <polymorphism>`.
563
571
564
572
@@ -580,6 +588,9 @@ Control Instructions
580
588
C \vdashinstr\BRIF~l : [t^?~\I32] \to [t^?]
581
589
}
582
590
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
+
583
594
584
595
.. _valid-br_table:
585
596
@@ -608,6 +619,8 @@ Control Instructions
608
619
}
609
620
610
621
.. 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
+
611
624
The |BRTABLE| instruction is :ref:`stack-polymorphic <polymorphism>`.
0 commit comments