Skip to content

Commit

Permalink
style: simplify function names
Browse files Browse the repository at this point in the history
Signed-off-by: ganjing <[email protected]>
  • Loading branch information
Shanks0224 committed Feb 4, 2024
1 parent c3dd378 commit c0ba0d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
22 changes: 11 additions & 11 deletions runtime-library/stdlib/lib_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ array_concat_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,
return NULL;
}

wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_arr;
create_new_array = true;

Expand All @@ -183,7 +183,7 @@ array_concat_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,

fail:
if (create_new_array) {
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
}

return new_arr_struct;
Expand Down Expand Up @@ -305,7 +305,7 @@ array_slice_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,
return NULL;
}

wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_arr;

for (i = start; i < end; i++) {
Expand All @@ -326,7 +326,7 @@ array_slice_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,
wasm_struct_obj_set_field(new_arr_struct, 1, &tmp_val);

end:
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
return new_arr_struct;
}

Expand Down Expand Up @@ -500,7 +500,7 @@ array_splice_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,
goto end1;
}

wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)delete_arr;

/* Copy deleted elements to delete_arr*/
Expand Down Expand Up @@ -551,7 +551,7 @@ array_splice_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,
tmp_val.u32 = delete_count;
wasm_struct_obj_set_field(new_arr_struct, 1, &tmp_val);

wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
return new_arr_struct;

end1:
Expand All @@ -560,7 +560,7 @@ array_splice_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,
return NULL;

end2:
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
wasm_runtime_set_exception(wasm_runtime_get_module_inst(exec_env),
"alloc memory failed");
return NULL;
Expand Down Expand Up @@ -1059,7 +1059,7 @@ array_map_generic(wasm_exec_env_t exec_env, void *ctx, void *obj, void *closure)
"alloc memory failed");
return NULL;
}
wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_arr;

/* get current array element type */
Expand Down Expand Up @@ -1110,7 +1110,7 @@ array_map_generic(wasm_exec_env_t exec_env, void *ctx, void *obj, void *closure)
wasm_struct_obj_set_field(new_arr_struct, 1, &tmp_val);

end:
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
return new_arr_struct;
}

Expand Down Expand Up @@ -1190,7 +1190,7 @@ array_filter_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,
"alloc memory failed");
goto end1;
}
wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_arr;

for (i = 0; i < new_arr_len; i++) {
Expand All @@ -1211,7 +1211,7 @@ array_filter_generic(wasm_exec_env_t exec_env, void *ctx, void *obj,
wasm_struct_obj_set_field(new_arr_struct, 1, &tmp_val);

end2:
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);

end1:
if (include_refs) {
Expand Down
4 changes: 2 additions & 2 deletions runtime-library/utils/object_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ call_wasm_func_with_boxing(wasm_exec_env_t exec_env, dyn_ctx_t ctx,
) {
/* unbox_value_from_any will create anyref for any-objects, we must
* hold its reference to avoid it being claimed */
wasm_runtime_push_local_object_ref(exec_env,
wasm_runtime_push_local_obj_ref(exec_env,
&local_refs[local_ref_count]);
local_refs[local_ref_count++].val = tmp_param.gc_obj;
}
Expand All @@ -454,7 +454,7 @@ call_wasm_func_with_boxing(wasm_exec_env_t exec_env, dyn_ctx_t ctx,
}

if (local_ref_count) {
wasm_runtime_pop_local_object_refs(exec_env, local_ref_count);
wasm_runtime_pop_local_obj_refs(exec_env, local_ref_count);
}

is_success =
Expand Down
28 changes: 14 additions & 14 deletions runtime-library/utils/type_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ create_wasm_array_with_string(wasm_exec_env_t exec_env, void **ptr,
}

/* Push object to local ref to avoid being freed at next allocation */
wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_arr;

/* create_wasm_string for every element */
Expand All @@ -367,7 +367,7 @@ create_wasm_array_with_string(wasm_exec_env_t exec_env, void **ptr,
wasm_struct_obj_new_with_type(exec_env, res_arr_struct_type);

if (!new_stringref_array_struct) {
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
wasm_runtime_set_exception(wasm_runtime_get_module_inst(exec_env),
"alloc memory failed");
return NULL;
Expand All @@ -379,7 +379,7 @@ create_wasm_array_with_string(wasm_exec_env_t exec_env, void **ptr,
val.u32 = arrlen;
wasm_struct_obj_set_field(new_stringref_array_struct, 1, &val);

wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
return new_stringref_array_struct;
}
#else
Expand Down Expand Up @@ -420,11 +420,11 @@ create_wasm_array_with_string(wasm_exec_env_t exec_env, void **ptr,
/* create new array */
new_arr =
wasm_array_obj_new_with_type(exec_env, res_arr_type, arrlen, &init);
wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_arr;

if (!new_arr) {
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
wasm_runtime_set_exception((wasm_module_inst_t)module_inst,
"alloc memory failed");
return NULL;
Expand Down Expand Up @@ -452,7 +452,7 @@ create_wasm_array_with_string(wasm_exec_env_t exec_env, void **ptr,
tmp_val.u32 = arrlen;
wasm_struct_obj_set_field(string_array_struct, 1, &tmp_val);

wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
return string_array_struct;
}
#endif /* end of WASM_ENABLE_STRINGREF != 0 */
Expand Down Expand Up @@ -672,15 +672,15 @@ create_wasm_string(wasm_exec_env_t exec_env, const char *value)
}

/* Push object to local ref to avoid being freed at next allocation */
wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_string_struct;

val.i32 = 0;
get_string_array_type(module, &string_array_type);
new_arr =
wasm_array_obj_new_with_type(exec_env, string_array_type, len, &val);
if (!new_arr) {
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
wasm_runtime_set_exception(module_inst, "alloc memory failed");
return NULL;
}
Expand All @@ -697,7 +697,7 @@ create_wasm_string(wasm_exec_env_t exec_env, const char *value)
val.gc_obj = (wasm_obj_t)new_arr;
wasm_struct_obj_set_field(new_string_struct, 1, &val);

wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);

(void)p_end;
return new_string_struct;
Expand Down Expand Up @@ -748,16 +748,16 @@ create_new_array_with_primitive_type(wasm_exec_env_t exec_env,
/* create new array */
new_arr =
wasm_array_obj_new_with_type(exec_env, res_arr_type, arrlen, &init);
wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_arr;

if (!new_arr) {
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
wasm_runtime_set_exception((wasm_module_inst_t)module_inst,
"alloc memory failed");
return NULL;
}
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
return new_arr;
}

Expand Down Expand Up @@ -1025,7 +1025,7 @@ array_to_string(wasm_exec_env_t exec_env, void *ctx, void *obj, void *separator)
}

/* Push object to local ref to avoid being freed at next allocation */
wasm_runtime_push_local_object_ref(exec_env, &local_ref);
wasm_runtime_push_local_obj_ref(exec_env, &local_ref);
local_ref.val = (wasm_obj_t)new_arr;

p = (char *)wasm_array_obj_first_elem_addr(new_arr);
Expand Down Expand Up @@ -1072,7 +1072,7 @@ array_to_string(wasm_exec_env_t exec_env, void *ctx, void *obj, void *separator)
}

if (local_ref.val) {
wasm_runtime_pop_local_object_ref(exec_env);
wasm_runtime_pop_local_obj_ref(exec_env);
}

if (sep) {
Expand Down

0 comments on commit c0ba0d5

Please sign in to comment.