diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 17 | ||||
-rw-r--r-- | src/binaryen-c.h | 2 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 5 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 53daef977..4dd306bd3 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -226,6 +226,23 @@ BinaryenFunctionTypeRef BinaryenAddFunctionType(BinaryenModuleRef module, const return ret; } +void BinaryenRemoveFunctionType(BinaryenModuleRef module, const char* name) { + if (tracing) { + std::cout << " BinaryenRemoveFunctionType(the_module, "; + traceNameOrNULL(name); + std::cout << ");\n"; + } + + auto* wasm = (Module*)module; + assert(name != NULL); + + // Lock. This can be called from multiple threads at once, and is a + // point where they all access and modify the module. + { + std::lock_guard<std::mutex> lock(BinaryenFunctionTypeMutex); + wasm->removeFunctionType(name); + } +} BinaryenLiteral BinaryenLiteralInt32(int32_t x) { return toBinaryenLiteral(Literal(x)); } BinaryenLiteral BinaryenLiteralInt64(int64_t x) { return toBinaryenLiteral(Literal(x)); } diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 1c9bd9da4..1047dca73 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -154,6 +154,8 @@ typedef void* BinaryenFunctionTypeRef; // Add a new function type. This is thread-safe. // Note: name can be NULL, in which case we auto-generate a name BinaryenFunctionTypeRef BinaryenAddFunctionType(BinaryenModuleRef module, const char* name, BinaryenType result, BinaryenType* paramTypes, BinaryenIndex numParams); +// Removes a function type. +void BinaryenRemoveFunctionType(BinaryenModuleRef module, const char* name); // Literals. These are passed by value. diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index fbabfe995..aca41ca6b 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -1052,6 +1052,11 @@ Module['Module'] = function(module) { i32sToStack(paramTypes), paramTypes.length); }); }; + this['removeFunctionType'] = function(name) { + return preserveStack(function () { + return Module['_BinaryenRemoveFunctionType'](module, strToStack(name)); + }); + }; this['addFunction'] = function(name, functionType, varTypes, body) { return preserveStack(function() { return Module['_BinaryenAddFunction'](module, strToStack(name), functionType, i32sToStack(varTypes), varTypes.length, body); |