summaryrefslogtreecommitdiff
path: root/test/binaryen.js/event.js
blob: 64d7659b8158975e90ac702d096af7c023b88bd5 (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
function cleanInfo(info) {
  var ret = {};
  for (var x in info) {
    ret[x] = info[x];
  }
  return ret;
}

var module = new binaryen.Module();
module.setFeatures(binaryen.Features.ExceptionHandling | binaryen.Features.Multivalue);

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());