Skip to content

Commit 76e0d6b

Browse files
authored
Merge pull request #377 from WebAssembly/spec.valid-instr
Validation of instructions (plus some infra and fixes)
2 parents 6b8ccab + 16e6620 commit 76e0d6b

File tree

11 files changed

+761
-109
lines changed

11 files changed

+761
-109
lines changed

Diff for: document/core/exec/instructions.rst

+36-34
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ Reference Instructions
462462
S; F; \val^n~(\STRUCTNEW~x) &\stepto& S'; F; (\REFSTRUCTADDR~|S.\SSTRUCTS|)
463463
\\&&
464464
\begin{array}[t]{@{}r@{~}l@{}}
465-
(\iff & F.\AMODULE.\MITYPES[x] = \TSTRUCT~\X{ft}^n \\
465+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
466466
\land & \X{si} = \{\SITYPE~F.\AMODULE.\MITYPES[x], \SIFIELDS~(\packval_{\X{ft}}(\val))^n\} \\
467467
\land & S' = S \with \SSTRUCTS = S.\SSTRUCTS~\X{si})
468468
\end{array} \\
@@ -501,7 +501,7 @@ Reference Instructions
501501
F; (\STRUCTNEWDEFAULT~x) &\stepto& (\default_{\unpacktype(\X{ft})}))^n~(\STRUCTNEW~x)
502502
\\&&
503503
\begin{array}[t]{@{}r@{~}l@{}}
504-
(\iff & F.\AMODULE.\MITYPES[x] = \TSTRUCT~\X{ft}^n)
504+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n)
505505
\end{array} \\
506506
\end{array}
507507
@@ -511,7 +511,7 @@ Reference Instructions
511511
S; F; (\STRUCTNEWDEFAULT~x) &\stepto& S'; F; (\REFSTRUCTADDR~|S.\SSTRUCTS|)
512512
\\&&
513513
\begin{array}[t]{@{}r@{~}l@{}}
514-
(\iff & F.\AMODULE.\MITYPES[x] = \TSTRUCT~\X{ft}^n \\
514+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
515515
\land & \X{si} = \{\SITYPE~F.\AMODULE.\MITYPES[x], \SIFIELDS~(\packval_{\X{ft}}(\default_{\unpacktype(\X{ft})}))^n\} \\
516516
\land & S' = S \with \SSTRUCTS = S.\SSTRUCTS~\X{si})
517517
\end{array} \\
@@ -561,7 +561,7 @@ Reference Instructions
561561
S; F; (\REFSTRUCTADDR~a)~(\STRUCTGET\K{\_}\sx^?~x~i) &\stepto& \val
562562
&
563563
\begin{array}[t]{@{}r@{~}l@{}}
564-
(\iff & F.\AMODULE.\MITYPES[x] = \TSTRUCT~\X{ft}^\ast \\
564+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
565565
\land & \val = \unpackval^{\sx^?}_{\X{ft}^\ast[i]}(S.\SSTRUCTS[a].\SIFIELDS[i]))
566566
\end{array} \\
567567
S; F; (\REFNULL~t)~(\STRUCTGET\K{\_}\sx^?~x~i) &\stepto& \TRAP
@@ -612,7 +612,7 @@ Reference Instructions
612612
S; F; (\REFSTRUCTADDR~a)~\val~(\STRUCTSET~x~i) &\stepto& S'; \epsilon
613613
&
614614
\begin{array}[t]{@{}r@{~}l@{}}
615-
(\iff & F.\AMODULE.\MITYPES[x] = \TSTRUCT~\X{ft}^\ast \\
615+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
616616
\land & S' = S \with \SSTRUCTS[a].\SIFIELDS[i] = \packval_{\X{ft}^\ast[i]}(\val))
617617
\end{array} \\
618618
S; F; (\REFNULL~t)~\val~(\STRUCTSET~x~i) &\stepto& \TRAP
@@ -657,7 +657,7 @@ Reference Instructions
657657
S; F; \val~(\I32.\CONST~n)~(\ARRAYNEW~x) &\stepto& S'; F; (\REFARRAYADDR~|S.\SARRAYS|)
658658
\\&&
659659
\begin{array}[t]{@{}r@{~}l@{}}
660-
(\iff & F.\AMODULE.\MITYPES[x] = \TARRAY~\X{ft} \\
660+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
661661
\land & \X{ai} = \{\AITYPE~F.\AMODULE.\MITYPES[x], \AIFIELDS~(\packval_{\X{ft}}(\val))^n\} \\
662662
\land & S' = S \with \SARRAYS = S.\SARRAYS~\X{ai})
663663
\end{array} \\
@@ -696,7 +696,7 @@ Reference Instructions
696696
F; (\I32.\CONST~n)~(\ARRAYNEWDEFAULT~x) &\stepto& (\default_{\unpacktype(\X{ft}}))^n~(\ARRAYNEWFIXED~x~n)
697697
\\&&
698698
\begin{array}[t]{@{}r@{~}l@{}}
699-
(\iff & F.\AMODULE.\MITYPES.\MITYPES[x] = \TARRAY~\X{ft})
699+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft})
700700
\end{array} \\
701701
\end{array}
702702
@@ -706,7 +706,7 @@ Reference Instructions
706706
S; F; (\I32.\CONST~n)~(\ARRAYNEWDEFAULT~x) &\stepto& S'; F; (\REFARRAYADDR~|S.\SARRAYS|)
707707
\\&&
708708
\begin{array}[t]{@{}r@{~}l@{}}
709-
(\iff & F.\AMODULE.\MITYPES[x] = \TARRAY~\X{ft} \\
709+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
710710
\land & \X{ai} = \{\AITYPE~F.\AMODULE.\MITYPES[x], \AIFIELDS~(\packval_{\X{ft}}(\default_{\unpacktype(\X{ft}}))^n\} \\
711711
\land & S' = S \with \SARRAYS = S.\SARRAYS~\X{ai})
712712
\end{array} \\
@@ -751,7 +751,7 @@ Reference Instructions
751751
S; F; \val^n~(\ARRAYNEWFIXED~x~n) &\stepto& S'; F; (\REFARRAYADDR~|S.\SARRAYS|)
752752
\\&&
753753
\begin{array}[t]{@{}r@{~}l@{}}
754-
(\iff & F.\AMODULE.\MITYPES[x] = \TARRAY~\X{ft} \\
754+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
755755
\land & \X{ai} = \{\AITYPE~F.\AMODULE.\MITYPES[x], \AIFIELDS~(\packval_{\X{ft}}(\val))^n\} \\
756756
\land & S' = S \with \SARRAYS = S.\SARRAYS~\X{ai})
757757
\end{array} \\
@@ -814,14 +814,14 @@ Reference Instructions
814814
S; F; (\I32.\CONST~s)~(\I32.\CONST~n)~(\ARRAYNEWDATA~x~y) &\stepto& \TRAP
815815
\\&&
816816
\begin{array}[t]{@{}r@{~}l@{}}
817-
(\iff & F.\AMODULE.\MITYPES[x] = \TARRAY~\X{ft}^n \\
817+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
818818
\land & s + n\cdot|\X{ft}| > |S.\SDATAS[F.\AMODULE.\MIDATAS[y]].\DIDATA|)
819819
\end{array} \\
820820
\\[1ex]
821821
S; F; (\I32.\CONST~s)~(\I32.\CONST~n)~(\ARRAYNEWDATA~x~y) &\stepto& (t.\CONST~c)^n~(\ARRAYNEWFIXED~x~n)
822822
\\&&
823823
\begin{array}[t]{@{}r@{~}l@{}}
824-
(\iff & F.\AMODULE.\MITYPES[x] = \TARRAY~\X{ft}^n \\
824+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft}^n \\
825825
\land & t = \unpacktype(\X{ft}) \\
826826
\land & (\bytes_{\X{ft}}(c))^n = S.\SDATAS[F.\AMODULE.\MIDATAS[y]].\DIDATA[s \slice n\cdot|\X{ft}|] \\
827827
\end{array} \\
@@ -931,7 +931,7 @@ Reference Instructions
931931
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~i)~(\ARRAYGET\K{\_}\sx^?~x) &\stepto& \val
932932
&
933933
\begin{array}[t]{@{}r@{~}l@{}}
934-
(\iff & F.\AMODULE.\MITYPES[x] = \TARRAY~\X{ft} \\
934+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TARRAY~\X{ft} \\
935935
\land & \val = \unpackval^{\sx^?}_{\X{ft}}(S.\SARRAYS[a].\AIFIELDS[i]))
936936
\end{array} \\
937937
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~i)~(\ARRAYGET\K{\_}\sx^?~x) &\stepto& \val
@@ -990,7 +990,7 @@ Reference Instructions
990990
S; F; (\REFARRAYADDR~a)~(\I32.\CONST~i)~\val~(\ARRAYSET~x) &\stepto& S'; \epsilon
991991
&
992992
\begin{array}[t]{@{}r@{~}l@{}}
993-
(\iff & F.\AMODULE.\MITYPES[x] = \TSTRUCT~\X{ft}^n \\
993+
(\iff & \expand(F.\AMODULE.\MITYPES[x]) = \TSTRUCT~\X{ft}^n \\
994994
\land & S' = S \with \SARRAYS[a].\AIFIELDS[i] = \packval_{\X{ft}}(\val))
995995
\end{array} \\
996996
S; F; (\REFNULL~t)~(\I32.\CONST~i)~\val~(\ARRAYSET~x) &\stepto& \TRAP
@@ -3589,9 +3589,9 @@ Control Instructions
35893589

35903590
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.
35913591

3592-
2. Assert: due to :ref:`validation <valid-blocktype>`, :math:`\expand_{S;F}(\blocktype)` is defined.
3592+
2. Assert: due to :ref:`validation <valid-blocktype>`, :math:`\fblocktype_{S;F}(\blocktype)` is defined.
35933593

3594-
3. Let :math:`[t_1^m] \to [t_2^n]` be the :ref:`instruction type <syntax-instrtype>` :math:`\expand_{S;F}(\blocktype)`.
3594+
3. Let :math:`[t_1^m] \to [t_2^n]` be the :ref:`instruction type <syntax-instrtype>` :math:`\fblocktype_{S;F}(\blocktype)`.
35953595

35963596
4. Let :math:`L` be the label whose arity is :math:`n` and whose continuation is the end of the block.
35973597

@@ -3606,7 +3606,7 @@ Control Instructions
36063606
\begin{array}{lcl}
36073607
S; F; \val^m~\BLOCK~\X{bt}~\instr^\ast~\END &\stepto&
36083608
S; F; \LABEL_n\{\epsilon\}~\val^m~\instr^\ast~\END
3609-
\\&&\quad (\iff \expand_{S;F}(\X{bt}) = [t_1^m] \to [t_2^n])
3609+
\\&&\quad (\iff \fblocktype_{S;F}(\X{bt}) = [t_1^m] \to [t_2^n])
36103610
\end{array}
36113611
36123612
@@ -3617,9 +3617,9 @@ Control Instructions
36173617

36183618
1. Let :math:`F` be the :ref:`current <exec-notation-textual>` :ref:`frame <syntax-frame>`.
36193619

3620-
2. Assert: due to :ref:`validation <valid-blocktype>`, :math:`\expand_{S;F}(\blocktype)` is defined.
3620+
2. Assert: due to :ref:`validation <valid-blocktype>`, :math:`\fblocktype_{S;F}(\blocktype)` is defined.
36213621

3622-
3. Let :math:`[t_1^m] \to [t_2^n]` be the :ref:`instruction type <syntax-instrtype>` :math:`\expand_{S;F}(\blocktype)`.
3622+
3. Let :math:`[t_1^m] \to [t_2^n]` be the :ref:`instruction type <syntax-instrtype>` :math:`\fblocktype_{S;F}(\blocktype)`.
36233623

36243624
4. Let :math:`L` be the label whose arity is :math:`m` and whose continuation is the start of the loop.
36253625

@@ -3634,7 +3634,7 @@ Control Instructions
36343634
\begin{array}{lcl}
36353635
S; F; \val^m~\LOOP~\X{bt}~\instr^\ast~\END &\stepto&
36363636
S; F; \LABEL_m\{\LOOP~\X{bt}~\instr^\ast~\END\}~\val^m~\instr^\ast~\END
3637-
\\&&\quad (\iff \expand_{S;F}(\X{bt}) = [t_1^m] \to [t_2^n])
3637+
\\&&\quad (\iff \fblocktype_{S;F}(\X{bt}) = [t_1^m] \to [t_2^n])
36383638
\end{array}
36393639
36403640
@@ -3978,9 +3978,9 @@ Control Instructions
39783978

39793979
5. Let :math:`\X{tab}` be the :ref:`table instance <syntax-tableinst>` :math:`S.\STABLES[\X{ta}]`.
39803980

3981-
6. Assert: due to :ref:`validation <valid-call_indirect>`, :math:`F.\AMODULE.\MITYPES[y]` exists.
3981+
6. Assert: due to :ref:`validation <valid-call_indirect>`, :math:`F.\AMODULE.\MITYPES[y]` is defined.
39823982

3983-
7. Let :math:`\X{ft}_{\F{expect}}` be the :ref:`function type <syntax-functype>` :math:`F.\AMODULE.\MITYPES[y]`.
3983+
7. Let :math:`\X{dt}_{\F{expect}}` be the :ref:`defined type <syntax-deftype>` :math:`F.\AMODULE.\MITYPES[y]`.
39843984

39853985
8. Assert: due to :ref:`validation <valid-call_indirect>`, a value with :ref:`value type <syntax-valtype>` |I32| is on the top of the stack.
39863986

@@ -4004,9 +4004,9 @@ Control Instructions
40044004

40054005
16. Let :math:`\X{f}` be the :ref:`function instance <syntax-funcinst>` :math:`S.\SFUNCS[a]`.
40064006

4007-
17. Let :math:`\X{ft}_{\F{actual}}` be the :ref:`function type <syntax-functype>` :math:`\X{f}.\FITYPE`.
4007+
17. Let :math:`\X{dt}_{\F{actual}}` be the :ref:`defined type <syntax-deftype>` :math:`\X{f}.\FITYPE`.
40084008

4009-
18. If :math:`\X{ft}_{\F{actual}}` and :math:`\X{ft}_{\F{expect}}` differ, then:
4009+
18. If :math:`\X{dt}_{\F{actual}}` does not :ref:`match <match-deftype>` :math:`\X{dt}_{\F{expect}}`, then:
40104010

40114011
a. Trap.
40124012

@@ -4022,7 +4022,7 @@ Control Instructions
40224022
\begin{array}[t]{@{}r@{~}l@{}}
40234023
(\iff & S.\STABLES[F.\AMODULE.\MITABLES[x]].\TIELEM[i] = \REFFUNCADDR~a \\
40244024
\wedge & S.\SFUNCS[a] = f \\
4025-
\wedge & S \vdashfunctypematch F.\AMODULE.\MITYPES[y] \matchesfunctype f.\FITYPE)
4025+
\wedge & S \vdashdeftypematch F.\AMODULE.\MITYPES[y] \matchesdeftype f.\FITYPE)
40264026
\end{array}
40274027
\\[1ex]
40284028
\begin{array}{lcl@{\qquad}l}
@@ -4099,9 +4099,9 @@ Control Instructions
40994099

41004100
5. Let :math:`\X{tab}` be the :ref:`table instance <syntax-tableinst>` :math:`S.\STABLES[\X{ta}]`.
41014101

4102-
6. Assert: due to :ref:`validation <valid-call_indirect>`, :math:`F.\AMODULE.\MITYPES[x]` exists.
4102+
6. Assert: due to :ref:`validation <valid-call_indirect>`, :math:`F.\AMODULE.\MITYPES[x]` is defined.
41034103

4104-
7. Let :math:`\X{ft}_{\F{expect}}` be the :ref:`function type <syntax-functype>` :math:`F.\AMODULE.\MITYPES[x]`.
4104+
7. Let :math:`\X{dt}_{\F{expect}}` be the :ref:`defined type <syntax-deftype>` :math:`F.\AMODULE.\MITYPES[x]`.
41054105

41064106
8. Assert: due to :ref:`validation <valid-call_indirect>`, a value with :ref:`value type <syntax-valtype>` |I32| is on the top of the stack.
41074107

@@ -4121,9 +4121,9 @@ Control Instructions
41214121

41224122
14. Let :math:`\X{f}` be the :ref:`function instance <syntax-funcinst>` :math:`S.\SFUNCS[a]`.
41234123

4124-
15. Let :math:`\X{ft}_{\F{actual}}` be the :ref:`function type <syntax-functype>` :math:`\X{f}.\FITYPE`.
4124+
15. Let :math:`\X{dt}_{\F{actual}}` be the :ref:`defined type <syntax-functype>` :math:`\X{f}.\FITYPE`.
41254125

4126-
16. If :math:`\X{ft}_{\F{actual}}` and :math:`\X{ft}_{\F{expect}}` differ, then:
4126+
16. If :math:`\X{dt}_{\F{actual}}` does not :ref:`match <match-functype>` :math:`\X{dt}_{\F{expect}}`, then:
41274127

41284128
a. Trap.
41294129

@@ -4210,7 +4210,7 @@ Invocation of :ref:`function address <syntax-funcaddr>` :math:`a`
42104210

42114211
2. Let :math:`f` be the :ref:`function instance <syntax-funcinst>`, :math:`S.\SFUNCS[a]`.
42124212

4213-
3. Let :math:`[t_1^n] \toF [t_2^m]` be the :ref:`function type <syntax-functype>` :math:`\X{f}.\FITYPE`.
4213+
3. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`structured type <syntax-strtype>` :math:`\expand(\X{f}.\FITYPE)`.
42144214

42154215
4. Let :math:`\local^\ast` be the list of :ref:`locals <syntax-local>` :math:`f.\FICODE.\FLOCALS`.
42164216

@@ -4237,7 +4237,7 @@ Invocation of :ref:`function address <syntax-funcaddr>` :math:`a`
42374237
\\ \qquad
42384238
\begin{array}[t]{@{}r@{~}l@{}}
42394239
(\iff & S.\SFUNCS[a] = f \\
4240-
\wedge & S.f.\FITYPE = [t_1^n] \toF [t_2^m] \\
4240+
\wedge & \expand(S.f.\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m] \\
42414241
\wedge & f.\FICODE = \{ \FTYPE~x, \FLOCALS~\{\LTYPE~t\}^k, \FBODY~\instr^\ast~\END \} \\
42424242
\wedge & F = \{ \AMODULE~f.\FIMODULE, ~\ALOCALS~\val^n~(\default_t)^k \})
42434243
\end{array} \\
@@ -4254,7 +4254,7 @@ Tail-invocation of :ref:`function address <syntax-funcaddr>` :math:`a`
42544254

42554255
1. Assert: due to :ref:`validation <valid-call>`, :math:`S.\SFUNCS[a]` exists.
42564256

4257-
2. Let :math:`[t_1^n] \toF [t_2^m]` be the :ref:`function type <syntax-functype>` :math:`S.\SFUNCS[a].\FITYPE`.
4257+
2. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`structured type <syntax-strtype>` :math:`\expand(S.\SFUNCS[a].\FITYPE)`.
42584258

42594259
3. Assert: due to :ref:`validation <valid-return_call>`, there are at least :math:`n` values on the top of the stack.
42604260

@@ -4279,7 +4279,7 @@ Tail-invocation of :ref:`function address <syntax-funcaddr>` :math:`a`
42794279
\begin{array}{lcl@{\qquad}l}
42804280
S; \FRAME_m\{F\}~B^\ast[\val^n~(\RETURNINVOKE~a)]~\END &\stepto&
42814281
\val^n~(\INVOKE~a)
4282-
& (\iff S.\SFUNCS[a].\FITYPE = [t_1^n] \toF [t_2^m])
4282+
& (\iff \expand(S.\SFUNCS[a].\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m])
42834283
\end{array}
42844284
42854285
@@ -4336,15 +4336,17 @@ Furthermore, the resulting store must be :ref:`valid <valid-store>`, i.e., all d
43364336
\end{array}
43374337
\\ \qquad
43384338
\begin{array}[t]{@{}r@{~}l@{}}
4339-
(\iff & S.\SFUNCS[a] = \{ \FITYPE~[t_1^n] \toF [t_2^m], \FIHOSTCODE~\X{hf} \} \\
4339+
(\iff & S.\SFUNCS[a] = \{ \FITYPE~\deftype, \FIHOSTCODE~\X{hf} \} \\
4340+
\wedge & \expand(\deftype) = \TFUNC~[t_1^n] \toF [t_2^m] \\
43404341
\wedge & (S'; \result) \in \X{hf}(S; \val^n)) \\
43414342
\end{array} \\
43424343
\begin{array}{lcl@{\qquad}l}
43434344
S; \val^n~(\INVOKE~a) &\stepto& S; \val^n~(\INVOKE~a)
43444345
\end{array}
43454346
\\ \qquad
43464347
\begin{array}[t]{@{}r@{~}l@{}}
4347-
(\iff & S.\SFUNCS[a] = \{ \FITYPE~[t_1^n] \toF [t_2^m], \FIHOSTCODE~\X{hf} \} \\
4348+
(\iff & S.\SFUNCS[a] = \{ \FITYPE~\deftype, \FIHOSTCODE~\X{hf} \} \\
4349+
\wedge & \expand(\deftype) = \TFUNC~[t_1^n] \toF [t_2^m] \\
43484350
\wedge & \bot \in \X{hf}(S; \val^n)) \\
43494351
\end{array} \\
43504352
\end{array}

Diff for: document/core/exec/modules.rst

+12-10
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ New instances of :ref:`functions <syntax-funcinst>`, :ref:`tables <syntax-tablei
2121

2222
1. Let :math:`\func` be the :ref:`function <syntax-func>` to allocate and :math:`\moduleinst` its :ref:`module instance <syntax-moduleinst>`.
2323

24-
2. Let :math:`\functype` be the :ref:`function type <syntax-functype>` :math:`\moduleinst.\MITYPES[\func.\FTYPE]`.
24+
2. Let :math:`\deftype` be the :ref:`defined type <syntax-deftype>` :math:`\moduleinst.\MITYPES[\func.\FTYPE]`.
2525

2626
3. Let :math:`a` be the first free :ref:`function address <syntax-funcaddr>` in :math:`S`.
2727

28-
4. Let :math:`\funcinst` be the :ref:`function instance <syntax-funcinst>` :math:`\{ \FITYPE~\functype, \FIMODULE~\moduleinst, \FICODE~\func \}`.
28+
4. Let :math:`\funcinst` be the :ref:`function instance <syntax-funcinst>` :math:`\{ \FITYPE~\deftype, \FIMODULE~\moduleinst, \FICODE~\func \}`.
2929

3030
6. Append :math:`\funcinst` to the |SFUNCS| of :math:`S`.
3131

@@ -36,9 +36,9 @@ New instances of :ref:`functions <syntax-funcinst>`, :ref:`tables <syntax-tablei
3636
\begin{array}{rlll}
3737
\allocfunc(S, \func, \moduleinst) &=& S', \funcaddr \\[1ex]
3838
\mbox{where:} \hfill \\
39-
\functype &=& \moduleinst.\MITYPES[\func.\FTYPE] \\
39+
\deftype &=& \moduleinst.\MITYPES[\func.\FTYPE] \\
4040
\funcaddr &=& |S.\SFUNCS| \\
41-
\funcinst &=& \{ \FITYPE~\functype, \FIMODULE~\moduleinst, \FICODE~\func \} \\
41+
\funcinst &=& \{ \FITYPE~\deftype, \FIMODULE~\moduleinst, \FICODE~\func \} \\
4242
S' &=& S \compose \{\SFUNCS~\funcinst\} \\
4343
\end{array}
4444
@@ -49,11 +49,11 @@ New instances of :ref:`functions <syntax-funcinst>`, :ref:`tables <syntax-tablei
4949
:ref:`Host Functions <syntax-hostfunc>`
5050
.......................................
5151

52-
1. Let :math:`\hostfunc` be the :ref:`host function <syntax-hostfunc>` to allocate and :math:`\functype` its :ref:`function type <syntax-functype>`.
52+
1. Let :math:`\hostfunc` be the :ref:`host function <syntax-hostfunc>` to allocate and :math:`\deftype` its :ref:`defined type <syntax-functype>`.
5353

5454
2. Let :math:`a` be the first free :ref:`function address <syntax-funcaddr>` in :math:`S`.
5555

56-
3. Let :math:`\funcinst` be the :ref:`function instance <syntax-funcinst>` :math:`\{ \FITYPE~\functype, \FIHOSTCODE~\hostfunc \}`.
56+
3. Let :math:`\funcinst` be the :ref:`function instance <syntax-funcinst>` :math:`\{ \FITYPE~\deftype, \FIHOSTCODE~\hostfunc \}`.
5757

5858
4. Append :math:`\funcinst` to the |SFUNCS| of :math:`S`.
5959

@@ -62,10 +62,10 @@ New instances of :ref:`functions <syntax-funcinst>`, :ref:`tables <syntax-tablei
6262
.. math::
6363
~\\[-1ex]
6464
\begin{array}{rlll}
65-
\allochostfunc(S, \functype, \hostfunc) &=& S', \funcaddr \\[1ex]
65+
\allochostfunc(S, \deftype, \hostfunc) &=& S', \funcaddr \\[1ex]
6666
\mbox{where:} \hfill \\
6767
\funcaddr &=& |S.\SFUNCS| \\
68-
\funcinst &=& \{ \FITYPE~\functype, \FIHOSTCODE~\hostfunc \} \\
68+
\funcinst &=& \{ \FITYPE~\deftype, \FIHOSTCODE~\hostfunc \} \\
6969
S' &=& S \compose \{\SFUNCS~\funcinst\} \\
7070
\end{array}
7171
@@ -381,6 +381,8 @@ and list of :ref:`reference <syntax-ref>` vectors for the module's :ref:`element
381381
382382
where:
383383

384+
.. todo:: adjust deftypes
385+
384386
.. math::
385387
\begin{array}{@{}rlll@{}}
386388
\table^\ast &=& \module.\MTABLES \\
@@ -663,7 +665,7 @@ The following steps are performed:
663665

664666
2. Let :math:`\funcinst` be the :ref:`function instance <syntax-funcinst>` :math:`S.\SFUNCS[\funcaddr]`.
665667

666-
3. Let :math:`[t_1^n] \toF [t_2^m]` be the :ref:`function type <syntax-functype>` :math:`\funcinst.\FITYPE`.
668+
3. Let :math:`\TFUNC~[t_1^n] \toF [t_2^m]` be the :ref:`structured type <syntax-strtype>` :math:`\expand(\funcinst.\FITYPE)`.
667669

668670
4. If the length :math:`|\val^\ast|` of the provided argument values is different from the number :math:`n` of expected arguments, then:
669671

@@ -695,7 +697,7 @@ The values :math:`\val_{\F{res}}^m` are returned as the results of the invocatio
695697
~\\[-1ex]
696698
\begin{array}{@{}lcl}
697699
\invoke(S, \funcaddr, \val^n) &=& S; F; \val^n~(\INVOKE~\funcaddr) \\
698-
&(\iff & S.\SFUNCS[\funcaddr].\FITYPE = [t_1^n] \toF [t_2^m] \\
700+
&(\iff & \expand(S.\SFUNCS[\funcaddr].\FITYPE) = \TFUNC~[t_1^n] \toF [t_2^m] \\
699701
&\wedge& (S \vdashval \val : t_1)^n \\
700702
&\wedge& F = \{ \AMODULE~\{\}, \ALOCALS~\epsilon \}) \\
701703
\end{array}

0 commit comments

Comments
 (0)