Skip to content

Commit 0e2749e

Browse files
committed
Create specification/wasm-latest
To give proposal repos a consistent location to make changes to the SpecTec source and to simplify merging those proposals back into the spec repo once they are completed. The new directory is a copy of the wasm-3.0 directory in its current state, created via a sequence of git mv and merge operations to preserve the blame history in both directories. Also add a new CI script ensuring that the contents of wasm-latest match the contents of the highest versioned wasm-X.Y directory. This will ensure that bug fixes are applied in both directories. As a drive-by fix, rename 6.3-text.modules.spectec to 6.4-text.modules.spectec.
2 parents 5084014 + 32177a8 commit 0e2749e

39 files changed

Lines changed: 8872 additions & 4 deletions

.github/workflows/ci-spec.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,25 @@ name: CI for specs
33
on:
44
push:
55
branches: [ main, wasm-3.0 ]
6-
paths: [ .github/**, document/**, spectec/** ]
6+
paths: [ .github/**, document/**, spectec/**, specification/** ]
77

88
pull_request:
99
branches: [ main, wasm-3.0 ]
10-
paths: [ .github/**, document/**, spectec/** ]
10+
paths: [ .github/**, document/**, spectec/**, specification/** ]
1111

1212
# Allows you to run this workflow manually from the Actions tab
1313
workflow_dispatch:
1414

1515
jobs:
16+
ensure-wasm-latest:
17+
if: ${{ github.repository == 'WebAssembly/spec' }}
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repo
21+
uses: actions/checkout@v4
22+
- name: Diff wasm-latest
23+
run: bash .github/workflows/diff-wasm-latest.sh
24+
1625
build-core-spec:
1726
runs-on: ubuntu-latest
1827
steps:
@@ -145,6 +154,7 @@ jobs:
145154
publish-spec:
146155
runs-on: ubuntu-latest
147156
needs:
157+
- ensure-wasm-latest
148158
- build-core-spec
149159
- build-js-api-spec
150160
- build-web-api-spec
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# Identify the highest versioned directory
4+
HIGHEST_VER=$(ls -d specification/wasm-[0-9]* 2>/dev/null | sort -V | tail -n 1)
5+
6+
if [ -z "$HIGHEST_VER" ]; then
7+
echo "❌ Error: No wasm-X.Y versioned directories found in specification/"
8+
exit 1
9+
fi
10+
11+
LATEST="specification/wasm-latest"
12+
13+
# Check that wasm-latest exists
14+
if [ ! -d "$LATEST" ]; then
15+
echo "❌ Error: $LATEST does not exist."
16+
exit 1
17+
fi
18+
19+
# Diff the highest version with wasm-latest and check that the diff is empty
20+
echo "Checking for differences between $HIGHEST_VER and $LATEST..."
21+
22+
if diff -qr "$HIGHEST_VER" "$LATEST" > /dev/null; then
23+
echo "✅ Success: Contents match. No changes needed."
24+
else
25+
echo "🔍 Differences detected:"
26+
echo "--------------------------------"
27+
diff -r "$HIGHEST_VER" "$LATEST"
28+
echo "--------------------------------"
29+
exit 1
30+
fi

.github/workflows/w3c-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
push:
55
# Disable on forks!
66
branches: [ main ]
7-
paths: [ .github/**, document/** ]
7+
paths: [ .github/**, document/**, specification/** ]
88
pull_request:
9-
paths: [ .github/**, document/** ]
9+
paths: [ .github/**, document/**, specification/** ]
1010

1111
# Allows you to run this workflow manually from the Actions tab, gh CLI tool,
1212
# or REST API. THe w3c-status options correspond to the valid options for
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
;;
2+
;; General Variable Conventions
3+
;;
4+
5+
syntax N hint(macro none) = nat
6+
syntax M hint(macro none) = nat
7+
syntax K hint(macro none) = nat
8+
syntax n hint(macro none) = nat ;; hack
9+
syntax m hint(macro none) = nat ;; hack
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
;;
2+
;; General Numeric Functions
3+
;;
4+
5+
def $min(nat, nat) : nat
6+
def $min(i, j) = i -- if $(i <= j)
7+
def $min(i, j) = j -- otherwise
8+
9+
def $sum(nat*) : nat hint(show (+) %) hint(macro none)
10+
def $sum(eps) = 0
11+
def $sum(n n'*) = $(n + $sum(n'*))
12+
13+
def $prod(nat*) : nat hint(show (*) %) hint(macro none)
14+
def $prod(eps) = 1
15+
def $prod(n n'*) = $(n * $prod(n'*))
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
;;
2+
;; General Functions on Sequences
3+
;;
4+
5+
;; Type casting
6+
7+
def $opt_(syntax X, X*) : X? hint(show %2)
8+
def $opt_(syntax X, eps) = eps
9+
def $opt_(syntax X, w) = w
10+
11+
12+
;; Concatenation
13+
14+
def $concat_(syntax X, (X*)*) : X* hint(show (++) %2) hint(inverse $inv_concat_)
15+
def $concat_(syntax X, eps) = eps
16+
def $concat_(syntax X, (w*) (w'*)*) = w* ++ $concat_(X, (w'*)*)
17+
18+
def $concatn_(syntax X, (X*)*, nat) : X* hint(show (++) %2) hint(inverse $inv_concatn_)
19+
def $concatn_(syntax X, eps, n) = eps
20+
def $concatn_(syntax X, (w^n) (w'^n)*, n) = w^n $concatn_(X, (w'^n)*, n)
21+
22+
def $concatopt_(syntax X, (X?)*) : X* hint(show (++) %2)
23+
def $concatopt_(syntax X, eps) = eps
24+
def $concatopt_(syntax X, (w?) (w'?)*) = w? ++ $concat_(X, (w'?)*)
25+
26+
def $inv_concat_(syntax X, X*) : (X*)*
27+
def $inv_concat_ hint(builtin)
28+
29+
def $inv_concatn_(syntax X, nat, X*) : (X*)*
30+
def $inv_concatn_ hint(builtin)
31+
32+
33+
;; Set functions
34+
35+
def $disjoint_(syntax X, X*) : bool hint(show %2 $disjoint) hint(macro none)
36+
def $disjoint_(syntax X, eps) = true
37+
def $disjoint_(syntax X, w w'*) = ~(w <- w'*) /\ $disjoint_(X, w'*)
38+
39+
def $setminus_(syntax X, X*, X*) : X* hint(show %2\%3)
40+
def $setminus1_(syntax X, X, X*) : X*
41+
42+
def $setminus_(syntax X, eps, w*) = eps
43+
def $setminus_(syntax X, w_1 w'*, w*) = $setminus1_(X, w_1, w*) ++ $setminus_(X, w'*, w*)
44+
def $setminus1_(syntax X, w, eps) = w
45+
def $setminus1_(syntax X, w, w_1 w'*) = eps -- if w = w_1
46+
def $setminus1_(syntax X, w, w_1 w'*) = $setminus1_(X, w, w'*) -- otherwise
47+
48+
;; [{1, 2}, {a, b, c}] -> {[1, a], [1, b], [1, c], [2, a], [2, b], [2, c]}
49+
def $setproduct_(syntax X, (X*)*) : (X*)* hint(show %latex("{\\Large\\times}") %2)
50+
def $setproduct1_(syntax X, X*, (X*)*) : (X*)*
51+
def $setproduct2_(syntax X, X, (X*)*) : (X*)*
52+
53+
def $setproduct_(syntax X, eps) = (eps)
54+
def $setproduct_(syntax X, (w_1*) (w*)*) = $setproduct1_(X, w_1*, $setproduct_(X, (w*)*))
55+
def $setproduct1_(syntax X, eps, (w*)*) = eps
56+
def $setproduct1_(syntax X, w_1 w'*, (w*)*) = $setproduct2_(X, w_1, (w*)*) ++ $setproduct1_(X, w'*, (w*)*)
57+
def $setproduct2_(syntax X, w_1, eps) = eps
58+
def $setproduct2_(syntax X, w_1, (w'*) (w*)*) = (w_1 w'*) ++ $setproduct2_(X, w_1, (w*)*)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
;;
2+
;; Profiles
3+
;;
4+
5+
def $ND : bool hint(builtin) ;; non-determinism
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
;;
2+
;; Syntax of Values
3+
;;
4+
5+
;; Integers
6+
7+
syntax bit hint(desc "bit") = 0 | 1
8+
syntax byte hint(desc "byte") = 0x00 | ... | 0xFF
9+
10+
syntax uN(N) hint(desc "unsigned integer") hint(show u#%) hint(macro "uNX") =
11+
0 | ... | $nat$(2^N-1)
12+
syntax sN(N) hint(desc "signed integer") hint(show s#%) hint(macro "sNX") =
13+
-2^(N-1) | ... | -1 | 0 | +1 | ... | +2^(N-1)-1
14+
syntax iN(N) hint(desc "integer") hint(show i#%) hint(macro "iNX") =
15+
uN(N)
16+
17+
syntax u8 = uN(`8)
18+
syntax u16 = uN(`16)
19+
syntax u31 = uN(`31)
20+
syntax u32 = uN(`32)
21+
syntax u64 = uN(`64)
22+
syntax s33 = sN(`33)
23+
syntax i32 = iN(`32)
24+
syntax i64 = iN(`64)
25+
syntax i128 = iN(`128)
26+
27+
var b : byte
28+
29+
30+
;; Floating-point
31+
32+
def $signif(N) : nat
33+
def $signif(32) = 23
34+
def $signif(64) = 52
35+
36+
def $expon(N) : nat
37+
def $expon(32) = 8
38+
def $expon(64) = 11
39+
40+
def $M(N) : nat hint(show `M) hint(macro none)
41+
def $M(N) = $signif(N)
42+
43+
def $E(N) : nat hint(show `E) hint(macro none)
44+
def $E(N) = $expon(N)
45+
46+
syntax fN(N) hint(desc "floating-point number") hint(show f#%) hint(macro "fNX") =
47+
| POS fNmag(N) hint(show $(+%)) \
48+
| NEG fNmag(N) hint(show $(-%))
49+
50+
syntax exp hint(show e) hint(macro none) = int
51+
syntax fNmag(N) hint(desc "floating-point magnitude") hint(show fNmag) =
52+
| NORM m exp hint(show $((1 + %*2^(-$M(N))) * 2^%)) -- if $(m < 2^$M(N) /\ 2-2^($E(N)-1) <= exp <= 2^($E(N)-1)-1)
53+
| SUBNORM m hint(show $((0 + %*2^(-$M(N))) * 2^exp)) -- if $(m < 2^$M(N) /\ 2-2^($E(N)-1) = exp)
54+
| INF hint(show infinity)
55+
| NAN (m) hint(show NAN#(%)) -- if $(1 <= m < 2^$M(N))
56+
57+
syntax f32 = fN(`32)
58+
syntax f64 = fN(`64)
59+
60+
def $fzero(N) : fN(N) hint(show $(+0))
61+
def $fzero(N) = POS (SUBNORM 0)
62+
63+
def $fnat(N, nat) : fN(N) hint(show $(+%))
64+
def $fnat(N, n) = POS (NORM n 0)
65+
66+
def $fone(N) : fN(N) hint(show $(+1))
67+
def $fone(N) = POS (NORM 1 0)
68+
69+
def $canon_(N) : nat
70+
def $canon_(N) = $(2^($signif(N)-1))
71+
72+
73+
;; Vectors
74+
75+
syntax vN(N) hint(desc "vector") hint(show v#%) hint(macro "vNX") =
76+
uN(N)
77+
78+
syntax v128 = vN(`128)
79+
80+
81+
;; Lists
82+
83+
;; TODO(3, rossberg): enable writing X^n
84+
syntax list(syntax X) = X* -- if |X*| < $(2^32)
85+
86+
87+
;; Names
88+
89+
syntax char hint(desc "character") = U+0000 | ... | U+D7FF | U+E000 | ... | U+10FFFF
90+
91+
def $utf8(char*) : byte*
92+
93+
syntax name hint(desc "name") = char* -- if |$utf8(char*)| < $(2^32)
94+
95+
var nm : name
96+
97+
98+
;; Indices
99+
100+
syntax idx hint(desc "index") = u32
101+
syntax laneidx hint(desc "lane index") = u8
102+
103+
syntax typeidx hint(desc "type index") = idx
104+
syntax funcidx hint(desc "function index") = idx
105+
syntax globalidx hint(desc "global index") = idx
106+
syntax tableidx hint(desc "table index") = idx
107+
syntax memidx hint(desc "memory index") = idx
108+
syntax tagidx hint(desc "tag index") = idx
109+
syntax elemidx hint(desc "elem index") = idx
110+
syntax dataidx hint(desc "data index") = idx
111+
syntax labelidx hint(desc "label index") = idx
112+
syntax localidx hint(desc "local index") = idx
113+
syntax fieldidx hint(desc "field index") = idx
114+
115+
syntax externidx hint(desc "external index") hint(macro "%" "XX%") =
116+
| FUNC funcidx | GLOBAL globalidx | TABLE tableidx | MEM memidx | TAG tagidx
117+
118+
var x : idx
119+
var y : idx
120+
var l : labelidx
121+
var xx : externidx
122+
var x33 : s33 hint(show x)
123+
124+
125+
;; Sort projection
126+
127+
;; TODO(3, rossberg): add built-in notation for comprehensions?
128+
129+
def $funcsxx(externidx*) : typeidx* hint(show $funcs(%)) hint(macro "funcsxx")
130+
def $globalsxx(externidx*) : globalidx* hint(show $globals(%)) hint(macro "globalsxx")
131+
def $tablesxx(externidx*) : tableidx* hint(show $tables(%)) hint(macro "tablesxx")
132+
def $memsxx(externidx*) : memidx* hint(show $mems(%)) hint(macro "memsxx")
133+
def $tagsxx(externidx*) : tagidx* hint(show $tags(%)) hint(macro "tagsxx")
134+
135+
def $funcsxx(eps) = eps
136+
def $funcsxx((FUNC x) xx*) = x $funcsxx(xx*)
137+
def $funcsxx(externidx xx*) = $funcsxx(xx*) -- otherwise
138+
139+
def $globalsxx(eps) = eps
140+
def $globalsxx((GLOBAL x) xx*) = x $globalsxx(xx*)
141+
def $globalsxx(externidx xx*) = $globalsxx(xx*) -- otherwise
142+
143+
def $tablesxx(eps) = eps
144+
def $tablesxx((TABLE x) xx*) = x $tablesxx(xx*)
145+
def $tablesxx(externidx xx*) = $tablesxx(xx*) -- otherwise
146+
147+
def $memsxx(eps) = eps
148+
def $memsxx((MEM x) xx*) = x $memsxx(xx*)
149+
def $memsxx(externidx xx*) = $memsxx(xx*) -- otherwise
150+
151+
def $tagsxx(eps) = eps
152+
def $tagsxx((TAG x) xx*) = x $tagsxx(xx*)
153+
def $tagsxx(externidx xx*) = $tagsxx(xx*) -- otherwise
154+
155+
156+
;; Free indices
157+
158+
syntax free =
159+
{ TYPES typeidx*,
160+
FUNCS funcidx*,
161+
GLOBALS globalidx*,
162+
TABLES tableidx*,
163+
MEMS memidx*,
164+
ELEMS elemidx*,
165+
DATAS dataidx*,
166+
LOCALS localidx*,
167+
LABELS labelidx*
168+
}
169+
170+
171+
def $free_opt(free?) : free
172+
def $free_list(free*) : free
173+
174+
def $free_opt(eps) = {}
175+
def $free_opt(free) = free
176+
177+
def $free_list(eps) = {}
178+
def $free_list(free free'*) = free ++ $free_list(free'*)
179+
180+
181+
def $free_typeidx(typeidx) : free
182+
def $free_funcidx(funcidx) : free
183+
def $free_globalidx(globalidx) : free
184+
def $free_tableidx(tableidx) : free
185+
def $free_memidx(memidx) : free
186+
def $free_elemidx(elemidx) : free
187+
def $free_dataidx(dataidx) : free
188+
def $free_localidx(localidx) : free
189+
def $free_labelidx(labelidx) : free
190+
def $free_externidx(externidx) : free
191+
192+
def $free_typeidx(typeidx) = {TYPES typeidx}
193+
def $free_funcidx(funcidx) = {FUNCS funcidx}
194+
def $free_globalidx(globalidx) = {GLOBALS globalidx}
195+
def $free_tableidx(tableidx) = {TABLES tableidx}
196+
def $free_memidx(memidx) = {MEMS memidx}
197+
def $free_elemidx(elemidx) = {ELEMS elemidx}
198+
def $free_dataidx(dataidx) = {DATAS dataidx}
199+
def $free_localidx(localidx) = {LOCALS localidx}
200+
def $free_labelidx(labelidx) = {LABELS labelidx}
201+
202+
def $free_externidx(FUNC funcidx) = $free_funcidx(funcidx)
203+
def $free_externidx(GLOBAL globalidx) = $free_globalidx(globalidx)
204+
def $free_externidx(TABLE tableidx) = $free_tableidx(tableidx)
205+
def $free_externidx(MEM memidx) = $free_memidx(memidx)

0 commit comments

Comments
 (0)