summaryrefslogtreecommitdiff
path: root/src/js
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2019-05-31 20:02:37 -0700
committerGitHub <noreply@github.com>2019-05-31 20:02:37 -0700
commitfe99e3458f11d1a01fa3ad5b68883dbcba3903af (patch)
tree6f5eda61c7c7cba9c3b16be5e361cdc148d8b315 /src/js
parent7306f60a4474ca1fa948bddee5c068e7c2f635f6 (diff)
downloadbinaryen-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/js')
-rw-r--r--src/js/binaryen.js-post.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index 180d08bb5..d2703e425 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -84,6 +84,7 @@ Module['ExternalFunction'] = Module['_BinaryenExternalFunction']();
Module['ExternalTable'] = Module['_BinaryenExternalTable']();
Module['ExternalMemory'] = Module['_BinaryenExternalMemory']();
Module['ExternalGlobal'] = Module['_BinaryenExternalGlobal']();
+Module['ExternalEvent'] = Module['_BinaryenExternalEvent']();
// Features
Module['Features'] = {
@@ -1788,6 +1789,21 @@ function wrapModule(module, self) {
return Module['_BinaryenRemoveGlobal'](module, strToStack(name));
});
}
+ self['addEvent'] = function(name, attribute, eventType) {
+ return preserveStack(function() {
+ return Module['_BinaryenAddEvent'](module, strToStack(name), attribute, eventType);
+ });
+ };
+ self['getEvent'] = function(name) {
+ return preserveStack(function() {
+ return Module['_BinaryenGetEvent'](module, strToStack(name));
+ });
+ };
+ self['removeEvent'] = function(name) {
+ return preserveStack(function() {
+ return Module['_BinaryenRemoveEvent'](module, strToStack(name));
+ });
+ };
self['addFunctionImport'] = function(internalName, externalModuleName, externalBaseName, functionType) {
return preserveStack(function() {
return Module['_BinaryenAddFunctionImport'](module, strToStack(internalName), strToStack(externalModuleName), strToStack(externalBaseName), functionType);
@@ -1808,6 +1824,11 @@ function wrapModule(module, self) {
return Module['_BinaryenAddGlobalImport'](module, strToStack(internalName), strToStack(externalModuleName), strToStack(externalBaseName), globalType);
});
};
+ self['addEventImport'] = function(internalName, externalModuleName, externalBaseName, attribute, eventType) {
+ return preserveStack(function() {
+ return Module['_BinaryenAddEventImport'](module, strToStack(internalName), strToStack(externalModuleName), strToStack(externalBaseName), attribute, eventType);
+ });
+ };
self['addExport'] = // deprecated
self['addFunctionExport'] = function(internalName, externalName) {
return preserveStack(function() {
@@ -1829,6 +1850,11 @@ function wrapModule(module, self) {
return Module['_BinaryenAddGlobalExport'](module, strToStack(internalName), strToStack(externalName));
});
};
+ self['addEventExport'] = function(internalName, externalName) {
+ return preserveStack(function() {
+ return Module['_BinaryenAddEventExport'](module, strToStack(internalName), strToStack(externalName));
+ });
+ };
self['removeExport'] = function(externalName) {
return preserveStack(function() {
return Module['_BinaryenRemoveExport'](module, strToStack(externalName));
@@ -2354,6 +2380,17 @@ Module['getGlobalInfo'] = function(global) {
};
};
+// Obtains information about a 'Event'
+Module['getEventInfo'] = function(event_) {
+ return {
+ 'name': UTF8ToString(Module['_BinaryenEventGetName'](event_)),
+ 'module': UTF8ToString(Module['_BinaryenEventImportGetModule'](event_)),
+ 'base': UTF8ToString(Module['_BinaryenEventImportGetBase'](event_)),
+ 'attribute': Module['_BinaryenEventGetAttribute'](event_),
+ 'type': UTF8ToString(Module['_BinaryenEventGetType'](event_))
+ };
+};
+
// Obtains information about an 'Export'
Module['getExportInfo'] = function(export_) {
return {