diff options
author | dzaima <dzaimagit@gmail.com> | 2024-02-05 04:54:55 +0200 |
---|---|---|
committer | dzaima <dzaimagit@gmail.com> | 2024-02-05 04:54:55 +0200 |
commit | a8772dc3ae6a57b71b80402315917328e8604e7a (patch) | |
tree | 7dfcb14249faa84d1c0498e76b665198567ec733 | |
parent | b22c5d288385ae2be1afefa9480b37ea32d14044 (diff) |
fix **:i8
-rw-r--r-- | src/ffi.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -770,16 +770,16 @@ void genObj(B o, B c, bool anyMut, void* ptr) { // doesn't consume } else { // *scalar:any / &scalar:any / *:any BQNFFIType* t2 = c(BQNFFIType, o2); B ore = t2->a[0].o; + assert(t2->ty==cty_ptr && (isC32(ore) || ore.u==ty_voidptr.u)); if (isNsp(c)) { genObj_ptr(ptr, c, ore); return; } - assert(t2->ty==cty_ptr && isC32(ore)); - if (styG(ore) == sty_void) { // *:any + if (ore.u == m_c32(sty_void).u) { // *:any elSz = sizeof(void*); goto toScalarReinterpret; } bool mut = t2->mutPtr; - u8 et = styG(ore); - u8 mul = (sty_w[et]*8) >> reW; + elSz = isC32(ore)? sty_w[styG(ore)] : sizeof(void*); + u8 mul = (elSz*8) >> reW; if (!isArr(c)) thrF("FFI: Expected array or pointer object corresponding to %R", ty_fmt(o)); if (mul && (IA(c) & (mul-1)) != 0) thrF("FFI: Bad array corresponding to %R: expected a multiple of %s elements, got %s", ty_fmt(o), (usz)mul, IA(c)); |