Skip to content

Commit 5d27b20

Browse files
pepyakinkripken
authored andcommitted
Add missing prototypes for globals in binaryen-c.h (#1183)
* Add missing prototypes for globals in binaryen-c.h * Use int8_t for mutable_
1 parent d669b5f commit 5d27b20

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/binaryen-c.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ BinaryenFunctionRef BinaryenAddFunction(BinaryenModuleRef module, const char* na
745745
return ret;
746746
}
747747

748-
BinaryenImportRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, bool mutable_, BinaryenExpressionRef init) {
748+
BinaryenImportRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, int8_t mutable_, BinaryenExpressionRef init) {
749749
if (tracing) {
750750
std::cout << " BinaryenAddGlobal(the_module, \"" << name << "\", types[" << type << "], " << mutable_ << ", " << expressions[init] << ");\n";
751751
}
@@ -754,7 +754,7 @@ BinaryenImportRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name,
754754
auto* ret = new Global();
755755
ret->name = name;
756756
ret->type = WasmType(type);
757-
ret->mutable_ = mutable_;
757+
ret->mutable_ = !!mutable_;
758758
ret->init = (Expression*)init;
759759
wasm->addGlobal(ret);
760760
return ret;

src/binaryen-c.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module, BinaryenExp
304304
BinaryenExpressionRef BinaryenGetLocal(BinaryenModuleRef module, BinaryenIndex index, BinaryenType type);
305305
BinaryenExpressionRef BinaryenSetLocal(BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value);
306306
BinaryenExpressionRef BinaryenTeeLocal(BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value);
307+
BinaryenExpressionRef BinaryenGetGlobal(BinaryenModuleRef module, const char *name, BinaryenType type);
308+
BinaryenExpressionRef BinaryenSetGlobal(BinaryenModuleRef module, const char *name, BinaryenExpressionRef value);
307309
// Load: align can be 0, in which case it will be the natural alignment (equal to bytes)
308310
BinaryenExpressionRef BinaryenLoad(BinaryenModuleRef module, uint32_t bytes, int8_t signed_, uint32_t offset, uint32_t align, BinaryenType type, BinaryenExpressionRef ptr);
309311
// Store: align can be 0, in which case it will be the natural alignment (equal to bytes)
@@ -351,6 +353,10 @@ typedef void* BinaryenExportRef;
351353
BinaryenExportRef BinaryenAddExport(BinaryenModuleRef module, const char* internalName, const char* externalName);
352354
void BinaryenRemoveExport(BinaryenModuleRef module, const char* externalName);
353355

356+
// Globals
357+
358+
BinaryenImportRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, int8_t mutable_, BinaryenExpressionRef init);
359+
354360
// Function table. One per module
355361

356362
void BinaryenSetFunctionTable(BinaryenModuleRef module, BinaryenFunctionRef* funcs, BinaryenIndex numFuncs);

0 commit comments

Comments
 (0)