Skip to content

Commit

Permalink
Add BinaryenRemoveGlobal / Module.removeGlobal to C/JS API (#1692)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO authored and kripken committed Oct 10, 2018
1 parent e775682 commit 1ec5a4f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions build-js.sh
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ export_function "_BinaryenAddFunction"
export_function "_BinaryenGetFunction"
export_function "_BinaryenRemoveFunction"
export_function "_BinaryenAddGlobal"
export_function "_BinaryenRemoveGlobal"
export_function "_BinaryenAddFunctionImport"
export_function "_BinaryenAddTableImport"
export_function "_BinaryenAddMemoryImport"
Expand Down
8 changes: 8 additions & 0 deletions src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1645,6 +1645,14 @@ BinaryenGlobalRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name,
wasm->addGlobal(ret);
return ret;
}
void BinaryenRemoveGlobal(BinaryenModuleRef module, const char* name) {
if (tracing) {
std::cout << " BinaryenRemoveGlobal(the_module, \"" << name << "\");\n";
}

auto* wasm = (Module*)module;
wasm->removeGlobal(name);
}

// Imports

Expand Down
1 change: 1 addition & 0 deletions src/binaryen-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ void BinaryenRemoveExport(BinaryenModuleRef module, const char* externalName);
typedef void* BinaryenGlobalRef;

BinaryenGlobalRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, int8_t mutable_, BinaryenExpressionRef init);
void BinaryenRemoveGlobal(BinaryenModuleRef module, const char* name);

// Function table. One per module

Expand Down
5 changes: 5 additions & 0 deletions src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,11 @@ Module['Module'] = function(module) {
return Module['_BinaryenAddGlobal'](module, strToStack(name), type, mutable, init);
});
}
this['removeGlobal'] = function(name) {
return preserveStack(function () {
return Module['_BinaryenRemoveGlobal'](module, strToStack(name));
});
}
this['addFunctionImport'] = function(internalName, externalModuleName, externalBaseName, functionType) {
return preserveStack(function() {
return Module['_BinaryenAddFunctionImport'](module, strToStack(internalName), strToStack(externalModuleName), strToStack(externalBaseName), functionType);
Expand Down

0 comments on commit 1ec5a4f

Please sign in to comment.