From 0750bdbc1f7c356a160493acdb8dc314a68f1f12 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 9 Jul 2024 10:06:15 -0700 Subject: [C API] Add APIs for getting/setting function types, and a CallRef example (#6721) Fixes #6718 --- src/binaryen-c.cpp | 6 ++++++ src/binaryen-c.h | 5 +++++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 9c9a1c54f..be80206f5 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -5684,6 +5684,12 @@ void BinaryenFunctionSetBody(BinaryenFunctionRef func, assert(body); ((Function*)func)->body = (Expression*)body; } +BinaryenHeapType BinaryenFunctionGetType(BinaryenFunctionRef func) { + return ((Function*)func)->type.getID(); +} +void BinaryenFunctionSetType(BinaryenFunctionRef func, BinaryenHeapType type) { + ((Function*)func)->type = HeapType(type); +} void BinaryenFunctionOptimize(BinaryenFunctionRef func, BinaryenModuleRef module) { PassRunner passRunner((Module*)module); diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 45230a117..35f1d8eb8 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -3136,6 +3136,11 @@ BinaryenFunctionGetBody(BinaryenFunctionRef func); // Sets the body of the specified `Function`. BINARYEN_API void BinaryenFunctionSetBody(BinaryenFunctionRef func, BinaryenExpressionRef body); +// Gets the type of the specified `Function`. +BINARYEN_API BinaryenHeapType BinaryenFunctionGetType(BinaryenFunctionRef func); +// Sets the type of the specified `Function`. +BINARYEN_API void BinaryenFunctionSetType(BinaryenFunctionRef func, + BinaryenHeapType type); // Runs the standard optimization passes on the function. Uses the currently set // global optimize and shrink level. -- cgit v1.2.3