forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct.js
More file actions
28 lines (26 loc) · 764 Bytes
/
struct.js
File metadata and controls
28 lines (26 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as assert from '../assert.js';
import Builder from '../Builder.js';
const builder = (new Builder())
builder.Type().End()
.Function().End()
.Memory().InitialMaxPages(1, 1).End()
.Export()
.Function("callFunc")
.End()
.Code()
.Function("callFunc", { params: ["i32", "i32"], ret: "i32" })
.GetLocal(0)
.If("void", b => {
return b.GetLocal(0)
.GetLocal(1)
.I32Load(0, 4)
.I32Sub()
.Return()
})
.I32Const(42)
.Return()
.End()
.End();
const bin = builder.WebAssembly().get();
const module = new WebAssembly.Module(bin);
const instance = new WebAssembly.Instance(module);