wesl 0.6.7 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +36 -9
- package/dist/index.js.map +1 -1
- package/dist/minified.js +1124 -1091
- package/dist/minified.js.map +1 -1
- package/dist/tools/packages/wesl/src/Linker.d.ts +2 -0
- package/package.json +4 -8
- package/src/Assertions.ts +1 -1
- package/src/BindIdents.ts +1 -1
- package/src/Linker.ts +10 -0
- package/src/WESLCollect.ts +4 -3
- package/src/debug/ASTtoString.ts +0 -2
- package/src/debug/ScopeToString.ts +2 -2
- package/src/test/TransformBindingStructs.test.ts +1 -1
package/dist/minified.js
CHANGED
|
@@ -1,56 +1,60 @@
|
|
|
1
|
-
var
|
|
1
|
+
var tr = Object.defineProperty;
|
|
2
|
+
var ve = (t) => {
|
|
2
3
|
throw TypeError(t);
|
|
3
4
|
};
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
|
|
5
|
+
var er = (t, e, n) => e in t ? tr(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
6
|
+
var w = (t, e, n) => er(t, typeof e != "symbol" ? e + "" : e, n), Se = (t, e, n) => e.has(t) || ve("Cannot " + n);
|
|
7
|
+
var b = (t, e, n) => (Se(t, e, "read from private field"), n ? n.call(t) : e.get(t)), B = (t, e, n) => e.has(t) ? ve("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), R = (t, e, n, r) => (Se(t, e, "write to private field"), r ? r.call(t, n) : e.set(t, n), n);
|
|
8
|
+
function nr(t, e) {
|
|
7
9
|
if (!t)
|
|
8
10
|
throw new Error(e);
|
|
9
11
|
}
|
|
10
|
-
function
|
|
11
|
-
throw new
|
|
12
|
+
function Nt(t) {
|
|
13
|
+
throw new rr("Unreachable value", { data: t });
|
|
12
14
|
}
|
|
13
|
-
let
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
15
|
+
let rr = class extends Error {
|
|
16
|
+
constructor(n, r) {
|
|
17
|
+
super(n, r);
|
|
18
|
+
w(this, "data");
|
|
19
|
+
this.data = r == null ? void 0 : r.data;
|
|
16
20
|
}
|
|
17
|
-
},
|
|
18
|
-
function
|
|
19
|
-
|
|
21
|
+
}, sr = console.log;
|
|
22
|
+
function or(t, e, ...n) {
|
|
23
|
+
ir(sr, t, e, ...n);
|
|
20
24
|
}
|
|
21
|
-
function
|
|
25
|
+
function je(t) {
|
|
22
26
|
return t ? `'${t.replace(/\n/g, "\\n")}'` : "";
|
|
23
27
|
}
|
|
24
|
-
function
|
|
28
|
+
function ir(t, e, n, ...r) {
|
|
25
29
|
if (typeof e == "string") {
|
|
26
|
-
|
|
30
|
+
ye(t, e, n, ...r);
|
|
27
31
|
return;
|
|
28
32
|
}
|
|
29
|
-
const { src: s, positions: o } =
|
|
30
|
-
|
|
33
|
+
const { src: s, positions: o } = ar(e, n);
|
|
34
|
+
ye(t, s.text, o, ...r);
|
|
31
35
|
}
|
|
32
|
-
function
|
|
36
|
+
function ar(t, e) {
|
|
33
37
|
var o, i, a, c;
|
|
34
38
|
const n = t.mapPositions(...[e].flat()), { src: r } = n[0];
|
|
35
39
|
let s;
|
|
36
40
|
return ((i = (o = n[1]) == null ? void 0 : o.src) == null ? void 0 : i.path) === r.path && ((c = (a = n[1]) == null ? void 0 : a.src) == null ? void 0 : c.text) === r.text ? s = n.map((l) => l.position) : s = n[0].position, { src: r, positions: s };
|
|
37
41
|
}
|
|
38
|
-
function
|
|
42
|
+
function ye(t, e, n, ...r) {
|
|
39
43
|
t(...r);
|
|
40
|
-
const { line: s, lineNum: o, linePos: i, linePos2: a } =
|
|
44
|
+
const { line: s, lineNum: o, linePos: i, linePos2: a } = lr(e, n);
|
|
41
45
|
t(s, ` Ln ${o}`);
|
|
42
|
-
const c =
|
|
46
|
+
const c = cr(i, a);
|
|
43
47
|
t(c);
|
|
44
48
|
}
|
|
45
|
-
function
|
|
49
|
+
function cr(t, e) {
|
|
46
50
|
const n = " ".repeat(t), r = e ? e - t : 1, s = "^".repeat(r);
|
|
47
51
|
return n + s;
|
|
48
52
|
}
|
|
49
|
-
const
|
|
50
|
-
function
|
|
53
|
+
const we = /* @__PURE__ */ new Map();
|
|
54
|
+
function lr(t, e) {
|
|
51
55
|
let n, r;
|
|
52
56
|
typeof e == "number" ? n = e : [n, r] = e;
|
|
53
|
-
const s =
|
|
57
|
+
const s = ur(t);
|
|
54
58
|
let o = 0, i = s.length - 1;
|
|
55
59
|
for (n >= s[i] && (o = i); o + 1 < i; ) {
|
|
56
60
|
const d = o + i >> 1;
|
|
@@ -62,19 +66,19 @@ function rr(t, e) {
|
|
|
62
66
|
return { line: c.slice(-1) === `
|
|
63
67
|
` ? c.slice(0, -1) : c, linePos: n - s[o], linePos2: a, lineNum: o + 1 };
|
|
64
68
|
}
|
|
65
|
-
function
|
|
66
|
-
const e =
|
|
69
|
+
function ur(t) {
|
|
70
|
+
const e = we.get(t);
|
|
67
71
|
if (e) return e;
|
|
68
72
|
const n = [...t.matchAll(/\n/g)].map((r) => r.index + 1);
|
|
69
|
-
return n.unshift(0),
|
|
73
|
+
return n.unshift(0), we.set(t, n), n;
|
|
70
74
|
}
|
|
71
|
-
function
|
|
75
|
+
function dr(t) {
|
|
72
76
|
const e = t.checkpoint(), n = t.nextToken();
|
|
73
77
|
return t.reset(e), n;
|
|
74
78
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
77
|
-
`token '${t}' ${
|
|
79
|
+
function it(t, e) {
|
|
80
|
+
return J(
|
|
81
|
+
`token '${t}' ${je(e)}`,
|
|
78
82
|
function(r) {
|
|
79
83
|
r.stream.checkpoint();
|
|
80
84
|
const s = r.stream.nextToken();
|
|
@@ -82,8 +86,8 @@ function ot(t, e) {
|
|
|
82
86
|
}
|
|
83
87
|
);
|
|
84
88
|
}
|
|
85
|
-
function
|
|
86
|
-
return
|
|
89
|
+
function kt(t, e) {
|
|
90
|
+
return J(
|
|
87
91
|
`tokenOf '${t}'`,
|
|
88
92
|
function(r) {
|
|
89
93
|
r.stream.checkpoint();
|
|
@@ -92,8 +96,8 @@ function xt(t, e) {
|
|
|
92
96
|
}
|
|
93
97
|
);
|
|
94
98
|
}
|
|
95
|
-
function
|
|
96
|
-
return
|
|
99
|
+
function Le(t) {
|
|
100
|
+
return J(
|
|
97
101
|
`tokenKind '${t}'`,
|
|
98
102
|
function(n) {
|
|
99
103
|
n.stream.checkpoint();
|
|
@@ -102,8 +106,8 @@ function Be(t) {
|
|
|
102
106
|
}
|
|
103
107
|
);
|
|
104
108
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
109
|
+
function Kt(t) {
|
|
110
|
+
return J(
|
|
107
111
|
`kind '${t}'`,
|
|
108
112
|
function(n) {
|
|
109
113
|
n.stream.checkpoint();
|
|
@@ -112,9 +116,9 @@ function Jt(t) {
|
|
|
112
116
|
}
|
|
113
117
|
);
|
|
114
118
|
}
|
|
115
|
-
function
|
|
116
|
-
return
|
|
117
|
-
`${
|
|
119
|
+
function $t(t) {
|
|
120
|
+
return J(
|
|
121
|
+
`${je(t)}`,
|
|
118
122
|
function(n) {
|
|
119
123
|
n.stream.checkpoint();
|
|
120
124
|
const r = n.stream.nextToken();
|
|
@@ -135,7 +139,7 @@ function u(...t) {
|
|
|
135
139
|
return { value: s };
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
|
-
function
|
|
142
|
+
function fr(t) {
|
|
139
143
|
const e = Object.entries(t).map(
|
|
140
144
|
([n, r]) => [n, k(r)]
|
|
141
145
|
);
|
|
@@ -150,23 +154,23 @@ function ir(t) {
|
|
|
150
154
|
return { value: s };
|
|
151
155
|
});
|
|
152
156
|
}
|
|
153
|
-
function
|
|
154
|
-
return t.collect({ before:
|
|
157
|
+
function pr(t) {
|
|
158
|
+
return t.collect({ before: vr, after: Sr });
|
|
155
159
|
}
|
|
156
|
-
function
|
|
160
|
+
function N(t, e) {
|
|
157
161
|
const n = k(t), r = k(e);
|
|
158
162
|
return y("preceded", function(o) {
|
|
159
163
|
return n._run(o) === null ? null : r._run(o);
|
|
160
164
|
});
|
|
161
165
|
}
|
|
162
|
-
function
|
|
166
|
+
function Ft(t, e) {
|
|
163
167
|
const n = k(t), r = k(e);
|
|
164
168
|
return y("terminated", function(o) {
|
|
165
169
|
const i = n._run(o);
|
|
166
170
|
return i === null || r._run(o) === null ? null : i;
|
|
167
171
|
});
|
|
168
172
|
}
|
|
169
|
-
function
|
|
173
|
+
function W(t, e, n) {
|
|
170
174
|
const r = k(t), s = k(e), o = k(n);
|
|
171
175
|
return y("delimited", function(a) {
|
|
172
176
|
if (r._run(a) === null) return null;
|
|
@@ -174,7 +178,7 @@ function F(t, e, n) {
|
|
|
174
178
|
return l === null || o._run(a) === null ? null : l;
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
|
-
function
|
|
181
|
+
function mr(t, e, n) {
|
|
178
182
|
const r = k(t), s = k(e), o = k(n);
|
|
179
183
|
return y(
|
|
180
184
|
"terminated",
|
|
@@ -209,22 +213,22 @@ function h(t) {
|
|
|
209
213
|
}
|
|
210
214
|
);
|
|
211
215
|
}
|
|
212
|
-
function
|
|
216
|
+
function gr(t) {
|
|
213
217
|
const e = k(t);
|
|
214
218
|
return y("not", function(r) {
|
|
215
219
|
const s = r.stream.checkpoint();
|
|
216
220
|
return e._run(r) === null ? (r.stream.reset(s), { value: !0 }) : null;
|
|
217
221
|
});
|
|
218
222
|
}
|
|
219
|
-
function
|
|
223
|
+
function $(t) {
|
|
220
224
|
const e = k(t);
|
|
221
|
-
return y("repeat",
|
|
225
|
+
return y("repeat", hr(e));
|
|
222
226
|
}
|
|
223
|
-
function
|
|
227
|
+
function D(t) {
|
|
224
228
|
const e = k(t);
|
|
225
|
-
return u(e,
|
|
229
|
+
return u(e, $(e)).map((n) => [n[0], ...n[1]]).setTraceName("repeatPlus");
|
|
226
230
|
}
|
|
227
|
-
function
|
|
231
|
+
function hr(t, e = () => !0) {
|
|
228
232
|
return function(r) {
|
|
229
233
|
const s = [];
|
|
230
234
|
for (; ; ) {
|
|
@@ -237,11 +241,11 @@ function ur(t, e = () => !0) {
|
|
|
237
241
|
}
|
|
238
242
|
};
|
|
239
243
|
}
|
|
240
|
-
function
|
|
244
|
+
function Ht(t) {
|
|
241
245
|
const e = k(t);
|
|
242
246
|
return y("span", function(r) {
|
|
243
247
|
var a, c;
|
|
244
|
-
const s = ((c = (a =
|
|
248
|
+
const s = ((c = (a = dr(r.stream)) == null ? void 0 : a.span) == null ? void 0 : c[0]) ?? null, o = e._run(r);
|
|
245
249
|
if (o === null) return null;
|
|
246
250
|
const i = r.stream.checkpoint();
|
|
247
251
|
return {
|
|
@@ -252,8 +256,8 @@ function Kt(t) {
|
|
|
252
256
|
};
|
|
253
257
|
});
|
|
254
258
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
259
|
+
function br() {
|
|
260
|
+
return J("eof", function(e) {
|
|
257
261
|
return e.stream.nextToken() !== null ? null : { value: !0 };
|
|
258
262
|
});
|
|
259
263
|
}
|
|
@@ -262,16 +266,16 @@ function f(t, e) {
|
|
|
262
266
|
return y("req", function(s) {
|
|
263
267
|
const o = s.stream.checkpoint(), i = n._run(s);
|
|
264
268
|
if (i === null)
|
|
265
|
-
throw new
|
|
269
|
+
throw new Z(e, [o, s.stream.checkpoint()]);
|
|
266
270
|
return i;
|
|
267
271
|
});
|
|
268
272
|
}
|
|
269
|
-
function
|
|
270
|
-
return
|
|
273
|
+
function _t() {
|
|
274
|
+
return J("yes", function() {
|
|
271
275
|
return { value: null };
|
|
272
276
|
});
|
|
273
277
|
}
|
|
274
|
-
function
|
|
278
|
+
function nt(t, e, n = {}) {
|
|
275
279
|
const { trailing: r = !0, requireOne: s = !1 } = n, o = k(e), i = k(t);
|
|
276
280
|
return y("withSep", function(c) {
|
|
277
281
|
const l = [], d = c.stream.checkpoint(), p = o._run(c);
|
|
@@ -285,23 +289,23 @@ function et(t, e, n = {}) {
|
|
|
285
289
|
c.stream.reset(g);
|
|
286
290
|
break;
|
|
287
291
|
}
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
r ? c.stream.reset(
|
|
292
|
+
const T = c.stream.checkpoint(), A = o._run(c);
|
|
293
|
+
if (A === null) {
|
|
294
|
+
r ? c.stream.reset(T) : c.stream.reset(g);
|
|
291
295
|
break;
|
|
292
296
|
}
|
|
293
|
-
l.push(
|
|
297
|
+
l.push(A.value);
|
|
294
298
|
}
|
|
295
299
|
return {
|
|
296
300
|
value: l
|
|
297
301
|
};
|
|
298
302
|
});
|
|
299
303
|
}
|
|
300
|
-
function
|
|
301
|
-
return
|
|
304
|
+
function Pt(t, e) {
|
|
305
|
+
return nt(t, e, { requireOne: !0 }).setTraceName("withSepPlus");
|
|
302
306
|
}
|
|
303
|
-
function
|
|
304
|
-
return
|
|
307
|
+
function Oe(t) {
|
|
308
|
+
return J(
|
|
305
309
|
"withStreamAction",
|
|
306
310
|
function(n) {
|
|
307
311
|
const r = t(n.stream);
|
|
@@ -310,15 +314,15 @@ function De(t) {
|
|
|
310
314
|
);
|
|
311
315
|
}
|
|
312
316
|
function k(t) {
|
|
313
|
-
return typeof t == "string" ?
|
|
317
|
+
return typeof t == "string" ? $t(t) : t instanceof te ? t : X(t);
|
|
314
318
|
}
|
|
315
|
-
function
|
|
316
|
-
const e = new
|
|
319
|
+
function X(t) {
|
|
320
|
+
const e = new te({
|
|
317
321
|
fn: function(r) {
|
|
318
322
|
const s = t();
|
|
319
323
|
if (!t) {
|
|
320
324
|
const o = r.stream.checkpoint();
|
|
321
|
-
throw new
|
|
325
|
+
throw new Z("fn parser called before definition", [
|
|
322
326
|
o,
|
|
323
327
|
o
|
|
324
328
|
]);
|
|
@@ -330,19 +334,19 @@ function G(t) {
|
|
|
330
334
|
});
|
|
331
335
|
return e;
|
|
332
336
|
}
|
|
333
|
-
function
|
|
337
|
+
function xr(t, e, n) {
|
|
334
338
|
const r = (e == null ? void 0 : e.after) ?? e, s = e == null ? void 0 : e.before;
|
|
335
339
|
let o = r;
|
|
336
340
|
n && (o = (a) => {
|
|
337
341
|
const c = r(a);
|
|
338
|
-
return c != null &&
|
|
342
|
+
return c != null && Zt(a.tags, n, c), c;
|
|
339
343
|
});
|
|
340
344
|
const i = n ? `${t.debugName}-${n}` : `${t.debugName}`;
|
|
341
345
|
return y(
|
|
342
346
|
"collect",
|
|
343
347
|
function(c) {
|
|
344
348
|
const l = c.stream.checkpoint();
|
|
345
|
-
return s &&
|
|
349
|
+
return s && Mt(c, l, s, `${i}.before`), Yt(t, c, o, i);
|
|
346
350
|
}
|
|
347
351
|
);
|
|
348
352
|
}
|
|
@@ -353,14 +357,14 @@ function _(t) {
|
|
|
353
357
|
function(r) {
|
|
354
358
|
const s = r.stream.checkpoint();
|
|
355
359
|
let o;
|
|
356
|
-
return
|
|
360
|
+
return Mt(
|
|
357
361
|
r,
|
|
358
362
|
s,
|
|
359
363
|
(i) => {
|
|
360
|
-
o =
|
|
364
|
+
o = kr(i.tags), i.tags = {};
|
|
361
365
|
},
|
|
362
366
|
`scope.before ${e.debugName}`
|
|
363
|
-
),
|
|
367
|
+
), Yt(
|
|
364
368
|
e,
|
|
365
369
|
r,
|
|
366
370
|
(i) => {
|
|
@@ -371,52 +375,52 @@ function _(t) {
|
|
|
371
375
|
}
|
|
372
376
|
);
|
|
373
377
|
}
|
|
374
|
-
function
|
|
378
|
+
function kr(t) {
|
|
375
379
|
const e = Object.entries(t).map(([n, r]) => [n, [...r]]);
|
|
376
380
|
return Object.fromEntries(e);
|
|
377
381
|
}
|
|
378
|
-
function
|
|
382
|
+
function _r(t, e) {
|
|
379
383
|
return y("ctag", function(r) {
|
|
380
|
-
return
|
|
384
|
+
return Yt(
|
|
381
385
|
t,
|
|
382
386
|
r,
|
|
383
387
|
(s) => {
|
|
384
|
-
const o =
|
|
385
|
-
|
|
388
|
+
const o = Qt(s._values);
|
|
389
|
+
Zt(s.tags, e, o.value);
|
|
386
390
|
},
|
|
387
391
|
`ctag ${e}`
|
|
388
392
|
);
|
|
389
393
|
});
|
|
390
394
|
}
|
|
391
|
-
function
|
|
395
|
+
function Yt(t, e, n, r = "") {
|
|
392
396
|
const s = e.stream.checkpoint(), o = t._run(e);
|
|
393
|
-
return o &&
|
|
397
|
+
return o && Mt(e, s, n, r), o;
|
|
394
398
|
}
|
|
395
|
-
function
|
|
396
|
-
const s =
|
|
399
|
+
function Mt(t, e, n, r) {
|
|
400
|
+
const s = Er(t.stream, e);
|
|
397
401
|
t._collect.push({
|
|
398
402
|
srcPosition: s,
|
|
399
403
|
collectFn: n,
|
|
400
404
|
debugName: r
|
|
401
405
|
});
|
|
402
406
|
}
|
|
403
|
-
function
|
|
407
|
+
function vr(t) {
|
|
404
408
|
t._values.push({ value: null, openArray: [] });
|
|
405
409
|
}
|
|
406
|
-
function
|
|
407
|
-
const e =
|
|
408
|
-
e.openArray === void 0 && console.log("---closeArray: no open array"), t._values.pop(),
|
|
410
|
+
function Sr(t) {
|
|
411
|
+
const e = Qt(t._values);
|
|
412
|
+
e.openArray === void 0 && console.log("---closeArray: no open array"), t._values.pop(), qe(t, e.openArray);
|
|
409
413
|
}
|
|
410
|
-
function
|
|
414
|
+
function yr(t, e) {
|
|
411
415
|
return y("ptag", function(r) {
|
|
412
416
|
const s = r.stream.checkpoint(), o = t._run(r);
|
|
413
|
-
return o &&
|
|
417
|
+
return o && Mt(r, s, (a) => Zt(a.tags, e, o.value), `ptag ${e}`), o;
|
|
414
418
|
});
|
|
415
419
|
}
|
|
416
|
-
function
|
|
420
|
+
function Zt(t, e, n) {
|
|
417
421
|
t[e] === void 0 && (t[e] = []), t[e].push(n);
|
|
418
422
|
}
|
|
419
|
-
function
|
|
423
|
+
function wr(t, e, n) {
|
|
420
424
|
const r = {}, { src: s } = n, i = {
|
|
421
425
|
tags: r,
|
|
422
426
|
src: s,
|
|
@@ -429,35 +433,40 @@ function xr(t, e, n) {
|
|
|
429
433
|
const { collectFn: c, srcPosition: l } = a;
|
|
430
434
|
i.start = l.start, i.end = l.end;
|
|
431
435
|
const d = c(i);
|
|
432
|
-
|
|
436
|
+
qe(i, d);
|
|
433
437
|
});
|
|
434
438
|
}
|
|
435
|
-
function
|
|
439
|
+
function qe(t, e) {
|
|
436
440
|
if (e !== void 0) {
|
|
437
|
-
const n =
|
|
441
|
+
const n = Qt(t._values);
|
|
438
442
|
n || console.log("----saveCollectValue: no valueEntry"), n && (n.value = e), (n == null ? void 0 : n.openArray) !== void 0 && n.openArray.push(e);
|
|
439
443
|
}
|
|
440
444
|
}
|
|
441
|
-
function
|
|
445
|
+
function Qt(t) {
|
|
442
446
|
return t[t.length - 1];
|
|
443
447
|
}
|
|
444
|
-
function
|
|
448
|
+
function Er(t, e) {
|
|
445
449
|
const n = t.checkpoint();
|
|
446
450
|
t.reset(e);
|
|
447
|
-
const r =
|
|
451
|
+
const r = Tr(t);
|
|
448
452
|
return t.reset(n), { start: r, end: n };
|
|
449
453
|
}
|
|
450
|
-
function
|
|
454
|
+
function Tr(t) {
|
|
451
455
|
const e = t.nextToken();
|
|
452
456
|
return e === null || t.reset(e.span[0]), t.checkpoint();
|
|
453
457
|
}
|
|
454
|
-
class
|
|
455
|
-
constructor(
|
|
456
|
-
super(
|
|
458
|
+
class Z extends Error {
|
|
459
|
+
constructor(n, r) {
|
|
460
|
+
super(n);
|
|
461
|
+
w(this, "span");
|
|
462
|
+
this.span = r;
|
|
457
463
|
}
|
|
458
464
|
}
|
|
459
|
-
class
|
|
465
|
+
class te {
|
|
460
466
|
constructor(e) {
|
|
467
|
+
/** If tracing is enabled, this exists. Otherwise it does not exist. */
|
|
468
|
+
w(this, "_traceInfo");
|
|
469
|
+
w(this, "fn");
|
|
461
470
|
this.fn = e.fn;
|
|
462
471
|
}
|
|
463
472
|
/** run the parser given an already created parsing context
|
|
@@ -476,11 +485,11 @@ class Qt {
|
|
|
476
485
|
}
|
|
477
486
|
/** tag parse results */
|
|
478
487
|
ptag(e) {
|
|
479
|
-
return
|
|
488
|
+
return yr(this, e);
|
|
480
489
|
}
|
|
481
490
|
/** tag collect results */
|
|
482
491
|
ctag(e) {
|
|
483
|
-
return
|
|
492
|
+
return _r(this, e);
|
|
484
493
|
}
|
|
485
494
|
/** record a name for debug tracing */
|
|
486
495
|
setTraceName(e) {
|
|
@@ -493,18 +502,18 @@ class Qt {
|
|
|
493
502
|
/** map results to a new value.
|
|
494
503
|
*/
|
|
495
504
|
map(e) {
|
|
496
|
-
return
|
|
505
|
+
return Nr(this, e);
|
|
497
506
|
}
|
|
498
507
|
/** Queue a function that runs later, typically to collect AST elements from the parse.
|
|
499
508
|
* when a commit() is parsed.
|
|
500
509
|
* Collection functions are dropped with parser backtracking, so
|
|
501
510
|
* only succsessful parses are collected. */
|
|
502
511
|
collect(e, n) {
|
|
503
|
-
return
|
|
512
|
+
return xr(this, e, n);
|
|
504
513
|
}
|
|
505
514
|
/** switch next parser based on results */
|
|
506
515
|
toParser(e) {
|
|
507
|
-
return
|
|
516
|
+
return $r(this, e);
|
|
508
517
|
}
|
|
509
518
|
/**
|
|
510
519
|
* start parsing
|
|
@@ -517,7 +526,7 @@ class Qt {
|
|
|
517
526
|
app: r,
|
|
518
527
|
_collect: s
|
|
519
528
|
});
|
|
520
|
-
return o &&
|
|
529
|
+
return o && wr(s, r, n), o;
|
|
521
530
|
}
|
|
522
531
|
/** name of this parser for debugging/tracing */
|
|
523
532
|
get debugName() {
|
|
@@ -525,18 +534,18 @@ class Qt {
|
|
|
525
534
|
}
|
|
526
535
|
}
|
|
527
536
|
function y(t, e, n) {
|
|
528
|
-
return new
|
|
537
|
+
return new te({ fn: e, traceName: t, terminal: n });
|
|
529
538
|
}
|
|
530
|
-
function
|
|
539
|
+
function J(t, e) {
|
|
531
540
|
return y(t, e, !0);
|
|
532
541
|
}
|
|
533
|
-
function
|
|
542
|
+
function Nr(t, e) {
|
|
534
543
|
return y("map", function(r) {
|
|
535
544
|
const s = t._run(r);
|
|
536
545
|
return s === null ? null : { value: e(s.value) };
|
|
537
546
|
});
|
|
538
547
|
}
|
|
539
|
-
function
|
|
548
|
+
function $r(t, e) {
|
|
540
549
|
return y(
|
|
541
550
|
"toParser",
|
|
542
551
|
function(r) {
|
|
@@ -547,8 +556,10 @@ function Sr(t, e) {
|
|
|
547
556
|
}
|
|
548
557
|
);
|
|
549
558
|
}
|
|
550
|
-
class
|
|
559
|
+
class ee {
|
|
551
560
|
constructor(e, n = []) {
|
|
561
|
+
w(this, "entries");
|
|
562
|
+
w(this, "dest");
|
|
552
563
|
this.dest = e, this.entries = n;
|
|
553
564
|
}
|
|
554
565
|
/** add a new mapping from src to dest ranges.
|
|
@@ -587,7 +598,7 @@ class te {
|
|
|
587
598
|
);
|
|
588
599
|
if (n.length === 0)
|
|
589
600
|
return console.log("other source map does not link to this one"), e;
|
|
590
|
-
|
|
601
|
+
Pr(n);
|
|
591
602
|
const r = n.map((i) => {
|
|
592
603
|
const { src: a, position: c } = this.destToSrc(i.srcStart), { src: l, position: d } = this.destToSrc(i.srcEnd);
|
|
593
604
|
if (l !== a) throw new Error("NYI, need to split");
|
|
@@ -600,7 +611,7 @@ class te {
|
|
|
600
611
|
};
|
|
601
612
|
}), s = e.entries.filter(
|
|
602
613
|
(i) => i.src.path !== this.dest.path || i.src.text !== this.dest.text
|
|
603
|
-
), o = new
|
|
614
|
+
), o = new ee(e.dest, [...s, ...r]);
|
|
604
615
|
return o.sort(), o;
|
|
605
616
|
}
|
|
606
617
|
/**
|
|
@@ -621,23 +632,23 @@ class te {
|
|
|
621
632
|
};
|
|
622
633
|
}
|
|
623
634
|
}
|
|
624
|
-
function
|
|
635
|
+
function Pr(t) {
|
|
625
636
|
t.sort((e, n) => e.srcStart - n.srcStart);
|
|
626
637
|
}
|
|
627
|
-
var
|
|
628
|
-
class
|
|
638
|
+
var Q, q, z;
|
|
639
|
+
class bt {
|
|
629
640
|
constructor(e) {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
641
|
+
B(this, Q, []);
|
|
642
|
+
B(this, q, 0);
|
|
643
|
+
B(this, z, []);
|
|
633
644
|
this.source = e;
|
|
634
645
|
}
|
|
635
646
|
/** append a string fragment to the destination string */
|
|
636
647
|
add(e, n, r) {
|
|
637
|
-
const s = b(this,
|
|
638
|
-
|
|
639
|
-
const o = b(this,
|
|
640
|
-
b(this,
|
|
648
|
+
const s = b(this, q);
|
|
649
|
+
R(this, q, b(this, q) + e.length);
|
|
650
|
+
const o = b(this, q);
|
|
651
|
+
b(this, Q).push(e), b(this, z).push({
|
|
641
652
|
src: this.source,
|
|
642
653
|
srcStart: n,
|
|
643
654
|
srcEnd: r,
|
|
@@ -653,14 +664,14 @@ class ht {
|
|
|
653
664
|
*/
|
|
654
665
|
appendNext(e) {
|
|
655
666
|
var r;
|
|
656
|
-
const n = ((r = b(this,
|
|
667
|
+
const n = ((r = b(this, z).at(-1)) == null ? void 0 : r.destEnd) ?? 0;
|
|
657
668
|
this.add(e, n, n + e.length);
|
|
658
669
|
}
|
|
659
670
|
addSynthetic(e, n, r, s) {
|
|
660
|
-
const o = b(this,
|
|
661
|
-
|
|
662
|
-
const i = b(this,
|
|
663
|
-
b(this,
|
|
671
|
+
const o = b(this, q);
|
|
672
|
+
R(this, q, b(this, q) + e.length);
|
|
673
|
+
const i = b(this, q);
|
|
674
|
+
b(this, Q).push(e), b(this, z).push({
|
|
664
675
|
src: { text: n },
|
|
665
676
|
srcStart: r,
|
|
666
677
|
srcEnd: s,
|
|
@@ -670,7 +681,7 @@ class ht {
|
|
|
670
681
|
}
|
|
671
682
|
/** append a synthetic newline, mapped to previous source location */
|
|
672
683
|
addNl() {
|
|
673
|
-
const e = b(this,
|
|
684
|
+
const e = b(this, z).at(-1) ?? { srcStart: 0, srcEnd: 0 }, { srcStart: n, srcEnd: r } = e;
|
|
674
685
|
this.add(`
|
|
675
686
|
`, n, r);
|
|
676
687
|
}
|
|
@@ -681,17 +692,18 @@ class ht {
|
|
|
681
692
|
}
|
|
682
693
|
/** return a SrcMap */
|
|
683
694
|
static build(e) {
|
|
684
|
-
const n = new
|
|
685
|
-
{ text: e.map((r) => b(r,
|
|
686
|
-
e.flatMap((r) => b(r,
|
|
695
|
+
const n = new ee(
|
|
696
|
+
{ text: e.map((r) => b(r, Q).join("")).join("") },
|
|
697
|
+
e.flatMap((r) => b(r, z))
|
|
687
698
|
);
|
|
688
699
|
return n.compact(), n;
|
|
689
700
|
}
|
|
690
701
|
}
|
|
691
|
-
|
|
692
|
-
class
|
|
702
|
+
Q = new WeakMap(), q = new WeakMap(), z = new WeakMap();
|
|
703
|
+
class Mr {
|
|
693
704
|
constructor(e) {
|
|
694
|
-
this
|
|
705
|
+
w(this, "cache", new Cr(5));
|
|
706
|
+
this.inner = e;
|
|
695
707
|
}
|
|
696
708
|
checkpoint() {
|
|
697
709
|
return this.inner.checkpoint();
|
|
@@ -712,7 +724,7 @@ class wr {
|
|
|
712
724
|
return this.inner.src;
|
|
713
725
|
}
|
|
714
726
|
}
|
|
715
|
-
class
|
|
727
|
+
class Cr extends Map {
|
|
716
728
|
constructor(e) {
|
|
717
729
|
super(), this.max = e;
|
|
718
730
|
}
|
|
@@ -724,31 +736,32 @@ class Er extends Map {
|
|
|
724
736
|
return super.set(e, n);
|
|
725
737
|
}
|
|
726
738
|
}
|
|
727
|
-
function
|
|
739
|
+
function Ar(t) {
|
|
728
740
|
const [e, n] = t;
|
|
729
741
|
if (typeof n == "string") {
|
|
730
|
-
const r = `(${
|
|
731
|
-
return
|
|
742
|
+
const r = `(${Fe(n)})`;
|
|
743
|
+
return Ee(e, new RegExp(r)), r;
|
|
732
744
|
} else
|
|
733
|
-
return
|
|
745
|
+
return Ee(e, n), `(${n.source})`;
|
|
734
746
|
}
|
|
735
|
-
function
|
|
747
|
+
function Ee(t, e) {
|
|
736
748
|
if (new RegExp("|" + e.source).exec("").length > 1)
|
|
737
749
|
throw new Error(
|
|
738
750
|
`match expression groups must be non-capturing: ${t}: /${e.source}/. Use (?:...) instead.`
|
|
739
751
|
);
|
|
740
752
|
}
|
|
741
|
-
const
|
|
742
|
-
function
|
|
743
|
-
return t.replace(
|
|
753
|
+
const Rr = /[$+*.?|(){}[\]\\/^]/g;
|
|
754
|
+
function Fe(t) {
|
|
755
|
+
return t.replace(Rr, "\\$&");
|
|
744
756
|
}
|
|
745
|
-
function
|
|
746
|
-
const n = t.split(/\s+/).sort((r, s) => s.length - r.length).filter((r) => r).map(
|
|
757
|
+
function Ct(t) {
|
|
758
|
+
const n = t.split(/\s+/).sort((r, s) => s.length - r.length).filter((r) => r).map(Fe);
|
|
747
759
|
return new RegExp(n.join("|"));
|
|
748
760
|
}
|
|
749
|
-
class
|
|
761
|
+
class Ir {
|
|
750
762
|
constructor(e, n) {
|
|
751
|
-
this
|
|
763
|
+
w(this, "position", 0);
|
|
764
|
+
this.text = e, this.matchers = n;
|
|
752
765
|
}
|
|
753
766
|
checkpoint() {
|
|
754
767
|
return this.position;
|
|
@@ -764,15 +777,17 @@ class $r {
|
|
|
764
777
|
return this.text;
|
|
765
778
|
}
|
|
766
779
|
}
|
|
767
|
-
class
|
|
780
|
+
class Br {
|
|
768
781
|
constructor(e) {
|
|
782
|
+
w(this, "groups");
|
|
783
|
+
w(this, "exp");
|
|
769
784
|
this.groups = Object.keys(e);
|
|
770
|
-
const n = Object.entries(e).map(
|
|
785
|
+
const n = Object.entries(e).map(Ar).join("|");
|
|
771
786
|
this.exp = new RegExp(n, "dyu");
|
|
772
787
|
}
|
|
773
788
|
execAt(e, n) {
|
|
774
789
|
this.exp.lastIndex = n;
|
|
775
|
-
const r = this.exp.exec(e), s =
|
|
790
|
+
const r = this.exp.exec(e), s = Dr(r == null ? void 0 : r.indices);
|
|
776
791
|
if (s) {
|
|
777
792
|
const { span: o, groupDex: i } = s;
|
|
778
793
|
return {
|
|
@@ -784,7 +799,7 @@ class Pr {
|
|
|
784
799
|
return null;
|
|
785
800
|
}
|
|
786
801
|
}
|
|
787
|
-
function
|
|
802
|
+
function Dr(t) {
|
|
788
803
|
if (t !== void 0)
|
|
789
804
|
for (let e = 1; e < t.length; e++) {
|
|
790
805
|
const n = t[e];
|
|
@@ -792,29 +807,31 @@ function Mr(t) {
|
|
|
792
807
|
return { span: n, groupDex: e - 1 };
|
|
793
808
|
}
|
|
794
809
|
}
|
|
795
|
-
function
|
|
796
|
-
throw new
|
|
810
|
+
function j(t) {
|
|
811
|
+
throw new jr("Unreachable value", { data: t });
|
|
797
812
|
}
|
|
798
|
-
class
|
|
799
|
-
constructor(
|
|
800
|
-
super(
|
|
813
|
+
class jr extends Error {
|
|
814
|
+
constructor(n, r) {
|
|
815
|
+
super(n, r);
|
|
816
|
+
w(this, "data");
|
|
817
|
+
this.data = r == null ? void 0 : r.data;
|
|
801
818
|
}
|
|
802
819
|
}
|
|
803
|
-
function
|
|
820
|
+
function sa(t, e, n, r) {
|
|
804
821
|
const s = t.get(e) || /* @__PURE__ */ new Map();
|
|
805
822
|
t.set(e, s), s.set(n, r);
|
|
806
823
|
}
|
|
807
|
-
const
|
|
808
|
-
function
|
|
809
|
-
return t.replaceAll(
|
|
824
|
+
const Lr = /\b(\w+)\b/gi;
|
|
825
|
+
function oa(t, e) {
|
|
826
|
+
return t.replaceAll(Lr, (n) => n in e ? e[n] : n);
|
|
810
827
|
}
|
|
811
|
-
function
|
|
828
|
+
function ia(t, e, n = e) {
|
|
812
829
|
const r = [];
|
|
813
830
|
for (let s = 0; s < t.length; s += n)
|
|
814
831
|
r.push(t.slice(s, s + e));
|
|
815
832
|
return r;
|
|
816
833
|
}
|
|
817
|
-
function
|
|
834
|
+
function aa(t, e) {
|
|
818
835
|
const n = /* @__PURE__ */ new Map();
|
|
819
836
|
for (const r of t) {
|
|
820
837
|
const s = e(r), o = n.get(s) || [];
|
|
@@ -822,44 +839,44 @@ function sa(t, e) {
|
|
|
822
839
|
}
|
|
823
840
|
return n;
|
|
824
841
|
}
|
|
825
|
-
function
|
|
842
|
+
function ca(t, e) {
|
|
826
843
|
const n = [], r = [];
|
|
827
844
|
for (const s of t)
|
|
828
845
|
e(s) ? n.push(s) : r.push(s);
|
|
829
846
|
return [n, r];
|
|
830
847
|
}
|
|
831
|
-
function
|
|
848
|
+
function la(t, e, n) {
|
|
832
849
|
const r = [n];
|
|
833
850
|
let s = n;
|
|
834
851
|
for (let o = 0; o < t.length; o++)
|
|
835
852
|
s = e(t[o], s), r.push(s);
|
|
836
853
|
return r;
|
|
837
854
|
}
|
|
838
|
-
function
|
|
855
|
+
function ua(t, e) {
|
|
839
856
|
const n = Object.entries(t).map(([r, s]) => {
|
|
840
857
|
const o = s in e ? e[s] : s;
|
|
841
858
|
return [r, o];
|
|
842
859
|
});
|
|
843
860
|
return Object.fromEntries(n);
|
|
844
861
|
}
|
|
845
|
-
function
|
|
862
|
+
function Or(t) {
|
|
846
863
|
return t[t.length - 1];
|
|
847
864
|
}
|
|
848
|
-
function
|
|
865
|
+
function da(t, e) {
|
|
849
866
|
let n = Math.min(t.length, e.length);
|
|
850
867
|
for (; n > 0; ) {
|
|
851
868
|
const r = t.slice(-n), s = e.slice(0, n);
|
|
852
|
-
if (
|
|
869
|
+
if (qr(r, s))
|
|
853
870
|
break;
|
|
854
871
|
n--;
|
|
855
872
|
}
|
|
856
873
|
if (n)
|
|
857
874
|
return e.slice(n);
|
|
858
875
|
}
|
|
859
|
-
function
|
|
876
|
+
function qr(t, e) {
|
|
860
877
|
return t.length === e.length && t.every((n, r) => n === e[r]);
|
|
861
878
|
}
|
|
862
|
-
function
|
|
879
|
+
function ne(t, e) {
|
|
863
880
|
const n = [];
|
|
864
881
|
for (const r of t) {
|
|
865
882
|
const s = e(r);
|
|
@@ -867,16 +884,16 @@ function ee(t, e) {
|
|
|
867
884
|
}
|
|
868
885
|
return n;
|
|
869
886
|
}
|
|
870
|
-
function
|
|
887
|
+
function Fr(t, e) {
|
|
871
888
|
for (const n of t) {
|
|
872
889
|
const r = e(n);
|
|
873
890
|
if (r) return r;
|
|
874
891
|
}
|
|
875
892
|
}
|
|
876
|
-
function
|
|
893
|
+
function Wr(t, e) {
|
|
877
894
|
return Object.fromEntries(Object.entries(t).map(([n, r]) => [n, e(r)]));
|
|
878
895
|
}
|
|
879
|
-
function
|
|
896
|
+
function At(t, e) {
|
|
880
897
|
const n = Math.min(e.length, Math.max(0, t));
|
|
881
898
|
let r = 0, s = 1;
|
|
882
899
|
for (; ; ) {
|
|
@@ -889,7 +906,7 @@ function Ct(t, e) {
|
|
|
889
906
|
r = o + 1, s += 1;
|
|
890
907
|
}
|
|
891
908
|
}
|
|
892
|
-
function
|
|
909
|
+
function We(t, e) {
|
|
893
910
|
let n = t.lastIndexOf(`
|
|
894
911
|
`, e[0]);
|
|
895
912
|
n === -1 && (n = 0);
|
|
@@ -911,35 +928,35 @@ The above copyright notice and this permission notice shall be included in all c
|
|
|
911
928
|
|
|
912
929
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
913
930
|
*/
|
|
914
|
-
const
|
|
931
|
+
const Ue = {};
|
|
915
932
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split("").forEach((t, e) => {
|
|
916
|
-
|
|
933
|
+
Ue[e] = t;
|
|
917
934
|
});
|
|
918
|
-
function
|
|
935
|
+
function Te(t) {
|
|
919
936
|
if (typeof t == "number")
|
|
920
|
-
return
|
|
937
|
+
return Ne(t);
|
|
921
938
|
let e = "";
|
|
922
939
|
for (let n = 0; n < t.length; n += 1)
|
|
923
|
-
e +=
|
|
940
|
+
e += Ne(t[n]);
|
|
924
941
|
return e;
|
|
925
942
|
}
|
|
926
|
-
function
|
|
943
|
+
function Ne(t) {
|
|
927
944
|
let e = "", n;
|
|
928
945
|
t < 0 ? n = -t << 1 | 1 : n = t << 1;
|
|
929
946
|
do {
|
|
930
947
|
let r = n & 31;
|
|
931
|
-
n >>>= 5, n > 0 && (r |= 32), e +=
|
|
948
|
+
n >>>= 5, n > 0 && (r |= 32), e += Ue[r];
|
|
932
949
|
} while (n > 0);
|
|
933
950
|
return e;
|
|
934
951
|
}
|
|
935
|
-
function
|
|
936
|
-
const { url: e, text: n, lineNumber: r, lineColumn: s, length: o, error: i } = t, a =
|
|
952
|
+
function re(t) {
|
|
953
|
+
const { url: e, text: n, lineNumber: r, lineColumn: s, length: o, error: i } = t, a = Te([
|
|
937
954
|
0,
|
|
938
955
|
0,
|
|
939
956
|
Math.max(0, r - 1),
|
|
940
957
|
Math.max(0, s - 1)
|
|
941
958
|
]) + "," + // Sadly no browser makes use of this info to map the error properly
|
|
942
|
-
|
|
959
|
+
Te([
|
|
943
960
|
18,
|
|
944
961
|
// Arbitrary number that is high enough
|
|
945
962
|
0,
|
|
@@ -965,18 +982,18 @@ function ne(t) {
|
|
|
965
982
|
throw "stackTraceLimit" in Error && (Error.stackTraceLimit = d), i.message = "", p;
|
|
966
983
|
}
|
|
967
984
|
}
|
|
968
|
-
function
|
|
985
|
+
function Ve(t, e) {
|
|
969
986
|
const { refIdentElem: n, originalName: r } = t, s = e ?? `'${r}'`;
|
|
970
987
|
if (n)
|
|
971
|
-
|
|
988
|
+
ze(n, s);
|
|
972
989
|
else
|
|
973
990
|
throw new Error(s);
|
|
974
991
|
}
|
|
975
|
-
function
|
|
992
|
+
function ze(t, e = "") {
|
|
976
993
|
const { srcModule: n, start: r, end: s } = t, { debugFilePath: o, src: i } = n, a = `${e} in file: ${o}`;
|
|
977
|
-
|
|
978
|
-
const [c, l] =
|
|
979
|
-
|
|
994
|
+
or(i, [r, s], a);
|
|
995
|
+
const [c, l] = At(r, i), d = s - r;
|
|
996
|
+
re({
|
|
980
997
|
url: o,
|
|
981
998
|
text: i,
|
|
982
999
|
lineNumber: c,
|
|
@@ -985,170 +1002,170 @@ function Ue(t, e = "") {
|
|
|
985
1002
|
error: new Error(a)
|
|
986
1003
|
});
|
|
987
1004
|
}
|
|
988
|
-
function
|
|
1005
|
+
function Ge(t, e) {
|
|
989
1006
|
const n = t.attributes;
|
|
990
1007
|
if (!n) return !0;
|
|
991
|
-
const r =
|
|
992
|
-
return !r ||
|
|
1008
|
+
const r = Fr(n, Ur);
|
|
1009
|
+
return !r || Je(r, e);
|
|
993
1010
|
}
|
|
994
|
-
function
|
|
1011
|
+
function Xe(t, e) {
|
|
995
1012
|
const { ifAttribute: n } = t;
|
|
996
|
-
return n ?
|
|
1013
|
+
return n ? Je(n, e) : !0;
|
|
997
1014
|
}
|
|
998
|
-
function
|
|
1015
|
+
function Ur(t) {
|
|
999
1016
|
const { attribute: e } = t;
|
|
1000
1017
|
return e.kind === "@if" ? e : void 0;
|
|
1001
1018
|
}
|
|
1002
|
-
function
|
|
1003
|
-
return
|
|
1019
|
+
function Je(t, e) {
|
|
1020
|
+
return Y(t.param.expression, e);
|
|
1004
1021
|
}
|
|
1005
|
-
function
|
|
1022
|
+
function Y(t, e) {
|
|
1006
1023
|
const { kind: n } = t;
|
|
1007
1024
|
if (n === "unary-expression")
|
|
1008
|
-
return t.operator.value, !
|
|
1025
|
+
return t.operator.value, !Y(t.expression, e);
|
|
1009
1026
|
if (n === "binary-expression") {
|
|
1010
|
-
const r = t.operator.value, s =
|
|
1027
|
+
const r = t.operator.value, s = Y(t.left, e);
|
|
1011
1028
|
if (r === "||")
|
|
1012
|
-
return s ||
|
|
1029
|
+
return s || Y(t.right, e);
|
|
1013
1030
|
if (r === "&&")
|
|
1014
|
-
return s &&
|
|
1015
|
-
|
|
1031
|
+
return s && Y(t.right, e);
|
|
1032
|
+
j(r);
|
|
1016
1033
|
} else if (n === "literal") {
|
|
1017
1034
|
const { value: r } = t;
|
|
1018
1035
|
return r === "true";
|
|
1019
1036
|
} else {
|
|
1020
1037
|
if (n === "parenthesized-expression")
|
|
1021
|
-
return
|
|
1038
|
+
return Y(t.expression, e);
|
|
1022
1039
|
if (n === "translate-time-feature")
|
|
1023
1040
|
return e[t.name];
|
|
1024
1041
|
throw new Error(`unexpected @if expression ${JSON.stringify(t)}`);
|
|
1025
1042
|
}
|
|
1026
1043
|
}
|
|
1027
|
-
function
|
|
1044
|
+
function Wt(t, e) {
|
|
1028
1045
|
e && (t.kind, e.kind, t.parent, e.parent, e.ifAttribute, t.contents = t.contents.concat(e.contents));
|
|
1029
1046
|
}
|
|
1030
|
-
function
|
|
1031
|
-
|
|
1047
|
+
function Vr() {
|
|
1048
|
+
Ke = 0, He = 0;
|
|
1032
1049
|
}
|
|
1033
|
-
let
|
|
1034
|
-
function
|
|
1035
|
-
return
|
|
1050
|
+
let Ke = 0, He = 0;
|
|
1051
|
+
function se() {
|
|
1052
|
+
return He++;
|
|
1036
1053
|
}
|
|
1037
|
-
function
|
|
1038
|
-
return { id:
|
|
1054
|
+
function Ye(t, e = "scope") {
|
|
1055
|
+
return { id: Ke++, kind: e, parent: t, contents: [] };
|
|
1039
1056
|
}
|
|
1040
|
-
function
|
|
1057
|
+
function zr(t, e) {
|
|
1041
1058
|
if (e === t)
|
|
1042
1059
|
return !0;
|
|
1043
1060
|
for (const n of t.contents)
|
|
1044
|
-
if (
|
|
1061
|
+
if (oe(n) && zr(n, e))
|
|
1045
1062
|
return !0;
|
|
1046
1063
|
return !1;
|
|
1047
1064
|
}
|
|
1048
|
-
function
|
|
1065
|
+
function oe(t) {
|
|
1049
1066
|
const { kind: e } = t;
|
|
1050
1067
|
return e === "partial" || e === "scope";
|
|
1051
1068
|
}
|
|
1052
|
-
function
|
|
1053
|
-
return !
|
|
1069
|
+
function fa(t) {
|
|
1070
|
+
return !oe(t);
|
|
1054
1071
|
}
|
|
1055
|
-
function
|
|
1072
|
+
function Ze(t, e, n) {
|
|
1056
1073
|
for (const r of t.contents) {
|
|
1057
1074
|
if (r.kind === "decl" && r.originalName === e)
|
|
1058
1075
|
return r;
|
|
1059
|
-
if (r.kind === "partial" &&
|
|
1060
|
-
const s =
|
|
1076
|
+
if (r.kind === "partial" && Xe(r, n)) {
|
|
1077
|
+
const s = Ze(r, e, n);
|
|
1061
1078
|
if (s) return s;
|
|
1062
1079
|
}
|
|
1063
1080
|
}
|
|
1064
1081
|
}
|
|
1065
|
-
var
|
|
1066
|
-
class
|
|
1082
|
+
var F, G, dt, ft, tt, pt;
|
|
1083
|
+
class ie {
|
|
1067
1084
|
constructor(e = 0, n = 60, r = 2) {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
this.indent = e, this.maxWidth = n, this.hangingIndent = r,
|
|
1085
|
+
B(this, F, []);
|
|
1086
|
+
B(this, G, 0);
|
|
1087
|
+
B(this, dt);
|
|
1088
|
+
B(this, ft, !0);
|
|
1089
|
+
B(this, tt, !1);
|
|
1090
|
+
B(this, pt);
|
|
1091
|
+
this.indent = e, this.maxWidth = n, this.hangingIndent = r, R(this, dt, " ".repeat(e)), R(this, pt, " ".repeat(r));
|
|
1075
1092
|
}
|
|
1076
1093
|
/** add a new line to the constructed string */
|
|
1077
1094
|
nl() {
|
|
1078
|
-
b(this,
|
|
1079
|
-
`),
|
|
1095
|
+
b(this, F).push(`
|
|
1096
|
+
`), R(this, G, 0), R(this, ft, !1), R(this, tt, !1);
|
|
1080
1097
|
}
|
|
1081
1098
|
/** add a string, wrapping to the next line if necessary */
|
|
1082
1099
|
add(e) {
|
|
1083
|
-
b(this,
|
|
1100
|
+
b(this, G) + Gr(e) > this.maxWidth && this.hangingNl(), b(this, G) === 0 && (b(this, F).push(b(this, dt)), b(this, tt) && b(this, F).push(b(this, pt)), R(this, G, this.indent)), b(this, F).push(e), R(this, G, b(this, G) + e.length);
|
|
1084
1101
|
}
|
|
1085
1102
|
/** add a raw block of text with no wrapping */
|
|
1086
1103
|
addBlock(e, n = !0) {
|
|
1087
|
-
b(this,
|
|
1104
|
+
b(this, F).push(e), n && this.nl();
|
|
1088
1105
|
}
|
|
1089
1106
|
/** @return the constructed string */
|
|
1090
1107
|
get result() {
|
|
1091
|
-
return b(this,
|
|
1108
|
+
return b(this, F).join("");
|
|
1092
1109
|
}
|
|
1093
1110
|
/** true if the result contains no newlines */
|
|
1094
1111
|
get oneLine() {
|
|
1095
|
-
return b(this,
|
|
1112
|
+
return b(this, ft);
|
|
1096
1113
|
}
|
|
1097
1114
|
hangingNl() {
|
|
1098
|
-
this.nl(),
|
|
1115
|
+
this.nl(), R(this, tt, !0);
|
|
1099
1116
|
}
|
|
1100
1117
|
}
|
|
1101
|
-
|
|
1102
|
-
function
|
|
1118
|
+
F = new WeakMap(), G = new WeakMap(), dt = new WeakMap(), ft = new WeakMap(), tt = new WeakMap(), pt = new WeakMap();
|
|
1119
|
+
function Gr(t) {
|
|
1103
1120
|
const e = t.indexOf(`
|
|
1104
1121
|
`);
|
|
1105
1122
|
return e === -1 ? t.length : e;
|
|
1106
1123
|
}
|
|
1107
|
-
function
|
|
1108
|
-
const { contents: r, kind: s, ifAttribute: o } = t, i = new
|
|
1124
|
+
function Qe(t, e = 0, n = !0) {
|
|
1125
|
+
const { contents: r, kind: s, ifAttribute: o } = t, i = new ie(e), a = o && Si(o);
|
|
1109
1126
|
a && i.add(a + " "), s === "partial" && i.add("-"), i.add("{ ");
|
|
1110
1127
|
const c = r.length - 1;
|
|
1111
1128
|
let l = !1, d = !1;
|
|
1112
1129
|
return r.forEach((p, g) => {
|
|
1113
|
-
if (
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1130
|
+
if (oe(p)) {
|
|
1131
|
+
const T = Qe(p, e + 2, n);
|
|
1132
|
+
l || i.nl(), i.addBlock(T), l = !0, d = !0;
|
|
1116
1133
|
} else {
|
|
1117
1134
|
l && i.add(" "), l = !1;
|
|
1118
1135
|
const x = p;
|
|
1119
|
-
n ? i.add(
|
|
1136
|
+
n ? i.add(Xr(x)) : i.add(Rt(x)), g < c && i.add(" ");
|
|
1120
1137
|
}
|
|
1121
1138
|
}), !d && i.oneLine ? i.add(" }") : (d && !l && i.nl(), i.add("}")), i.add(` #${t.id}`), i.result;
|
|
1122
1139
|
}
|
|
1123
|
-
function
|
|
1124
|
-
return
|
|
1140
|
+
function pa(t) {
|
|
1141
|
+
return Qe(t, 0, !1);
|
|
1125
1142
|
}
|
|
1126
|
-
function
|
|
1143
|
+
function Xr(t) {
|
|
1127
1144
|
const { kind: e, originalName: n } = t;
|
|
1128
1145
|
return `${e === "decl" ? "%" : ""}${n}`;
|
|
1129
1146
|
}
|
|
1130
|
-
function
|
|
1147
|
+
function Rt(t) {
|
|
1131
1148
|
if (!t) return JSON.stringify(t);
|
|
1132
1149
|
const { kind: e, originalName: n } = t, r = t.id ? `#${t.id}` : "";
|
|
1133
1150
|
if (e === "ref") {
|
|
1134
|
-
const s =
|
|
1151
|
+
const s = Rt(t.refersTo);
|
|
1135
1152
|
return `${n} ${r} -> ${s}`;
|
|
1136
1153
|
} else {
|
|
1137
1154
|
const { mangledName: s } = t, o = s ? `(${s})` : "";
|
|
1138
1155
|
return `%${n}${o} ${r} `;
|
|
1139
1156
|
}
|
|
1140
1157
|
}
|
|
1141
|
-
function
|
|
1158
|
+
function tn(t = null) {
|
|
1142
1159
|
return { decls: /* @__PURE__ */ new Map(), parent: t };
|
|
1143
1160
|
}
|
|
1144
|
-
function
|
|
1161
|
+
function ma(t, e) {
|
|
1145
1162
|
const { modulePath: n } = e;
|
|
1146
1163
|
return [...n.split("::"), t.originalName].map((r) => {
|
|
1147
1164
|
const s = (r.match(/_/g) ?? []).length;
|
|
1148
1165
|
return s > 0 ? "_" + s + r : r;
|
|
1149
1166
|
}).join("_");
|
|
1150
1167
|
}
|
|
1151
|
-
function
|
|
1168
|
+
function ga(t, e) {
|
|
1152
1169
|
function n(s) {
|
|
1153
1170
|
return [...s].length;
|
|
1154
1171
|
}
|
|
@@ -1157,16 +1174,16 @@ function fa(t, e) {
|
|
|
1157
1174
|
t.originalName
|
|
1158
1175
|
].map((s) => n(s) + s).join("");
|
|
1159
1176
|
}
|
|
1160
|
-
function
|
|
1161
|
-
return
|
|
1177
|
+
function en(t, e, n, r) {
|
|
1178
|
+
return nn(n, r);
|
|
1162
1179
|
}
|
|
1163
|
-
function
|
|
1180
|
+
function nn(t, e) {
|
|
1164
1181
|
let n = t, r = 0;
|
|
1165
1182
|
for (; e.has(n); )
|
|
1166
1183
|
n = t + r++;
|
|
1167
1184
|
return n;
|
|
1168
1185
|
}
|
|
1169
|
-
function
|
|
1186
|
+
function Jr(t) {
|
|
1170
1187
|
return e([], [], t.segments, t.finalSegment);
|
|
1171
1188
|
function e(n, r, s, o) {
|
|
1172
1189
|
if (s.length > 0) {
|
|
@@ -1187,13 +1204,13 @@ function Ur(t) {
|
|
|
1187
1204
|
], a = [...r, o.name];
|
|
1188
1205
|
return [{ importPath: i, modulePath: a }];
|
|
1189
1206
|
} else
|
|
1190
|
-
|
|
1207
|
+
j(o);
|
|
1191
1208
|
}
|
|
1192
1209
|
}
|
|
1193
1210
|
}
|
|
1194
|
-
var
|
|
1195
|
-
"" +
|
|
1196
|
-
function
|
|
1211
|
+
var Kr = Yr((t) => " ".repeat(t)), Hr = 20;
|
|
1212
|
+
"" + Kr(Hr + 3);
|
|
1213
|
+
function Yr(t) {
|
|
1197
1214
|
const e = /* @__PURE__ */ new Map();
|
|
1198
1215
|
return function(...n) {
|
|
1199
1216
|
const r = JSON.stringify(n);
|
|
@@ -1207,111 +1224,111 @@ function zr(t) {
|
|
|
1207
1224
|
}
|
|
1208
1225
|
typeof DOMRect > "u" && (globalThis.DOMRect = function() {
|
|
1209
1226
|
});
|
|
1210
|
-
function
|
|
1227
|
+
function Zr(t) {
|
|
1211
1228
|
var n;
|
|
1212
1229
|
const e = (n = t.tags.owo) == null ? void 0 : n[0];
|
|
1213
1230
|
for (const r of e)
|
|
1214
|
-
t.app.stable.imports.push(r.imports),
|
|
1231
|
+
t.app.stable.imports.push(r.imports), rt(t, r);
|
|
1215
1232
|
}
|
|
1216
|
-
function
|
|
1233
|
+
function rt(t, e) {
|
|
1217
1234
|
const n = t.app.context, { openElems: r } = n;
|
|
1218
1235
|
r != null && r.length && r[r.length - 1].contents.push(e);
|
|
1219
1236
|
}
|
|
1220
|
-
function
|
|
1237
|
+
function mt(t) {
|
|
1221
1238
|
const { src: e, start: n, end: r } = t, s = t.app, { srcModule: o } = s.stable, i = e.slice(n, r), a = "ref", c = {
|
|
1222
1239
|
kind: a,
|
|
1223
1240
|
originalName: i,
|
|
1224
1241
|
ast: t.app.stable,
|
|
1225
|
-
id:
|
|
1242
|
+
id: se(),
|
|
1226
1243
|
refIdentElem: null
|
|
1227
1244
|
// set below
|
|
1228
1245
|
}, l = { kind: a, start: n, end: r, srcModule: o, ident: c };
|
|
1229
|
-
return c.refIdentElem = l,
|
|
1246
|
+
return c.refIdentElem = l, on(t, l), rt(t, l), l;
|
|
1230
1247
|
}
|
|
1231
|
-
function
|
|
1232
|
-
return
|
|
1248
|
+
function rn(t) {
|
|
1249
|
+
return sn(t, !1);
|
|
1233
1250
|
}
|
|
1234
|
-
function
|
|
1235
|
-
return
|
|
1251
|
+
function It(t) {
|
|
1252
|
+
return sn(t, !0);
|
|
1236
1253
|
}
|
|
1237
|
-
function
|
|
1254
|
+
function sn(t, e) {
|
|
1238
1255
|
const { src: n, start: r, end: s } = t, o = t.app, { scope: i } = o.context, { srcModule: a } = o.stable, c = n.slice(r, s), l = "decl", p = {
|
|
1239
1256
|
declElem: null,
|
|
1240
1257
|
kind: l,
|
|
1241
1258
|
originalName: c,
|
|
1242
1259
|
containingScope: i,
|
|
1243
1260
|
isGlobal: e,
|
|
1244
|
-
id:
|
|
1261
|
+
id: se(),
|
|
1245
1262
|
srcModule: a
|
|
1246
1263
|
}, g = { kind: l, start: r, end: s, srcModule: a, ident: p };
|
|
1247
|
-
return
|
|
1264
|
+
return on(t, g), rt(t, g), g;
|
|
1248
1265
|
}
|
|
1249
|
-
const
|
|
1266
|
+
const ae = E(
|
|
1250
1267
|
"typeDecl",
|
|
1251
1268
|
(t, e) => {
|
|
1252
1269
|
var a, c, l;
|
|
1253
1270
|
const n = (a = t.tags.decl_elem) == null ? void 0 : a[0], r = (c = t.tags.typeRefElem) == null ? void 0 : c[0], s = (l = t.tags.decl_type) == null ? void 0 : l[0], o = { ...e, decl: n, typeScope: s, typeRef: r };
|
|
1254
|
-
return
|
|
1271
|
+
return C(o, t);
|
|
1255
1272
|
}
|
|
1256
1273
|
);
|
|
1257
|
-
function
|
|
1274
|
+
function on(t, e) {
|
|
1258
1275
|
const { ident: n } = e;
|
|
1259
|
-
n.id =
|
|
1276
|
+
n.id = se(), t.app.context.scope.contents.push(n);
|
|
1260
1277
|
}
|
|
1261
|
-
function
|
|
1262
|
-
|
|
1278
|
+
function an(t) {
|
|
1279
|
+
cn("scope", t);
|
|
1263
1280
|
}
|
|
1264
|
-
function
|
|
1265
|
-
|
|
1281
|
+
function Qr(t) {
|
|
1282
|
+
cn("partial", t);
|
|
1266
1283
|
}
|
|
1267
|
-
function
|
|
1268
|
-
const { scope: n } = e.app.context, r =
|
|
1284
|
+
function cn(t, e) {
|
|
1285
|
+
const { scope: n } = e.app.context, r = Ye(n, t);
|
|
1269
1286
|
n.contents.push(r), e.app.context.scope = r;
|
|
1270
1287
|
}
|
|
1271
|
-
function
|
|
1272
|
-
return
|
|
1288
|
+
function ln(t) {
|
|
1289
|
+
return un(t, !0);
|
|
1273
1290
|
}
|
|
1274
|
-
function
|
|
1275
|
-
return
|
|
1291
|
+
function ts(t) {
|
|
1292
|
+
return un(t, !1);
|
|
1276
1293
|
}
|
|
1277
|
-
function
|
|
1294
|
+
function un(t, e) {
|
|
1278
1295
|
const n = t.app.context, r = n.scope, { parent: s } = r;
|
|
1279
1296
|
if (s && (n.scope = s), e) {
|
|
1280
|
-
const o =
|
|
1297
|
+
const o = es(t);
|
|
1281
1298
|
r.ifAttribute = o == null ? void 0 : o[0];
|
|
1282
1299
|
}
|
|
1283
1300
|
return r;
|
|
1284
1301
|
}
|
|
1285
|
-
function
|
|
1302
|
+
function es(t) {
|
|
1286
1303
|
const e = t.tags.attribute;
|
|
1287
|
-
return
|
|
1304
|
+
return dn(e);
|
|
1288
1305
|
}
|
|
1289
|
-
function
|
|
1306
|
+
function dn(t) {
|
|
1290
1307
|
if (t)
|
|
1291
|
-
return
|
|
1308
|
+
return ne(
|
|
1292
1309
|
t,
|
|
1293
1310
|
(e) => e.attribute.kind === "@if" ? e.attribute : void 0
|
|
1294
1311
|
);
|
|
1295
1312
|
}
|
|
1296
|
-
function
|
|
1297
|
-
return
|
|
1313
|
+
function vt(t) {
|
|
1314
|
+
return E(t, (e, n) => {
|
|
1298
1315
|
var l, d;
|
|
1299
|
-
const r = (l = e.tags.var_name) == null ? void 0 : l[0], s = (d = e.tags.decl_scope) == null ? void 0 : d[0], o = e.tags.attribute, i = { ...n, name: r, attributes: o }, a =
|
|
1300
|
-
return c.declElem = a, r.typeScope ? (
|
|
1316
|
+
const r = (l = e.tags.var_name) == null ? void 0 : l[0], s = (d = e.tags.decl_scope) == null ? void 0 : d[0], o = e.tags.attribute, i = { ...n, name: r, attributes: o }, a = C(i, e), c = r.decl.ident;
|
|
1317
|
+
return c.declElem = a, r.typeScope ? (Wt(r.typeScope, s), c.dependentScope = r.typeScope) : c.dependentScope = s, a;
|
|
1301
1318
|
});
|
|
1302
1319
|
}
|
|
1303
|
-
const
|
|
1320
|
+
const ns = E(
|
|
1304
1321
|
"alias",
|
|
1305
1322
|
(t, e) => {
|
|
1306
1323
|
var c, l, d, p;
|
|
1307
|
-
const n = (c = t.tags.alias_name) == null ? void 0 : c[0], r = (l = t.tags.alias_scope) == null ? void 0 : l[0], s = (d = t.tags.typeRefElem) == null ? void 0 : d[0], o = ((p = t.tags.attributes) == null ? void 0 : p.flat()) ?? [], i = { ...e, name: n, attributes: o, typeRef: s }, a =
|
|
1324
|
+
const n = (c = t.tags.alias_name) == null ? void 0 : c[0], r = (l = t.tags.alias_scope) == null ? void 0 : l[0], s = (d = t.tags.typeRefElem) == null ? void 0 : d[0], o = ((p = t.tags.attributes) == null ? void 0 : p.flat()) ?? [], i = { ...e, name: n, attributes: o, typeRef: s }, a = C(i, t);
|
|
1308
1325
|
return n.ident.dependentScope = r, n.ident.declElem = a, a;
|
|
1309
1326
|
}
|
|
1310
|
-
),
|
|
1327
|
+
), rs = E(
|
|
1311
1328
|
"fn",
|
|
1312
1329
|
(t, e) => {
|
|
1313
1330
|
var U;
|
|
1314
|
-
const n =
|
|
1331
|
+
const n = ss(t), { name: r, headerScope: s, returnScope: o, bodyScope: i, body: a, params: c } = n, { attributes: l, returnAttributes: d, returnType: p, fnScope: g } = n, x = {
|
|
1315
1332
|
...e,
|
|
1316
1333
|
name: r,
|
|
1317
1334
|
attributes: l,
|
|
@@ -1320,78 +1337,78 @@ const Hr = w(
|
|
|
1320
1337
|
body: a,
|
|
1321
1338
|
returnType: p
|
|
1322
1339
|
};
|
|
1323
|
-
g.ifAttribute = (U =
|
|
1324
|
-
const
|
|
1325
|
-
o &&
|
|
1326
|
-
const
|
|
1327
|
-
for (const
|
|
1328
|
-
|
|
1329
|
-
return g.contents =
|
|
1340
|
+
g.ifAttribute = (U = dn(l)) == null ? void 0 : U[0];
|
|
1341
|
+
const T = s;
|
|
1342
|
+
o && Wt(T, o), Wt(T, i);
|
|
1343
|
+
const A = [];
|
|
1344
|
+
for (const V of g.contents)
|
|
1345
|
+
V === s || V === o || (V === i ? A.push(T) : A.push(V));
|
|
1346
|
+
return g.contents = A, r.ident.declElem = x, r.ident.dependentScope = T, x;
|
|
1330
1347
|
}
|
|
1331
1348
|
);
|
|
1332
|
-
function
|
|
1333
|
-
const { fn_attributes: e, fn_name: n, fn_param: r, return_attributes: s } = t.tags, { return_type: o } = t.tags, { header_scope: i, return_scope: a, body_scope: c, body_statement: l } = t.tags, { fn_partial_scope: d } = t.tags, p = n == null ? void 0 : n[0], g = i == null ? void 0 : i[0], x = a == null ? void 0 : a[0],
|
|
1349
|
+
function ss(t) {
|
|
1350
|
+
const { fn_attributes: e, fn_name: n, fn_param: r, return_attributes: s } = t.tags, { return_type: o } = t.tags, { header_scope: i, return_scope: a, body_scope: c, body_statement: l } = t.tags, { fn_partial_scope: d } = t.tags, p = n == null ? void 0 : n[0], g = i == null ? void 0 : i[0], x = a == null ? void 0 : a[0], T = c == null ? void 0 : c[0], A = l == null ? void 0 : l[0], U = (r == null ? void 0 : r.flat(3)) ?? [], V = e == null ? void 0 : e.flat(), L = s == null ? void 0 : s.flat(), Zn = o == null ? void 0 : o.flat(3)[0], Qn = d == null ? void 0 : d[0];
|
|
1334
1351
|
return {
|
|
1335
1352
|
name: p,
|
|
1336
1353
|
headerScope: g,
|
|
1337
1354
|
returnScope: x,
|
|
1338
|
-
bodyScope:
|
|
1339
|
-
body:
|
|
1355
|
+
bodyScope: T,
|
|
1356
|
+
body: A,
|
|
1340
1357
|
params: U,
|
|
1341
|
-
attributes:
|
|
1342
|
-
returnAttributes:
|
|
1343
|
-
returnType:
|
|
1344
|
-
fnScope:
|
|
1358
|
+
attributes: V,
|
|
1359
|
+
returnAttributes: L,
|
|
1360
|
+
returnType: Zn,
|
|
1361
|
+
fnScope: Qn
|
|
1345
1362
|
};
|
|
1346
1363
|
}
|
|
1347
|
-
const
|
|
1364
|
+
const os = E(
|
|
1348
1365
|
"param",
|
|
1349
1366
|
(t, e) => {
|
|
1350
1367
|
var i, a;
|
|
1351
|
-
const n = (i = t.tags.param_name) == null ? void 0 : i[0], r = ((a = t.tags.attributes) == null ? void 0 : a.flat()) ?? [], s = { ...e, name: n, attributes: r }, o =
|
|
1368
|
+
const n = (i = t.tags.param_name) == null ? void 0 : i[0], r = ((a = t.tags.attributes) == null ? void 0 : a.flat()) ?? [], s = { ...e, name: n, attributes: r }, o = C(s, t);
|
|
1352
1369
|
return n.decl.ident.declElem = o, o;
|
|
1353
1370
|
}
|
|
1354
|
-
),
|
|
1371
|
+
), is = E(
|
|
1355
1372
|
"struct",
|
|
1356
1373
|
(t, e) => {
|
|
1357
1374
|
var a, c, l;
|
|
1358
1375
|
const n = (a = t.tags.type_name) == null ? void 0 : a[0], r = t.tags.members, s = ((c = t.tags.attributes) == null ? void 0 : c.flat()) ?? [];
|
|
1359
1376
|
n.ident.dependentScope = (l = t.tags.struct_scope) == null ? void 0 : l[0];
|
|
1360
|
-
const o = { ...e, name: n, attributes: s, members: r }, i =
|
|
1377
|
+
const o = { ...e, name: n, attributes: s, members: r }, i = C(o, t);
|
|
1361
1378
|
return n.ident.declElem = i, i;
|
|
1362
1379
|
}
|
|
1363
|
-
),
|
|
1380
|
+
), as = E(
|
|
1364
1381
|
"member",
|
|
1365
1382
|
(t, e) => {
|
|
1366
1383
|
var i, a, c;
|
|
1367
1384
|
const n = (i = t.tags.nameElem) == null ? void 0 : i[0], r = (a = t.tags.typeRefElem) == null ? void 0 : a[0], s = (c = t.tags.attribute) == null ? void 0 : c.flat(3), o = { ...e, name: n, attributes: s, typeRef: r };
|
|
1368
|
-
return
|
|
1385
|
+
return C(o, t);
|
|
1369
1386
|
}
|
|
1370
|
-
),
|
|
1387
|
+
), fn = E(
|
|
1371
1388
|
"attribute",
|
|
1372
1389
|
(t, e) => {
|
|
1373
1390
|
var s;
|
|
1374
1391
|
const n = (s = t.tags.attr_variant) == null ? void 0 : s[0];
|
|
1375
1392
|
return { ...e, attribute: n };
|
|
1376
1393
|
}
|
|
1377
|
-
),
|
|
1378
|
-
function
|
|
1379
|
-
return
|
|
1394
|
+
), cs = ce("assert"), at = ce("statement"), ls = ce("switch-clause");
|
|
1395
|
+
function ce(t) {
|
|
1396
|
+
return E(t, (e, n) => {
|
|
1380
1397
|
var o;
|
|
1381
1398
|
const r = (o = e.tags.attribute) == null ? void 0 : o.flat(3), s = { ...n, attributes: r };
|
|
1382
|
-
return
|
|
1399
|
+
return C(s, e);
|
|
1383
1400
|
});
|
|
1384
1401
|
}
|
|
1385
|
-
const
|
|
1402
|
+
const us = E(
|
|
1386
1403
|
"attribute",
|
|
1387
1404
|
(t, e) => {
|
|
1388
1405
|
var a;
|
|
1389
1406
|
const n = t.tags.attrParam, o = { kind: "@attribute", name: (a = t.tags.name) == null ? void 0 : a[0], params: n };
|
|
1390
1407
|
return { ...e, attribute: o };
|
|
1391
1408
|
}
|
|
1392
|
-
),
|
|
1409
|
+
), ds = E(
|
|
1393
1410
|
"type",
|
|
1394
|
-
// @ts-
|
|
1411
|
+
// @ts-expect-error type mismatch
|
|
1395
1412
|
(t, e) => {
|
|
1396
1413
|
var i, a;
|
|
1397
1414
|
const n = (i = t.tags.templateParam) == null ? void 0 : i.flat(3), r = (a = t.tags.typeRefName) == null ? void 0 : a[0], s = typeof r == "string" ? r : r.ident, o = {
|
|
@@ -1399,27 +1416,27 @@ const ss = w(
|
|
|
1399
1416
|
name: s,
|
|
1400
1417
|
templateParams: n
|
|
1401
1418
|
};
|
|
1402
|
-
return
|
|
1419
|
+
return C(o, t);
|
|
1403
1420
|
}
|
|
1404
|
-
),
|
|
1421
|
+
), pn = E(
|
|
1405
1422
|
"expression",
|
|
1406
1423
|
(t, e) => {
|
|
1407
1424
|
const n = { ...e };
|
|
1408
|
-
return
|
|
1425
|
+
return C(n, t);
|
|
1409
1426
|
}
|
|
1410
1427
|
);
|
|
1411
|
-
function
|
|
1428
|
+
function fs(t) {
|
|
1412
1429
|
var r;
|
|
1413
1430
|
const e = (r = t.tags.const_assert) == null ? void 0 : r.flat()[0], n = t.app.stable;
|
|
1414
1431
|
n.moduleAsserts || (n.moduleAsserts = []), n.moduleAsserts.push(e);
|
|
1415
1432
|
}
|
|
1416
|
-
const
|
|
1433
|
+
const ps = E(
|
|
1417
1434
|
"stuff",
|
|
1418
1435
|
(t, e) => {
|
|
1419
1436
|
const n = { ...e };
|
|
1420
|
-
return
|
|
1437
|
+
return C(n, t);
|
|
1421
1438
|
}
|
|
1422
|
-
),
|
|
1439
|
+
), ms = E(
|
|
1423
1440
|
"memberRef",
|
|
1424
1441
|
(t, e) => {
|
|
1425
1442
|
const { component: n, structRef: r, extra_components: s } = t.tags, o = n == null ? void 0 : n[0], i = r == null ? void 0 : r.flat()[0], a = s == null ? void 0 : s.flat()[0], c = {
|
|
@@ -1428,36 +1445,36 @@ const as = w(
|
|
|
1428
1445
|
member: o,
|
|
1429
1446
|
extraComponents: a
|
|
1430
1447
|
};
|
|
1431
|
-
return
|
|
1448
|
+
return C(c, t);
|
|
1432
1449
|
}
|
|
1433
1450
|
);
|
|
1434
|
-
function
|
|
1451
|
+
function mn(t) {
|
|
1435
1452
|
const { start: e, end: n, src: r } = t, s = r.slice(e, n), o = { kind: "name", start: e, end: n, name: s };
|
|
1436
|
-
return
|
|
1453
|
+
return rt(t, o), o;
|
|
1437
1454
|
}
|
|
1438
|
-
const
|
|
1455
|
+
const gs = E(
|
|
1439
1456
|
"module",
|
|
1440
1457
|
(t, e) => {
|
|
1441
|
-
const n = { ...t, start: 0, end: t.src.length }, r =
|
|
1458
|
+
const n = { ...t, start: 0, end: t.src.length }, r = C(e, n), s = t.app.stable;
|
|
1442
1459
|
return s.moduleElem = r, r;
|
|
1443
1460
|
}
|
|
1444
1461
|
);
|
|
1445
|
-
function
|
|
1462
|
+
function hs(t) {
|
|
1446
1463
|
var a, c;
|
|
1447
1464
|
const { start: e, end: n } = t, r = (a = t.tags.directive) == null ? void 0 : a.flat()[0], i = { kind: "directive", attributes: (c = t.tags.attribute) == null ? void 0 : c.flat(), start: e, end: n, directive: r };
|
|
1448
|
-
return
|
|
1449
|
-
}
|
|
1450
|
-
const
|
|
1451
|
-
before:
|
|
1452
|
-
after:
|
|
1453
|
-
},
|
|
1454
|
-
before:
|
|
1455
|
-
after:
|
|
1456
|
-
},
|
|
1457
|
-
before:
|
|
1458
|
-
after:
|
|
1465
|
+
return rt(t, i), i;
|
|
1466
|
+
}
|
|
1467
|
+
const I = {
|
|
1468
|
+
before: an,
|
|
1469
|
+
after: ln
|
|
1470
|
+
}, $e = {
|
|
1471
|
+
before: an,
|
|
1472
|
+
after: ts
|
|
1473
|
+
}, Bt = {
|
|
1474
|
+
before: Qr,
|
|
1475
|
+
after: ln
|
|
1459
1476
|
};
|
|
1460
|
-
function
|
|
1477
|
+
function E(t, e) {
|
|
1461
1478
|
return {
|
|
1462
1479
|
before: (n) => {
|
|
1463
1480
|
const r = { kind: t, contents: [] };
|
|
@@ -1467,15 +1484,15 @@ function w(t, e) {
|
|
|
1467
1484
|
const s = n.app.context.openElems.pop();
|
|
1468
1485
|
console.assert(s && s.kind === t);
|
|
1469
1486
|
const o = e(n, { ...s, start: n.start, end: n.end });
|
|
1470
|
-
return o &&
|
|
1487
|
+
return o && rt(n, o), o;
|
|
1471
1488
|
}
|
|
1472
1489
|
};
|
|
1473
1490
|
}
|
|
1474
|
-
function
|
|
1475
|
-
const n =
|
|
1491
|
+
function C(t, e) {
|
|
1492
|
+
const n = bs(e, t);
|
|
1476
1493
|
return { ...t, contents: n };
|
|
1477
1494
|
}
|
|
1478
|
-
function
|
|
1495
|
+
function bs(t, e) {
|
|
1479
1496
|
let { start: n } = t;
|
|
1480
1497
|
const r = t.app.stable, { contents: s, end: o } = e, i = s.sort((l, d) => l.start - d.start), a = [];
|
|
1481
1498
|
for (const l of i)
|
|
@@ -1485,81 +1502,81 @@ function ds(t, e) {
|
|
|
1485
1502
|
return { kind: "text", start: n, end: l, srcModule: r.srcModule };
|
|
1486
1503
|
}
|
|
1487
1504
|
}
|
|
1488
|
-
const
|
|
1505
|
+
const M = Kt("word"), gn = Kt("keyword"), gt = Pt(
|
|
1489
1506
|
"::",
|
|
1490
|
-
m(
|
|
1491
|
-
),
|
|
1507
|
+
m(M, gn, "package", "super")
|
|
1508
|
+
), xs = Kt("number");
|
|
1492
1509
|
function Ut(t, e) {
|
|
1493
1510
|
return { kind: "import-statement", segments: t, finalSegment: e };
|
|
1494
1511
|
}
|
|
1495
|
-
function
|
|
1512
|
+
function St(t) {
|
|
1496
1513
|
return { kind: "import-segment", name: t };
|
|
1497
1514
|
}
|
|
1498
|
-
function
|
|
1515
|
+
function ks(t) {
|
|
1499
1516
|
return {
|
|
1500
1517
|
kind: "import-collection",
|
|
1501
1518
|
subtrees: t
|
|
1502
1519
|
};
|
|
1503
1520
|
}
|
|
1504
|
-
function
|
|
1521
|
+
function Pe(t, e) {
|
|
1505
1522
|
return { kind: "import-item", name: t, as: e };
|
|
1506
1523
|
}
|
|
1507
|
-
function
|
|
1524
|
+
function hn(t, e) {
|
|
1508
1525
|
return e.segments = t.concat(e.segments), e;
|
|
1509
1526
|
}
|
|
1510
|
-
let
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1527
|
+
let le = null;
|
|
1528
|
+
const _s = m("super", "package", "import", "as"), vs = N(gr(_s), m(M, gn)), ue = u(
|
|
1529
|
+
vs,
|
|
1513
1530
|
m(
|
|
1514
|
-
|
|
1531
|
+
N(
|
|
1515
1532
|
"::",
|
|
1516
1533
|
f(
|
|
1517
1534
|
m(
|
|
1518
|
-
|
|
1519
|
-
|
|
1535
|
+
X(() => le),
|
|
1536
|
+
X(() => ue)
|
|
1520
1537
|
),
|
|
1521
1538
|
"invalid import, expected '{' or name"
|
|
1522
1539
|
)
|
|
1523
1540
|
),
|
|
1524
|
-
|
|
1525
|
-
(t) =>
|
|
1541
|
+
N("as", f(M, "invalid alias, expected name")).map(
|
|
1542
|
+
(t) => Pe("", t)
|
|
1526
1543
|
),
|
|
1527
|
-
|
|
1544
|
+
_t().map(() => Pe(""))
|
|
1528
1545
|
// Optional
|
|
1529
1546
|
)
|
|
1530
1547
|
).map(([t, e]) => {
|
|
1531
1548
|
if (e.kind === "import-collection")
|
|
1532
|
-
return Ut([
|
|
1549
|
+
return Ut([St(t)], e);
|
|
1533
1550
|
if (e.kind === "import-statement")
|
|
1534
|
-
return
|
|
1551
|
+
return hn([St(t)], e);
|
|
1535
1552
|
if (e.kind === "import-item")
|
|
1536
1553
|
return e.name = t, Ut([], e);
|
|
1537
|
-
|
|
1554
|
+
j(e);
|
|
1538
1555
|
});
|
|
1539
|
-
|
|
1556
|
+
le = W(
|
|
1540
1557
|
"{",
|
|
1541
|
-
|
|
1558
|
+
Pt(",", () => ue).map(ks),
|
|
1542
1559
|
f("}", "invalid import collection, expected }")
|
|
1543
1560
|
);
|
|
1544
|
-
const
|
|
1545
|
-
|
|
1546
|
-
|
|
1561
|
+
const Ss = m(
|
|
1562
|
+
Ft("package", f("::", "invalid import, expected '::'")).map((t) => [
|
|
1563
|
+
St(t)
|
|
1547
1564
|
]),
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1565
|
+
D(
|
|
1566
|
+
Ft("super", f("::", "invalid import, expected '::'")).map(
|
|
1567
|
+
St
|
|
1551
1568
|
)
|
|
1552
1569
|
)
|
|
1553
|
-
),
|
|
1554
|
-
|
|
1570
|
+
), ys = Ht(
|
|
1571
|
+
W(
|
|
1555
1572
|
"import",
|
|
1556
|
-
|
|
1557
|
-
relative: h(
|
|
1573
|
+
fr({
|
|
1574
|
+
relative: h(Ss),
|
|
1558
1575
|
collection_or_statement: f(
|
|
1559
|
-
m(
|
|
1576
|
+
m(le, ue),
|
|
1560
1577
|
"invalid import, expected { or name"
|
|
1561
1578
|
)
|
|
1562
|
-
}).map(({ relative: t, collection_or_statement: e }) => e.kind === "import-statement" ?
|
|
1579
|
+
}).map(({ relative: t, collection_or_statement: e }) => e.kind === "import-statement" ? hn(t ?? [], e) : Ut(t ?? [], e)),
|
|
1563
1580
|
f(";", "invalid import, expected ';'")
|
|
1564
1581
|
)
|
|
1565
1582
|
).map(
|
|
@@ -1569,11 +1586,11 @@ const hs = m(
|
|
|
1569
1586
|
start: t.span[0],
|
|
1570
1587
|
end: t.span[1]
|
|
1571
1588
|
})
|
|
1572
|
-
),
|
|
1573
|
-
|
|
1574
|
-
),
|
|
1589
|
+
), ws = _(
|
|
1590
|
+
$(ys).ptag("owo").collect(Zr)
|
|
1591
|
+
), Es = `alias break case const const_assert continue continuing
|
|
1575
1592
|
default diagnostic discard else enable false fn for if
|
|
1576
|
-
let loop override requires return struct switch true var while`.split(/\s+/),
|
|
1593
|
+
let loop override requires return struct switch true var while`.split(/\s+/), Ts = `NULL Self abstract active alignas alignof as asm asm_fragment async attribute auto await
|
|
1577
1594
|
become binding_array cast catch class co_await co_return co_yield coherent column_major
|
|
1578
1595
|
common compile compile_fragment concept const_cast consteval constexpr constinit crate
|
|
1579
1596
|
debugger decltype delete demote demote_to_helper do dynamic_cast
|
|
@@ -1587,24 +1604,29 @@ const hs = m(
|
|
|
1587
1604
|
target template this thread_local throw trait try type typedef typeid typename typeof
|
|
1588
1605
|
union unless unorm unsafe unsized use using varying virtual volatile wgsl where with writeonly yield`.split(
|
|
1589
1606
|
/\s+/
|
|
1590
|
-
),
|
|
1607
|
+
), Ns = /[ \t\n\v\f\r\u{0085}\u{200E}\u{200F}\u{2028}\u{2029}]+/u, $s = "& && -> @ / ! [ ] { } :: : , == = != >>= >> >= > <<= << <= < % - -- . + ++ | || ( ) ; * ~ ^ // /* */ += -= *= /= %= &= |= ^= _", Ps = /(?:(?:[_\p{XID_Start}][\p{XID_Continue}]+)|(?:[\p{XID_Start}]))/u, Ms = new Set(Es.concat(Ts)), Cs = new RegExp(
|
|
1591
1608
|
// decimal_float_literal
|
|
1592
1609
|
/(?:0[fh])|(?:[1-9][0-9]*[fh])/.source + /|(?:[0-9]*\.[0-9]+(?:[eE][+-]?[0-9]+)?[fh]?)/.source + /|(?:[0-9]+\.[0-9]*(?:[eE][+-]?[0-9]+)?[fh]?)/.source + /|(?:[0-9]+[eE][+-]?[0-9]+[fh]?)/.source + // hex_float_literal
|
|
1593
1610
|
/|(?:0[xX][0-9a-fA-F]*\.[0-9a-fA-F]+(?:[pP][+-]?[0-9]+[fh]?)?)/.source + /|(?:0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*(?:[pP][+-]?[0-9]+[fh]?)?)/.source + /|(?:0[xX][0-9a-fA-F]+[pP][+-]?[0-9]+[fh]?)/.source + // hex_int_literal
|
|
1594
1611
|
/|(?:0[xX][0-9a-fA-F]+[iu]?)/.source + // decimal_int_literal
|
|
1595
1612
|
/|(?:0[iu]?)|(?:[1-9][0-9]*[iu]?)/.source
|
|
1596
|
-
),
|
|
1597
|
-
word:
|
|
1598
|
-
number:
|
|
1599
|
-
blankspaces:
|
|
1600
|
-
commentStart:
|
|
1601
|
-
symbol:
|
|
1613
|
+
), As = /\/\/|\/\*/, Rs = new Br({
|
|
1614
|
+
word: Ps,
|
|
1615
|
+
number: Cs,
|
|
1616
|
+
blankspaces: Ns,
|
|
1617
|
+
commentStart: As,
|
|
1618
|
+
symbol: Ct($s),
|
|
1602
1619
|
// biome-ignore lint/correctness/noEmptyCharacterClassInRegex: TODO
|
|
1603
1620
|
invalid: /[^]/
|
|
1604
1621
|
});
|
|
1605
|
-
class
|
|
1622
|
+
class Is {
|
|
1606
1623
|
constructor(e) {
|
|
1607
|
-
this
|
|
1624
|
+
w(this, "stream");
|
|
1625
|
+
/** New line */
|
|
1626
|
+
w(this, "eolPattern", /[\n\v\f\u{0085}\u{2028}\u{2029}]|\r\n?/gu);
|
|
1627
|
+
/** Block comments */
|
|
1628
|
+
w(this, "blockCommentPattern", /\/\*|\*\//g);
|
|
1629
|
+
this.src = e, this.stream = new Mr(new Ir(e, Rs));
|
|
1608
1630
|
}
|
|
1609
1631
|
checkpoint() {
|
|
1610
1632
|
return this.stream.checkpoint();
|
|
@@ -1622,10 +1644,10 @@ class $s {
|
|
|
1622
1644
|
e.text === "//" ? this.stream.reset(this.skipToEol(e.span[1])) : this.stream.reset(this.skipBlockComment(e.span[1]));
|
|
1623
1645
|
else if (n === "word") {
|
|
1624
1646
|
const r = e;
|
|
1625
|
-
return
|
|
1647
|
+
return Ms.has(e.text) && (r.kind = "keyword"), r;
|
|
1626
1648
|
} else {
|
|
1627
1649
|
if (n === "invalid")
|
|
1628
|
-
throw new
|
|
1650
|
+
throw new Z("Invalid token " + e.text, e.span);
|
|
1629
1651
|
return e;
|
|
1630
1652
|
}
|
|
1631
1653
|
}
|
|
@@ -1639,7 +1661,7 @@ class $s {
|
|
|
1639
1661
|
this.blockCommentPattern.lastIndex = n;
|
|
1640
1662
|
const r = this.blockCommentPattern.exec(this.src);
|
|
1641
1663
|
if (r === null)
|
|
1642
|
-
throw new
|
|
1664
|
+
throw new Z("Unclosed block comment!", [n, n]);
|
|
1643
1665
|
if (r[0] === "*/")
|
|
1644
1666
|
return this.blockCommentPattern.lastIndex;
|
|
1645
1667
|
if (r[0] === "/*")
|
|
@@ -1708,7 +1730,7 @@ class $s {
|
|
|
1708
1730
|
const n = this.stream.nextToken();
|
|
1709
1731
|
if (n === null) {
|
|
1710
1732
|
const r = this.stream.checkpoint();
|
|
1711
|
-
throw new
|
|
1733
|
+
throw new Z("Unclosed bracket!", [r, r]);
|
|
1712
1734
|
}
|
|
1713
1735
|
if (n.kind === "symbol") {
|
|
1714
1736
|
if (n.text === "(")
|
|
@@ -1721,165 +1743,165 @@ class $s {
|
|
|
1721
1743
|
}
|
|
1722
1744
|
}
|
|
1723
1745
|
}
|
|
1724
|
-
const
|
|
1746
|
+
const bn = Oe((t) => t.nextTemplateStartToken()), xn = Oe((t) => t.nextTemplateEndToken()), de = h(
|
|
1725
1747
|
u(
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
f(
|
|
1748
|
+
bn,
|
|
1749
|
+
Pt(",", () => Xs),
|
|
1750
|
+
f(xn, "invalid template, expected '>'")
|
|
1729
1751
|
)
|
|
1730
|
-
),
|
|
1752
|
+
), Bs = m("private", "workgroup", "uniform", "function"), Ds = u(
|
|
1731
1753
|
"storage",
|
|
1732
1754
|
h(u(",", m("read", "read_write")))
|
|
1733
|
-
),
|
|
1755
|
+
), kn = h(
|
|
1734
1756
|
u(
|
|
1735
|
-
|
|
1736
|
-
m(
|
|
1737
|
-
f(
|
|
1757
|
+
bn,
|
|
1758
|
+
m(Ds, Bs),
|
|
1759
|
+
f(xn, "invalid template, expected '>'")
|
|
1738
1760
|
)
|
|
1739
|
-
),
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
),
|
|
1761
|
+
), js = u(
|
|
1762
|
+
gt.collect(mt),
|
|
1763
|
+
de
|
|
1764
|
+
), Ls = m("true", "false", xs), Os = u(
|
|
1743
1765
|
"(",
|
|
1744
1766
|
() => v,
|
|
1745
1767
|
f(")", "invalid expression, expected ')'")
|
|
1746
|
-
),
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
u(
|
|
1750
|
-
),
|
|
1768
|
+
), qs = m(
|
|
1769
|
+
Ls,
|
|
1770
|
+
Os,
|
|
1771
|
+
u(js, h(X(() => Sn)))
|
|
1772
|
+
), yt = D(
|
|
1751
1773
|
m(
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1774
|
+
N(".", M),
|
|
1775
|
+
pr(
|
|
1776
|
+
W(
|
|
1755
1777
|
"[",
|
|
1756
1778
|
() => v,
|
|
1757
1779
|
f("]", "invalid expression, expected ']'")
|
|
1758
1780
|
)
|
|
1759
1781
|
)
|
|
1760
1782
|
)
|
|
1761
|
-
),
|
|
1783
|
+
), _n = _(
|
|
1762
1784
|
u(
|
|
1763
|
-
|
|
1764
|
-
u(".",
|
|
1765
|
-
h(
|
|
1766
|
-
).collect(
|
|
1767
|
-
),
|
|
1768
|
-
u(
|
|
1785
|
+
gt.collect(mt, "structRef"),
|
|
1786
|
+
u(".", M.collect(mn, "component")),
|
|
1787
|
+
h(yt.collect(ps, "extra_components"))
|
|
1788
|
+
).collect(ms)
|
|
1789
|
+
), P = m(
|
|
1790
|
+
u(kt("symbol", ["!", "&", "*", "-", "~"]), () => P),
|
|
1769
1791
|
m(
|
|
1770
|
-
|
|
1771
|
-
u(
|
|
1792
|
+
_n,
|
|
1793
|
+
u(qs, h(yt))
|
|
1772
1794
|
)
|
|
1773
|
-
),
|
|
1795
|
+
), Fs = m(
|
|
1774
1796
|
// LATER I can skip template list discovery in these cases, because a&b<c cannot be a comparison. Must be a template
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
),
|
|
1779
|
-
const e = u("<<",
|
|
1780
|
-
|
|
1781
|
-
|
|
1797
|
+
D(u("&", P)),
|
|
1798
|
+
D(u("^", P)),
|
|
1799
|
+
D(u("|", P))
|
|
1800
|
+
), Me = m("%", "*", "/"), Ws = m("+", "-"), Ce = (t) => {
|
|
1801
|
+
const e = u("<<", P), n = u(">>", P), r = u(
|
|
1802
|
+
$(u(Me, P)),
|
|
1803
|
+
$(
|
|
1782
1804
|
u(
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1805
|
+
Ws,
|
|
1806
|
+
P,
|
|
1807
|
+
$(u(Me, P))
|
|
1786
1808
|
)
|
|
1787
1809
|
)
|
|
1788
1810
|
);
|
|
1789
1811
|
return t ? m(e, r) : m(e, n, r);
|
|
1790
|
-
},
|
|
1791
|
-
|
|
1812
|
+
}, Lt = (t) => u(
|
|
1813
|
+
Ce(t),
|
|
1792
1814
|
h(
|
|
1793
1815
|
u(
|
|
1794
1816
|
// '<' is unambiguous, since templates were already caught by the primary expression inside of the previous unary_expression!
|
|
1795
|
-
t ?
|
|
1817
|
+
t ? kt("symbol", ["<", "<=", "!=", "=="]) : kt("symbol", [">", ">=", "<", "<=", "!=", "=="]),
|
|
1796
1818
|
// LATER I can skip template list discovery in this cases, because a>=b<c cannot be a comparison. Must be a template
|
|
1797
|
-
|
|
1798
|
-
|
|
1819
|
+
P,
|
|
1820
|
+
Ce(t)
|
|
1799
1821
|
)
|
|
1800
1822
|
)
|
|
1801
|
-
),
|
|
1802
|
-
|
|
1823
|
+
), vn = (t) => u(
|
|
1824
|
+
P,
|
|
1803
1825
|
m(
|
|
1804
|
-
|
|
1826
|
+
Fs,
|
|
1805
1827
|
u(
|
|
1806
|
-
|
|
1828
|
+
Lt(t),
|
|
1807
1829
|
t ? (
|
|
1808
1830
|
// Don't accept || or && in template mode
|
|
1809
|
-
|
|
1831
|
+
_t()
|
|
1810
1832
|
) : m(
|
|
1811
|
-
|
|
1812
|
-
u("||", u(
|
|
1833
|
+
D(
|
|
1834
|
+
u("||", u(P, Lt(!1)))
|
|
1813
1835
|
),
|
|
1814
|
-
|
|
1815
|
-
u("&&", u(
|
|
1836
|
+
D(
|
|
1837
|
+
u("&&", u(P, Lt(!1)))
|
|
1816
1838
|
),
|
|
1817
|
-
|
|
1839
|
+
_t().map(() => [])
|
|
1818
1840
|
)
|
|
1819
1841
|
)
|
|
1820
1842
|
)
|
|
1821
|
-
),
|
|
1822
|
-
|
|
1823
|
-
() =>
|
|
1824
|
-
).collect(
|
|
1825
|
-
|
|
1826
|
-
).ctag("typeRefElem"),
|
|
1843
|
+
), Us = !1, v = vn(Us), Vs = !0, zs = vn(Vs), Gs = u(
|
|
1844
|
+
gt.collect(mt, "typeRefName"),
|
|
1845
|
+
() => de
|
|
1846
|
+
).collect(ds), H = _(
|
|
1847
|
+
Gs
|
|
1848
|
+
).ctag("typeRefElem"), Xs = m(
|
|
1827
1849
|
// LATER Remove this, it's wrong. This should instead be done by inspecting the syntax tree.
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
),
|
|
1850
|
+
H.ctag("templateParam"),
|
|
1851
|
+
zs.collect(pn, "templateParam")
|
|
1852
|
+
), Sn = u(
|
|
1831
1853
|
"(",
|
|
1832
|
-
|
|
1854
|
+
nt(",", v),
|
|
1833
1855
|
f(")", "invalid fn arguments, expected ')'")
|
|
1834
|
-
),
|
|
1835
|
-
|
|
1836
|
-
h(
|
|
1837
|
-
),
|
|
1856
|
+
), ct = Le("word").map(Do), Js = u(
|
|
1857
|
+
ct,
|
|
1858
|
+
h(N(".", f(ct, "invalid diagnostic rule name, expected name")))
|
|
1859
|
+
), yn = W(
|
|
1838
1860
|
"(",
|
|
1839
1861
|
f(
|
|
1840
|
-
|
|
1862
|
+
mr(ct, ",", Js),
|
|
1841
1863
|
"invalid diagnostic control, expected rule name"
|
|
1842
1864
|
),
|
|
1843
1865
|
u(h(","), f(")", "invalid diagnostic control, expected ')'"))
|
|
1844
|
-
),
|
|
1845
|
-
|
|
1866
|
+
), Vt = nt(",", ct, { requireOne: !0 }), wn = _(
|
|
1867
|
+
N(
|
|
1846
1868
|
"@",
|
|
1847
1869
|
m(
|
|
1848
1870
|
// These attributes have no arguments
|
|
1849
1871
|
m("compute", "const", "fragment", "invariant", "must_use", "vertex").map(
|
|
1850
|
-
(t) =>
|
|
1872
|
+
(t) => Mo([t, []])
|
|
1851
1873
|
),
|
|
1852
1874
|
// These attributes have arguments, but the argument doesn't have any identifiers
|
|
1853
|
-
|
|
1875
|
+
N(
|
|
1854
1876
|
"interpolate",
|
|
1855
1877
|
f(
|
|
1856
|
-
|
|
1878
|
+
W("(", Vt, ")"),
|
|
1857
1879
|
"invalid @interpolate, expected '('"
|
|
1858
1880
|
)
|
|
1859
|
-
).map(
|
|
1860
|
-
|
|
1881
|
+
).map(Co),
|
|
1882
|
+
N(
|
|
1861
1883
|
"builtin",
|
|
1862
|
-
f(
|
|
1863
|
-
).map(
|
|
1864
|
-
|
|
1884
|
+
f(W("(", ct, ")"), "invalid @builtin, expected '('")
|
|
1885
|
+
).map(Ao),
|
|
1886
|
+
N(
|
|
1865
1887
|
"diagnostic",
|
|
1866
|
-
f(
|
|
1867
|
-
).map(
|
|
1888
|
+
f(yn, "invalid @diagnostic, expected '('")
|
|
1889
|
+
).map(Ro)
|
|
1868
1890
|
).ptag("attr_variant")
|
|
1869
|
-
).collect(
|
|
1870
|
-
),
|
|
1871
|
-
|
|
1891
|
+
).collect(fn)
|
|
1892
|
+
), Ks = _(
|
|
1893
|
+
N(
|
|
1872
1894
|
u("@", "if"),
|
|
1873
|
-
|
|
1874
|
-
|
|
1895
|
+
Ht(
|
|
1896
|
+
W(
|
|
1875
1897
|
"(",
|
|
1876
|
-
|
|
1898
|
+
X(() => Tn),
|
|
1877
1899
|
u(h(","), ")")
|
|
1878
1900
|
)
|
|
1879
|
-
).map(
|
|
1880
|
-
).map(
|
|
1881
|
-
),
|
|
1882
|
-
|
|
1901
|
+
).map(Bo)
|
|
1902
|
+
).map(Io).ptag("attr_variant").collect(fn)
|
|
1903
|
+
), En = _(
|
|
1904
|
+
N(
|
|
1883
1905
|
"@",
|
|
1884
1906
|
m(
|
|
1885
1907
|
// These are normal attributes, with required arguments
|
|
@@ -1894,427 +1916,427 @@ const mn = De((t) => t.nextTemplateStartToken()), gn = De((t) => t.nextTemplateE
|
|
|
1894
1916
|
"location",
|
|
1895
1917
|
"size"
|
|
1896
1918
|
).ptag("name"),
|
|
1897
|
-
f(() =>
|
|
1919
|
+
f(() => Ae, "invalid attribute, expected '('")
|
|
1898
1920
|
),
|
|
1899
1921
|
// Everything else is also a normal attribute, optional expression list
|
|
1900
1922
|
u(
|
|
1901
1923
|
// we don't want this to interfere with if_attribute,
|
|
1902
1924
|
// but not("if") isn't necessary for now, since 'if' is a keyword, not a word
|
|
1903
|
-
|
|
1904
|
-
h(() =>
|
|
1925
|
+
M.ptag("name"),
|
|
1926
|
+
h(() => Ae)
|
|
1905
1927
|
)
|
|
1906
1928
|
)
|
|
1907
|
-
).collect(
|
|
1908
|
-
),
|
|
1929
|
+
).collect(us)
|
|
1930
|
+
), Ae = W(
|
|
1909
1931
|
"(",
|
|
1910
|
-
|
|
1932
|
+
nt(
|
|
1911
1933
|
",",
|
|
1912
|
-
|
|
1934
|
+
Ht(X(() => v)).collect(pn, "attrParam")
|
|
1913
1935
|
// LATER These unknown expressions have decls inside of them, that's why they're tough to replace!
|
|
1914
1936
|
),
|
|
1915
1937
|
f(")", "invalid attribute arguments, expected ')'")
|
|
1916
|
-
),
|
|
1938
|
+
), Hs = m(wn, En).ctag(
|
|
1917
1939
|
"attribute"
|
|
1918
|
-
),
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
).ctag("attribute"), S =
|
|
1923
|
-
|
|
1940
|
+
), Ys = m(
|
|
1941
|
+
Ks,
|
|
1942
|
+
wn,
|
|
1943
|
+
En
|
|
1944
|
+
).ctag("attribute"), S = $(Ys), zt = $(Hs), Zs = f(
|
|
1945
|
+
M.collect(It, "type_name"),
|
|
1924
1946
|
"invalid type name, expected a name"
|
|
1925
|
-
),
|
|
1926
|
-
|
|
1947
|
+
), Qs = f(
|
|
1948
|
+
M.collect(It, "fn_name"),
|
|
1927
1949
|
"missing fn name"
|
|
1928
|
-
),
|
|
1950
|
+
), to = _(
|
|
1929
1951
|
u(
|
|
1930
|
-
|
|
1931
|
-
h(u(":",
|
|
1932
|
-
).collect(
|
|
1933
|
-
).ctag("var_name"),
|
|
1952
|
+
M.collect(rn, "decl_elem"),
|
|
1953
|
+
h(u(":", H))
|
|
1954
|
+
).collect(ae)
|
|
1955
|
+
).ctag("var_name"), Gt = f(to, "invalid ident"), Xt = _(
|
|
1934
1956
|
f(
|
|
1935
1957
|
u(
|
|
1936
|
-
|
|
1937
|
-
h(u(":",
|
|
1938
|
-
).collect(
|
|
1958
|
+
M.collect(It, "decl_elem"),
|
|
1959
|
+
h(u(":", H.collect(I, "decl_type")))
|
|
1960
|
+
).collect(ae),
|
|
1939
1961
|
"expected identifier"
|
|
1940
1962
|
)
|
|
1941
|
-
).ctag("var_name"),
|
|
1963
|
+
).ctag("var_name"), eo = _(
|
|
1942
1964
|
u(
|
|
1943
1965
|
S,
|
|
1944
|
-
|
|
1966
|
+
M.collect(mn, "nameElem"),
|
|
1945
1967
|
f(":", "invalid struct member, expected ':'"),
|
|
1946
|
-
f(
|
|
1947
|
-
).collect(
|
|
1948
|
-
).ctag("members"),
|
|
1968
|
+
f(H, "invalid struct member, expected type specifier")
|
|
1969
|
+
).collect(as)
|
|
1970
|
+
).ctag("members"), no = u(
|
|
1949
1971
|
S.collect((t) => t.tags.attribute, "attributes"),
|
|
1950
1972
|
"struct",
|
|
1951
|
-
f(
|
|
1973
|
+
f(Zs, "invalid struct, expected name"),
|
|
1952
1974
|
u(
|
|
1953
1975
|
f("{", "invalid struct, expected '{'"),
|
|
1954
|
-
|
|
1976
|
+
Pt(",", eo),
|
|
1955
1977
|
f("}", "invalid struct, expected '}'")
|
|
1956
|
-
).collect(
|
|
1957
|
-
).collect(
|
|
1958
|
-
|
|
1959
|
-
() =>
|
|
1960
|
-
|
|
1961
|
-
),
|
|
1978
|
+
).collect(I, "struct_scope")
|
|
1979
|
+
).collect(is), fe = u(
|
|
1980
|
+
gt.collect(mt),
|
|
1981
|
+
() => de,
|
|
1982
|
+
Sn
|
|
1983
|
+
), ro = _(
|
|
1962
1984
|
u(
|
|
1963
1985
|
S.collect((t) => t.tags.attribute, "attributes"),
|
|
1964
|
-
|
|
1986
|
+
M.collect(rn, "decl_elem"),
|
|
1965
1987
|
h(
|
|
1966
1988
|
u(
|
|
1967
1989
|
":",
|
|
1968
|
-
f(
|
|
1990
|
+
f(H, "invalid fn parameter, expected type specifier")
|
|
1969
1991
|
)
|
|
1970
|
-
).collect(
|
|
1971
|
-
).collect(
|
|
1972
|
-
).ctag("fn_param"),
|
|
1992
|
+
).collect(ae, "param_name")
|
|
1993
|
+
).collect(os)
|
|
1994
|
+
).ctag("fn_param"), so = u("(", nt(",", ro), ")"), oo = u(
|
|
1973
1995
|
"var",
|
|
1974
|
-
() =>
|
|
1975
|
-
|
|
1996
|
+
() => kn,
|
|
1997
|
+
Gt,
|
|
1976
1998
|
h(u("=", () => v))
|
|
1977
1999
|
// no decl_scope, but I think that's ok
|
|
1978
|
-
).collect(
|
|
2000
|
+
).collect(vt("var")), io = u(
|
|
1979
2001
|
S,
|
|
1980
2002
|
"var",
|
|
1981
|
-
() =>
|
|
1982
|
-
|
|
1983
|
-
h(u("=", () => v.collect(
|
|
2003
|
+
() => kn,
|
|
2004
|
+
Xt,
|
|
2005
|
+
h(u("=", () => v.collect(I, "decl_scope"))),
|
|
1984
2006
|
";"
|
|
1985
|
-
).collect(
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
).map(
|
|
1992
|
-
|
|
1993
|
-
),
|
|
2007
|
+
).collect(vt("gvar")).collect(Bt), ao = m(
|
|
2008
|
+
kt("keyword", ["true", "false"]).map(jo),
|
|
2009
|
+
W(
|
|
2010
|
+
it("symbol", "("),
|
|
2011
|
+
X(() => Tn),
|
|
2012
|
+
it("symbol", ")")
|
|
2013
|
+
).map(Oo),
|
|
2014
|
+
Le("word").map(Lo)
|
|
2015
|
+
), xt = m(
|
|
1994
2016
|
u(
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
).map(
|
|
1998
|
-
|
|
1999
|
-
),
|
|
2000
|
-
|
|
2017
|
+
it("symbol", "!").map(qo),
|
|
2018
|
+
X(() => xt)
|
|
2019
|
+
).map(Fo),
|
|
2020
|
+
ao
|
|
2021
|
+
), Tn = u(
|
|
2022
|
+
xt,
|
|
2001
2023
|
m(
|
|
2002
|
-
|
|
2024
|
+
D(
|
|
2003
2025
|
u(
|
|
2004
|
-
|
|
2026
|
+
it("symbol", "||").map(Re),
|
|
2005
2027
|
f(
|
|
2006
|
-
|
|
2028
|
+
xt,
|
|
2007
2029
|
"invalid expression, expected expression"
|
|
2008
2030
|
)
|
|
2009
2031
|
)
|
|
2010
2032
|
),
|
|
2011
|
-
|
|
2033
|
+
D(
|
|
2012
2034
|
u(
|
|
2013
|
-
|
|
2035
|
+
it("symbol", "&&").map(Re),
|
|
2014
2036
|
f(
|
|
2015
|
-
|
|
2037
|
+
xt,
|
|
2016
2038
|
"invalid expression, expected expression"
|
|
2017
2039
|
)
|
|
2018
2040
|
)
|
|
2019
2041
|
),
|
|
2020
|
-
|
|
2042
|
+
_t().map(() => [])
|
|
2021
2043
|
)
|
|
2022
|
-
).map(
|
|
2044
|
+
).map(Wo), Nn = u(
|
|
2023
2045
|
S,
|
|
2024
|
-
|
|
2025
|
-
|
|
2046
|
+
$t("{"),
|
|
2047
|
+
$(() => wt),
|
|
2026
2048
|
f("}", "invalid block, expected }")
|
|
2027
|
-
).collect(
|
|
2049
|
+
).collect(at), K = _(
|
|
2028
2050
|
u(
|
|
2029
2051
|
S,
|
|
2030
2052
|
u(
|
|
2031
|
-
|
|
2032
|
-
|
|
2053
|
+
$t("{"),
|
|
2054
|
+
$(() => wt),
|
|
2033
2055
|
f("}", "invalid block, expected '}'")
|
|
2034
|
-
).collect(
|
|
2035
|
-
).collect(
|
|
2036
|
-
),
|
|
2056
|
+
).collect(I)
|
|
2057
|
+
).collect(at)
|
|
2058
|
+
), co = u(
|
|
2037
2059
|
S,
|
|
2038
2060
|
m(
|
|
2039
|
-
|
|
2040
|
-
() =>
|
|
2041
|
-
() =>
|
|
2061
|
+
fe,
|
|
2062
|
+
() => Pn,
|
|
2063
|
+
() => pe
|
|
2042
2064
|
)
|
|
2043
|
-
),
|
|
2065
|
+
), lo = u(
|
|
2044
2066
|
S,
|
|
2045
|
-
m(
|
|
2046
|
-
),
|
|
2067
|
+
m(fe, () => pe)
|
|
2068
|
+
), uo = u(
|
|
2047
2069
|
// LATER consider allowing @if on for_init, expression and for_update
|
|
2048
2070
|
"for",
|
|
2049
2071
|
u(
|
|
2050
2072
|
f("(", "invalid for loop, expected '('"),
|
|
2051
|
-
h(
|
|
2073
|
+
h(co),
|
|
2052
2074
|
f(";", "invalid for loop, expected ';'"),
|
|
2053
2075
|
h(v),
|
|
2054
2076
|
f(";", "invalid for loop, expected ';'"),
|
|
2055
|
-
h(
|
|
2077
|
+
h(lo),
|
|
2056
2078
|
f(")", "invalid for loop, expected ')'"),
|
|
2057
|
-
|
|
2058
|
-
).collect(
|
|
2059
|
-
),
|
|
2079
|
+
Nn
|
|
2080
|
+
).collect(I)
|
|
2081
|
+
), fo = u(
|
|
2060
2082
|
"if",
|
|
2061
|
-
f(u(v,
|
|
2062
|
-
|
|
2083
|
+
f(u(v, K), "invalid if statement"),
|
|
2084
|
+
$(
|
|
2063
2085
|
u(
|
|
2064
2086
|
"else",
|
|
2065
2087
|
"if",
|
|
2066
|
-
f(u(v,
|
|
2088
|
+
f(u(v, K), "invalid else if branch")
|
|
2067
2089
|
)
|
|
2068
2090
|
),
|
|
2069
2091
|
h(
|
|
2070
|
-
u("else", f(
|
|
2092
|
+
u("else", f(K, "invalid else branch, expected '{'"))
|
|
2071
2093
|
)
|
|
2072
|
-
),
|
|
2094
|
+
), po = u(
|
|
2073
2095
|
"loop",
|
|
2074
|
-
|
|
2096
|
+
zt,
|
|
2075
2097
|
f(
|
|
2076
2098
|
u(
|
|
2077
2099
|
"{",
|
|
2078
|
-
|
|
2100
|
+
$(() => wt),
|
|
2079
2101
|
h(
|
|
2080
2102
|
_(
|
|
2081
2103
|
u(
|
|
2082
2104
|
S,
|
|
2083
2105
|
"continuing",
|
|
2084
|
-
|
|
2106
|
+
zt,
|
|
2085
2107
|
"{",
|
|
2086
|
-
|
|
2108
|
+
$(() => wt),
|
|
2087
2109
|
_(
|
|
2088
2110
|
h(
|
|
2089
2111
|
u(
|
|
2090
2112
|
S,
|
|
2091
2113
|
u("break", "if", v, ";")
|
|
2092
|
-
).collect(
|
|
2114
|
+
).collect(at)
|
|
2093
2115
|
)
|
|
2094
2116
|
),
|
|
2095
2117
|
"}"
|
|
2096
|
-
).collect(
|
|
2118
|
+
).collect(at).collect(I)
|
|
2097
2119
|
)
|
|
2098
2120
|
),
|
|
2099
2121
|
"}"
|
|
2100
2122
|
),
|
|
2101
2123
|
"invalid loop statement"
|
|
2102
2124
|
)
|
|
2103
|
-
).collect(
|
|
2125
|
+
).collect(I), mo = m("default", v), go = _(
|
|
2104
2126
|
u(
|
|
2105
2127
|
S,
|
|
2106
2128
|
m(
|
|
2107
2129
|
u(
|
|
2108
2130
|
"case",
|
|
2109
|
-
|
|
2131
|
+
nt(",", mo, { requireOne: !0 }),
|
|
2110
2132
|
h(":"),
|
|
2111
|
-
|
|
2133
|
+
K
|
|
2112
2134
|
),
|
|
2113
|
-
u("default", h(":"),
|
|
2114
|
-
).collect(
|
|
2135
|
+
u("default", h(":"), K)
|
|
2136
|
+
).collect(ls)
|
|
2115
2137
|
)
|
|
2116
|
-
),
|
|
2117
|
-
so,
|
|
2118
|
-
oo,
|
|
2119
|
-
io,
|
|
2138
|
+
), ho = u(S, "{", D(go), "}"), bo = u("switch", v, ho), xo = u("while", v, K), $n = m(
|
|
2120
2139
|
uo,
|
|
2121
2140
|
fo,
|
|
2141
|
+
po,
|
|
2142
|
+
bo,
|
|
2143
|
+
xo,
|
|
2122
2144
|
u("break", ";"),
|
|
2123
2145
|
// ambiguous with break if
|
|
2124
2146
|
u("continue", f(";", "invalid statement, expected ';'")),
|
|
2125
2147
|
u(";"),
|
|
2126
2148
|
// LATER this one cannot have attributes in front of it
|
|
2127
|
-
() =>
|
|
2149
|
+
() => Mn,
|
|
2128
2150
|
u("discard", f(";", "invalid statement, expected ';'")),
|
|
2129
2151
|
u("return", h(v), f(";", "invalid statement, expected ';'")),
|
|
2130
|
-
u(
|
|
2152
|
+
u(fe, f(";", "invalid statement, expected ';'")),
|
|
2131
2153
|
u(
|
|
2132
|
-
() =>
|
|
2154
|
+
() => Pn,
|
|
2133
2155
|
f(";", "invalid statement, expected ';'")
|
|
2134
2156
|
),
|
|
2135
2157
|
u(
|
|
2136
|
-
() =>
|
|
2158
|
+
() => pe,
|
|
2137
2159
|
f(";", "invalid statement, expected ';'")
|
|
2138
2160
|
)
|
|
2139
|
-
),
|
|
2140
|
-
u(S,
|
|
2141
|
-
),
|
|
2142
|
-
u(
|
|
2143
|
-
),
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
),
|
|
2148
|
-
|
|
2149
|
-
u(
|
|
2161
|
+
), ko = _(
|
|
2162
|
+
u(S, $n).collect(at).collect(Bt)
|
|
2163
|
+
), _o = _(
|
|
2164
|
+
u(zt, $n)
|
|
2165
|
+
), wt = m(
|
|
2166
|
+
K,
|
|
2167
|
+
_o,
|
|
2168
|
+
ko
|
|
2169
|
+
), st = m(
|
|
2170
|
+
_n,
|
|
2171
|
+
u(gt.collect(mt), h(yt)),
|
|
2150
2172
|
u(
|
|
2151
2173
|
"(",
|
|
2152
|
-
() =>
|
|
2174
|
+
() => st,
|
|
2153
2175
|
")",
|
|
2154
|
-
h(
|
|
2176
|
+
h(yt)
|
|
2155
2177
|
// LATER this doesn't find member references.
|
|
2156
2178
|
),
|
|
2157
|
-
u("&", () =>
|
|
2158
|
-
u("*", () =>
|
|
2159
|
-
),
|
|
2179
|
+
u("&", () => st),
|
|
2180
|
+
u("*", () => st)
|
|
2181
|
+
), Pn = _(
|
|
2160
2182
|
// LATER consider collecting these as var elems and scopes
|
|
2161
2183
|
m(
|
|
2162
2184
|
// Also covers the = expression case
|
|
2163
|
-
|
|
2185
|
+
oo,
|
|
2164
2186
|
u(
|
|
2165
2187
|
"const",
|
|
2166
|
-
|
|
2188
|
+
Gt,
|
|
2167
2189
|
f("=", "invalid const declaration, expected '='"),
|
|
2168
2190
|
v
|
|
2169
2191
|
),
|
|
2170
2192
|
u(
|
|
2171
2193
|
"let",
|
|
2172
|
-
|
|
2194
|
+
Gt,
|
|
2173
2195
|
f("=", "invalid let declaration, expected '='"),
|
|
2174
2196
|
v
|
|
2175
2197
|
)
|
|
2176
2198
|
)
|
|
2177
|
-
),
|
|
2199
|
+
), pe = m(
|
|
2178
2200
|
u(
|
|
2179
|
-
|
|
2201
|
+
st,
|
|
2180
2202
|
m("=", "<<=", ">>=", "%=", "&=", "*=", "+=", "-=", "/=", "^=", "|="),
|
|
2181
2203
|
v
|
|
2182
2204
|
),
|
|
2183
|
-
u(
|
|
2205
|
+
u(st, m("++", "--")),
|
|
2184
2206
|
u("_", "=", v)
|
|
2185
|
-
),
|
|
2207
|
+
), vo = u(
|
|
2186
2208
|
_(S.collect((t) => t.tags.attribute || [])).ctag(
|
|
2187
2209
|
"fn_attributes"
|
|
2188
2210
|
),
|
|
2189
|
-
|
|
2190
|
-
f(
|
|
2211
|
+
$t("fn"),
|
|
2212
|
+
f(Qs, "invalid fn, expected function name"),
|
|
2191
2213
|
u(
|
|
2192
|
-
f(
|
|
2193
|
-
|
|
2214
|
+
f(so, "invalid fn, expected function parameters").collect(
|
|
2215
|
+
I,
|
|
2194
2216
|
"header_scope"
|
|
2195
2217
|
),
|
|
2196
2218
|
h(
|
|
2197
2219
|
u(
|
|
2198
2220
|
"->",
|
|
2199
2221
|
S.collect((t) => t.tags.attribute, "return_attributes"),
|
|
2200
|
-
|
|
2222
|
+
H.ctag("return_type").collect(I, "return_scope")
|
|
2201
2223
|
)
|
|
2202
2224
|
),
|
|
2203
|
-
f(
|
|
2225
|
+
f(Nn, "invalid fn, expected function body").ctag("body_statement").collect(I, "body_scope")
|
|
2204
2226
|
)
|
|
2205
|
-
).collect(
|
|
2227
|
+
).collect(Bt, "fn_partial_scope").collect(rs), So = m(
|
|
2206
2228
|
u(
|
|
2207
2229
|
S,
|
|
2208
2230
|
"override",
|
|
2209
|
-
|
|
2210
|
-
u(h(u("=", v.collect(
|
|
2231
|
+
Xt,
|
|
2232
|
+
u(h(u("=", v.collect($e, "decl_scope")))),
|
|
2211
2233
|
";"
|
|
2212
|
-
).collect(
|
|
2234
|
+
).collect(vt("override")),
|
|
2213
2235
|
u(
|
|
2214
2236
|
S,
|
|
2215
2237
|
"const",
|
|
2216
|
-
|
|
2238
|
+
Xt,
|
|
2217
2239
|
"=",
|
|
2218
|
-
u(v).collect(
|
|
2240
|
+
u(v).collect($e, "decl_scope"),
|
|
2219
2241
|
";"
|
|
2220
|
-
).collect(
|
|
2221
|
-
).collect(
|
|
2242
|
+
).collect(vt("const"))
|
|
2243
|
+
).collect(Bt), yo = u(
|
|
2222
2244
|
S.collect((t) => t.tags.attribute, "attributes"),
|
|
2223
2245
|
"alias",
|
|
2224
|
-
f(
|
|
2225
|
-
|
|
2246
|
+
f(M, "invalid alias, expected name").collect(
|
|
2247
|
+
It,
|
|
2226
2248
|
"alias_name"
|
|
2227
2249
|
),
|
|
2228
2250
|
f("=", "invalid alias, expected '='"),
|
|
2229
|
-
f(
|
|
2230
|
-
|
|
2251
|
+
f(H, "invalid alias, expected type").collect(
|
|
2252
|
+
I,
|
|
2231
2253
|
"alias_scope"
|
|
2232
2254
|
),
|
|
2233
2255
|
f(";", "invalid alias, expected ';'")
|
|
2234
|
-
).collect(
|
|
2256
|
+
).collect(ns), Mn = _(
|
|
2235
2257
|
u(
|
|
2236
2258
|
S,
|
|
2237
2259
|
"const_assert",
|
|
2238
2260
|
f(v, "invalid const_assert, expected expression"),
|
|
2239
2261
|
f(";", "invalid statement, expected ';'")
|
|
2240
|
-
).collect(
|
|
2241
|
-
).ctag("const_assert"),
|
|
2262
|
+
).collect(cs)
|
|
2263
|
+
).ctag("const_assert"), wo = _(
|
|
2242
2264
|
u(
|
|
2243
2265
|
S,
|
|
2244
|
-
|
|
2266
|
+
Ft(
|
|
2245
2267
|
m(
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2268
|
+
N("diagnostic", yn).map(No),
|
|
2269
|
+
N("enable", Vt).map($o),
|
|
2270
|
+
N("requires", Vt).map(Po)
|
|
2249
2271
|
).ptag("directive"),
|
|
2250
2272
|
";"
|
|
2251
2273
|
)
|
|
2252
|
-
).collect(
|
|
2253
|
-
),
|
|
2274
|
+
).collect(hs)
|
|
2275
|
+
), Eo = _(
|
|
2254
2276
|
m(
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2277
|
+
vo,
|
|
2278
|
+
io,
|
|
2279
|
+
So,
|
|
2258
2280
|
";",
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2281
|
+
yo,
|
|
2282
|
+
Mn.collect(fs),
|
|
2283
|
+
no
|
|
2262
2284
|
)
|
|
2263
|
-
),
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
f(
|
|
2268
|
-
).collect(
|
|
2269
|
-
function
|
|
2285
|
+
), To = u(
|
|
2286
|
+
ws,
|
|
2287
|
+
$(wo),
|
|
2288
|
+
$(Eo),
|
|
2289
|
+
f(br(), "invalid WESL, expected EOF")
|
|
2290
|
+
).collect(gs, "collectModule");
|
|
2291
|
+
function No([t, e]) {
|
|
2270
2292
|
return { kind: "diagnostic", severity: t, rule: e };
|
|
2271
2293
|
}
|
|
2272
|
-
function
|
|
2294
|
+
function $o(t) {
|
|
2273
2295
|
return { kind: "enable", extensions: t };
|
|
2274
2296
|
}
|
|
2275
|
-
function
|
|
2297
|
+
function Po(t) {
|
|
2276
2298
|
return { kind: "requires", extensions: t };
|
|
2277
2299
|
}
|
|
2278
|
-
function
|
|
2300
|
+
function Mo([t, e]) {
|
|
2279
2301
|
return {
|
|
2280
2302
|
kind: "@attribute",
|
|
2281
2303
|
name: t,
|
|
2282
2304
|
params: e
|
|
2283
2305
|
};
|
|
2284
2306
|
}
|
|
2285
|
-
function
|
|
2307
|
+
function Co(t) {
|
|
2286
2308
|
return {
|
|
2287
2309
|
kind: "@interpolate",
|
|
2288
2310
|
params: t
|
|
2289
2311
|
};
|
|
2290
2312
|
}
|
|
2291
|
-
function
|
|
2313
|
+
function Ao(t) {
|
|
2292
2314
|
return {
|
|
2293
2315
|
kind: "@builtin",
|
|
2294
2316
|
param: t
|
|
2295
2317
|
};
|
|
2296
2318
|
}
|
|
2297
|
-
function
|
|
2319
|
+
function Ro([t, e]) {
|
|
2298
2320
|
return {
|
|
2299
2321
|
kind: "@diagnostic",
|
|
2300
2322
|
severity: t,
|
|
2301
2323
|
rule: e
|
|
2302
2324
|
};
|
|
2303
2325
|
}
|
|
2304
|
-
function
|
|
2326
|
+
function Io(t) {
|
|
2305
2327
|
return {
|
|
2306
2328
|
kind: "@if",
|
|
2307
2329
|
param: t
|
|
2308
2330
|
};
|
|
2309
2331
|
}
|
|
2310
|
-
function
|
|
2332
|
+
function Bo(t) {
|
|
2311
2333
|
return {
|
|
2312
2334
|
kind: "translate-time-expression",
|
|
2313
2335
|
expression: t.value,
|
|
2314
2336
|
span: t.span
|
|
2315
2337
|
};
|
|
2316
2338
|
}
|
|
2317
|
-
function
|
|
2339
|
+
function Do(t) {
|
|
2318
2340
|
return {
|
|
2319
2341
|
kind: "name",
|
|
2320
2342
|
name: t.text,
|
|
@@ -2322,52 +2344,52 @@ function Mo(t) {
|
|
|
2322
2344
|
end: t.span[1]
|
|
2323
2345
|
};
|
|
2324
2346
|
}
|
|
2325
|
-
function
|
|
2347
|
+
function jo(t) {
|
|
2326
2348
|
return {
|
|
2327
2349
|
kind: "literal",
|
|
2328
2350
|
value: t.text,
|
|
2329
2351
|
span: t.span
|
|
2330
2352
|
};
|
|
2331
2353
|
}
|
|
2332
|
-
function
|
|
2354
|
+
function Lo(t) {
|
|
2333
2355
|
return {
|
|
2334
2356
|
kind: "translate-time-feature",
|
|
2335
2357
|
name: t.text,
|
|
2336
2358
|
span: t.span
|
|
2337
2359
|
};
|
|
2338
2360
|
}
|
|
2339
|
-
function
|
|
2361
|
+
function Oo(t) {
|
|
2340
2362
|
return {
|
|
2341
2363
|
kind: "parenthesized-expression",
|
|
2342
2364
|
expression: t
|
|
2343
2365
|
};
|
|
2344
2366
|
}
|
|
2345
|
-
function
|
|
2367
|
+
function qo(t) {
|
|
2346
2368
|
return {
|
|
2347
2369
|
value: t.text,
|
|
2348
2370
|
span: t.span
|
|
2349
2371
|
};
|
|
2350
2372
|
}
|
|
2351
|
-
function
|
|
2373
|
+
function Re(t) {
|
|
2352
2374
|
return {
|
|
2353
2375
|
value: t.text,
|
|
2354
2376
|
span: t.span
|
|
2355
2377
|
};
|
|
2356
2378
|
}
|
|
2357
|
-
function
|
|
2379
|
+
function Fo([t, e]) {
|
|
2358
2380
|
return {
|
|
2359
2381
|
kind: "unary-expression",
|
|
2360
2382
|
operator: t,
|
|
2361
2383
|
expression: e
|
|
2362
2384
|
};
|
|
2363
2385
|
}
|
|
2364
|
-
function
|
|
2386
|
+
function Wo([t, e]) {
|
|
2365
2387
|
let n = t;
|
|
2366
2388
|
for (const [r, s] of e)
|
|
2367
|
-
n =
|
|
2389
|
+
n = Uo([n, r, s]);
|
|
2368
2390
|
return n;
|
|
2369
2391
|
}
|
|
2370
|
-
function
|
|
2392
|
+
function Uo([t, e, n]) {
|
|
2371
2393
|
return {
|
|
2372
2394
|
kind: "binary-expression",
|
|
2373
2395
|
operator: e,
|
|
@@ -2375,29 +2397,33 @@ function jo([t, e, n]) {
|
|
|
2375
2397
|
right: n
|
|
2376
2398
|
};
|
|
2377
2399
|
}
|
|
2378
|
-
class
|
|
2379
|
-
constructor(
|
|
2380
|
-
const
|
|
2381
|
-
let
|
|
2382
|
-
|
|
2383
|
-
`,
|
|
2384
|
-
`)
|
|
2385
|
-
|
|
2386
|
-
|
|
2400
|
+
class Vo extends Error {
|
|
2401
|
+
constructor(n) {
|
|
2402
|
+
const r = n.src.src, [s, o] = At(n.cause.span[0], r);
|
|
2403
|
+
let i = `${n.src.debugFilePath}:${s}:${o}`;
|
|
2404
|
+
i += ` error: ${n.cause.message}
|
|
2405
|
+
`, i += We(r, n.cause.span).join(`
|
|
2406
|
+
`);
|
|
2407
|
+
super(i, {
|
|
2408
|
+
cause: n.cause
|
|
2409
|
+
});
|
|
2410
|
+
w(this, "span");
|
|
2411
|
+
w(this, "src");
|
|
2412
|
+
this.span = n.cause.span, this.src = n.src;
|
|
2387
2413
|
}
|
|
2388
2414
|
}
|
|
2389
|
-
function
|
|
2390
|
-
const e = new
|
|
2415
|
+
function Cn(t) {
|
|
2416
|
+
const e = new Is(t.src), n = An(t), r = { stream: e, appState: n };
|
|
2391
2417
|
try {
|
|
2392
|
-
if (
|
|
2418
|
+
if (To.parse(r) === null)
|
|
2393
2419
|
throw new Error("parseWESL failed");
|
|
2394
2420
|
} catch (s) {
|
|
2395
|
-
if (s instanceof
|
|
2396
|
-
const [o, i] =
|
|
2421
|
+
if (s instanceof Z) {
|
|
2422
|
+
const [o, i] = At(
|
|
2397
2423
|
s.span[0],
|
|
2398
2424
|
t.src
|
|
2399
|
-
), a = new
|
|
2400
|
-
|
|
2425
|
+
), a = new Vo({ cause: s, src: t });
|
|
2426
|
+
re({
|
|
2401
2427
|
url: t.debugFilePath,
|
|
2402
2428
|
text: t.src,
|
|
2403
2429
|
error: a,
|
|
@@ -2410,26 +2436,26 @@ function $n(t) {
|
|
|
2410
2436
|
}
|
|
2411
2437
|
return n.stable;
|
|
2412
2438
|
}
|
|
2413
|
-
function
|
|
2414
|
-
const e =
|
|
2439
|
+
function An(t) {
|
|
2440
|
+
const e = Ye(null);
|
|
2415
2441
|
return {
|
|
2416
2442
|
context: { scope: e, openElems: [] },
|
|
2417
2443
|
stable: { srcModule: t, imports: [], rootScope: e, moduleElem: null }
|
|
2418
2444
|
};
|
|
2419
2445
|
}
|
|
2420
|
-
function
|
|
2421
|
-
return
|
|
2446
|
+
function ha() {
|
|
2447
|
+
return An({
|
|
2422
2448
|
modulePath: "package::test",
|
|
2423
2449
|
debugFilePath: "./test.wesl",
|
|
2424
2450
|
src: ""
|
|
2425
2451
|
});
|
|
2426
2452
|
}
|
|
2427
|
-
function
|
|
2453
|
+
function zo(t) {
|
|
2428
2454
|
if (t._flatImports) return t._flatImports;
|
|
2429
|
-
const e = t.imports.flatMap(
|
|
2455
|
+
const e = t.imports.flatMap(Jr);
|
|
2430
2456
|
return t._flatImports = e, e;
|
|
2431
2457
|
}
|
|
2432
|
-
const
|
|
2458
|
+
const Go = `bitcast all any select arrayLength
|
|
2433
2459
|
abs acos acosh asin asinh atan atanh atan2 ceil clamp cos cosh
|
|
2434
2460
|
countLeadingZeros countOneBits countTrailingZeros cross
|
|
2435
2461
|
degrees determinant distance dot dot4U8Packed dot4I8Packed
|
|
@@ -2457,15 +2483,15 @@ const qo = `bitcast all any select arrayLength
|
|
|
2457
2483
|
subgroupExclusiveAdd subgroupExclusiveMul subgroupInclusiveAdd
|
|
2458
2484
|
subgroupInclusiveMul subgroupMax subgroupMin subgroupMul subgroupOr
|
|
2459
2485
|
subgroupShuffle subgroupShuffleUp subgroupShuffleXor subgroupXor
|
|
2460
|
-
quadBroadcast quadSwapDiagonal quadSwapX quadSwapY`.split(/\s+/),
|
|
2486
|
+
quadBroadcast quadSwapDiagonal quadSwapX quadSwapY`.split(/\s+/), Rn = `
|
|
2461
2487
|
texture_1d texture_2d texture_2d_array texture_3d
|
|
2462
2488
|
texture_cube texture_cube_array
|
|
2463
|
-
`,
|
|
2489
|
+
`, In = `
|
|
2464
2490
|
texture_multisampled_2d texture_depth_multisampled_2d
|
|
2465
|
-
`,
|
|
2491
|
+
`, Bn = `
|
|
2466
2492
|
texture_storage_1d texture_storage_2d texture_storage_2d_array
|
|
2467
2493
|
texture_storage_3d
|
|
2468
|
-
`,
|
|
2494
|
+
`, Xo = `array atomic bool f16 f32 i32
|
|
2469
2495
|
mat2x2 mat2x3 mat2x4 mat3x2 mat3x3 mat3x4 mat4x2 mat4x3 mat4x4
|
|
2470
2496
|
mat2x2f mat2x3f mat2x4f mat3x2f mat3x3f mat3x4f
|
|
2471
2497
|
mat4x2f mat4x3f mat4x4f
|
|
@@ -2474,10 +2500,10 @@ const qo = `bitcast all any select arrayLength
|
|
|
2474
2500
|
u32 vec2 vec3 vec4 ptr
|
|
2475
2501
|
vec2i vec3i vec4i vec2u vec3u vec4u
|
|
2476
2502
|
vec2f vec3f vec4f vec2h vec3h vec4h
|
|
2477
|
-
${
|
|
2478
|
-
${
|
|
2503
|
+
${Rn}
|
|
2504
|
+
${In}
|
|
2479
2505
|
texture_external
|
|
2480
|
-
${
|
|
2506
|
+
${Bn}
|
|
2481
2507
|
texture_depth_2d texture_depth_2d_array texture_depth_cube
|
|
2482
2508
|
texture_depth_cube_array
|
|
2483
2509
|
sampler sampler_comparison
|
|
@@ -2485,25 +2511,25 @@ const qo = `bitcast all any select arrayLength
|
|
|
2485
2511
|
rgba16uint rgba16sint rgba16float
|
|
2486
2512
|
r32uint r32sint r32float rg32uint rg32sint rg32float
|
|
2487
2513
|
rgba32uint rgba32sint rgba32float
|
|
2488
|
-
bgra8unorm`.split(/\s+/),
|
|
2514
|
+
bgra8unorm`.split(/\s+/), Jo = `read write read_write
|
|
2489
2515
|
function private workgroup uniform storage
|
|
2490
2516
|
rgba8unorm rgba8snorm rgba8uint rgba8sint
|
|
2491
2517
|
rgba16uint rgba16sint rgba16float
|
|
2492
2518
|
r32uint r32sint r32float rg32uint rg32sint rg32float
|
|
2493
2519
|
rgba32uint rgba32sint rgba32float bgra8unorm`.split(/\s+/);
|
|
2494
|
-
function
|
|
2495
|
-
return
|
|
2520
|
+
function Dn(t) {
|
|
2521
|
+
return Xo.includes(t);
|
|
2496
2522
|
}
|
|
2497
|
-
function
|
|
2498
|
-
return
|
|
2523
|
+
function Ko(t) {
|
|
2524
|
+
return Go.includes(t) || Dn(t);
|
|
2499
2525
|
}
|
|
2500
|
-
function
|
|
2501
|
-
return
|
|
2526
|
+
function Ho(t) {
|
|
2527
|
+
return Jo.includes(t);
|
|
2502
2528
|
}
|
|
2503
|
-
function
|
|
2504
|
-
const { rootAst: e, registry: n, virtuals: r, accumulateUnbound: s } = t, { conditions: o = {}, mangler: i =
|
|
2505
|
-
d.forEach((
|
|
2506
|
-
|
|
2529
|
+
function Yo(t) {
|
|
2530
|
+
const { rootAst: e, registry: n, virtuals: r, accumulateUnbound: s } = t, { conditions: o = {}, mangler: i = en } = t, { rootScope: a } = e, c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), d = Dt(a, o);
|
|
2531
|
+
d.forEach((L) => {
|
|
2532
|
+
L.mangledName = L.originalName, c.add(L.originalName), l.add(L);
|
|
2507
2533
|
});
|
|
2508
2534
|
const p = s ? [] : void 0, g = /* @__PURE__ */ new Map(), x = {
|
|
2509
2535
|
registry: n,
|
|
@@ -2515,10 +2541,10 @@ function zo(t) {
|
|
|
2515
2541
|
virtuals: r,
|
|
2516
2542
|
mangler: i,
|
|
2517
2543
|
unbound: p
|
|
2518
|
-
},
|
|
2519
|
-
return { decls: U, globalNames: c, newStatements:
|
|
2544
|
+
}, T = d.map((L) => [L.originalName, L]), A = { decls: new Map(T), parent: null }, U = lt(a, x, A, !0), V = [...g.values()];
|
|
2545
|
+
return { decls: U, globalNames: c, newStatements: V, unbound: p };
|
|
2520
2546
|
}
|
|
2521
|
-
function
|
|
2547
|
+
function ba(t) {
|
|
2522
2548
|
const e = {
|
|
2523
2549
|
registry: t,
|
|
2524
2550
|
conditions: {},
|
|
@@ -2526,22 +2552,22 @@ function ma(t) {
|
|
|
2526
2552
|
foundScopes: /* @__PURE__ */ new Set(),
|
|
2527
2553
|
globalNames: /* @__PURE__ */ new Set(),
|
|
2528
2554
|
globalStatements: /* @__PURE__ */ new Map(),
|
|
2529
|
-
mangler:
|
|
2555
|
+
mangler: en,
|
|
2530
2556
|
unbound: [],
|
|
2531
2557
|
dontFollowDecls: !0
|
|
2532
2558
|
};
|
|
2533
2559
|
return Object.entries(t.modules).map(([n, r]) => {
|
|
2534
|
-
const o =
|
|
2535
|
-
|
|
2560
|
+
const o = Dt(r.rootScope, {}).map((a) => [a.originalName, a]), i = { decls: new Map(o), parent: null };
|
|
2561
|
+
lt(r.rootScope, e, i, !0);
|
|
2536
2562
|
}), e.unbound;
|
|
2537
2563
|
}
|
|
2538
|
-
function
|
|
2564
|
+
function Dt(t, e) {
|
|
2539
2565
|
const n = [];
|
|
2540
2566
|
for (const r of t.contents)
|
|
2541
|
-
r.kind === "decl" ? (r.declElem,
|
|
2567
|
+
r.kind === "decl" ? (r.declElem, Ge(r.declElem, e) && n.push(r)) : r.kind === "partial" && n.push(...Dt(r, e));
|
|
2542
2568
|
return n;
|
|
2543
2569
|
}
|
|
2544
|
-
function
|
|
2570
|
+
function lt(t, e, n, r = !1) {
|
|
2545
2571
|
const { dontFollowDecls: s, foundScopes: o } = e;
|
|
2546
2572
|
if (o.has(t)) return [];
|
|
2547
2573
|
o.add(t);
|
|
@@ -2552,75 +2578,75 @@ function ct(t, e, n, r = !1) {
|
|
|
2552
2578
|
const p = l;
|
|
2553
2579
|
r || n.decls.set(p.originalName, p);
|
|
2554
2580
|
} else if (d === "ref") {
|
|
2555
|
-
const p =
|
|
2581
|
+
const p = Qo(l, n, e);
|
|
2556
2582
|
p && i.push(p);
|
|
2557
2583
|
} else {
|
|
2558
|
-
const p =
|
|
2584
|
+
const p = ti(l, n, e);
|
|
2559
2585
|
p && a.push(...p);
|
|
2560
2586
|
}
|
|
2561
2587
|
});
|
|
2562
|
-
const c = s ? [] :
|
|
2588
|
+
const c = s ? [] : Zo(i, e);
|
|
2563
2589
|
return [i, a, c].flat();
|
|
2564
2590
|
}
|
|
2565
|
-
function
|
|
2591
|
+
function Zo(t, e) {
|
|
2566
2592
|
const { conditions: n } = e;
|
|
2567
2593
|
return t.flatMap((r) => {
|
|
2568
2594
|
const s = r.dependentScope;
|
|
2569
2595
|
if (s) {
|
|
2570
|
-
const o =
|
|
2596
|
+
const o = ni(r, n);
|
|
2571
2597
|
if (o) {
|
|
2572
|
-
const i =
|
|
2573
|
-
return
|
|
2598
|
+
const i = tn(o);
|
|
2599
|
+
return lt(s, e, i);
|
|
2574
2600
|
}
|
|
2575
2601
|
}
|
|
2576
2602
|
return [];
|
|
2577
2603
|
});
|
|
2578
2604
|
}
|
|
2579
|
-
function
|
|
2605
|
+
function Qo(t, e, n) {
|
|
2580
2606
|
const { registry: r, conditions: s, unbound: o } = n, { virtuals: i } = n;
|
|
2581
2607
|
if (!t.refersTo && !t.std) {
|
|
2582
|
-
const a =
|
|
2608
|
+
const a = jn(t, e) ?? oi(t, r, s, i, o);
|
|
2583
2609
|
if (a)
|
|
2584
|
-
return t.refersTo = a.decl,
|
|
2585
|
-
|
|
2610
|
+
return t.refersTo = a.decl, ei(t, a, n);
|
|
2611
|
+
si(t.originalName) ? t.std = !0 : o || Ve(t, `unresolved identifier '${t.originalName}'`);
|
|
2586
2612
|
}
|
|
2587
2613
|
}
|
|
2588
|
-
function
|
|
2614
|
+
function ti(t, e, n) {
|
|
2589
2615
|
const { conditions: r } = n;
|
|
2590
|
-
if (!
|
|
2616
|
+
if (!Xe(t, r)) return;
|
|
2591
2617
|
const { kind: s } = t;
|
|
2592
2618
|
if (s === "scope") {
|
|
2593
|
-
const o =
|
|
2594
|
-
return
|
|
2619
|
+
const o = tn(e);
|
|
2620
|
+
return lt(t, n, o);
|
|
2595
2621
|
} else if (s === "partial")
|
|
2596
|
-
return
|
|
2622
|
+
return lt(t, n, e);
|
|
2597
2623
|
}
|
|
2598
|
-
function
|
|
2624
|
+
function ei(t, e, n) {
|
|
2599
2625
|
const { decl: r, moduleAst: s } = e, { knownDecls: o, globalNames: i, mangler: a, globalStatements: c } = n;
|
|
2600
2626
|
if (!o.has(r)) {
|
|
2601
2627
|
o.add(r);
|
|
2602
2628
|
const { srcModule: l } = r, d = t.originalName;
|
|
2603
|
-
if (
|
|
2629
|
+
if (ri(d, r, i, l, a), me(r)) {
|
|
2604
2630
|
const { moduleAsserts: p } = s, g = p == null ? void 0 : p.map((x) => ({ srcModule: l, elem: x }));
|
|
2605
2631
|
return g == null || g.forEach((x) => c.set(x.elem, x)), r;
|
|
2606
2632
|
}
|
|
2607
2633
|
}
|
|
2608
2634
|
}
|
|
2609
|
-
function
|
|
2610
|
-
t.isGlobal,
|
|
2635
|
+
function ni(t, e) {
|
|
2636
|
+
t.isGlobal, Rt(t);
|
|
2611
2637
|
let n = t.containingScope;
|
|
2612
2638
|
for (; n.parent; )
|
|
2613
2639
|
n = n.parent;
|
|
2614
2640
|
n.kind;
|
|
2615
2641
|
const r = n;
|
|
2616
2642
|
if (r._scopeDecls) return r._scopeDecls;
|
|
2617
|
-
const o =
|
|
2643
|
+
const o = Dt(n, e).map((c) => [c.originalName, c]), a = { decls: new Map(o) };
|
|
2618
2644
|
return r._scopeDecls = a, a;
|
|
2619
2645
|
}
|
|
2620
|
-
function
|
|
2646
|
+
function ri(t, e, n, r, s) {
|
|
2621
2647
|
if (!e.mangledName) {
|
|
2622
2648
|
let o;
|
|
2623
|
-
if (
|
|
2649
|
+
if (me(e)) {
|
|
2624
2650
|
const i = t.lastIndexOf("::"), a = i === -1 ? t : t.slice(i + 2);
|
|
2625
2651
|
o = s(e, r, a, n);
|
|
2626
2652
|
} else
|
|
@@ -2628,21 +2654,21 @@ function Yo(t, e, n, r, s) {
|
|
|
2628
2654
|
e.mangledName = o, n.add(o);
|
|
2629
2655
|
}
|
|
2630
2656
|
}
|
|
2631
|
-
function
|
|
2632
|
-
return
|
|
2657
|
+
function si(t) {
|
|
2658
|
+
return Dn(t) || Ko(t) || Ho(t);
|
|
2633
2659
|
}
|
|
2634
|
-
function
|
|
2660
|
+
function jn(t, e) {
|
|
2635
2661
|
const { originalName: n } = t, r = e.decls.get(n);
|
|
2636
2662
|
if (r)
|
|
2637
2663
|
return { decl: r, moduleAst: t.ast };
|
|
2638
2664
|
const { parent: s } = e;
|
|
2639
2665
|
if (s)
|
|
2640
|
-
return
|
|
2666
|
+
return jn(t, s);
|
|
2641
2667
|
}
|
|
2642
|
-
function
|
|
2643
|
-
const o =
|
|
2668
|
+
function oi(t, e, n, r, s) {
|
|
2669
|
+
const o = zo(t.ast), i = t.originalName.split("::"), a = ai(i, o) ?? ii(i);
|
|
2644
2670
|
if (a) {
|
|
2645
|
-
const { srcModule: c } = t.ast, l =
|
|
2671
|
+
const { srcModule: c } = t.ast, l = ci(
|
|
2646
2672
|
a,
|
|
2647
2673
|
c,
|
|
2648
2674
|
e,
|
|
@@ -2654,28 +2680,28 @@ function Qo(t, e, n, r, s) {
|
|
|
2654
2680
|
s.push(a);
|
|
2655
2681
|
else {
|
|
2656
2682
|
const d = `module not found for '${a.join("::")}'`;
|
|
2657
|
-
|
|
2683
|
+
Ve(t, d);
|
|
2658
2684
|
}
|
|
2659
2685
|
return l;
|
|
2660
2686
|
} else s && s.push(i);
|
|
2661
2687
|
}
|
|
2662
|
-
function
|
|
2688
|
+
function ii(t) {
|
|
2663
2689
|
if (t.length > 1) return t;
|
|
2664
2690
|
}
|
|
2665
|
-
function
|
|
2691
|
+
function ai(t, e) {
|
|
2666
2692
|
for (const n of e)
|
|
2667
2693
|
if (n.importPath.at(-1) === t.at(0))
|
|
2668
2694
|
return [...n.modulePath, ...t.slice(1)];
|
|
2669
2695
|
}
|
|
2670
|
-
function
|
|
2671
|
-
const i =
|
|
2696
|
+
function ci(t, e, n, r = {}, s) {
|
|
2697
|
+
const i = li(t, e).slice(0, -1).join("::"), a = n.modules[i] ?? ui(t[0], r, s);
|
|
2672
2698
|
if (!a)
|
|
2673
2699
|
return;
|
|
2674
|
-
const c =
|
|
2700
|
+
const c = Or(t), l = Ze(a.rootScope, c, r);
|
|
2675
2701
|
if (l)
|
|
2676
2702
|
return { decl: l, moduleAst: a };
|
|
2677
2703
|
}
|
|
2678
|
-
function
|
|
2704
|
+
function li(t, e) {
|
|
2679
2705
|
const n = t.findLastIndex((r) => r === "super");
|
|
2680
2706
|
if (n > -1) {
|
|
2681
2707
|
const s = e.modulePath.split("::").slice(0, -(n + 1)), o = t.slice(n + 1);
|
|
@@ -2683,7 +2709,7 @@ function ri(t, e) {
|
|
|
2683
2709
|
}
|
|
2684
2710
|
return t;
|
|
2685
2711
|
}
|
|
2686
|
-
function
|
|
2712
|
+
function ui(t, e = {}, n) {
|
|
2687
2713
|
if (!n) return;
|
|
2688
2714
|
const r = n[t];
|
|
2689
2715
|
if (r) {
|
|
@@ -2694,41 +2720,41 @@ function si(t, e = {}, n) {
|
|
|
2694
2720
|
debugFilePath: t,
|
|
2695
2721
|
src: i
|
|
2696
2722
|
};
|
|
2697
|
-
return r.ast =
|
|
2723
|
+
return r.ast = Cn(a), r.ast;
|
|
2698
2724
|
}
|
|
2699
2725
|
}
|
|
2700
|
-
function
|
|
2726
|
+
function me(t) {
|
|
2701
2727
|
const { declElem: e } = t;
|
|
2702
2728
|
return e ? ["alias", "const", "override", "fn", "struct", "gvar"].includes(
|
|
2703
2729
|
e.kind
|
|
2704
2730
|
) : !1;
|
|
2705
2731
|
}
|
|
2706
|
-
function
|
|
2732
|
+
function Ot(t, e, n, r = !0) {
|
|
2707
2733
|
const s = { conditions: n, srcBuilder: t, extracting: r };
|
|
2708
|
-
e.forEach((o) =>
|
|
2734
|
+
e.forEach((o) => ge(o, s));
|
|
2709
2735
|
}
|
|
2710
|
-
function
|
|
2711
|
-
if (
|
|
2736
|
+
function ge(t, e) {
|
|
2737
|
+
if (be(t, e.conditions))
|
|
2712
2738
|
switch (t.kind) {
|
|
2713
2739
|
// import statements are dropped from from emitted text
|
|
2714
2740
|
case "import":
|
|
2715
2741
|
return;
|
|
2716
2742
|
// terminal elements copy strings to the output
|
|
2717
2743
|
case "text":
|
|
2718
|
-
|
|
2744
|
+
di(t, e);
|
|
2719
2745
|
return;
|
|
2720
2746
|
case "name":
|
|
2721
|
-
|
|
2747
|
+
fi(t, e);
|
|
2722
2748
|
return;
|
|
2723
2749
|
case "synthetic":
|
|
2724
|
-
|
|
2750
|
+
hi(t, e);
|
|
2725
2751
|
return;
|
|
2726
2752
|
// identifiers are copied to the output, but with potentially mangled names
|
|
2727
2753
|
case "ref":
|
|
2728
|
-
|
|
2754
|
+
bi(t, e);
|
|
2729
2755
|
return;
|
|
2730
2756
|
case "decl":
|
|
2731
|
-
|
|
2757
|
+
he(t, e);
|
|
2732
2758
|
return;
|
|
2733
2759
|
// container elements just emit their child elements
|
|
2734
2760
|
case "param":
|
|
@@ -2743,7 +2769,7 @@ function me(t, e) {
|
|
|
2743
2769
|
case "statement":
|
|
2744
2770
|
case "stuff":
|
|
2745
2771
|
case "switch-clause":
|
|
2746
|
-
|
|
2772
|
+
ut(t, e);
|
|
2747
2773
|
return;
|
|
2748
2774
|
// root level container elements get some extra newlines to make the output prettier
|
|
2749
2775
|
case "override":
|
|
@@ -2751,93 +2777,93 @@ function me(t, e) {
|
|
|
2751
2777
|
case "assert":
|
|
2752
2778
|
case "alias":
|
|
2753
2779
|
case "gvar":
|
|
2754
|
-
|
|
2780
|
+
qt(e), ut(t, e);
|
|
2755
2781
|
return;
|
|
2756
2782
|
case "fn":
|
|
2757
|
-
|
|
2783
|
+
qt(e), pi(t, e);
|
|
2758
2784
|
return;
|
|
2759
2785
|
case "struct":
|
|
2760
|
-
|
|
2786
|
+
qt(e), mi(t, e);
|
|
2761
2787
|
return;
|
|
2762
2788
|
case "attribute":
|
|
2763
|
-
|
|
2789
|
+
Ln(t, e);
|
|
2764
2790
|
return;
|
|
2765
2791
|
case "directive":
|
|
2766
|
-
|
|
2792
|
+
xi(t, e);
|
|
2767
2793
|
return;
|
|
2768
2794
|
default:
|
|
2769
|
-
|
|
2795
|
+
j(t);
|
|
2770
2796
|
}
|
|
2771
2797
|
}
|
|
2772
|
-
function
|
|
2798
|
+
function qt(t) {
|
|
2773
2799
|
t.extracting && (t.srcBuilder.addNl(), t.srcBuilder.addNl());
|
|
2774
2800
|
}
|
|
2775
|
-
function
|
|
2801
|
+
function di(t, e) {
|
|
2776
2802
|
e.srcBuilder.addCopy(t.start, t.end);
|
|
2777
2803
|
}
|
|
2778
|
-
function
|
|
2804
|
+
function fi(t, e) {
|
|
2779
2805
|
e.srcBuilder.add(t.name, t.start, t.end);
|
|
2780
2806
|
}
|
|
2781
|
-
function
|
|
2807
|
+
function pi(t, e) {
|
|
2782
2808
|
const { attributes: n, name: r, params: s, returnAttributes: o, returnType: i, body: a } = t, { conditions: c, srcBuilder: l } = e;
|
|
2783
|
-
|
|
2784
|
-
const d = s.filter((p) =>
|
|
2809
|
+
Ie(n, e), l.add("fn ", r.start - 3, r.start), he(r, e), l.appendNext("(");
|
|
2810
|
+
const d = s.filter((p) => be(p, c));
|
|
2785
2811
|
d.forEach((p, g) => {
|
|
2786
|
-
|
|
2787
|
-
}), l.appendNext(") "), i && (l.appendNext("-> "),
|
|
2812
|
+
Jt(p, e), g < d.length - 1 && l.appendNext(", ");
|
|
2813
|
+
}), l.appendNext(") "), i && (l.appendNext("-> "), Ie(o, e), ut(i, e), l.appendNext(" ")), ut(a, e);
|
|
2788
2814
|
}
|
|
2789
|
-
function
|
|
2815
|
+
function Ie(t, e) {
|
|
2790
2816
|
t == null || t.forEach((n) => {
|
|
2791
|
-
|
|
2817
|
+
Ln(n, e), e.srcBuilder.add(" ", n.start, n.end);
|
|
2792
2818
|
});
|
|
2793
2819
|
}
|
|
2794
|
-
function
|
|
2795
|
-
const { name: n, members: r, start: s, end: o } = t, { srcBuilder: i } = e, a = r.filter((l) =>
|
|
2820
|
+
function mi(t, e) {
|
|
2821
|
+
const { name: n, members: r, start: s, end: o } = t, { srcBuilder: i } = e, a = r.filter((l) => be(l, e.conditions)), c = a.length;
|
|
2796
2822
|
if (c === 0) {
|
|
2797
|
-
|
|
2823
|
+
gi(t);
|
|
2798
2824
|
return;
|
|
2799
2825
|
}
|
|
2800
|
-
i.add("struct ", s, n.start),
|
|
2826
|
+
i.add("struct ", s, n.start), he(n, e), c === 1 ? (i.add(" { ", n.end, r[0].start), Jt(a[0], e), i.add(` }
|
|
2801
2827
|
`, o - 1, o)) : (i.add(` {
|
|
2802
2828
|
`, n.end, r[0].start), a.forEach((l) => {
|
|
2803
|
-
i.add(" ", l.start - 1, l.start),
|
|
2829
|
+
i.add(" ", l.start - 1, l.start), Jt(l, e), i.add(",", l.end, l.end + 1), i.addNl();
|
|
2804
2830
|
}), i.add(`}
|
|
2805
2831
|
`, o - 1, o));
|
|
2806
2832
|
}
|
|
2807
|
-
function
|
|
2833
|
+
function gi(t) {
|
|
2808
2834
|
const { name: e, members: n } = t, r = n.length ? "(with current conditions)" : "", s = `struct '${e.ident.originalName}' has no members ${r}`;
|
|
2809
|
-
|
|
2835
|
+
ze(e, s);
|
|
2810
2836
|
}
|
|
2811
|
-
function
|
|
2837
|
+
function hi(t, e) {
|
|
2812
2838
|
const { text: n } = t;
|
|
2813
2839
|
e.srcBuilder.addSynthetic(n, n, 0, n.length);
|
|
2814
2840
|
}
|
|
2815
|
-
function
|
|
2816
|
-
t.contents.forEach((n) =>
|
|
2841
|
+
function ut(t, e) {
|
|
2842
|
+
t.contents.forEach((n) => ge(n, e));
|
|
2817
2843
|
}
|
|
2818
|
-
function
|
|
2844
|
+
function Jt(t, e) {
|
|
2819
2845
|
t.contents.forEach((n) => {
|
|
2820
2846
|
if (n.kind === "text") {
|
|
2821
2847
|
const { srcModule: r, start: s, end: o } = n;
|
|
2822
2848
|
if (r.src.slice(s, o).trim() === "")
|
|
2823
2849
|
return;
|
|
2824
2850
|
}
|
|
2825
|
-
|
|
2851
|
+
ge(n, e);
|
|
2826
2852
|
});
|
|
2827
2853
|
}
|
|
2828
|
-
function
|
|
2854
|
+
function bi(t, e) {
|
|
2829
2855
|
if (t.ident.std)
|
|
2830
2856
|
e.srcBuilder.add(t.ident.originalName, t.start, t.end);
|
|
2831
2857
|
else {
|
|
2832
|
-
const n =
|
|
2858
|
+
const n = Et(t.ident), r = On(n);
|
|
2833
2859
|
e.srcBuilder.add(r, t.start, t.end);
|
|
2834
2860
|
}
|
|
2835
2861
|
}
|
|
2836
|
-
function
|
|
2837
|
-
const n =
|
|
2862
|
+
function he(t, e) {
|
|
2863
|
+
const n = On(t.ident);
|
|
2838
2864
|
e.srcBuilder.add(n, t.start, t.end);
|
|
2839
2865
|
}
|
|
2840
|
-
function
|
|
2866
|
+
function Ln(t, e) {
|
|
2841
2867
|
const { kind: n } = t.attribute;
|
|
2842
2868
|
if (n === "@attribute") {
|
|
2843
2869
|
const { params: r } = t.attribute;
|
|
@@ -2850,7 +2876,7 @@ function Bn(t, e) {
|
|
|
2850
2876
|
r[0].start
|
|
2851
2877
|
);
|
|
2852
2878
|
for (let s = 0; s < r.length; s++)
|
|
2853
|
-
|
|
2879
|
+
ut(r[s], e), s < r.length - 1 && e.srcBuilder.add(",", r[s].end, r[s + 1].start);
|
|
2854
2880
|
e.srcBuilder.add(")", r[r.length - 1].end, t.end);
|
|
2855
2881
|
}
|
|
2856
2882
|
} else n === "@builtin" ? e.srcBuilder.add(
|
|
@@ -2858,25 +2884,25 @@ function Bn(t, e) {
|
|
|
2858
2884
|
t.start,
|
|
2859
2885
|
t.end
|
|
2860
2886
|
) : n === "@diagnostic" ? e.srcBuilder.add(
|
|
2861
|
-
"@diagnostic" +
|
|
2887
|
+
"@diagnostic" + ht(t.attribute.severity, t.attribute.rule),
|
|
2862
2888
|
t.start,
|
|
2863
2889
|
t.end
|
|
2864
2890
|
) : n === "@if" || (n === "@interpolate" ? e.srcBuilder.add(
|
|
2865
2891
|
`@interpolate(${t.attribute.params.map((r) => r.name).join(", ")})`,
|
|
2866
2892
|
t.start,
|
|
2867
2893
|
t.end
|
|
2868
|
-
) :
|
|
2894
|
+
) : j(n));
|
|
2869
2895
|
}
|
|
2870
|
-
function
|
|
2896
|
+
function ht(t, e) {
|
|
2871
2897
|
const n = e[0].name + (e[1] !== null ? "." + e[1].name : "");
|
|
2872
2898
|
return `(${t.name}, ${n})`;
|
|
2873
2899
|
}
|
|
2874
|
-
function
|
|
2900
|
+
function O(t) {
|
|
2875
2901
|
const { kind: e } = t;
|
|
2876
2902
|
if (e === "binary-expression")
|
|
2877
|
-
return `${
|
|
2903
|
+
return `${O(t.left)} ${t.operator.value} ${O(t.right)}`;
|
|
2878
2904
|
if (e === "unary-expression")
|
|
2879
|
-
return `${t.operator.value}${
|
|
2905
|
+
return `${t.operator.value}${O(t.expression)}`;
|
|
2880
2906
|
if (e === "ref")
|
|
2881
2907
|
return t.ident.originalName;
|
|
2882
2908
|
if (e === "literal")
|
|
@@ -2884,19 +2910,19 @@ function L(t) {
|
|
|
2884
2910
|
if (e === "translate-time-feature")
|
|
2885
2911
|
return t.name;
|
|
2886
2912
|
if (e === "parenthesized-expression")
|
|
2887
|
-
return `(${
|
|
2913
|
+
return `(${O(t.expression)})`;
|
|
2888
2914
|
if (e === "component-expression")
|
|
2889
|
-
return `${
|
|
2915
|
+
return `${O(t.base)}[${t.access}]`;
|
|
2890
2916
|
if (e === "component-member-expression")
|
|
2891
|
-
return `${
|
|
2917
|
+
return `${O(t.base)}.${t.access}`;
|
|
2892
2918
|
if (e === "call-expression")
|
|
2893
|
-
return `${t.function.ident.originalName}(${t.arguments.map(
|
|
2894
|
-
|
|
2919
|
+
return `${t.function.ident.originalName}(${t.arguments.map(O).join(", ")})`;
|
|
2920
|
+
j(e);
|
|
2895
2921
|
}
|
|
2896
|
-
function
|
|
2922
|
+
function xi(t, e) {
|
|
2897
2923
|
const { directive: n } = t, { kind: r } = n;
|
|
2898
2924
|
r === "diagnostic" ? e.srcBuilder.add(
|
|
2899
|
-
`diagnostic${
|
|
2925
|
+
`diagnostic${ht(n.severity, n.rule)};`,
|
|
2900
2926
|
t.start,
|
|
2901
2927
|
t.end
|
|
2902
2928
|
) : r === "enable" ? e.srcBuilder.add(
|
|
@@ -2907,12 +2933,12 @@ function fi(t, e) {
|
|
|
2907
2933
|
`requires ${n.extensions.map((s) => s.name).join(", ")};`,
|
|
2908
2934
|
t.start,
|
|
2909
2935
|
t.end
|
|
2910
|
-
) :
|
|
2936
|
+
) : j(r);
|
|
2911
2937
|
}
|
|
2912
|
-
function
|
|
2913
|
-
return
|
|
2938
|
+
function On(t) {
|
|
2939
|
+
return me(t) ? (t.mangledName, `${Rt(t)}`, t.mangledName) : t.mangledName || t.originalName;
|
|
2914
2940
|
}
|
|
2915
|
-
function
|
|
2941
|
+
function Et(t) {
|
|
2916
2942
|
let e = t;
|
|
2917
2943
|
do {
|
|
2918
2944
|
if (e.kind === "decl")
|
|
@@ -2921,7 +2947,7 @@ function wt(t) {
|
|
|
2921
2947
|
} while (e);
|
|
2922
2948
|
throw new Error(`unresolved identifer: ${t.originalName}`);
|
|
2923
2949
|
}
|
|
2924
|
-
function
|
|
2950
|
+
function be(t, e) {
|
|
2925
2951
|
const n = t, { kind: r } = n;
|
|
2926
2952
|
switch (r) {
|
|
2927
2953
|
case "alias":
|
|
@@ -2938,145 +2964,145 @@ function he(t, e) {
|
|
|
2938
2964
|
case "fn":
|
|
2939
2965
|
case "struct":
|
|
2940
2966
|
case "param":
|
|
2941
|
-
return
|
|
2967
|
+
return Ge(n, e);
|
|
2942
2968
|
}
|
|
2943
2969
|
return !0;
|
|
2944
2970
|
}
|
|
2945
|
-
function
|
|
2946
|
-
return
|
|
2971
|
+
function ki(t) {
|
|
2972
|
+
return qn(t) + ";";
|
|
2947
2973
|
}
|
|
2948
|
-
function
|
|
2974
|
+
function qn(t) {
|
|
2949
2975
|
return [
|
|
2950
2976
|
...t.segments.map((e) => e.name),
|
|
2951
|
-
|
|
2977
|
+
_i(t.finalSegment)
|
|
2952
2978
|
].join("::");
|
|
2953
2979
|
}
|
|
2954
|
-
function
|
|
2980
|
+
function _i(t) {
|
|
2955
2981
|
if (t.kind === "import-item") {
|
|
2956
2982
|
const { name: e, as: n } = t, r = n ? ` as ${n}` : "";
|
|
2957
2983
|
return `${e}${r}`;
|
|
2958
2984
|
} else {
|
|
2959
2985
|
if (t.kind === "import-collection")
|
|
2960
|
-
return `{${t.subtrees.map((e) =>
|
|
2961
|
-
|
|
2986
|
+
return `{${t.subtrees.map((e) => qn(e)).join(", ")}}`;
|
|
2987
|
+
Nt(t);
|
|
2962
2988
|
}
|
|
2963
2989
|
}
|
|
2964
|
-
const
|
|
2965
|
-
function
|
|
2966
|
-
const { kind: n } = t, r = new
|
|
2967
|
-
r.add(n),
|
|
2990
|
+
const Fn = 150;
|
|
2991
|
+
function Tt(t, e = 0) {
|
|
2992
|
+
const { kind: n } = t, r = new ie(e, Fn);
|
|
2993
|
+
r.add(n), vi(t, r);
|
|
2968
2994
|
let s = [];
|
|
2969
|
-
return "contents" in t && (s = t.contents.map((o) =>
|
|
2995
|
+
return "contents" in t && (s = t.contents.map((o) => Tt(o, e + 2))), s.length && (r.nl(), r.addBlock(s.join(`
|
|
2970
2996
|
`), !1)), r.result;
|
|
2971
2997
|
}
|
|
2972
|
-
function
|
|
2998
|
+
function vi(t, e) {
|
|
2973
2999
|
const { kind: n } = t;
|
|
2974
3000
|
if (n === "text") {
|
|
2975
3001
|
const { srcModule: r, start: s, end: o } = t;
|
|
2976
3002
|
e.add(` '${r.src.slice(s, o)}'`);
|
|
2977
3003
|
} else if (n === "var" || n === "let" || n === "gvar" || n === "const" || n === "override")
|
|
2978
|
-
|
|
3004
|
+
Be(t.name, e), ot(t.attributes, e);
|
|
2979
3005
|
else if (n === "struct")
|
|
2980
3006
|
e.add(" " + t.name.ident.originalName);
|
|
2981
3007
|
else if (n === "member") {
|
|
2982
3008
|
const { name: r, typeRef: s, attributes: o } = t;
|
|
2983
|
-
|
|
3009
|
+
ot(o, e), e.add(" " + r.name), e.add(": " + et(s));
|
|
2984
3010
|
} else if (n === "name")
|
|
2985
3011
|
e.add(" " + t.name);
|
|
2986
3012
|
else if (n === "memberRef") {
|
|
2987
|
-
const { extraComponents: r } = t, s = r ?
|
|
3013
|
+
const { extraComponents: r } = t, s = r ? Ti(r) : "";
|
|
2988
3014
|
e.add(` ${t.name.ident.originalName}.${t.member.name}${s}`);
|
|
2989
3015
|
} else if (n === "fn")
|
|
2990
|
-
|
|
3016
|
+
yi(t, e);
|
|
2991
3017
|
else if (n === "alias") {
|
|
2992
3018
|
const { name: r, typeRef: s } = t, o = r.ident.kind === "decl" ? "%" : "";
|
|
2993
|
-
e.add(" " + o + r.ident.originalName), e.add("=" +
|
|
3019
|
+
e.add(" " + o + r.ident.originalName), e.add("=" + et(s));
|
|
2994
3020
|
} else if (n === "attribute")
|
|
2995
|
-
|
|
3021
|
+
Wn(t.attribute, e);
|
|
2996
3022
|
else if (n === "expression") {
|
|
2997
|
-
const r = t.contents.map((s) => s.kind === "text" ? "'" + s.srcModule.src.slice(s.start, s.end) + "'" :
|
|
3023
|
+
const r = t.contents.map((s) => s.kind === "text" ? "'" + s.srcModule.src.slice(s.start, s.end) + "'" : Tt(s)).join(" ");
|
|
2998
3024
|
e.add(" " + r);
|
|
2999
3025
|
} else if (n === "type") {
|
|
3000
3026
|
const { name: r } = t, s = typeof r == "string" ? r : r.originalName;
|
|
3001
3027
|
if (e.add(" " + s), t.templateParams !== void 0) {
|
|
3002
|
-
const o = t.templateParams.map(
|
|
3028
|
+
const o = t.templateParams.map(Vn).join(", ");
|
|
3003
3029
|
e.add("<" + o + ">");
|
|
3004
3030
|
}
|
|
3005
3031
|
} else if (n === "synthetic")
|
|
3006
3032
|
e.add(` '${t.text}'`);
|
|
3007
3033
|
else if (n === "import")
|
|
3008
|
-
e.add(" " +
|
|
3034
|
+
e.add(" " + ki(t.imports));
|
|
3009
3035
|
else if (n === "ref")
|
|
3010
3036
|
e.add(" " + t.ident.originalName);
|
|
3011
3037
|
else if (n === "typeDecl")
|
|
3012
|
-
|
|
3038
|
+
Be(t, e);
|
|
3013
3039
|
else if (n === "decl") {
|
|
3014
3040
|
const { ident: r } = t;
|
|
3015
3041
|
e.add(" %" + r.originalName);
|
|
3016
|
-
} else n === "assert" || n === "module" || n === "param" || n === "stuff" || (n === "directive" ?
|
|
3042
|
+
} else n === "assert" || n === "module" || n === "param" || n === "stuff" || (n === "directive" ? Ei(t, e) : n === "statement" ? ot(t.attributes, e) : n === "switch-clause" || Nt(n));
|
|
3017
3043
|
}
|
|
3018
|
-
function
|
|
3044
|
+
function Wn(t, e) {
|
|
3019
3045
|
const { kind: n } = t;
|
|
3020
3046
|
if (n === "@attribute") {
|
|
3021
3047
|
const { name: r, params: s } = t;
|
|
3022
|
-
e.add(" @" + r), s && s.length > 0 && (e.add("("), e.add(s.map(
|
|
3048
|
+
e.add(" @" + r), s && s.length > 0 && (e.add("("), e.add(s.map(Un).join(", ")), e.add(")"));
|
|
3023
3049
|
} else n === "@builtin" ? e.add(` @builtin(${t.param.name})`) : n === "@diagnostic" ? e.add(
|
|
3024
|
-
` @diagnostic${
|
|
3025
|
-
) : n === "@if" ? (e.add(" @if"), e.add("("), e.add(
|
|
3050
|
+
` @diagnostic${ht(t.severity, t.rule)}`
|
|
3051
|
+
) : n === "@if" ? (e.add(" @if"), e.add("("), e.add(O(t.param.expression)), e.add(")")) : n === "@interpolate" ? e.add(` @interpolate(${t.params.map((r) => r.name).join(", ")})`) : Nt(n);
|
|
3026
3052
|
}
|
|
3027
|
-
function
|
|
3028
|
-
const e = new
|
|
3029
|
-
return
|
|
3053
|
+
function Si(t) {
|
|
3054
|
+
const e = new ie(0, Fn);
|
|
3055
|
+
return Wn(t, e), e.result;
|
|
3030
3056
|
}
|
|
3031
|
-
function
|
|
3057
|
+
function Be(t, e) {
|
|
3032
3058
|
const { decl: n, typeRef: r } = t;
|
|
3033
|
-
e.add(" %" + n.ident.originalName), r && e.add(" : " +
|
|
3059
|
+
e.add(" %" + n.ident.originalName), r && e.add(" : " + et(r));
|
|
3034
3060
|
}
|
|
3035
|
-
function
|
|
3061
|
+
function yi(t, e) {
|
|
3036
3062
|
const { name: n, params: r, returnType: s, attributes: o } = t;
|
|
3037
3063
|
e.add(" " + n.ident.originalName), e.add("(");
|
|
3038
3064
|
const i = r.map(
|
|
3039
3065
|
(a) => {
|
|
3040
|
-
const { name: c } = a, { originalName: l } = c.decl.ident, d =
|
|
3066
|
+
const { name: c } = a, { originalName: l } = c.decl.ident, d = et(c.typeRef);
|
|
3041
3067
|
return l + ": " + d;
|
|
3042
3068
|
}
|
|
3043
3069
|
).join(", ");
|
|
3044
|
-
e.add(i), e.add(")"),
|
|
3070
|
+
e.add(i), e.add(")"), ot(o, e), s && e.add(" -> " + et(s));
|
|
3045
3071
|
}
|
|
3046
|
-
function
|
|
3047
|
-
t == null || t.forEach((n) => e.add(" " +
|
|
3072
|
+
function ot(t, e) {
|
|
3073
|
+
t == null || t.forEach((n) => e.add(" " + wi(n.attribute)));
|
|
3048
3074
|
}
|
|
3049
|
-
function
|
|
3075
|
+
function wi(t) {
|
|
3050
3076
|
const { kind: e } = t;
|
|
3051
3077
|
return e === "@attribute" ? "@" + t.name : e;
|
|
3052
3078
|
}
|
|
3053
|
-
function
|
|
3079
|
+
function Ei(t, e) {
|
|
3054
3080
|
const { directive: n, attributes: r } = t, { kind: s } = n;
|
|
3055
3081
|
if (s === "diagnostic") {
|
|
3056
|
-
const { severity: o, rule: i } = n, a =
|
|
3082
|
+
const { severity: o, rule: i } = n, a = ht(o, i);
|
|
3057
3083
|
e.add(` diagnostic${a}`);
|
|
3058
|
-
} else s === "enable" || s === "requires" ? e.add(` ${s} ${n.extensions.map((o) => o.name).join(", ")}`) :
|
|
3059
|
-
|
|
3084
|
+
} else s === "enable" || s === "requires" ? e.add(` ${s} ${n.extensions.map((o) => o.name).join(", ")}`) : Nt(s);
|
|
3085
|
+
ot(r, e);
|
|
3060
3086
|
}
|
|
3061
|
-
function
|
|
3062
|
-
return "contents" in t ? t.contents.map((n) => n.kind === "text" ? "'" + n.srcModule.src.slice(n.start, n.end) + "'" :
|
|
3087
|
+
function Un(t) {
|
|
3088
|
+
return "contents" in t ? t.contents.map((n) => n.kind === "text" ? "'" + n.srcModule.src.slice(n.start, n.end) + "'" : Tt(n)).join(" ") : Tt(t);
|
|
3063
3089
|
}
|
|
3064
|
-
function
|
|
3065
|
-
return typeof t == "string" ? t : t.kind === "type" ?
|
|
3090
|
+
function Vn(t) {
|
|
3091
|
+
return typeof t == "string" ? t : t.kind === "type" ? et(t) : t.kind === "expression" ? Un(t) : (console.log("unknown template parameter type", t), "??");
|
|
3066
3092
|
}
|
|
3067
|
-
function
|
|
3093
|
+
function et(t) {
|
|
3068
3094
|
if (!t) return "?type?";
|
|
3069
3095
|
const { name: e } = t, n = typeof e == "string" ? e : e.originalName;
|
|
3070
3096
|
let r = "";
|
|
3071
|
-
return t.templateParams !== void 0 && (r = "<" + t.templateParams.map(
|
|
3097
|
+
return t.templateParams !== void 0 && (r = "<" + t.templateParams.map(Vn).join(", ") + ">"), n + r;
|
|
3072
3098
|
}
|
|
3073
|
-
function
|
|
3099
|
+
function Ti(t) {
|
|
3074
3100
|
return t.contents.map((n) => {
|
|
3075
3101
|
const { kind: r } = n;
|
|
3076
3102
|
return r === "text" ? n.srcModule.src.slice(n.start, n.end) : r === "ref" ? n.ident.originalName : `?${n.kind}?`;
|
|
3077
3103
|
}).join(" ");
|
|
3078
3104
|
}
|
|
3079
|
-
class
|
|
3105
|
+
class zn {
|
|
3080
3106
|
constructor(e) {
|
|
3081
3107
|
this.sourceMap = e;
|
|
3082
3108
|
}
|
|
@@ -3107,11 +3133,11 @@ class vi {
|
|
|
3107
3133
|
o(null);
|
|
3108
3134
|
return;
|
|
3109
3135
|
}
|
|
3110
|
-
const a = this.mapGPUCompilationInfo(i), c =
|
|
3136
|
+
const a = this.mapGPUCompilationInfo(i), c = Ni(
|
|
3111
3137
|
a,
|
|
3112
3138
|
r
|
|
3113
3139
|
);
|
|
3114
|
-
|
|
3140
|
+
nr(c !== null);
|
|
3115
3141
|
const l = new GPUValidationError(
|
|
3116
3142
|
c
|
|
3117
3143
|
);
|
|
@@ -3136,7 +3162,7 @@ class vi {
|
|
|
3136
3162
|
};
|
|
3137
3163
|
}
|
|
3138
3164
|
mapGPUCompilationMessage(e) {
|
|
3139
|
-
const n = this.sourceMap, r = n.destToSrc(e.offset), o = (e.length > 0 ? n.destToSrc(e.offset + e.length) : r).position - r.position, [i, a] =
|
|
3165
|
+
const n = this.sourceMap, r = n.destToSrc(e.offset), o = (e.length > 0 ? n.destToSrc(e.offset + e.length) : r).position - r.position, [i, a] = At(
|
|
3140
3166
|
r.position,
|
|
3141
3167
|
r.src.text
|
|
3142
3168
|
);
|
|
@@ -3155,7 +3181,7 @@ class vi {
|
|
|
3155
3181
|
};
|
|
3156
3182
|
}
|
|
3157
3183
|
}
|
|
3158
|
-
function
|
|
3184
|
+
function Ni(t, e) {
|
|
3159
3185
|
if (t.messages.length === 0) return null;
|
|
3160
3186
|
let n = `Compilation log for [Invalid ShaderModule (${e.label || "unlabled"})]:
|
|
3161
3187
|
`;
|
|
@@ -3169,7 +3195,7 @@ function Si(t, e) {
|
|
|
3169
3195
|
n += `${s.module.url}:${o}:${i}`, n += ` ${s.type}: ${s.message}
|
|
3170
3196
|
`;
|
|
3171
3197
|
const a = s.module.text;
|
|
3172
|
-
a && (n +=
|
|
3198
|
+
a && (n += We(a, [
|
|
3173
3199
|
s.offset,
|
|
3174
3200
|
s.offset + s.length
|
|
3175
3201
|
]).join(`
|
|
@@ -3177,63 +3203,69 @@ function Si(t, e) {
|
|
|
3177
3203
|
}
|
|
3178
3204
|
return n;
|
|
3179
3205
|
}
|
|
3180
|
-
function
|
|
3206
|
+
function $i(t) {
|
|
3181
3207
|
const n = t.split("/").filter((s) => s !== "."), r = [];
|
|
3182
3208
|
return n.forEach((s) => {
|
|
3183
3209
|
s !== "" && (s === ".." && r.length && r[r.length - 1] !== ".." ? r.pop() : r.push(s));
|
|
3184
3210
|
}), r.join("/");
|
|
3185
3211
|
}
|
|
3186
|
-
function
|
|
3212
|
+
function Pi(t) {
|
|
3187
3213
|
const e = t.lastIndexOf("/"), n = e === -1 ? 0 : e + 1, r = t.indexOf(".", n), s = r === -1 ? t.length : r;
|
|
3188
3214
|
return t.slice(0, s);
|
|
3189
3215
|
}
|
|
3190
|
-
function
|
|
3191
|
-
return
|
|
3216
|
+
function Gn() {
|
|
3217
|
+
return Vr(), { modules: {} };
|
|
3192
3218
|
}
|
|
3193
|
-
function
|
|
3219
|
+
function xa(t) {
|
|
3194
3220
|
return `modules: ${[...Object.keys(t.modules)]}`;
|
|
3195
3221
|
}
|
|
3196
|
-
function
|
|
3222
|
+
function Mi(t, e, n = "package") {
|
|
3197
3223
|
let r;
|
|
3198
|
-
return e.includes("::") ? r = e : e.includes("/") || e.endsWith(".wesl") || e.endsWith(".wgsl") ? r =
|
|
3224
|
+
return e.includes("::") ? r = e : e.includes("/") || e.endsWith(".wesl") || e.endsWith(".wgsl") ? r = Xn(e, n) : r = n + "::" + e, t.modules[r];
|
|
3199
3225
|
}
|
|
3200
|
-
function
|
|
3226
|
+
function xe(t, e, n = "package", r) {
|
|
3201
3227
|
let s = r;
|
|
3202
3228
|
s === void 0 ? s = "" : s.endsWith("/") || (s += "/"), Object.entries(t).map(
|
|
3203
|
-
([i, a]) => ({ modulePath:
|
|
3229
|
+
([i, a]) => ({ modulePath: Xn(i, n), debugFilePath: s + i, src: a })
|
|
3204
3230
|
).forEach((i) => {
|
|
3205
|
-
const a =
|
|
3231
|
+
const a = Cn(i);
|
|
3206
3232
|
if (e.modules[i.modulePath])
|
|
3207
3233
|
throw new Error(`duplicate module path: '${i.modulePath}'`);
|
|
3208
3234
|
e.modules[i.modulePath] = a;
|
|
3209
3235
|
});
|
|
3210
3236
|
}
|
|
3211
|
-
function
|
|
3237
|
+
function ke(t, e) {
|
|
3212
3238
|
t.forEach(
|
|
3213
|
-
({ modules: n, name: r }) =>
|
|
3239
|
+
({ modules: n, name: r }) => xe(n, e, r)
|
|
3214
3240
|
), t.forEach(
|
|
3215
|
-
({ dependencies: n }) =>
|
|
3241
|
+
({ dependencies: n }) => ke(n || [], e)
|
|
3216
3242
|
);
|
|
3217
3243
|
}
|
|
3218
|
-
const
|
|
3219
|
-
function
|
|
3244
|
+
const Ci = /^lib\.w[eg]sl$/i;
|
|
3245
|
+
function Xn(t, e) {
|
|
3220
3246
|
if (t.includes("::"))
|
|
3221
3247
|
return t;
|
|
3222
|
-
if (e !== "package" &&
|
|
3248
|
+
if (e !== "package" && Ci.test(t))
|
|
3223
3249
|
return e;
|
|
3224
|
-
const r =
|
|
3250
|
+
const r = Pi($i(t)).replaceAll("/", "::");
|
|
3225
3251
|
return e + "::" + r;
|
|
3226
3252
|
}
|
|
3227
|
-
async function
|
|
3228
|
-
const { weslSrc: e, debugWeslRoot: n, libs: r = [] } = t, s =
|
|
3229
|
-
|
|
3230
|
-
const o =
|
|
3231
|
-
return new
|
|
3232
|
-
}
|
|
3233
|
-
function
|
|
3234
|
-
const
|
|
3235
|
-
|
|
3236
|
-
|
|
3253
|
+
async function ka(t) {
|
|
3254
|
+
const { weslSrc: e, debugWeslRoot: n, libs: r = [] } = t, s = Gn();
|
|
3255
|
+
xe(e, s, "package", n), ke(r, s);
|
|
3256
|
+
const o = Jn({ registry: s, ...t });
|
|
3257
|
+
return new zn(o);
|
|
3258
|
+
}
|
|
3259
|
+
function _a(t) {
|
|
3260
|
+
const { weslSrc: e, debugWeslRoot: n, libs: r = [] } = t, s = Gn();
|
|
3261
|
+
xe(e, s, "package", n), ke(r, s);
|
|
3262
|
+
const o = Jn({ registry: s, ...t });
|
|
3263
|
+
return new zn(o);
|
|
3264
|
+
}
|
|
3265
|
+
function Jn(t) {
|
|
3266
|
+
const e = Ai(t), { transformedAst: n, newDecls: r, newStatements: s } = e;
|
|
3267
|
+
return bt.build(
|
|
3268
|
+
Di(
|
|
3237
3269
|
n.moduleElem,
|
|
3238
3270
|
n.srcModule,
|
|
3239
3271
|
r,
|
|
@@ -3242,133 +3274,133 @@ function $i(t) {
|
|
|
3242
3274
|
)
|
|
3243
3275
|
);
|
|
3244
3276
|
}
|
|
3245
|
-
function
|
|
3246
|
-
const { registry: e, mangler: n } = t, { rootModuleName: r = "main", conditions: s = {} } = t, o =
|
|
3277
|
+
function Ai(t) {
|
|
3278
|
+
const { registry: e, mangler: n } = t, { rootModuleName: r = "main", conditions: s = {} } = t, o = Ii(e, r), { constants: i, config: a } = t;
|
|
3247
3279
|
let { virtualLibs: c } = t;
|
|
3248
|
-
i && (c = { ...c, constants:
|
|
3249
|
-
const l = c &&
|
|
3250
|
-
return { transformedAst:
|
|
3280
|
+
i && (c = { ...c, constants: Ri(i) });
|
|
3281
|
+
const l = c && Wr(c, (U) => ({ fn: U })), p = Yo({ rootAst: o, registry: e, conditions: s, virtuals: l, mangler: n }), { globalNames: g, decls: x, newStatements: T } = p;
|
|
3282
|
+
return { transformedAst: Bi(o, g, a), newDecls: x, newStatements: T };
|
|
3251
3283
|
}
|
|
3252
|
-
function
|
|
3284
|
+
function Ri(t) {
|
|
3253
3285
|
return () => Object.entries(t).map(([e, n]) => `const ${e} = ${n};`).join(`
|
|
3254
3286
|
`);
|
|
3255
3287
|
}
|
|
3256
|
-
function
|
|
3257
|
-
const n =
|
|
3288
|
+
function Ii(t, e) {
|
|
3289
|
+
const n = Mi(t, e);
|
|
3258
3290
|
if (!n)
|
|
3259
3291
|
throw new Error(`Root module not found: ${e}`);
|
|
3260
3292
|
return n;
|
|
3261
3293
|
}
|
|
3262
|
-
function
|
|
3294
|
+
function Bi(t, e, n) {
|
|
3263
3295
|
const { moduleElem: r, srcModule: s } = t, o = { moduleElem: r, srcModule: s, globalNames: e, notableElems: {} }, i = (n == null ? void 0 : n.plugins) ?? [];
|
|
3264
|
-
return
|
|
3296
|
+
return ne(i, (l) => l.transform).reduce(
|
|
3265
3297
|
(l, d) => d(l),
|
|
3266
3298
|
o
|
|
3267
3299
|
);
|
|
3268
3300
|
}
|
|
3269
|
-
function
|
|
3301
|
+
function Di(t, e, n, r, s = {}) {
|
|
3270
3302
|
const o = r.map((c) => {
|
|
3271
|
-
const { elem: l, srcModule: d } = c, { src: p, debugFilePath: g } = d, x = new
|
|
3272
|
-
return
|
|
3273
|
-
}), i = new
|
|
3303
|
+
const { elem: l, srcModule: d } = c, { src: p, debugFilePath: g } = d, x = new bt({ text: p, path: g });
|
|
3304
|
+
return Ot(x, [l], s), x.addNl(), x;
|
|
3305
|
+
}), i = new bt({
|
|
3274
3306
|
text: e.src,
|
|
3275
3307
|
path: e.debugFilePath
|
|
3276
3308
|
});
|
|
3277
|
-
|
|
3309
|
+
Ot(i, [t], s, !1);
|
|
3278
3310
|
const a = n.map((c) => {
|
|
3279
|
-
const l = new
|
|
3311
|
+
const l = new bt({
|
|
3280
3312
|
text: c.srcModule.src,
|
|
3281
3313
|
path: c.srcModule.debugFilePath
|
|
3282
3314
|
});
|
|
3283
|
-
return
|
|
3315
|
+
return Ot(l, [c.declElem], s), l;
|
|
3284
3316
|
});
|
|
3285
3317
|
return [...o, i, ...a];
|
|
3286
3318
|
}
|
|
3287
|
-
function
|
|
3288
|
-
e(t), t.contents && t.contents.forEach((r) =>
|
|
3319
|
+
function Kn(t, e) {
|
|
3320
|
+
e(t), t.contents && t.contents.forEach((r) => Kn(r, e));
|
|
3289
3321
|
}
|
|
3290
|
-
function
|
|
3322
|
+
function ji(t) {
|
|
3291
3323
|
const { kind: e } = t.attribute;
|
|
3292
3324
|
if (e === "@attribute") {
|
|
3293
3325
|
const { params: n } = t.attribute;
|
|
3294
|
-
return n === void 0 || n.length === 0 ? "@" + t.attribute.name : `@${t.attribute.name}(${n.map((r) =>
|
|
3326
|
+
return n === void 0 || n.length === 0 ? "@" + t.attribute.name : `@${t.attribute.name}(${n.map((r) => _e(r)).join(", ")})`;
|
|
3295
3327
|
} else {
|
|
3296
3328
|
if (e === "@builtin")
|
|
3297
3329
|
return "@builtin(" + t.attribute.param.name + ")";
|
|
3298
3330
|
if (e === "@diagnostic")
|
|
3299
|
-
return "@diagnostic" +
|
|
3331
|
+
return "@diagnostic" + ht(t.attribute.severity, t.attribute.rule);
|
|
3300
3332
|
if (e === "@if")
|
|
3301
|
-
return `@if(${
|
|
3333
|
+
return `@if(${O(t.attribute.param.expression)})`;
|
|
3302
3334
|
if (e === "@interpolate")
|
|
3303
3335
|
return `@interpolate(${t.attribute.params.map((n) => n.name).join(", ")})`;
|
|
3304
|
-
|
|
3336
|
+
j(e);
|
|
3305
3337
|
}
|
|
3306
3338
|
}
|
|
3307
|
-
function
|
|
3308
|
-
return `<${t.map(
|
|
3339
|
+
function jt(t) {
|
|
3340
|
+
return `<${t.map(Hn).join(", ")}>`;
|
|
3309
3341
|
}
|
|
3310
|
-
function
|
|
3342
|
+
function Hn(t) {
|
|
3311
3343
|
if (t === void 0) return "?";
|
|
3312
3344
|
if (typeof t == "string") return t;
|
|
3313
|
-
if (t.kind === "expression") return
|
|
3314
|
-
if (t.kind === "type") return
|
|
3315
|
-
|
|
3345
|
+
if (t.kind === "expression") return _e(t);
|
|
3346
|
+
if (t.kind === "type") return Li(t);
|
|
3347
|
+
j(t);
|
|
3316
3348
|
}
|
|
3317
|
-
function
|
|
3349
|
+
function Li(t) {
|
|
3318
3350
|
if (!t) return "?";
|
|
3319
|
-
const { name: e, templateParams: n } = t, r = n ?
|
|
3320
|
-
return `${
|
|
3351
|
+
const { name: e, templateParams: n } = t, r = n ? jt(n) : "";
|
|
3352
|
+
return `${Yn(e)}${r}`;
|
|
3321
3353
|
}
|
|
3322
|
-
function
|
|
3354
|
+
function Yn(t) {
|
|
3323
3355
|
if (typeof t == "string") return t;
|
|
3324
3356
|
if (t.std) return t.originalName;
|
|
3325
|
-
const e =
|
|
3357
|
+
const e = Et(t);
|
|
3326
3358
|
return e.mangledName || e.originalName;
|
|
3327
3359
|
}
|
|
3328
|
-
function
|
|
3360
|
+
function _e(t) {
|
|
3329
3361
|
if (t.kind === "translate-time-expression")
|
|
3330
3362
|
throw new Error("Not supported");
|
|
3331
3363
|
if (t.kind === "expression" || t.kind === "stuff")
|
|
3332
3364
|
return t.contents.map((n) => {
|
|
3333
3365
|
const { kind: r } = n;
|
|
3334
|
-
return r === "text" ? n.srcModule.src.slice(n.start, n.end) : r === "ref" ?
|
|
3366
|
+
return r === "text" ? n.srcModule.src.slice(n.start, n.end) : r === "ref" ? Yn(n.ident) : `?${n.kind}?`;
|
|
3335
3367
|
}).join(" ");
|
|
3336
3368
|
if (t.kind === "name")
|
|
3337
3369
|
return t.name;
|
|
3338
|
-
|
|
3370
|
+
j(t);
|
|
3339
3371
|
}
|
|
3340
|
-
const
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
function
|
|
3372
|
+
const Oi = Ct(Bn);
|
|
3373
|
+
Ct(Rn);
|
|
3374
|
+
Ct(In);
|
|
3375
|
+
function va() {
|
|
3344
3376
|
return {
|
|
3345
|
-
transform:
|
|
3377
|
+
transform: qi
|
|
3346
3378
|
};
|
|
3347
3379
|
}
|
|
3348
|
-
function
|
|
3349
|
-
const e = structuredClone(t), { moduleElem: n, globalNames: r, notableElems: s } = e, o =
|
|
3350
|
-
|
|
3380
|
+
function qi(t) {
|
|
3381
|
+
const e = structuredClone(t), { moduleElem: n, globalNames: r, notableElems: s } = e, o = Vi(n);
|
|
3382
|
+
Fi(n, o);
|
|
3351
3383
|
const i = o.flatMap(
|
|
3352
|
-
(l) =>
|
|
3353
|
-
), a =
|
|
3384
|
+
(l) => Xi(l, r)
|
|
3385
|
+
), a = Yi(n);
|
|
3354
3386
|
a.forEach(
|
|
3355
|
-
({ memberRef: l, struct: d }) =>
|
|
3387
|
+
({ memberRef: l, struct: d }) => ta(l, d)
|
|
3356
3388
|
), a.forEach(
|
|
3357
3389
|
({ intermediates: l }) => l.forEach((d) => {
|
|
3358
3390
|
d.contents = [];
|
|
3359
3391
|
})
|
|
3360
3392
|
);
|
|
3361
|
-
const c =
|
|
3393
|
+
const c = Ui(n);
|
|
3362
3394
|
return n.contents = [...i, ...c], s.bindingStructs = o, { ...e, moduleElem: n };
|
|
3363
3395
|
}
|
|
3364
|
-
function
|
|
3365
|
-
const n = t.contents.filter((s) => s.kind === "fn"), r =
|
|
3396
|
+
function Fi(t, e) {
|
|
3397
|
+
const n = t.contents.filter((s) => s.kind === "fn"), r = Wi(n, e);
|
|
3366
3398
|
if (r) {
|
|
3367
3399
|
const { fn: s, struct: o } = r;
|
|
3368
3400
|
o.entryFn = s;
|
|
3369
3401
|
}
|
|
3370
3402
|
}
|
|
3371
|
-
function
|
|
3403
|
+
function Wi(t, e) {
|
|
3372
3404
|
var n, r, s;
|
|
3373
3405
|
for (const o of t) {
|
|
3374
3406
|
const { params: i } = o;
|
|
@@ -3379,101 +3411,101 @@ function Oi(t, e) {
|
|
|
3379
3411
|
}
|
|
3380
3412
|
}
|
|
3381
3413
|
}
|
|
3382
|
-
function
|
|
3414
|
+
function Ui(t) {
|
|
3383
3415
|
return t.contents.filter(
|
|
3384
3416
|
(e) => e.kind !== "struct" || !e.bindingStruct
|
|
3385
3417
|
);
|
|
3386
3418
|
}
|
|
3387
|
-
function
|
|
3388
|
-
const n = t.contents.filter((r) => r.kind === "struct").filter(
|
|
3419
|
+
function Vi(t) {
|
|
3420
|
+
const n = t.contents.filter((r) => r.kind === "struct").filter(zi);
|
|
3389
3421
|
return n.forEach((r) => {
|
|
3390
3422
|
r.bindingStruct = !0;
|
|
3391
3423
|
}), n;
|
|
3392
3424
|
}
|
|
3393
|
-
function
|
|
3394
|
-
return t.members.some(({ attributes: e }) =>
|
|
3425
|
+
function zi(t) {
|
|
3426
|
+
return t.members.some(({ attributes: e }) => Gi(e));
|
|
3395
3427
|
}
|
|
3396
|
-
function
|
|
3428
|
+
function Gi(t) {
|
|
3397
3429
|
return t ? t.some(
|
|
3398
3430
|
({ attribute: e }) => e.kind === "@attribute" && (e.name === "binding" || e.name === "group")
|
|
3399
3431
|
) : !1;
|
|
3400
3432
|
}
|
|
3401
|
-
function
|
|
3433
|
+
function Xi(t, e) {
|
|
3402
3434
|
return t.members.map((n) => {
|
|
3403
3435
|
var g;
|
|
3404
|
-
const { typeRef: r, name: s } = n, { name: o } = r, i = r == null ? void 0 : r.templateParams, a =
|
|
3436
|
+
const { typeRef: r, name: s } = n, { name: o } = r, i = r == null ? void 0 : r.templateParams, a = nn(s.name, e);
|
|
3405
3437
|
n.mangledVarName = a, e.add(a);
|
|
3406
|
-
const c = ((g = n.attributes) == null ? void 0 : g.map(
|
|
3438
|
+
const c = ((g = n.attributes) == null ? void 0 : g.map(ji).join(" ")) ?? "", l = Ji(o, i) ?? Ki(o, i) ?? Hi(o, i);
|
|
3407
3439
|
if (!l)
|
|
3408
|
-
return console.log("unhandled case transforming member", o),
|
|
3440
|
+
return console.log("unhandled case transforming member", o), De(c, a, "", "??");
|
|
3409
3441
|
const { storage: d, varType: p } = l;
|
|
3410
|
-
return
|
|
3442
|
+
return De(c, a, d, p);
|
|
3411
3443
|
});
|
|
3412
3444
|
}
|
|
3413
|
-
function
|
|
3445
|
+
function Ji(t, e) {
|
|
3414
3446
|
if (t.originalName === "ptr") {
|
|
3415
3447
|
const n = e ?? [], r = [n[0]];
|
|
3416
3448
|
n[2] && r.push(n[2]);
|
|
3417
|
-
const s =
|
|
3449
|
+
const s = jt(r), o = Hn(n == null ? void 0 : n[1]);
|
|
3418
3450
|
return { storage: s, varType: o };
|
|
3419
3451
|
}
|
|
3420
3452
|
}
|
|
3421
|
-
function
|
|
3453
|
+
function Ki(t, e) {
|
|
3422
3454
|
if (typeof t != "string") {
|
|
3423
|
-
const n = t.std ? t.originalName : "??", r = e ?
|
|
3455
|
+
const n = t.std ? t.originalName : "??", r = e ? jt(e) : "";
|
|
3424
3456
|
return { varType: n + r, storage: "" };
|
|
3425
3457
|
}
|
|
3426
3458
|
}
|
|
3427
|
-
function
|
|
3428
|
-
if (
|
|
3429
|
-
const n = e ?
|
|
3459
|
+
function Hi(t, e) {
|
|
3460
|
+
if (Oi.test(t.originalName)) {
|
|
3461
|
+
const n = e ? jt(e) : "";
|
|
3430
3462
|
return { varType: t + n, storage: "" };
|
|
3431
3463
|
}
|
|
3432
3464
|
}
|
|
3433
|
-
function
|
|
3465
|
+
function De(t, e, n, r) {
|
|
3434
3466
|
return {
|
|
3435
3467
|
kind: "synthetic",
|
|
3436
3468
|
text: `${t} var${n} ${e} : ${r};
|
|
3437
3469
|
`
|
|
3438
3470
|
};
|
|
3439
3471
|
}
|
|
3440
|
-
function
|
|
3472
|
+
function Yi(t) {
|
|
3441
3473
|
const e = [];
|
|
3442
|
-
return
|
|
3474
|
+
return Kn(t, (n) => {
|
|
3443
3475
|
n.kind === "memberRef" && e.push(n);
|
|
3444
|
-
}),
|
|
3476
|
+
}), ne(e, Zi);
|
|
3445
3477
|
}
|
|
3446
|
-
function
|
|
3447
|
-
const e =
|
|
3478
|
+
function Zi(t) {
|
|
3479
|
+
const e = Qi(t.name.ident);
|
|
3448
3480
|
if (e != null && e.struct.bindingStruct)
|
|
3449
3481
|
return { memberRef: t, ...e };
|
|
3450
3482
|
}
|
|
3451
|
-
function
|
|
3483
|
+
function Qi(t) {
|
|
3452
3484
|
var r;
|
|
3453
|
-
const n =
|
|
3485
|
+
const n = Et(t).declElem;
|
|
3454
3486
|
if (n && n.kind === "param") {
|
|
3455
3487
|
const s = (r = n.name.typeRef) == null ? void 0 : r.name;
|
|
3456
3488
|
if (typeof s != "string") {
|
|
3457
3489
|
if (s != null && s.std)
|
|
3458
3490
|
return;
|
|
3459
|
-
const i =
|
|
3491
|
+
const i = Et(s).declElem;
|
|
3460
3492
|
return (i == null ? void 0 : i.kind) === "struct" ? { struct: i, intermediates: [n] } : void 0;
|
|
3461
3493
|
}
|
|
3462
3494
|
}
|
|
3463
3495
|
}
|
|
3464
|
-
function
|
|
3496
|
+
function ta(t, e) {
|
|
3465
3497
|
const n = t.member.name, r = e.members.find((c) => c.name.name === n);
|
|
3466
3498
|
if (!r || !r.mangledVarName)
|
|
3467
3499
|
return { kind: "synthetic", text: n };
|
|
3468
|
-
const { extraComponents: s } = t, o = s ?
|
|
3500
|
+
const { extraComponents: s } = t, o = s ? _e(s) : "", a = { kind: "synthetic", text: r.mangledVarName + o };
|
|
3469
3501
|
return t.contents = [a], a;
|
|
3470
3502
|
}
|
|
3471
|
-
async function
|
|
3503
|
+
async function Sa(t, e) {
|
|
3472
3504
|
if (!t)
|
|
3473
3505
|
throw new Error("No GPU adapter");
|
|
3474
|
-
return t.requestDevice(e).then(
|
|
3506
|
+
return t.requestDevice(e).then(ea);
|
|
3475
3507
|
}
|
|
3476
|
-
function
|
|
3508
|
+
function ea(t) {
|
|
3477
3509
|
const e = [];
|
|
3478
3510
|
t.injectError = (r, s) => {
|
|
3479
3511
|
const o = e.findLast((i) => i.filter === r);
|
|
@@ -3490,7 +3522,7 @@ function Zi(t) {
|
|
|
3490
3522
|
const o = s.error;
|
|
3491
3523
|
if (o.compilationInfo)
|
|
3492
3524
|
for (const i of o.compilationInfo.messages)
|
|
3493
|
-
|
|
3525
|
+
re({
|
|
3494
3526
|
url: i.module.url,
|
|
3495
3527
|
text: i.module.text ?? null,
|
|
3496
3528
|
lineNumber: i.lineNum,
|
|
@@ -3529,67 +3561,68 @@ function Zi(t) {
|
|
|
3529
3561
|
})(t.popErrorScope), t;
|
|
3530
3562
|
}
|
|
3531
3563
|
export {
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3564
|
+
zn as LinkedWesl,
|
|
3565
|
+
Vo as WeslParseError,
|
|
3566
|
+
Is as WeslStream,
|
|
3567
|
+
_a as _linkSync,
|
|
3568
|
+
Tt as astToString,
|
|
3569
|
+
Si as attributeToString,
|
|
3570
|
+
Ai as bindAndTransform,
|
|
3571
|
+
Yo as bindIdents,
|
|
3572
|
+
va as bindingStructsPlugin,
|
|
3573
|
+
An as blankWeslParseState,
|
|
3574
|
+
fa as childIdent,
|
|
3575
|
+
oe as childScope,
|
|
3576
|
+
zr as containsScope,
|
|
3577
|
+
Ti as debugContentsToString,
|
|
3578
|
+
Ye as emptyScope,
|
|
3579
|
+
We as errorHighlight,
|
|
3580
|
+
ne as filterMap,
|
|
3581
|
+
Fr as findMap,
|
|
3582
|
+
Yi as findRefsToBindingStructs,
|
|
3583
|
+
ba as findUnboundIdents,
|
|
3584
|
+
Dt as findValidRootDecls,
|
|
3585
|
+
zo as flatImports,
|
|
3586
|
+
aa as groupBy,
|
|
3587
|
+
ia as grouped,
|
|
3588
|
+
Rt as identToString,
|
|
3589
|
+
me as isGlobal,
|
|
3590
|
+
Or as last,
|
|
3591
|
+
ga as lengthPrefixMangle,
|
|
3592
|
+
ka as link,
|
|
3593
|
+
Jn as linkRegistry,
|
|
3594
|
+
qi as lowerBindingStructs,
|
|
3595
|
+
ea as makeWeslDevice,
|
|
3596
|
+
ua as mapForward,
|
|
3597
|
+
Wr as mapValues,
|
|
3598
|
+
Vi as markBindingStructs,
|
|
3599
|
+
Fi as markEntryTypes,
|
|
3600
|
+
Wt as mergeScope,
|
|
3601
|
+
en as minimalMangle,
|
|
3602
|
+
nn as minimallyMangledName,
|
|
3603
|
+
sa as multiKeySet,
|
|
3604
|
+
se as nextIdentId,
|
|
3605
|
+
Pi as noSuffix,
|
|
3606
|
+
$i as normalize,
|
|
3607
|
+
At as offsetToLineNumber,
|
|
3608
|
+
da as overlapTail,
|
|
3609
|
+
xe as parseIntoRegistry,
|
|
3610
|
+
ke as parseLibsIntoRegistry,
|
|
3611
|
+
Cn as parseSrcModule,
|
|
3612
|
+
Gn as parsedRegistry,
|
|
3613
|
+
ca as partition,
|
|
3614
|
+
Ze as publicDecl,
|
|
3615
|
+
xa as registryToString,
|
|
3616
|
+
oa as replaceWords,
|
|
3617
|
+
Sa as requestWeslDevice,
|
|
3618
|
+
Vr as resetScopeIds,
|
|
3619
|
+
la as scan,
|
|
3620
|
+
Qe as scopeToString,
|
|
3621
|
+
pa as scopeToStringLong,
|
|
3622
|
+
Mi as selectModule,
|
|
3623
|
+
ha as syntheticWeslParseState,
|
|
3624
|
+
ta as transformBindingReference,
|
|
3625
|
+
Xi as transformBindingStruct,
|
|
3626
|
+
ma as underscoreMangle
|
|
3594
3627
|
};
|
|
3595
3628
|
//# sourceMappingURL=minified.js.map
|