Merge branch 'master' into cellwidth

This commit is contained in:
Marshall Lochbaum 2022-09-18 15:26:34 -04:00
commit d525acb51e
5 changed files with 37 additions and 22 deletions

View File

@ -950,24 +950,38 @@ B pick_ucw(B t, B o, B w, B x) {
if (isArr(w) || isAtm(x) || RNK(x)!=1) return def_fn_ucw(t, o, w, x);
usz xia = IA(x);
usz wi = WRAP(o2i64(w), xia, thrF("𝔽⌾(n⊸⊑)𝕩: reading out-of-bounds (n≡%R, %s≡≠𝕩)", w, xia));
if (TI(x,elType)==el_B) {
B* xp;
if (TY(x)==t_harr || TY(x)==t_hslice) {
if (!(TY(x)==t_harr && reusable(x))) x = taga(cpyHArr(x));
xp = harr_ptr(x);
} else if (TY(x)==t_fillarr && reusable(x)) {
xp = fillarr_ptr(a(x));
} else {
Arr* x2 = m_fillarrp(xia);
fillarr_setFill(x2, getFillQ(x));
xp = fillarr_ptr(x2);
COPY_TO(xp, el_B, 0, x, 0, xia);
arr_shCopy(x2, x);
dec(x);
x = taga(x2);
}
B c = xp[wi];
xp[wi] = m_f64(0);
xp[wi] = c1(o, c);
return x;
}
B arg = IGet(x, wi);
B rep = c1(o, arg);
if (reusable(x) && TI(x,canStore)(rep)) { REUSE(x);
if (TI(x,elType)==el_i8 ) { i8* xp = i8any_ptr (x); xp[wi] = o2iG(rep); return x; }
else if (TI(x,elType)==el_i16) { i16* xp = i16any_ptr(x); xp[wi] = o2iG(rep); return x; }
else if (TI(x,elType)==el_i32) { i32* xp = i32any_ptr(x); xp[wi] = o2iG(rep); return x; }
else if (TI(x,elType)==el_f64) { f64* xp = f64any_ptr(x); xp[wi] = o2fG(rep); return x; }
else if (TY(x)==t_harr) {
B* xp = harr_ptr(x);
dec(xp[wi]);
xp[wi] = rep;
return x;
} else if (TY(x)==t_fillarr) {
B* xp = fillarr_ptr(a(x));
dec(xp[wi]);
xp[wi] = rep;
return x;
}
u8 xt = TY(x);
if (xt==t_i8arr ) { i8* xp = i8any_ptr (x); xp[wi] = o2iG(rep); return x; }
else if (xt==t_i16arr) { i16* xp = i16any_ptr(x); xp[wi] = o2iG(rep); return x; }
else if (xt==t_i32arr) { i32* xp = i32any_ptr(x); xp[wi] = o2iG(rep); return x; }
else if (xt==t_f64arr) { f64* xp = f64any_ptr(x); xp[wi] = o2fG(rep); return x; }
else if (xt==t_c8arr ) { u8* xp = c8any_ptr (x); xp[wi] = o2cG(rep); return x; }
else if (xt==t_c16arr) { u16* xp = c16any_ptr(x); xp[wi] = o2cG(rep); return x; }
else if (xt==t_c32arr) { u32* xp = c32any_ptr(x); xp[wi] = o2cG(rep); return x; }
}
MAKE_MUT(r, xia); mut_init(r, el_or(TI(x,elType), selfElType(rep)));
MUTG_INIT(r);

View File

@ -565,9 +565,7 @@ bool eequal(B w, B x) { // doesn't consume
return true;
}
u64 depth(B x) { // doesn't consume
if (isAtm(x)) return 0;
if (TI(x,arrD1)) return 1;
usz depthF(B x) { // doesn't consume
u64 r = 0;
usz ia = IA(x);
SGetU(x)

View File

@ -215,6 +215,12 @@ static bool atomEqual(B w, B x) { // doesn't consume
return atomEqualF(w, x);
}
NOINLINE usz depthF(B x);
static usz depth(B x) { // doesn't consume
if (isAtm(x)) return 0;
if (TI(x,arrD1)) return 1;
return depthF(x);
}

View File

@ -338,7 +338,6 @@ void printRaw(B x); // doesn't consume
void arr_print(B x); // doesn't consume
bool equal(B w, B x); // doesn't consume
bool eequal(B w, B x); // doesn't consume
u64 depth(B x); // doesn't consume
B toCells(B x); // consumes
B toKCells(B x, ur k); // consumes
B withFill(B x, B f); // consumes both

View File

@ -34,9 +34,7 @@ B utf8Decode(const char* s, i64 len) {
j+= l;
}
if (sz==len) {
u8* rp; B r = m_c8arrv(&rp, sz);
for (i64 i = 0; i < len; i++) rp[i] = s[i];
return r;
return m_c8vec((char*)s, len);
} else {
u32* rp; B r = m_c32arrv(&rp, sz);
u64 p = 0;