blob: f728e922823b6dc5187089dafc4b26e77cc5535b (
plain)
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
29
30
31
32
33
34
35
36
37
38
39
|
function assert(x) {
if (!x) throw 'error!';
}
function cleanInfo(info) {
var ret = {};
for (var x in info) {
ret[x] = info[x];
}
return ret;
}
function test() {
var module = new Binaryen.Module();
module.setFeatures(Binaryen.Features.ExceptionHandling);
var pairType = Binaryen.createType([Binaryen.i32, Binaryen.f32]);
var event_ = module.addEvent("a-event", 0, Binaryen.i32, Binaryen.none);
console.log("GetEvent is equal: " + (event_ === module.getEvent("a-event")));
var eventInfo = Binaryen.getEventInfo(event_);
console.log("getEventInfo=" + JSON.stringify(cleanInfo(eventInfo)));
module.addEventExport("a-event", "a-event-exp");
module.addEventImport("a-event-imp", "module", "base", 0, pairType, Binaryen.none);
assert(module.validate());
console.log(module.emitText());
module.removeExport("a-event-exp");
module.removeEvent("a-event");
assert(module.validate());
console.log(module.emitText());
}
Binaryen.ready.then(test);
|