summaryrefslogtreecommitdiff
path: root/src/binaryen-c.h
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2017-06-07 20:28:08 +0200
committerAlon Zakai <alonzakai@gmail.com>2017-06-07 11:28:08 -0700
commit2c220f5cebd915447e786f0b365b0bac1e2f719f (patch)
tree103ed218e637ff868e7ee067d51c25bdeb1a6f9a /src/binaryen-c.h
parent3f0db5a7aafaaa4de713ff3ba3c3bbeb59fe566e (diff)
downloadbinaryen-2c220f5cebd915447e786f0b365b0bac1e2f719f.tar.gz
binaryen-2c220f5cebd915447e786f0b365b0bac1e2f719f.tar.bz2
binaryen-2c220f5cebd915447e786f0b365b0bac1e2f719f.zip
Update binaryen-c/binaryen.js, fixes #1028, fixes #1029 (#1030)
This PR adds global variable support (addGlobal, getGlobal, setGlobal), host operations (currentMemory, growMemory), a few utility functions (removeImport, removeExport, getFunctionTypeBySignature with the latter being scheduled for removal once a better alternative is in place) and it introduces an additional argument to specify the result type in BinaryenBlock (effectively breaking the C-API but retaining previous behaviour by introducing the BinaryenUndefined() type for this purpose). Additionally, it enables compilation with exception support in build-js.sh as exceptions are thrown and caught when optimizing endless loops, intentionally resulting in an unreachable opcode. Affected test cases have been updated accordingly.
Diffstat (limited to 'src/binaryen-c.h')
-rw-r--r--src/binaryen-c.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index c7c1d7292..889b5ba45 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -72,6 +72,10 @@ BinaryenType BinaryenInt64(void);
BinaryenType BinaryenFloat32(void);
BinaryenType BinaryenFloat64(void);
+// Not a real type. Used as the last parameter to BinaryenBlock to let
+// the API figure out the type instead of providing one.
+BinaryenType BinaryenUndefined(void);
+
// Modules
//
// Modules contain lists of functions, imports, exports, function types. The
@@ -261,8 +265,11 @@ BinaryenOp BinaryenHasFeature(void);
typedef void* BinaryenExpressionRef;
-// Block: name can be NULL
-BinaryenExpressionRef BinaryenBlock(BinaryenModuleRef module, const char* name, BinaryenExpressionRef* children, BinaryenIndex numChildren);
+// Block: name can be NULL. Specifying BinaryenUndefined() as the 'type'
+// parameter indicates that the block's type shall be figured out
+// automatically instead of explicitly providing it. This conforms
+// to the behavior before the 'type' parameter has been introduced.
+BinaryenExpressionRef BinaryenBlock(BinaryenModuleRef module, const char* name, BinaryenExpressionRef* children, BinaryenIndex numChildren, BinaryenType type);
// If: ifFalse can be NULL
BinaryenExpressionRef BinaryenIf(BinaryenModuleRef module, BinaryenExpressionRef condition, BinaryenExpressionRef ifTrue, BinaryenExpressionRef ifFalse);
BinaryenExpressionRef BinaryenLoop(BinaryenModuleRef module, const char* in, BinaryenExpressionRef body);
@@ -332,12 +339,14 @@ BinaryenFunctionRef BinaryenAddFunction(BinaryenModuleRef module, const char* na
typedef void* BinaryenImportRef;
BinaryenImportRef BinaryenAddImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char *externalBaseName, BinaryenFunctionTypeRef type);
+void BinaryenRemoveImport(BinaryenModuleRef module, const char* internalName);
// Exports
typedef void* BinaryenExportRef;
BinaryenExportRef BinaryenAddExport(BinaryenModuleRef module, const char* internalName, const char* externalName);
+void BinaryenRemoveExport(BinaryenModuleRef module, const char* externalName);
// Function table. One per module
@@ -432,6 +441,17 @@ BinaryenExpressionRef RelooperRenderAndDispose(RelooperRef relooper, RelooperBlo
// TODO: compile-time option to enable/disable this feature entirely at build time?
void BinaryenSetAPITracing(int on);
+//
+// ========= Utilities =========
+//
+
+// Note that this function has been added because there is no better alternative
+// currently and is scheduled for removal once there is one. It takes the same set
+// of parameters as BinaryenAddFunctionType but instead of adding a new function
+// signature, it returns a pointer to the existing signature or NULL if there is no
+// such signature yet.
+BinaryenFunctionTypeRef BinaryenGetFunctionTypeBySignature(BinaryenModuleRef module, BinaryenType result, BinaryenType* paramTypes, BinaryenIndex numParams);
+
#ifdef __cplusplus
} // extern "C"
#endif