diff options
-rw-r--r-- | src/binaryen-c.cpp | 4 | ||||
-rw-r--r-- | src/binaryen-c.h | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 2aa0633af..7cbd22a69 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -745,7 +745,7 @@ BinaryenFunctionRef BinaryenAddFunction(BinaryenModuleRef module, const char* na return ret; } -BinaryenImportRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, bool mutable_, BinaryenExpressionRef init) { +BinaryenImportRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, int8_t mutable_, BinaryenExpressionRef init) { if (tracing) { std::cout << " BinaryenAddGlobal(the_module, \"" << name << "\", types[" << type << "], " << mutable_ << ", " << expressions[init] << ");\n"; } @@ -754,7 +754,7 @@ BinaryenImportRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, auto* ret = new Global(); ret->name = name; ret->type = WasmType(type); - ret->mutable_ = mutable_; + ret->mutable_ = !!mutable_; ret->init = (Expression*)init; wasm->addGlobal(ret); return ret; diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 9427584fd..d6e420546 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -304,6 +304,8 @@ BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module, BinaryenExp BinaryenExpressionRef BinaryenGetLocal(BinaryenModuleRef module, BinaryenIndex index, BinaryenType type); BinaryenExpressionRef BinaryenSetLocal(BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value); BinaryenExpressionRef BinaryenTeeLocal(BinaryenModuleRef module, BinaryenIndex index, BinaryenExpressionRef value); +BinaryenExpressionRef BinaryenGetGlobal(BinaryenModuleRef module, const char *name, BinaryenType type); +BinaryenExpressionRef BinaryenSetGlobal(BinaryenModuleRef module, const char *name, BinaryenExpressionRef value); // Load: align can be 0, in which case it will be the natural alignment (equal to bytes) BinaryenExpressionRef BinaryenLoad(BinaryenModuleRef module, uint32_t bytes, int8_t signed_, uint32_t offset, uint32_t align, BinaryenType type, BinaryenExpressionRef ptr); // Store: align can be 0, in which case it will be the natural alignment (equal to bytes) @@ -351,6 +353,10 @@ typedef void* BinaryenExportRef; BinaryenExportRef BinaryenAddExport(BinaryenModuleRef module, const char* internalName, const char* externalName); void BinaryenRemoveExport(BinaryenModuleRef module, const char* externalName); +// Globals + +BinaryenImportRef BinaryenAddGlobal(BinaryenModuleRef module, const char* name, BinaryenType type, int8_t mutable_, BinaryenExpressionRef init); + // Function table. One per module void BinaryenSetFunctionTable(BinaryenModuleRef module, BinaryenFunctionRef* funcs, BinaryenIndex numFuncs); |