mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-11-26 15:32:05 +00:00
Change WASM_ANYREF to WASM_EXTERNREF (#3426)
wasm-c-api wasm.h had changed WASM_ANYREF to WASM_EXTERNREF,
we had better change it in WAMR also:
2ce1367c9d/include/wasm.h (L185)
This commit is contained in:
parent
004d07bb86
commit
773efc006d
|
@ -759,7 +759,7 @@ val_type_rt_2_valkind(uint8 val_type_rt)
|
||||||
#undef WAMR_VAL_TYPE_2_WASM_VAL_KIND
|
#undef WAMR_VAL_TYPE_2_WASM_VAL_KIND
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return WASM_ANYREF;
|
return WASM_EXTERNREF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,7 +776,7 @@ wasm_valtype_new(wasm_valkind_t kind)
|
||||||
|
|
||||||
if (kind > WASM_V128 && WASM_FUNCREF != kind
|
if (kind > WASM_V128 && WASM_FUNCREF != kind
|
||||||
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
||||||
&& WASM_ANYREF != kind
|
&& WASM_EXTERNREF != kind
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -808,7 +808,7 @@ wasm_valtype_copy(const wasm_valtype_t *src)
|
||||||
wasm_valkind_t
|
wasm_valkind_t
|
||||||
wasm_valtype_kind(const wasm_valtype_t *val_type)
|
wasm_valtype_kind(const wasm_valtype_t *val_type)
|
||||||
{
|
{
|
||||||
return val_type ? val_type->kind : WASM_ANYREF;
|
return val_type ? val_type->kind : WASM_EXTERNREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static wasm_functype_t *
|
static wasm_functype_t *
|
||||||
|
@ -976,7 +976,7 @@ cmp_val_kind_with_val_type(wasm_valkind_t v_k, uint8 v_t)
|
||||||
|| (v_k == WASM_F32 && v_t == VALUE_TYPE_F32)
|
|| (v_k == WASM_F32 && v_t == VALUE_TYPE_F32)
|
||||||
|| (v_k == WASM_F64 && v_t == VALUE_TYPE_F64)
|
|| (v_k == WASM_F64 && v_t == VALUE_TYPE_F64)
|
||||||
|| (v_k == WASM_V128 && v_t == VALUE_TYPE_V128)
|
|| (v_k == WASM_V128 && v_t == VALUE_TYPE_V128)
|
||||||
|| (v_k == WASM_ANYREF && v_t == VALUE_TYPE_EXTERNREF)
|
|| (v_k == WASM_EXTERNREF && v_t == VALUE_TYPE_EXTERNREF)
|
||||||
|| (v_k == WASM_FUNCREF && v_t == VALUE_TYPE_FUNCREF);
|
|| (v_k == WASM_FUNCREF && v_t == VALUE_TYPE_FUNCREF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1135,7 +1135,7 @@ wasm_tabletype_new(own wasm_valtype_t *val_type, const wasm_limits_t *limits)
|
||||||
|
|
||||||
if (wasm_valtype_kind(val_type) != WASM_FUNCREF
|
if (wasm_valtype_kind(val_type) != WASM_FUNCREF
|
||||||
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
||||||
&& wasm_valtype_kind(val_type) != WASM_ANYREF
|
&& wasm_valtype_kind(val_type) != WASM_EXTERNREF
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1653,7 +1653,7 @@ rt_val_to_wasm_val(const uint8 *data, uint8 val_type_rt, wasm_val_t *out)
|
||||||
break;
|
break;
|
||||||
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
||||||
case VALUE_TYPE_EXTERNREF:
|
case VALUE_TYPE_EXTERNREF:
|
||||||
out->kind = WASM_ANYREF;
|
out->kind = WASM_EXTERNREF;
|
||||||
if (NULL_REF == *(uint32 *)data) {
|
if (NULL_REF == *(uint32 *)data) {
|
||||||
out->of.ref = NULL;
|
out->of.ref = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1697,7 +1697,7 @@ wasm_val_to_rt_val(WASMModuleInstanceCommon *inst_comm_rt, uint8 val_type_rt,
|
||||||
break;
|
break;
|
||||||
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
||||||
case VALUE_TYPE_EXTERNREF:
|
case VALUE_TYPE_EXTERNREF:
|
||||||
bh_assert(WASM_ANYREF == v->kind);
|
bh_assert(WASM_EXTERNREF == v->kind);
|
||||||
ret =
|
ret =
|
||||||
wasm_externref_obj2ref(inst_comm_rt, v->of.ref, (uint32 *)data);
|
wasm_externref_obj2ref(inst_comm_rt, v->of.ref, (uint32 *)data);
|
||||||
break;
|
break;
|
||||||
|
@ -3263,7 +3263,7 @@ params_to_argv(const wasm_val_vec_t *params,
|
||||||
bh_assert(0);
|
bh_assert(0);
|
||||||
break;
|
break;
|
||||||
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
||||||
case WASM_ANYREF:
|
case WASM_EXTERNREF:
|
||||||
*(uintptr_t *)argv = (uintptr_t)param->of.ref;
|
*(uintptr_t *)argv = (uintptr_t)param->of.ref;
|
||||||
argv += sizeof(uintptr_t) / sizeof(uint32);
|
argv += sizeof(uintptr_t) / sizeof(uint32);
|
||||||
break;
|
break;
|
||||||
|
@ -3308,7 +3308,7 @@ argv_to_results(const uint32 *argv, const wasm_valtype_vec_t *result_defs,
|
||||||
bh_assert(0);
|
bh_assert(0);
|
||||||
break;
|
break;
|
||||||
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
||||||
case WASM_ANYREF:
|
case WASM_EXTERNREF:
|
||||||
result->of.ref = (struct wasm_ref_t *)(*(uintptr_t *)argv);
|
result->of.ref = (struct wasm_ref_t *)(*(uintptr_t *)argv);
|
||||||
argv += sizeof(uintptr_t) / sizeof(uint32);
|
argv += sizeof(uintptr_t) / sizeof(uint32);
|
||||||
break;
|
break;
|
||||||
|
@ -4034,7 +4034,7 @@ wasm_table_get(const wasm_table_t *table, wasm_table_size_t index)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_REF_TYPES != 0
|
||||||
if (table->type->val_type->kind == WASM_ANYREF) {
|
if (table->type->val_type->kind == WASM_EXTERNREF) {
|
||||||
void *externref_obj;
|
void *externref_obj;
|
||||||
if (!wasm_externref_ref2obj(ref_idx, &externref_obj)) {
|
if (!wasm_externref_ref2obj(ref_idx, &externref_obj)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4064,7 +4064,7 @@ wasm_table_set(wasm_table_t *table, wasm_table_size_t index,
|
||||||
if (ref
|
if (ref
|
||||||
#if WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_REF_TYPES != 0
|
||||||
&& !(WASM_REF_foreign == ref->kind
|
&& !(WASM_REF_foreign == ref->kind
|
||||||
&& WASM_ANYREF == table->type->val_type->kind)
|
&& WASM_EXTERNREF == table->type->val_type->kind)
|
||||||
#endif
|
#endif
|
||||||
&& !(WASM_REF_func == ref->kind
|
&& !(WASM_REF_func == ref->kind
|
||||||
&& WASM_FUNCREF == table->type->val_type->kind)) {
|
&& WASM_FUNCREF == table->type->val_type->kind)) {
|
||||||
|
@ -4111,7 +4111,7 @@ wasm_table_set(wasm_table_t *table, wasm_table_size_t index,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_REF_TYPES != 0
|
||||||
if (table->type->val_type->kind == WASM_ANYREF) {
|
if (table->type->val_type->kind == WASM_EXTERNREF) {
|
||||||
return wasm_externref_obj2ref(table->inst_comm_rt, ref, p_ref_idx);
|
return wasm_externref_obj2ref(table->inst_comm_rt, ref, p_ref_idx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -5268,7 +5268,7 @@ wasm_externkind_t
|
||||||
wasm_extern_kind(const wasm_extern_t *external)
|
wasm_extern_kind(const wasm_extern_t *external)
|
||||||
{
|
{
|
||||||
if (!external) {
|
if (!external) {
|
||||||
return WASM_ANYREF;
|
return WASM_EXTERNREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
return external->kind;
|
return external->kind;
|
||||||
|
|
|
@ -2000,7 +2000,7 @@ val_type_to_val_kind(uint8 value_type)
|
||||||
case VALUE_TYPE_FUNCREF:
|
case VALUE_TYPE_FUNCREF:
|
||||||
return WASM_FUNCREF;
|
return WASM_FUNCREF;
|
||||||
case VALUE_TYPE_EXTERNREF:
|
case VALUE_TYPE_EXTERNREF:
|
||||||
return WASM_ANYREF;
|
return WASM_EXTERNREF;
|
||||||
default:
|
default:
|
||||||
bh_assert(0);
|
bh_assert(0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2318,7 +2318,7 @@ parse_args_to_uint32_array(WASMFuncType *type, wasm_val_t *args,
|
||||||
#else
|
#else
|
||||||
case WASM_FUNCREF:
|
case WASM_FUNCREF:
|
||||||
#endif
|
#endif
|
||||||
case WASM_ANYREF:
|
case WASM_EXTERNREF:
|
||||||
{
|
{
|
||||||
#if UINTPTR_MAX == UINT32_MAX
|
#if UINTPTR_MAX == UINT32_MAX
|
||||||
out_argv[p++] = args[i].of.foreign;
|
out_argv[p++] = args[i].of.foreign;
|
||||||
|
@ -2419,7 +2419,7 @@ parse_uint32_array_to_results(WASMFuncType *type, uint32 *argv,
|
||||||
#endif /* end of WASM_ENABLE_GC == 0 */
|
#endif /* end of WASM_ENABLE_GC == 0 */
|
||||||
{
|
{
|
||||||
#if UINTPTR_MAX == UINT32_MAX
|
#if UINTPTR_MAX == UINT32_MAX
|
||||||
out_results[i].kind = WASM_ANYREF;
|
out_results[i].kind = WASM_EXTERNREF;
|
||||||
out_results[i].of.foreign = (uintptr_t)argv[p++];
|
out_results[i].of.foreign = (uintptr_t)argv[p++];
|
||||||
#else
|
#else
|
||||||
union {
|
union {
|
||||||
|
@ -2428,7 +2428,7 @@ parse_uint32_array_to_results(WASMFuncType *type, uint32 *argv,
|
||||||
} u;
|
} u;
|
||||||
u.parts[0] = argv[p++];
|
u.parts[0] = argv[p++];
|
||||||
u.parts[1] = argv[p++];
|
u.parts[1] = argv[p++];
|
||||||
out_results[i].kind = WASM_ANYREF;
|
out_results[i].kind = WASM_EXTERNREF;
|
||||||
out_results[i].of.foreign = u.val;
|
out_results[i].of.foreign = u.val;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -2582,7 +2582,7 @@ wasm_runtime_call_wasm_v(WASMExecEnv *exec_env,
|
||||||
}
|
}
|
||||||
case VALUE_TYPE_EXTERNREF:
|
case VALUE_TYPE_EXTERNREF:
|
||||||
{
|
{
|
||||||
args[i].kind = WASM_ANYREF;
|
args[i].kind = WASM_EXTERNREF;
|
||||||
args[i].of.foreign = va_arg(vargs, uintptr_t);
|
args[i].of.foreign = va_arg(vargs, uintptr_t);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6528,7 +6528,7 @@ argv_to_params(wasm_val_t *out_params, const uint32 *argv,
|
||||||
break;
|
break;
|
||||||
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
#if WASM_ENABLE_GC == 0 && WASM_ENABLE_REF_TYPES != 0
|
||||||
case VALUE_TYPE_EXTERNREF:
|
case VALUE_TYPE_EXTERNREF:
|
||||||
param->kind = WASM_ANYREF;
|
param->kind = WASM_EXTERNREF;
|
||||||
|
|
||||||
if (!wasm_externref_ref2obj(*argv,
|
if (!wasm_externref_ref2obj(*argv,
|
||||||
(void **)¶m->of.foreign)) {
|
(void **)¶m->of.foreign)) {
|
||||||
|
|
|
@ -298,7 +298,7 @@ enum wasm_valkind_enum {
|
||||||
WASM_F32,
|
WASM_F32,
|
||||||
WASM_F64,
|
WASM_F64,
|
||||||
WASM_V128,
|
WASM_V128,
|
||||||
WASM_ANYREF = 128,
|
WASM_EXTERNREF = 128,
|
||||||
WASM_FUNCREF,
|
WASM_FUNCREF,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -308,10 +308,10 @@ WASM_API_EXTERN own wasm_valtype_t* wasm_valtype_new(wasm_valkind_t);
|
||||||
WASM_API_EXTERN wasm_valkind_t wasm_valtype_kind(const wasm_valtype_t*);
|
WASM_API_EXTERN wasm_valkind_t wasm_valtype_kind(const wasm_valtype_t*);
|
||||||
|
|
||||||
static inline bool wasm_valkind_is_num(wasm_valkind_t k) {
|
static inline bool wasm_valkind_is_num(wasm_valkind_t k) {
|
||||||
return k < WASM_ANYREF;
|
return k < WASM_EXTERNREF;
|
||||||
}
|
}
|
||||||
static inline bool wasm_valkind_is_ref(wasm_valkind_t k) {
|
static inline bool wasm_valkind_is_ref(wasm_valkind_t k) {
|
||||||
return k >= WASM_ANYREF;
|
return k >= WASM_EXTERNREF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool wasm_valtype_is_num(const wasm_valtype_t* t) {
|
static inline bool wasm_valtype_is_num(const wasm_valtype_t* t) {
|
||||||
|
@ -712,7 +712,7 @@ static inline own wasm_valtype_t* wasm_valtype_new_v128(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline own wasm_valtype_t* wasm_valtype_new_anyref(void) {
|
static inline own wasm_valtype_t* wasm_valtype_new_anyref(void) {
|
||||||
return wasm_valtype_new(WASM_ANYREF);
|
return wasm_valtype_new(WASM_EXTERNREF);
|
||||||
}
|
}
|
||||||
static inline own wasm_valtype_t* wasm_valtype_new_funcref(void) {
|
static inline own wasm_valtype_t* wasm_valtype_new_funcref(void) {
|
||||||
return wasm_valtype_new(WASM_FUNCREF);
|
return wasm_valtype_new(WASM_FUNCREF);
|
||||||
|
@ -872,8 +872,8 @@ static inline void* wasm_val_ptr(const wasm_val_t* val) {
|
||||||
#define WASM_I64_VAL(i) {.kind = WASM_I64, ._paddings = {0}, .of = {.i64 = i}}
|
#define WASM_I64_VAL(i) {.kind = WASM_I64, ._paddings = {0}, .of = {.i64 = i}}
|
||||||
#define WASM_F32_VAL(z) {.kind = WASM_F32, ._paddings = {0}, .of = {.f32 = z}}
|
#define WASM_F32_VAL(z) {.kind = WASM_F32, ._paddings = {0}, .of = {.f32 = z}}
|
||||||
#define WASM_F64_VAL(z) {.kind = WASM_F64, ._paddings = {0}, .of = {.f64 = z}}
|
#define WASM_F64_VAL(z) {.kind = WASM_F64, ._paddings = {0}, .of = {.f64 = z}}
|
||||||
#define WASM_REF_VAL(r) {.kind = WASM_ANYREF, ._paddings = {0}, .of = {.ref = r}}
|
#define WASM_REF_VAL(r) {.kind = WASM_EXTERNREF, ._paddings = {0}, .of = {.ref = r}}
|
||||||
#define WASM_INIT_VAL {.kind = WASM_ANYREF, ._paddings = {0}, .of = {.ref = NULL}}
|
#define WASM_INIT_VAL {.kind = WASM_EXTERNREF, ._paddings = {0}, .of = {.ref = NULL}}
|
||||||
|
|
||||||
#define KILOBYTE(n) ((n) * 1024)
|
#define KILOBYTE(n) ((n) * 1024)
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ enum wasm_valkind_enum {
|
||||||
WASM_F32,
|
WASM_F32,
|
||||||
WASM_F64,
|
WASM_F64,
|
||||||
WASM_V128,
|
WASM_V128,
|
||||||
WASM_ANYREF = 128,
|
WASM_EXTERNREF = 128,
|
||||||
WASM_FUNCREF,
|
WASM_FUNCREF,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -211,7 +211,7 @@ func (self *Instance) CallFuncV(funcName string,
|
||||||
case int32:
|
case int32:
|
||||||
if (param_types[i] != C.WASM_I32 &&
|
if (param_types[i] != C.WASM_I32 &&
|
||||||
param_types[i] != C.WASM_FUNCREF &&
|
param_types[i] != C.WASM_FUNCREF &&
|
||||||
param_types[i] != C.WASM_ANYREF) {
|
param_types[i] != C.WASM_EXTERNREF) {
|
||||||
str := "CallFunc error: invalid param type %d, " +
|
str := "CallFunc error: invalid param type %d, " +
|
||||||
"expect i32 but got other"
|
"expect i32 but got other"
|
||||||
return fmt.Errorf(str, param_types[i])
|
return fmt.Errorf(str, param_types[i])
|
||||||
|
@ -273,7 +273,7 @@ func (self *Instance) CallFuncV(funcName string,
|
||||||
fallthrough
|
fallthrough
|
||||||
case C.WASM_FUNCREF:
|
case C.WASM_FUNCREF:
|
||||||
fallthrough
|
fallthrough
|
||||||
case C.WASM_ANYREF:
|
case C.WASM_EXTERNREF:
|
||||||
i32 := (int32)(argv[argc])
|
i32 := (int32)(argv[argc])
|
||||||
results[i] = i32
|
results[i] = i32
|
||||||
argc++
|
argc++
|
||||||
|
|
|
@ -213,7 +213,7 @@ WASM_I32 = 0
|
||||||
WASM_I64 = 1
|
WASM_I64 = 1
|
||||||
WASM_F32 = 2
|
WASM_F32 = 2
|
||||||
WASM_F64 = 3
|
WASM_F64 = 3
|
||||||
WASM_ANYREF = 128
|
WASM_EXTERNREF = 128
|
||||||
WASM_FUNCREF = 129
|
WASM_FUNCREF = 129
|
||||||
|
|
||||||
def wasm_valtype_new(arg0):
|
def wasm_valtype_new(arg0):
|
||||||
|
|
|
@ -180,7 +180,7 @@ def __repr_wasm_valtype_t(self):
|
||||||
elif WASM_FUNCREF == val_kind:
|
elif WASM_FUNCREF == val_kind:
|
||||||
return "funcref"
|
return "funcref"
|
||||||
else:
|
else:
|
||||||
return "anyref"
|
return "externref"
|
||||||
|
|
||||||
|
|
||||||
wasm_valtype_t.__eq__ = __compare_wasm_valtype_t
|
wasm_valtype_t.__eq__ = __compare_wasm_valtype_t
|
||||||
|
@ -406,7 +406,7 @@ def __compare_wasm_val_t(self, other):
|
||||||
return self.of.f32 == other.of.f32
|
return self.of.f32 == other.of.f32
|
||||||
elif WASM_F64 == self.kind:
|
elif WASM_F64 == self.kind:
|
||||||
return self.of.f64 == other.of.f63
|
return self.of.f64 == other.of.f63
|
||||||
elif WASM_ANYREF == self.kind:
|
elif WASM_EXTERNREF == self.kind:
|
||||||
raise RuntimeError("FIXME")
|
raise RuntimeError("FIXME")
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("not a valid val kind")
|
raise RuntimeError("not a valid val kind")
|
||||||
|
@ -421,8 +421,8 @@ def __repr_wasm_val_t(self):
|
||||||
return f"f32 {self.of.f32}"
|
return f"f32 {self.of.f32}"
|
||||||
elif WASM_F64 == self.kind:
|
elif WASM_F64 == self.kind:
|
||||||
return f"f64 {self.of.f64}"
|
return f"f64 {self.of.f64}"
|
||||||
elif WASM_ANYREF == self.kind:
|
elif WASM_EXTERNREF == self.kind:
|
||||||
return f"anyref {self.of.ref}"
|
return f"externref {self.of.ref}"
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("not a valid val kind")
|
raise RuntimeError("not a valid val kind")
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class BasicTestSuite(unittest.TestCase):
|
||||||
|
|
||||||
def test_wasm_valkind(self):
|
def test_wasm_valkind(self):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[WASM_I32, WASM_I64, WASM_F32, WASM_F64, WASM_ANYREF, WASM_FUNCREF],
|
[WASM_I32, WASM_I64, WASM_F32, WASM_F64, WASM_EXTERNREF, WASM_FUNCREF],
|
||||||
[0, 1, 2, 3, 128, 129],
|
[0, 1, 2, 3, 128, 129],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ wasm_get_externref(wasm_exec_env_t exec_env, wasm_module_inst_t inst,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WASM_ANYREF != results[0].kind) {
|
if (WASM_EXTERNREF != results[0].kind) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ wasm_cmp_externref(wasm_exec_env_t exec_env, wasm_module_inst_t inst,
|
||||||
wasm_val_t results[1] = { 0 };
|
wasm_val_t results[1] = { 0 };
|
||||||
wasm_val_t arguments[2] = {
|
wasm_val_t arguments[2] = {
|
||||||
{ .kind = WASM_I32, .of.i32 = index },
|
{ .kind = WASM_I32, .of.i32 = index },
|
||||||
{ .kind = WASM_ANYREF, .of.foreign = externref },
|
{ .kind = WASM_EXTERNREF, .of.foreign = externref },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!exec_env || !wasm_cmp_externref_ptr || !ret_result) {
|
if (!exec_env || !wasm_cmp_externref_ptr || !ret_result) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ void wasm_val_print(wasm_val_t val) {
|
||||||
case WASM_F64: {
|
case WASM_F64: {
|
||||||
printf("%g", val.of.f64);
|
printf("%g", val.of.f64);
|
||||||
} break;
|
} break;
|
||||||
case WASM_ANYREF:
|
case WASM_EXTERNREF:
|
||||||
case WASM_FUNCREF: {
|
case WASM_FUNCREF: {
|
||||||
if (val.of.ref == NULL) {
|
if (val.of.ref == NULL) {
|
||||||
printf("null");
|
printf("null");
|
||||||
|
|
|
@ -193,7 +193,7 @@ int main(int argc, const char* argv[]) {
|
||||||
// Create external callback function.
|
// Create external callback function.
|
||||||
printf("Creating callback...\n");
|
printf("Creating callback...\n");
|
||||||
own wasm_functype_t* callback_type = wasm_functype_new_1_1(
|
own wasm_functype_t* callback_type = wasm_functype_new_1_1(
|
||||||
wasm_valtype_new(WASM_ANYREF), wasm_valtype_new(WASM_ANYREF));
|
wasm_valtype_new(WASM_EXTERNREF), wasm_valtype_new(WASM_EXTERNREF));
|
||||||
own wasm_func_t* callback_func =
|
own wasm_func_t* callback_func =
|
||||||
wasm_func_new(store, callback_type, callback);
|
wasm_func_new(store, callback_type, callback);
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ int main(int argc, const char* argv[]) {
|
||||||
wasm_ref_delete(host2_cp);
|
wasm_ref_delete(host2_cp);
|
||||||
|
|
||||||
own wasm_val_t val;
|
own wasm_val_t val;
|
||||||
val.kind = WASM_ANYREF;
|
val.kind = WASM_EXTERNREF;
|
||||||
val.of.ref = wasm_ref_copy(host1);
|
val.of.ref = wasm_ref_copy(host1);
|
||||||
wasm_ref_t *ref_cp = wasm_ref_copy(val.of.ref);
|
wasm_ref_t *ref_cp = wasm_ref_copy(val.of.ref);
|
||||||
check(ref_cp, host1);
|
check(ref_cp, host1);
|
||||||
|
@ -264,12 +264,12 @@ int main(int argc, const char* argv[]) {
|
||||||
check(call_v_r(global_get), NULL);
|
check(call_v_r(global_get), NULL);
|
||||||
|
|
||||||
wasm_global_get(global, &val);
|
wasm_global_get(global, &val);
|
||||||
assert(val.kind == WASM_ANYREF);
|
assert(val.kind == WASM_EXTERNREF);
|
||||||
assert(val.of.ref == NULL);
|
assert(val.of.ref == NULL);
|
||||||
val.of.ref = host2;
|
val.of.ref = host2;
|
||||||
wasm_global_set(global, &val);
|
wasm_global_set(global, &val);
|
||||||
wasm_global_get(global, &val);
|
wasm_global_get(global, &val);
|
||||||
assert(val.kind == WASM_ANYREF);
|
assert(val.kind == WASM_EXTERNREF);
|
||||||
assert(val.of.ref == host2);
|
assert(val.of.ref == host2);
|
||||||
|
|
||||||
printf("Accessing table...\n");
|
printf("Accessing table...\n");
|
||||||
|
|
|
@ -30,7 +30,7 @@ void print_valtype(const wasm_valtype_t* type) {
|
||||||
case WASM_F32: printf("f32"); break;
|
case WASM_F32: printf("f32"); break;
|
||||||
case WASM_F64: printf("f64"); break;
|
case WASM_F64: printf("f64"); break;
|
||||||
case WASM_V128: printf("v128"); break;
|
case WASM_V128: printf("v128"); break;
|
||||||
case WASM_ANYREF: printf("anyref"); break;
|
case WASM_EXTERNREF: printf("externref"); break;
|
||||||
case WASM_FUNCREF: printf("funcref"); break;
|
case WASM_FUNCREF: printf("funcref"); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user