Enable call wasm-c-api native func directly from interpreter (#656)
And update loader error messages for latest spec cases, fix aot compiler build error based on latest LLVM code base.
This commit is contained in:
@ -56,15 +56,26 @@ int main(int argc, const char* argv[]) {
|
||||
|
||||
wasm_byte_vec_delete(&binary);
|
||||
|
||||
// Create external print functions.
|
||||
printf("Creating callback...\n");
|
||||
own wasm_functype_t* hello_type = wasm_functype_new_0_0();
|
||||
own wasm_func_t* hello_func =
|
||||
wasm_func_new(store, hello_type, hello_callback);
|
||||
|
||||
wasm_functype_delete(hello_type);
|
||||
|
||||
// Instantiate.
|
||||
printf("Instantiating module...\n");
|
||||
const wasm_extern_t* imports[] = { wasm_func_as_extern(hello_func) };
|
||||
own wasm_instance_t* instance =
|
||||
wasm_instance_new(store, module, NULL, NULL);
|
||||
wasm_instance_new(store, module, imports, NULL);
|
||||
if (!instance) {
|
||||
printf("> Error instantiating module!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
wasm_func_delete(hello_func);
|
||||
|
||||
// Extract export.
|
||||
printf("Extracting export...\n");
|
||||
own wasm_extern_vec_t exports;
|
||||
@ -74,9 +85,22 @@ int main(int argc, const char* argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const wasm_func_t* run_func = wasm_extern_as_func(exports.data[0]);
|
||||
if (run_func == NULL) {
|
||||
printf("> Error accessing export!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
wasm_module_delete(module);
|
||||
wasm_instance_delete(instance);
|
||||
|
||||
// Call.
|
||||
printf("Calling export...\n");
|
||||
if (wasm_func_call(run_func, NULL, NULL)) {
|
||||
printf("> Error calling function!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
wasm_extern_vec_delete(&exports);
|
||||
|
||||
// Shut down.
|
||||
|
||||
Reference in New Issue
Block a user