From bf917aa07c7572b85c04e52542a29d055f9afcf9 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Mon, 10 Nov 2025 11:16:56 -0600 Subject: [PATCH 1/3] Spec new encoding from #3 --- specification/wasm-3.0/5.4-binary.modules.spectec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/wasm-3.0/5.4-binary.modules.spectec b/specification/wasm-3.0/5.4-binary.modules.spectec index cc33191cc..302ff2a37 100644 --- a/specification/wasm-3.0/5.4-binary.modules.spectec +++ b/specification/wasm-3.0/5.4-binary.modules.spectec @@ -36,7 +36,7 @@ grammar Bimport : (name, externtype) = grammar Bimports : import* = | nm_1:Bname (nm_2, xt):Bimport => IMPORT nm_1 nm_2 xt - | 0x01 0xFF nm_1:Bname (nm_2, xt)*:Blist(Bimport) => (IMPORT nm_1 nm_2 xt)* + | nm_1:Bname nm_e:Bname 0x7F (nm_2, xt)*:Blist(Bimport) => (IMPORT nm_1 nm_2 xt)* -- if nm_e = "" grammar Bimportsec : import* hint(desc "import section") = | im**:Bsection_(2, Blist(Bimports)) => $concat_(import, im**) From 1d92d096fd46a6931e5b68e47dfa0e70d0765cea Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Mon, 10 Nov 2025 13:33:53 -0600 Subject: [PATCH 2/3] Fix empty name type error --- document/core/binary/modules.rst | 2 +- specification/wasm-3.0/5.4-binary.modules.spectec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/document/core/binary/modules.rst b/document/core/binary/modules.rst index d2f937a87..ccb7b5fe3 100644 --- a/document/core/binary/modules.rst +++ b/document/core/binary/modules.rst @@ -152,7 +152,7 @@ It decodes into the list of :ref:`imports ` of a :ref:`module ` beginning with ${:0x01 0xFF} allows multiple imports to be expressed without repeating the module name. ${:0x01 0xFF} decodes as an invalid :ref:`name ` for compatibility with older implementations. + The encoding of :ref:`imports ` containing ${:0x7F} allows multiple imports to be encoded without repeating the module name. Because ${:0x7F} is not a valid encoding for an :ref:`external type `, the encoding is unambiguous. .. index:: ! function section, function, type index, function type diff --git a/specification/wasm-3.0/5.4-binary.modules.spectec b/specification/wasm-3.0/5.4-binary.modules.spectec index 302ff2a37..8bf570f8e 100644 --- a/specification/wasm-3.0/5.4-binary.modules.spectec +++ b/specification/wasm-3.0/5.4-binary.modules.spectec @@ -36,7 +36,7 @@ grammar Bimport : (name, externtype) = grammar Bimports : import* = | nm_1:Bname (nm_2, xt):Bimport => IMPORT nm_1 nm_2 xt - | nm_1:Bname nm_e:Bname 0x7F (nm_2, xt)*:Blist(Bimport) => (IMPORT nm_1 nm_2 xt)* -- if nm_e = "" + | nm_1:Bname nm_e:Bname 0x7F (nm_2, xt)*:Blist(Bimport) => (IMPORT nm_1 nm_2 xt)* -- if nm_e = eps grammar Bimportsec : import* hint(desc "import section") = | im**:Bsection_(2, Blist(Bimports)) => $concat_(import, im**) From 887d07318e5c18ef62fa20a463851970cfc84457 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Mon, 10 Nov 2025 13:52:31 -0600 Subject: [PATCH 3/3] Fix spectec tests --- spectec/doc/example/output/NanoWasm.pdf | Bin 244263 -> 244263 bytes spectec/test-frontend/TEST.md | 3 ++- spectec/test-latex/TEST.md | 2 +- spectec/test-middlend/TEST.md | 9 ++++++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spectec/doc/example/output/NanoWasm.pdf b/spectec/doc/example/output/NanoWasm.pdf index 2a0cbb015a581d3ea39a2e3ecac8807d39d9db43..24a3018246f0b9eb69b5ba82a8ea306cafd53750 100644 GIT binary patch delta 348 zcmZ4fg>U&6z75Gj^clob+voP8`sr_ z`xCR}*6%4bTfO_hga@XY%KIH$YExP_RV?HB*)X@ZfYtr>oObo_Nx61W)!`j#yKCRy zx@{kH*+#hCMwk(ZnYP;qGryg~ zVQ64zY-(g^GTm?kvoxHyJ!AuO6`Qk(n~RZ)rIV4Np`){@p{u2_nVE%=nW?FniJ7UJ TfvJm~f(;=h+Xc5Xi!lQLW+{?? delta 348 zcmZ4fg>U&6z75Gj^;w4vc-S87p6}!?EfyZ6b9$%PHb?&Ez{7m8{EBC<9lDg0le6A_ zxg^WA$#t9`6&3d|9ol=a{_Ej@l^iUm76{fRH0BxXwmr1)jCsSpOr<|D+t@gq=9y0W z!xsIy;_2GWk#|{{_~IrDJrPd`(_gaS$UFlly94L!c61%t_Wa|?s~NYW&L0e2b29J# z?{{B%N?+Vsf4QRU_nw^vOXhhVIuiI`5_8CsN3Xv;f113XF4ISMqEG!*O9E}|vEuBrAoefPbTpXQ@Eu0K2 UElmt8>=bMWDcLT#omq?-0G;@h0{{R3 diff --git a/spectec/test-frontend/TEST.md b/spectec/test-frontend/TEST.md index c96071b60..03e2f9250 100644 --- a/spectec/test-frontend/TEST.md +++ b/spectec/test-frontend/TEST.md @@ -8717,7 +8717,8 @@ grammar Bimports : import* ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec prod{nm_1 : name, nm_2 : name, xt : externtype} {{nm_1:Bname} {(nm_2, xt):Bimport}} => [IMPORT_import(nm_1, nm_2, xt)] ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec - prod{nm_1 : name, `nm_2*` : name*, `xt*` : externtype*} {{0x01} {0xFF} {nm_1:Bname} {(nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`}:Blist(syntax (name, externtype), grammar Bimport)}} => IMPORT_import(nm_1, nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`} + prod{nm_1 : name, nm_e : name, `nm_2*` : name*, `xt*` : externtype*} {{nm_1:Bname} {nm_e:Bname} {0x7F} {(nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`}:Blist(syntax (name, externtype), grammar Bimport)}} => IMPORT_import(nm_1, nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`} + -- if (nm_e = `%`_name([])) ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec grammar Bimportsec : import* diff --git a/spectec/test-latex/TEST.md b/spectec/test-latex/TEST.md index 15cc55116..9cab84c70 100644 --- a/spectec/test-latex/TEST.md +++ b/spectec/test-latex/TEST.md @@ -12026,7 +12026,7 @@ $$ \begin{array}[t]{@{}lrrl@{}l@{}l@{}l@{}} & {\mathtt{import}} & ::= & {\mathit{nm}}_2{:}{\mathtt{name}}~~{\mathit{xt}}{:}{\mathtt{externtype}} & \quad\Rightarrow\quad{} & ({\mathit{nm}}_2, {\mathit{xt}}) \\ & {\mathtt{imports}} & ::= & {\mathit{nm}}_1{:}{\mathtt{name}}~~({\mathit{nm}}_2, {\mathit{xt}}){:}{\mathtt{import}} & \quad\Rightarrow\quad{} & \mathsf{import}~{\mathit{nm}}_1~{\mathit{nm}}_2~{\mathit{xt}} \\ -& & | & \mathtt{0x01}~~\mathtt{0xFF}~~{\mathit{nm}}_1{:}{\mathtt{name}}~~{({\mathit{nm}}_2, {\mathit{xt}})^\ast}{:}{\mathtt{list}}({\mathtt{import}}) & \quad\Rightarrow\quad{} & {(\mathsf{import}~{\mathit{nm}}_1~{\mathit{nm}}_2~{\mathit{xt}})^\ast} \\ +& & | & {\mathit{nm}}_1{:}{\mathtt{name}}~~{\mathit{nm}}_e{:}{\mathtt{name}}~~\mathtt{0x7F}~~{({\mathit{nm}}_2, {\mathit{xt}})^\ast}{:}{\mathtt{list}}({\mathtt{import}}) & \quad\Rightarrow\quad{} & {(\mathsf{import}~{\mathit{nm}}_1~{\mathit{nm}}_2~{\mathit{xt}})^\ast} & \quad \mbox{if}~ {\mathit{nm}}_e = \epsilon \\ \mbox{(import section)} & {\mathtt{importsec}} & ::= & {{{\mathit{im}}^\ast}^\ast}{:}{{\mathtt{section}}}_{2}({\mathtt{list}}({\mathtt{imports}})) & \quad\Rightarrow\quad{} & {\bigoplus}\, {{{\mathit{im}}^\ast}^\ast} \\ \end{array} $$ diff --git a/spectec/test-middlend/TEST.md b/spectec/test-middlend/TEST.md index f75b85ed8..157523b22 100644 --- a/spectec/test-middlend/TEST.md +++ b/spectec/test-middlend/TEST.md @@ -8707,7 +8707,8 @@ grammar Bimports : import* ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec prod{nm_1 : name, nm_2 : name, xt : externtype} {{nm_1:Bname} {(nm_2, xt):Bimport}} => [IMPORT_import(nm_1, nm_2, xt)] ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec - prod{nm_1 : name, `nm_2*` : name*, `xt*` : externtype*} {{0x01} {0xFF} {nm_1:Bname} {(nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`}:Blist(syntax (name, externtype), grammar Bimport)}} => IMPORT_import(nm_1, nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`} + prod{nm_1 : name, nm_e : name, `nm_2*` : name*, `xt*` : externtype*} {{nm_1:Bname} {nm_e:Bname} {0x7F} {(nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`}:Blist(syntax (name, externtype), grammar Bimport)}} => IMPORT_import(nm_1, nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`} + -- if (nm_e = `%`_name([])) ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec grammar Bimportsec : import* @@ -20058,7 +20059,8 @@ grammar Bimports : import* ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec prod{nm_1 : name, nm_2 : name, xt : externtype} {{nm_1:Bname} {(nm_2, xt):Bimport}} => [IMPORT_import(nm_1, nm_2, xt)] ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec - prod{nm_1 : name, `nm_2*` : name*, `xt*` : externtype*} {{0x01} {0xFF} {nm_1:Bname} {(nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`}:Blist(syntax (name, externtype), grammar Bimport)}} => IMPORT_import(nm_1, nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`} + prod{nm_1 : name, nm_e : name, `nm_2*` : name*, `xt*` : externtype*} {{nm_1:Bname} {nm_e:Bname} {0x7F} {(nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`}:Blist(syntax (name, externtype), grammar Bimport)}} => IMPORT_import(nm_1, nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`} + -- if (nm_e = `%`_name([])) ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec grammar Bimportsec : import* @@ -31588,7 +31590,8 @@ grammar Bimports : import* ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec prod{nm_1 : name, nm_2 : name, xt : externtype} {{nm_1:Bname} {(nm_2, xt):Bimport}} => [IMPORT_import(nm_1, nm_2, xt)] ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec - prod{nm_1 : name, `nm_2*` : name*, `xt*` : externtype*} {{0x01} {0xFF} {nm_1:Bname} {(nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`}:Blist(syntax (name, externtype), grammar Bimport)}} => IMPORT_import(nm_1, nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`} + prod{nm_1 : name, nm_e : name, `nm_2*` : name*, `xt*` : externtype*} {{nm_1:Bname} {nm_e:Bname} {0x7F} {(nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`}:Blist(syntax (name, externtype), grammar Bimport)}} => IMPORT_import(nm_1, nm_2, xt)*{nm_2 <- `nm_2*`, xt <- `xt*`} + -- if (nm_e = `%`_name([])) ;; ../../../../specification/wasm-3.0/5.4-binary.modules.spectec grammar Bimportsec : import*