Fix •bit._cast handling of boolean output with shared or slice input
This commit is contained in:
parent
69e496f7fa
commit
77dfaf75a4
@ -882,6 +882,16 @@ B convert(CastType t, B x) {
|
|||||||
default: thrM("•bit._cast: unsupported input width");
|
default: thrM("•bit._cast: unsupported input width");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TyArr* copy(CastType t, B x) {
|
||||||
|
switch (t.s) {
|
||||||
|
case 1: return cpyBitArr(x);
|
||||||
|
case 8: return t.t=='c' ? cpyC8Arr (x) : cpyI8Arr (x);
|
||||||
|
case 16: return t.t=='c' ? cpyC16Arr(x) : cpyI16Arr(x);
|
||||||
|
case 32: return t.t=='c' ? cpyC32Arr(x) : cpyI32Arr(x);
|
||||||
|
case 64: return cpyF64Arr(x);
|
||||||
|
default: thrM("•bit._cast: unsupported input width");
|
||||||
|
}
|
||||||
|
}
|
||||||
u8 typeOfCast(CastType t) {
|
u8 typeOfCast(CastType t) {
|
||||||
switch (t.s) {
|
switch (t.s) {
|
||||||
case 1: return t_bitarr;
|
case 1: return t_bitarr;
|
||||||
@ -904,13 +914,15 @@ B bitcast_c1(Md1D* d, B x) { B f = d->f;
|
|||||||
if (zl*zt.s != s) thrM("•bit._cast: incompatible lengths");
|
if (zl*zt.s != s) thrM("•bit._cast: incompatible lengths");
|
||||||
// Convert to input type
|
// Convert to input type
|
||||||
B r = convert(xt, x);
|
B r = convert(xt, x);
|
||||||
if (v(r)->refc!=1) {
|
u8 rt = typeOfCast(zt);
|
||||||
|
if (rt==t_bitarr && (v(r)->refc!=1 || IS_SLICE(v(r)->type))) {
|
||||||
|
r = taga(copy(xt, r));
|
||||||
|
} else if (v(r)->refc!=1) {
|
||||||
r = taga(TI(r,slice)(r, 0, a(r)->ia));
|
r = taga(TI(r,slice)(r, 0, a(r)->ia));
|
||||||
sprnk(v(r),xr);
|
sprnk(v(r),xr);
|
||||||
}
|
}
|
||||||
// Cast to output type
|
// Cast to output type
|
||||||
u8 rt = typeOfCast(zt); if (IS_SLICE(v(r)->type)) rt = TO_SLICE(rt);
|
v(r)->type = IS_SLICE(v(r)->type) ? TO_SLICE(rt) : rt;
|
||||||
v(r)->type = rt;
|
|
||||||
// Adjust shape
|
// Adjust shape
|
||||||
if (xr<=1) {
|
if (xr<=1) {
|
||||||
Arr* a = a(r);
|
Arr* a = a(r);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user