Skip to content

Commit 5f9560d

Browse files
authored
feat!: Update WASM extension (#1047)
Upstream changes to the WASM extension from the `gpu` branch. Namely, * Add a new type `Result`, which can be lazily read to get the operation result and return the context * The `call` operation returns a `Result` instead of a context + future * Functions can now be looked up either by name or by id in the wasm module * `ConstWasmModule` no longer contains a `hash` field (that we weren't using) and its other field has been renamed BREAKING CHANGE: This is a breaking change to the WASM extension and its serialised representation
1 parent f94a24b commit 5f9560d

File tree

2 files changed

+437
-99
lines changed

2 files changed

+437
-99
lines changed

tket-exts/src/tket_exts/data/tket/wasm.json

Lines changed: 175 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.3.0",
2+
"version": "0.4.0",
33
"name": "tket.wasm",
44
"types": {
55
"context": {
@@ -46,6 +46,24 @@
4646
"b": "Explicit",
4747
"bound": "C"
4848
}
49+
},
50+
"result": {
51+
"extension": "tket.wasm",
52+
"name": "result",
53+
"params": [
54+
{
55+
"tp": "List",
56+
"param": {
57+
"tp": "Type",
58+
"b": "A"
59+
}
60+
}
61+
],
62+
"description": "wasm result",
63+
"bound": {
64+
"b": "Explicit",
65+
"bound": "A"
66+
}
4967
}
5068
},
5169
"operations": {
@@ -129,30 +147,23 @@
129147
{
130148
"t": "Opaque",
131149
"extension": "tket.wasm",
132-
"id": "context",
133-
"args": [],
134-
"bound": "A"
135-
},
136-
{
137-
"t": "Opaque",
138-
"extension": "tket.futures",
139-
"id": "Future",
150+
"id": "result",
140151
"args": [
141152
{
142-
"tya": "Type",
143-
"ty": {
144-
"t": "Sum",
145-
"s": "General",
146-
"rows": [
147-
[
148-
{
149-
"t": "R",
150-
"i": 1,
153+
"tya": "List",
154+
"elems": [
155+
{
156+
"tya": "Variable",
157+
"idx": 1,
158+
"cached_decl": {
159+
"tp": "List",
160+
"param": {
161+
"tp": "Type",
151162
"b": "C"
152163
}
153-
]
154-
]
155-
}
164+
}
165+
}
166+
]
156167
}
157168
],
158169
"bound": "A"
@@ -217,10 +228,91 @@
217228
},
218229
"binary": false
219230
},
220-
"lookup": {
231+
"lookup_by_id": {
221232
"extension": "tket.wasm",
222-
"name": "lookup",
223-
"description": "lookup",
233+
"name": "lookup_by_id",
234+
"description": "lookup_by_id",
235+
"signature": {
236+
"params": [
237+
{
238+
"tp": "BoundedNat",
239+
"bound": null
240+
},
241+
{
242+
"tp": "List",
243+
"param": {
244+
"tp": "Type",
245+
"b": "A"
246+
}
247+
},
248+
{
249+
"tp": "List",
250+
"param": {
251+
"tp": "Type",
252+
"b": "A"
253+
}
254+
}
255+
],
256+
"body": {
257+
"input": [
258+
{
259+
"t": "Opaque",
260+
"extension": "tket.wasm",
261+
"id": "module",
262+
"args": [],
263+
"bound": "C"
264+
}
265+
],
266+
"output": [
267+
{
268+
"t": "Opaque",
269+
"extension": "tket.wasm",
270+
"id": "func",
271+
"args": [
272+
{
273+
"tya": "List",
274+
"elems": [
275+
{
276+
"tya": "Variable",
277+
"idx": 1,
278+
"cached_decl": {
279+
"tp": "List",
280+
"param": {
281+
"tp": "Type",
282+
"b": "C"
283+
}
284+
}
285+
}
286+
]
287+
},
288+
{
289+
"tya": "List",
290+
"elems": [
291+
{
292+
"tya": "Variable",
293+
"idx": 2,
294+
"cached_decl": {
295+
"tp": "List",
296+
"param": {
297+
"tp": "Type",
298+
"b": "C"
299+
}
300+
}
301+
}
302+
]
303+
}
304+
],
305+
"bound": "C"
306+
}
307+
]
308+
}
309+
},
310+
"binary": false
311+
},
312+
"lookup_by_name": {
313+
"extension": "tket.wasm",
314+
"name": "lookup_by_name",
315+
"description": "lookup_by_name",
224316
"signature": {
225317
"params": [
226318
{
@@ -296,6 +388,65 @@
296388
}
297389
},
298390
"binary": false
391+
},
392+
"read_result": {
393+
"extension": "tket.wasm",
394+
"name": "read_result",
395+
"description": "read_result",
396+
"signature": {
397+
"params": [
398+
{
399+
"tp": "List",
400+
"param": {
401+
"tp": "Type",
402+
"b": "A"
403+
}
404+
}
405+
],
406+
"body": {
407+
"input": [
408+
{
409+
"t": "Opaque",
410+
"extension": "tket.wasm",
411+
"id": "result",
412+
"args": [
413+
{
414+
"tya": "List",
415+
"elems": [
416+
{
417+
"tya": "Variable",
418+
"idx": 0,
419+
"cached_decl": {
420+
"tp": "List",
421+
"param": {
422+
"tp": "Type",
423+
"b": "C"
424+
}
425+
}
426+
}
427+
]
428+
}
429+
],
430+
"bound": "A"
431+
}
432+
],
433+
"output": [
434+
{
435+
"t": "Opaque",
436+
"extension": "tket.wasm",
437+
"id": "context",
438+
"args": [],
439+
"bound": "A"
440+
},
441+
{
442+
"t": "R",
443+
"i": 0,
444+
"b": "C"
445+
}
446+
]
447+
}
448+
},
449+
"binary": false
299450
}
300451
}
301452
}

0 commit comments

Comments
 (0)