summaryrefslogtreecommitdiff
path: root/src/binaryen-c.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-09-19 15:50:30 -0700
committerGitHub <noreply@github.com>2018-09-19 15:50:30 -0700
commitfe88b47749115009da0447e340cbdc86edf30984 (patch)
tree7dfd9aba7086c8aa6dff4877ac1ee3b9d78bc5ce /src/binaryen-c.h
parenta53356ab155a7d8c2f334dc9a3c1432bacbc78fe (diff)
downloadbinaryen-fe88b47749115009da0447e340cbdc86edf30984.tar.gz
binaryen-fe88b47749115009da0447e340cbdc86edf30984.tar.bz2
binaryen-fe88b47749115009da0447e340cbdc86edf30984.zip
Unify imported and non-imported things (#1678)
Fixes #1649 This moves us to a single object for functions, which can be imported or nor, and likewise for globals (as a result, GetGlobals do not need to check if the global is imported or not, etc.). All imported things now inherit from Importable, which has the module and base of the import, and if they are set then it is an import. For convenient iteration, there are a few helpers like ModuleUtils::iterDefinedGlobals(wasm, [&](Global* global) { .. use global .. }); as often iteration only cares about imported or defined (non-imported) things.
Diffstat (limited to 'src/binaryen-c.h')
-rw-r--r--src/binaryen-c.h46
1 files changed, 12 insertions, 34 deletions
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index 95892443d..9a2750353 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -96,7 +96,6 @@ BinaryenExpressionId BinaryenLoopId(void);
BinaryenExpressionId BinaryenBreakId(void);
BinaryenExpressionId BinaryenSwitchId(void);
BinaryenExpressionId BinaryenCallId(void);
-BinaryenExpressionId BinaryenCallImportId(void);
BinaryenExpressionId BinaryenCallIndirectId(void);
BinaryenExpressionId BinaryenGetLocalId(void);
BinaryenExpressionId BinaryenSetLocalId(void);
@@ -339,15 +338,11 @@ BinaryenExpressionRef BinaryenLoop(BinaryenModuleRef module, const char* in, Bin
BinaryenExpressionRef BinaryenBreak(BinaryenModuleRef module, const char* name, BinaryenExpressionRef condition, BinaryenExpressionRef value);
// Switch: value can be NULL
BinaryenExpressionRef BinaryenSwitch(BinaryenModuleRef module, const char** names, BinaryenIndex numNames, const char* defaultName, BinaryenExpressionRef condition, BinaryenExpressionRef value);
-// Call, CallImport: Note the 'returnType' parameter. You must declare the
-// type returned by the function being called, as that
-// function might not have been created yet, so we don't
-// know what it is.
-// Also note that WebAssembly does not differentiate
-// between Call and CallImport, but Binaryen does, so you
-// must use CallImport if calling an import, and vice versa.
+// Call: Note the 'returnType' parameter. You must declare the
+// type returned by the function being called, as that
+// function might not have been created yet, so we don't
+// know what it is.
BinaryenExpressionRef BinaryenCall(BinaryenModuleRef module, const char* target, BinaryenExpressionRef* operands, BinaryenIndex numOperands, BinaryenType returnType);
-BinaryenExpressionRef BinaryenCallImport(BinaryenModuleRef module, const char* target, BinaryenExpressionRef* operands, BinaryenIndex numOperands, BinaryenType returnType);
BinaryenExpressionRef BinaryenCallIndirect(BinaryenModuleRef module, BinaryenExpressionRef target, BinaryenExpressionRef* operands, BinaryenIndex numOperands, const char* type);
// GetLocal: Note the 'type' parameter. It might seem redundant, since the
// local at that index must have a type. However, this API lets you
@@ -441,13 +436,6 @@ BinaryenIndex BinaryenCallGetNumOperands(BinaryenExpressionRef expr);
// Gets the nested operand expression at the specified index within the specified `Call` expression.
BinaryenExpressionRef BinaryenCallGetOperand(BinaryenExpressionRef expr, BinaryenIndex index);
-// Gets the name of the target of the specified `CallImport` expression.
-const char* BinaryenCallImportGetTarget(BinaryenExpressionRef expr);
-// Gets the number of nested operand expressions within the specified `CallImport` expression.
-BinaryenIndex BinaryenCallImportGetNumOperands(BinaryenExpressionRef expr);
-// Gets the nested operand expression at the specified index within the specified `CallImport` expression.
-BinaryenExpressionRef BinaryenCallImportGetOperand(BinaryenExpressionRef expr, BinaryenIndex index);
-
// Gets the nested target expression of the specified `CallIndirect` expression.
BinaryenExpressionRef BinaryenCallIndirectGetTarget(BinaryenExpressionRef expr);
// Gets the number of nested operand expressions within the specified `CallIndirect` expression.
@@ -604,14 +592,10 @@ void BinaryenRemoveFunction(BinaryenModuleRef module, const char* name);
// Imports
-typedef void* BinaryenImportRef;
-
-WASM_DEPRECATED BinaryenImportRef BinaryenAddImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName, BinaryenFunctionTypeRef type);
-BinaryenImportRef BinaryenAddFunctionImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName, BinaryenFunctionTypeRef functionType);
-BinaryenImportRef BinaryenAddTableImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName);
-BinaryenImportRef BinaryenAddMemoryImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName);
-BinaryenImportRef BinaryenAddGlobalImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName, BinaryenType globalType);
-void BinaryenRemoveImport(BinaryenModuleRef module, const char* internalName);
+void BinaryenAddFunctionImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName, BinaryenFunctionTypeRef functionType);
+void BinaryenAddTableImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName);
+void BinaryenAddMemoryImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName);
+void BinaryenAddGlobalImport(BinaryenModuleRef module, const char* internalName, const char* externalModuleName, const char* externalBaseName, BinaryenType globalType);
// Exports
@@ -790,18 +774,12 @@ void BinaryenFunctionSetDebugLocation(BinaryenFunctionRef func, BinaryenExpressi
// ========== Import Operations ==========
//
-// Gets the external kind of the specified import.
-BinaryenExternalKind BinaryenImportGetKind(BinaryenImportRef import);
// Gets the external module name of the specified import.
-const char* BinaryenImportGetModule(BinaryenImportRef import);
+const char* BinaryenFunctionImportGetModule(BinaryenFunctionRef import);
+const char* BinaryeGlobalImportGetModule(BinaryenGlobalRef import);
// Gets the external base name of the specified import.
-const char* BinaryenImportGetBase(BinaryenImportRef import);
-// Gets the internal name of the specified import.
-const char* BinaryenImportGetName(BinaryenImportRef import);
-// Gets the type of the imported global, if referencing a `Global`.
-BinaryenType BinaryenImportGetGlobalType(BinaryenImportRef import);
-// Gets the name of the function type of the imported function, if referencing a `Function`.
-const char* BinaryenImportGetFunctionType(BinaryenImportRef import);
+const char* BinaryenFunctionImportGetBase(BinaryenFunctionRef import);
+const char* BinaryenGlobalImportGetBase(BinaryenGlobalRef import);
//
// ========== Export Operations ==========