Call asc app exported new/pin/unpin APIs to align with its latest compiler (#577)
AssemblyScript's latest compiler 0.18 exports __new__/__pin__/unpin APIs to allocate/retain/free memory instead of __new/__retain/__release APIs in older version, we lookup functions of both version to make it compatible for both version.
This commit is contained in:
@ -1664,7 +1664,7 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
||||
}
|
||||
else if (!strcmp(export->name, "__new")
|
||||
&& export->index >= module->import_function_count) {
|
||||
/* __new && __retain for AssemblyScript */
|
||||
/* __new && __pin for AssemblyScript */
|
||||
func_index = export->index - module->import_function_count;
|
||||
func_type = module->functions[func_index]->func_type;
|
||||
if (func_type->param_count == 2
|
||||
@ -1685,7 +1685,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
||||
export_tmp = module->exports;
|
||||
for (j = 0; j < module->export_count; j++, export_tmp++) {
|
||||
if ((export_tmp->kind == EXPORT_KIND_FUNC)
|
||||
&& (!strcmp(export_tmp->name, "__retain"))
|
||||
&& (!strcmp(export_tmp->name, "__retain")
|
||||
|| !strcmp(export_tmp->name, "__pin"))
|
||||
&& (export_tmp->index
|
||||
>= module->import_function_count)) {
|
||||
func_index = export_tmp->index
|
||||
@ -1714,7 +1715,8 @@ load_from_sections(WASMModule *module, WASMSection *sections,
|
||||
}
|
||||
}
|
||||
else if (((!strcmp(export->name, "free"))
|
||||
|| (!strcmp(export->name, "__release")))
|
||||
|| (!strcmp(export->name, "__release"))
|
||||
|| (!strcmp(export->name, "__unpin")))
|
||||
&& export->index >= module->import_function_count) {
|
||||
func_index = export->index - module->import_function_count;
|
||||
func_type = module->functions[func_index]->func_type;
|
||||
|
||||
Reference in New Issue
Block a user