diff options
author | Heejin Ahn <aheejin@gmail.com> | 2019-05-31 20:02:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-31 20:02:37 -0700 |
commit | fe99e3458f11d1a01fa3ad5b68883dbcba3903af (patch) | |
tree | 6f5eda61c7c7cba9c3b16be5e361cdc148d8b315 /test/binaryen.js/event.js | |
parent | 7306f60a4474ca1fa948bddee5c068e7c2f635f6 (diff) | |
download | binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.tar.gz binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.tar.bz2 binaryen-fe99e3458f11d1a01fa3ad5b68883dbcba3903af.zip |
Add event section (#2151)
This adds support for the event and the event section, as specified in
https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md#changes-to-the-binary-model.
Wasm events are features that suspend the current execution and transfer
the control flow to a corresponding handler. Currently the only
supported event kind is exceptions.
For events, this includes support for
- Binary file reading/writing
- Wast file reading/writing
- Binaryen.js API
- Fuzzer
- Validation
- Metadce
- Passes: metrics, minify-imports-and-exports,
remove-unused-module-elements
Diffstat (limited to 'test/binaryen.js/event.js')
-rw-r--r-- | test/binaryen.js/event.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/binaryen.js/event.js b/test/binaryen.js/event.js new file mode 100644 index 000000000..ec7a0f3b1 --- /dev/null +++ b/test/binaryen.js/event.js @@ -0,0 +1,32 @@ +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); + +var vi = module.addFunctionType("vi", Binaryen.none, [Binaryen.i32]); +var vif = module.addFunctionType("vif", Binaryen.none, [Binaryen.i32, Binaryen.f32]); + +var event_ = module.addEvent("a-event", 0, vi); + +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, vif); + +module.validate(); +console.log(module.emitText()); + +module.removeExport("a-event-exp"); +module.removeEvent("a-event"); + +module.validate(); +console.log(module.emitText()); |