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 /src/passes/Print.cpp | |
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 'src/passes/Print.cpp')
-rw-r--r-- | src/passes/Print.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index fb85023f0..9dbf3cc1f 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -1660,6 +1660,9 @@ struct PrintSExpression : public Visitor<PrintSExpression> { case ExternalKind::Global: o << "global"; break; + case ExternalKind::Event: + o << "event"; + break; case ExternalKind::Invalid: WASM_UNREACHABLE(); } @@ -1805,6 +1808,25 @@ struct PrintSExpression : public Visitor<PrintSExpression> { } o << maybeNewLine; } + void visitEvent(Event* curr) { + doIndent(o, indent); + if (curr->imported()) { + o << '('; + emitImportHeader(curr); + } + o << "(event "; + printName(curr->name, o); + o << maybeSpace << "(attr " << curr->attribute << ')' << maybeSpace << '('; + printMinor(o, "param"); + for (auto& param : curr->params) { + o << ' ' << printType(param); + } + o << "))"; + if (curr->imported()) { + o << ')'; + } + o << maybeNewLine; + } void printTableHeader(Table* curr) { o << '('; printMedium(o, "table") << ' '; @@ -1948,12 +1970,16 @@ struct PrintSExpression : public Visitor<PrintSExpression> { *curr, [&](Global* global) { visitGlobal(global); }); ModuleUtils::iterImportedFunctions( *curr, [&](Function* func) { visitFunction(func); }); + ModuleUtils::iterImportedEvents(*curr, + [&](Event* event) { visitEvent(event); }); ModuleUtils::iterDefinedMemories( *curr, [&](Memory* memory) { visitMemory(memory); }); ModuleUtils::iterDefinedTables(*curr, [&](Table* table) { visitTable(table); }); ModuleUtils::iterDefinedGlobals( *curr, [&](Global* global) { visitGlobal(global); }); + ModuleUtils::iterDefinedEvents(*curr, + [&](Event* event) { visitEvent(event); }); for (auto& child : curr->exports) { doIndent(o, indent); visitExport(child.get()); |