fix type equality checking on untyped pointer elements
This commit is contained in:
parent
ac16b69fe1
commit
a4c0424931
12
src/ffi.c
12
src/ffi.c
@ -1281,11 +1281,19 @@ static B ptrty_simplify(B x) {
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
static bool ptrty_equal(B a, B b) {
|
static bool ptrty_equal(B a, B b) {
|
||||||
|
assert(isC32(a) || v(a)->type==t_ffiType);
|
||||||
|
assert(isC32(b) || v(b)->type==t_ffiType);
|
||||||
if (!isC32(a)) a = ptrty_simplify(a);
|
if (!isC32(a)) a = ptrty_simplify(a);
|
||||||
if (a.u == m_c32(sty_ptr).u) return true;
|
if (a.u == m_c32(sty_void).u) return true;
|
||||||
|
|
||||||
if (!isC32(b)) b = ptrty_simplify(b);
|
if (!isC32(b)) b = ptrty_simplify(b);
|
||||||
if (b.u == m_c32(sty_ptr).u) return true;
|
if (b.u == m_c32(sty_void).u) return true;
|
||||||
|
|
||||||
|
if (a.u == b.u) return true;
|
||||||
|
// TODO get rid of sty_ptr and this, represent as cty_ptr(sty_void)
|
||||||
|
if (a.u == m_c32(sty_ptr).u) return !isC32(b) && c(BQNFFIType,b)->ty==cty_ptr; // both being sty_ptr is handled by the preceding a.u == b.u
|
||||||
|
if (b.u == m_c32(sty_ptr).u) return !isC32(a) && c(BQNFFIType,a)->ty==cty_ptr;
|
||||||
|
|
||||||
if (isC32(a) || isC32(b)) return a.u==b.u; // if only one is a character, this test trivially fails
|
if (isC32(a) || isC32(b)) return a.u==b.u; // if only one is a character, this test trivially fails
|
||||||
|
|
||||||
BQNFFIType* at = c(BQNFFIType,a);
|
BQNFFIType* at = c(BQNFFIType,a);
|
||||||
|
|||||||
@ -253,6 +253,9 @@
|
|||||||
1 %USE TyEq ⟨"{i32:i8,i64}", "{i32,i64}"⟩
|
1 %USE TyEq ⟨"{i32:i8,i64}", "{i32,i64}"⟩
|
||||||
1 %USE TyEq ⟨"*i32:i8", "*"⟩
|
1 %USE TyEq ⟨"*i32:i8", "*"⟩
|
||||||
1 %USE TyEq ⟨"*i32:i8", "*:c32"⟩
|
1 %USE TyEq ⟨"*i32:i8", "*:c32"⟩
|
||||||
|
0 %USE TyEq ⟨"**", "*i8"⟩
|
||||||
|
0 %USE TyEq ⟨"*{*}", "*{i8}"⟩
|
||||||
|
0 %USE TyEq ⟨"*{i8}", "*{*}"⟩
|
||||||
|
|
||||||
|
|
||||||
# !"FFI: Unimplemented result type" % @•FFI"*i32"‿"bqn_init"
|
# !"FFI: Unimplemented result type" % @•FFI"*i32"‿"bqn_init"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user