Add wasm module global type information APIs (#3406)

Support getting global type from `wasm_runtime_get_import_type` and
`wasm_runtime_get_export_type`, and add two APIs:

```C
wasm_valkind_t
wasm_global_type_get_valkind(const wasm_global_type_t global_type);

bool
wasm_global_type_get_mutable(const wasm_global_type_t global_type);
```
This commit is contained in:
Benbuck Nason
2024-05-09 18:15:58 -07:00
committed by GitHub
parent 46f83cf486
commit c85bada2a9
15 changed files with 255 additions and 172 deletions

View File

@ -75,6 +75,9 @@ typedef enum {
struct WASMFuncType;
typedef struct WASMFuncType *wasm_func_type_t;
struct WASMGlobalType;
typedef struct WASMGlobalType *wasm_global_type_t;
typedef struct wasm_import_t {
const char *module_name;
const char *name;
@ -82,6 +85,7 @@ typedef struct wasm_import_t {
bool linked;
union {
wasm_func_type_t func_type;
wasm_global_type_t global_type;
} u;
} wasm_import_t;
@ -90,6 +94,7 @@ typedef struct wasm_export_t {
wasm_import_export_kind_t kind;
union {
wasm_func_type_t func_type;
wasm_global_type_t global_type;
} u;
} wasm_export_t;
@ -1310,6 +1315,12 @@ WASM_RUNTIME_API_EXTERN wasm_valkind_t
wasm_func_type_get_result_valkind(wasm_func_type_t const func_type,
uint32_t result_index);
WASM_RUNTIME_API_EXTERN wasm_valkind_t
wasm_global_type_get_valkind(const wasm_global_type_t global_type);
WASM_RUNTIME_API_EXTERN bool
wasm_global_type_get_mutable(const wasm_global_type_t global_type);
/**
* Register native functions with same module name
*