@@ -80,6 +80,17 @@ typedef struct FizzyExternalFunction
8080 void * context ;
8181} FizzyExternalFunction ;
8282
83+ /// Imported function.
84+ typedef struct FizzyImportedFunction
85+ {
86+ /// Module name. NULL-terminated string. Cannot be NULL.
87+ const char * module ;
88+ /// Function name. NULL-terminated string. Cannot be NULL.
89+ const char * name ;
90+ /// External function, defining its type, pointer to function and context for calling it.
91+ FizzyExternalFunction external_function ;
92+ } FizzyImportedFunction ;
93+
8394/// Validate binary module.
8495bool fizzy_validate (const uint8_t * wasm_binary , size_t wasm_binary_size );
8596
@@ -130,6 +141,22 @@ bool fizzy_find_exported_function(
130141FizzyInstance * fizzy_instantiate (const FizzyModule * module ,
131142 const FizzyExternalFunction * imported_functions , size_t imported_functions_size );
132143
144+ /// Instantiate a module resolving imported functions.
145+ /// Takes ownership of module, i.e. @p module is invalidated after this call.
146+ ///
147+ /// @param module Pointer to module.
148+ /// @param imported_functions Pointer to the imported function array. Can be NULL iff
149+ /// imported_functions_size equals 0.
150+ /// @param imported_functions_size Size of the imported function array. Can be zero.
151+ /// @returns non-NULL pointer to instance in case of success, NULL otherwise.
152+ ///
153+ /// @note
154+ /// Functions in @a imported_functions are allowed to be in any order and allowed to include some
155+ /// functions not required by instantiated module.
156+ /// Functions are matched to module's imports based on their module and name strings.
157+ FizzyInstance * fizzy_resolve_instantiate (const FizzyModule * module ,
158+ const FizzyImportedFunction * imported_functions , size_t imported_functions_size );
159+
133160/// Free resources associated with the instance.
134161/// If passed pointer is NULL, has no effect.
135162void fizzy_free_instance (FizzyInstance * instance );
0 commit comments