add best effort guesses for many more builtin error messages
This commit is contained in:
parent
63ee20b6fe
commit
5790d126cd
@ -427,7 +427,7 @@ B GRADE_CAT(c2)(B t, B w, B x) {
|
|||||||
|
|
||||||
if (wr > 1) {
|
if (wr > 1) {
|
||||||
ur xr = RNK(x);
|
ur xr = RNK(x);
|
||||||
if (wr > xr+1) thrM("𝕨"GRADE_CHR"𝕩": =𝕨 cannot be greater than =𝕩");
|
if (wr > xr+1) thrM("𝕨"GRADE_CHR"𝕩: =𝕨 cannot be greater than =𝕩");
|
||||||
i32 nxr = xr-wr+1;
|
i32 nxr = xr-wr+1;
|
||||||
x = toKCells(x, nxr);
|
x = toKCells(x, nxr);
|
||||||
w = toCells(w);
|
w = toCells(w);
|
||||||
|
|||||||
@ -126,10 +126,10 @@ FORCE_INLINE void cf_call(CFRes f, void* r, ux rs, void* x, ux xs) {
|
|||||||
|
|
||||||
extern GLOBAL B rt_select;
|
extern GLOBAL B rt_select;
|
||||||
B select_c1(B t, B x) {
|
B select_c1(B t, B x) {
|
||||||
if (isAtm(x)) thrM("⊏: Argument cannot be an atom");
|
if (isAtm(x)) thrM("⊏𝕩: 𝕩 cannot be an atom");
|
||||||
ur xr = RNK(x);
|
ur xr = RNK(x);
|
||||||
if (xr==0) thrM("⊏: Argument cannot be rank 0");
|
if (xr==0) thrM("⊏𝕩: 𝕩 cannot be rank 0");
|
||||||
if (SH(x)[0]==0) thrF("⊏: Argument shape cannot start with 0 (%H ≡ ≢𝕩)", x);
|
if (SH(x)[0]==0) thrF("⊏𝕩: 𝕩 shape cannot start with 0 (%H ≡ ≢𝕩)", x);
|
||||||
usz ia = shProd(SH(x), 1, xr);
|
usz ia = shProd(SH(x), 1, xr);
|
||||||
Arr* r = TI(x,slice)(incG(x), 0, ia);
|
Arr* r = TI(x,slice)(incG(x), 0, ia);
|
||||||
usz* sh = arr_shAlloc(r, xr-1);
|
usz* sh = arr_shAlloc(r, xr-1);
|
||||||
@ -145,13 +145,13 @@ static NOINLINE NORETURN void select_properError(B w, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B select_c2(B t, B w, B x) {
|
B select_c2(B t, B w, B x) {
|
||||||
if (isAtm(x)) thrM("⊏: 𝕩 cannot be an atom");
|
if (isAtm(x)) thrM("𝕨⊏𝕩: 𝕩 cannot be an atom");
|
||||||
ur xr = RNK(x);
|
ur xr = RNK(x);
|
||||||
if (xr==0) thrM("⊏: 𝕩 cannot be a unit");
|
if (xr==0) thrM("𝕨⊏𝕩: 𝕩 cannot be a unit");
|
||||||
if (isAtm(w)) {
|
if (isAtm(w)) {
|
||||||
watom:;
|
watom:;
|
||||||
usz xn = *SH(x);
|
usz xn = *SH(x);
|
||||||
usz wi = WRAP(o2i64(w), xn, thrF("⊏: Indexing out-of-bounds (%R∊𝕨, %s≡≠𝕩)", w, xn));
|
usz wi = WRAP(o2i64(w), xn, thrF("𝕨⊏𝕩: Indexing out-of-bounds (%R∊𝕨, %s≡≠𝕩)", w, xn));
|
||||||
if (xr==1) {
|
if (xr==1) {
|
||||||
B xf = getFillR(x);
|
B xf = getFillR(x);
|
||||||
B xv = IGet(x, wi);
|
B xv = IGet(x, wi);
|
||||||
@ -220,7 +220,7 @@ B select_c2(B t, B w, B x) {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
#define CASE(S, E) case S: for (usz i=i0; i<i1; i++) ((E*)rp)[i] = ((E*)xp+off)[ip[i]]; break
|
#define CASE(S, E) case S: for (usz i=i0; i<i1; i++) ((E*)rp)[i] = ((E*)xp+off)[ip[i]]; break
|
||||||
#define CASEW(S, E) case S: for (usz i=0; i<wia; i++) ((E*)rp)[i] = ((E*)xp)[WRAP(wp[i], xn, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn))]; break
|
#define CASEW(S, E) case S: for (usz i=0; i<wia; i++) ((E*)rp)[i] = ((E*)xp)[WRAP(wp[i], xn, thrF("𝕨⊏𝕩: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn))]; break
|
||||||
#define CPUSEL(W, NEXT) /*assumes 3≤xl≤6*/ \
|
#define CPUSEL(W, NEXT) /*assumes 3≤xl≤6*/ \
|
||||||
if (sizeof(W) >= 4) { \
|
if (sizeof(W) >= 4) { \
|
||||||
switch(xl) { default:UD; CASEW(3,u8); CASEW(4,u16); CASEW(5,u32); CASEW(6,u64); } \
|
switch(xl) { default:UD; CASEW(3,u8); CASEW(4,u16); CASEW(5,u32); CASEW(6,u64); } \
|
||||||
@ -298,8 +298,8 @@ B select_c2(B t, B w, B x) {
|
|||||||
if (xl!=6) goto generic_l; \
|
if (xl!=6) goto generic_l; \
|
||||||
M_HARR(ra, wia); B* xp = arr_bptr(x); \
|
M_HARR(ra, wia); B* xp = arr_bptr(x); \
|
||||||
SLOWIF(xp==NULL) SLOW2("𝕨⊏𝕩", w, x); \
|
SLOWIF(xp==NULL) SLOW2("𝕨⊏𝕩", w, x); \
|
||||||
if (xp!=NULL) { for (usz i=0; i<wia; i++) HARR_ADD(ra, i, inc(xp[WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn))])); } \
|
if (xp!=NULL) { for (usz i=0; i<wia; i++) HARR_ADD(ra, i, inc(xp[WRAP(wp[i], xia, thrF("𝕨⊏𝕩: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn))])); } \
|
||||||
else { SGet(x); for (usz i=0; i<wia; i++) HARR_ADD(ra, i, Get(x, WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn)) )); } \
|
else { SGet(x); for (usz i=0; i<wia; i++) HARR_ADD(ra, i, Get(x, WRAP(wp[i], xia, thrF("𝕨⊏𝕩: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn)) )); } \
|
||||||
r = a(withFill(HARR_FV(ra), xf)); goto setsh; \
|
r = a(withFill(HARR_FV(ra), xf)); goto setsh; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ B select_c2(B t, B w, B x) {
|
|||||||
if (xia<2) {
|
if (xia<2) {
|
||||||
u64* wp=bitany_ptr(w);
|
u64* wp=bitany_ptr(w);
|
||||||
usz i; for (i=0; i<wia/64; i++) if (wp[i]) break;
|
usz i; for (i=0; i<wia/64; i++) if (wp[i]) break;
|
||||||
if (i<wia/64 || bitp_l0(wp,wia)!=0) thrF("⊏: Indexing out-of-bounds (1∊𝕨, %s≡≠𝕩)", xn);
|
if (i<wia/64 || bitp_l0(wp,wia)!=0) thrF("𝕨⊏𝕩: Indexing out-of-bounds (1∊𝕨, %s≡≠𝕩)", xn);
|
||||||
x1 = x0;
|
x1 = x0;
|
||||||
} else {
|
} else {
|
||||||
x1 = GetU(x,1);
|
x1 = GetU(x,1);
|
||||||
@ -387,14 +387,14 @@ B select_c2(B t, B w, B x) {
|
|||||||
bad1:;
|
bad1:;
|
||||||
mut_pfree(rm, i*csz);
|
mut_pfree(rm, i*csz);
|
||||||
if (!q_fi64(badw)) expI_f64(badw);
|
if (!q_fi64(badw)) expI_f64(badw);
|
||||||
thrF("⊏: Indexing out-of-bounds (%f∊𝕨, %s≡≠𝕩)", badw, xn);
|
thrF("𝕨⊏𝕩: Indexing out-of-bounds (%f∊𝕨, %s≡≠𝕩)", badw, xn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setsh:
|
setsh:
|
||||||
if (rr>1) {
|
if (rr>1) {
|
||||||
if (rr > UR_MAX) thrF("⊏: Result rank too large (%i≡=𝕨, %i≡=𝕩)", wr, xr);
|
if (rr > UR_MAX) thrF("𝕨⊏𝕩: Result rank too large (%i≡=𝕨, %i≡=𝕩)", wr, xr);
|
||||||
ShArr* sh = m_shArr(rr);
|
ShArr* sh = m_shArr(rr);
|
||||||
shcpy(sh->a, SH(w), wr);
|
shcpy(sh->a, SH(w), wr);
|
||||||
shcpy(sh->a+wr, SH(x)+1, xr-1);
|
shcpy(sh->a+wr, SH(x)+1, xr-1);
|
||||||
@ -915,7 +915,7 @@ B select_rows_B(B x, ux csz, ux cam, B inds) { // consumes inds,x; ⥊ inds⊸
|
|||||||
if (in == 0) return taga(emptyArr(x, 1));
|
if (in == 0) return taga(emptyArr(x, 1));
|
||||||
if (in == 1) {
|
if (in == 1) {
|
||||||
B w = IGetU(inds,0); if (!isF64(w)) goto generic;
|
B w = IGetU(inds,0); if (!isF64(w)) goto generic;
|
||||||
B r = select_cells_single(WRAP(o2i64(w), csz, thrF("⊏: Indexing out-of-bounds (%R∊𝕨, %s≡≠𝕩)", w, csz)), x, cam, csz, 1, false);
|
B r = select_cells_single(WRAP(o2i64(w), csz, thrF("𝕨⊏𝕩: Indexing out-of-bounds (%R∊𝕨, %s≡≠𝕩)", w, csz)), x, cam, csz, 1, false);
|
||||||
decG(x); decG(inds); return r;
|
decG(x); decG(inds); return r;
|
||||||
}
|
}
|
||||||
u8 ie = TI(inds,elType);
|
u8 ie = TI(inds,elType);
|
||||||
|
|||||||
@ -155,7 +155,7 @@ extern u64 (*const simd_deduplicate_u8)(void*,uint64_t,void*,void*);
|
|||||||
|
|
||||||
#define PRUP ptr_roundUpToEl
|
#define PRUP ptr_roundUpToEl
|
||||||
B memberOf_c1(B t, B x) {
|
B memberOf_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)==0) thrM("∊: Argument cannot have rank 0");
|
if (isAtm(x) || RNK(x)==0) thrM("∊𝕩: 𝕩 cannot have rank 0");
|
||||||
u64 n = *SH(x);
|
u64 n = *SH(x);
|
||||||
if (n<=1) { decG(x); return n ? taga(arr_shVec(allOnes(1))) : emptyIVec(); }
|
if (n<=1) { decG(x); return n ? taga(arr_shVec(allOnes(1))) : emptyIVec(); }
|
||||||
|
|
||||||
@ -288,10 +288,10 @@ B memberOf_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B count_c1(B t, B x) {
|
B count_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)==0) thrM("⊒: Argument cannot have rank 0");
|
if (isAtm(x) || RNK(x)==0) thrM("⊒𝕩: 𝕩 cannot have rank 0");
|
||||||
u64 n = *SH(x);
|
u64 n = *SH(x);
|
||||||
if (n<=1) { decG(x); return n ? taga(arr_shVec(allZeroes(1))) : emptyIVec(); }
|
if (n<=1) { decG(x); return n ? taga(arr_shVec(allZeroes(1))) : emptyIVec(); }
|
||||||
if (n>(usz)I32_MAX+1) thrM("⊒: Argument length >2⋆31 not supported");
|
if (n>(usz)I32_MAX+1) thrM("⊒𝕩: 𝕩 length >2⋆31 not supported");
|
||||||
|
|
||||||
usz csz = arr_csz(x);
|
usz csz = arr_csz(x);
|
||||||
if (csz==0) { decG(x); return C1(ud, m_f64(n)); }
|
if (csz==0) { decG(x); return C1(ud, m_f64(n)); }
|
||||||
@ -401,10 +401,10 @@ static B reduceI32WidthBelow(B r, usz after) {
|
|||||||
B find_c1(B, B);
|
B find_c1(B, B);
|
||||||
|
|
||||||
B indexOf_c1(B t, B x) {
|
B indexOf_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)==0) thrM("⊐: 𝕩 cannot have rank 0");
|
if (isAtm(x) || RNK(x)==0) thrM("⊐𝕩: 𝕩 cannot have rank 0");
|
||||||
u64 n = *SH(x);
|
u64 n = *SH(x);
|
||||||
if (n<=1) { zeroRes: decG(x); return n? taga(arr_shVec(allZeroesFl(n))) : emptyIVec(); }
|
if (n<=1) { zeroRes: decG(x); return n? taga(arr_shVec(allZeroesFl(n))) : emptyIVec(); }
|
||||||
if (n>(usz)I32_MAX+1) thrM("⊐: Argument length >2⋆31 not supported");
|
if (n>(usz)I32_MAX+1) thrM("⊐𝕩: 𝕩 length >2⋆31 not supported");
|
||||||
|
|
||||||
usz csz = arr_csz(x);
|
usz csz = arr_csz(x);
|
||||||
if (csz==0) goto zeroRes;
|
if (csz==0) goto zeroRes;
|
||||||
@ -516,7 +516,7 @@ B indexOf_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B find_c1(B t, B x) {
|
B find_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)==0) thrM("⍷: Argument cannot have rank 0");
|
if (isAtm(x) || RNK(x)==0) thrM("⍷𝕩: 𝕩 cannot have rank 0");
|
||||||
usz n = *SH(x);
|
usz n = *SH(x);
|
||||||
if (n<=1) return x;
|
if (n<=1) return x;
|
||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
|
|||||||
@ -569,7 +569,7 @@ static B compress(B w, B x, usz wia, u8 xl, u8 xt) {
|
|||||||
|
|
||||||
extern GLOBAL B rt_slash;
|
extern GLOBAL B rt_slash;
|
||||||
B slash_c1(B t, B x) {
|
B slash_c1(B t, B x) {
|
||||||
if (RARE(isAtm(x)) || RARE(RNK(x)!=1)) thrF("/: Argument must have rank 1 (%H ≡ ≢𝕩)", x);
|
if (RARE(isAtm(x)) || RARE(RNK(x)!=1)) thrF("/𝕩: 𝕩 must have rank 1 (%H ≡ ≢𝕩)", x);
|
||||||
u64 s = usum(x);
|
u64 s = usum(x);
|
||||||
if (s>=USZ_MAX) thrOOM();
|
if (s>=USZ_MAX) thrOOM();
|
||||||
if (s==0) { decG(x); return emptyIVec(); }
|
if (s==0) { decG(x); return emptyIVec(); }
|
||||||
@ -627,7 +627,7 @@ B slash_c2(B t, B w, B x) {
|
|||||||
if (isArr(w)) {
|
if (isArr(w)) {
|
||||||
if (depth(w)>1) goto base;
|
if (depth(w)>1) goto base;
|
||||||
ur wr = RNK(w);
|
ur wr = RNK(w);
|
||||||
if (wr>1) thrF("/: Simple 𝕨 must have rank 0 or 1 (%i≡=𝕨)", wr);
|
if (wr>1) thrF("𝕨/𝕩: Simple 𝕨 must have rank 0 or 1 (%i≡=𝕨)", wr);
|
||||||
if (wr<1) { w = TO_GET(w, 0); goto atom; }
|
if (wr<1) { w = TO_GET(w, 0); goto atom; }
|
||||||
wia = IA(w);
|
wia = IA(w);
|
||||||
if (wia==0) { decG(w); return isArr(x)? x : m_unit(x); }
|
if (wia==0) { decG(w); return isArr(x)? x : m_unit(x); }
|
||||||
@ -635,9 +635,9 @@ B slash_c2(B t, B w, B x) {
|
|||||||
atom:
|
atom:
|
||||||
if (!q_i32(w)) goto base;
|
if (!q_i32(w)) goto base;
|
||||||
wv = o2iG(w);
|
wv = o2iG(w);
|
||||||
if (wv < 0) thrM("/: 𝕨 cannot be negative");
|
if (wv < 0) thrM("𝕨/𝕩: 𝕨 cannot be negative");
|
||||||
}
|
}
|
||||||
if (isAtm(x) || RNK(x)==0) thrM("/: 𝕩 must have rank at least 1 for simple 𝕨");
|
if (isAtm(x) || RNK(x)==0) thrM("𝕨/𝕩: 𝕩 must have rank at least 1 for simple 𝕨");
|
||||||
ur xr = RNK(x);
|
ur xr = RNK(x);
|
||||||
usz xlen = *SH(x);
|
usz xlen = *SH(x);
|
||||||
u8 xl = cellWidthLog(x);
|
u8 xl = cellWidthLog(x);
|
||||||
@ -645,7 +645,7 @@ B slash_c2(B t, B w, B x) {
|
|||||||
|
|
||||||
B r;
|
B r;
|
||||||
if (wv < 0) { // Array w
|
if (wv < 0) { // Array w
|
||||||
if (RARE(wia!=xlen)) thrF("/: Lengths of components of 𝕨 must match 𝕩 (%s ≠ %s)", wia, xlen);
|
if (RARE(wia!=xlen)) thrF("𝕨/𝕩: Lengths of components of 𝕨 must match 𝕩 (%s ≠ %s)", wia, xlen);
|
||||||
|
|
||||||
u64 s;
|
u64 s;
|
||||||
u8 we = TI(w,elType);
|
u8 we = TI(w,elType);
|
||||||
@ -867,7 +867,7 @@ static B finish_sorted_count(B r, usz* ov, usz* oc, usz on) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
B slash_im(B t, B x) {
|
B slash_im(B t, B x) {
|
||||||
if (!isArr(x) || RNK(x)!=1) thrM("/⁼: Argument must be a list");
|
if (!isArr(x) || RNK(x)!=1) thrM("/⁼𝕩: 𝕩 must be a list");
|
||||||
u8 xe = TI(x,elType);
|
u8 xe = TI(x,elType);
|
||||||
usz xia = IA(x);
|
usz xia = IA(x);
|
||||||
if (xia==0) { decG(x); return emptyIVec(); }
|
if (xia==0) { decG(x); return emptyIVec(); }
|
||||||
@ -886,7 +886,7 @@ B slash_im(B t, B x) {
|
|||||||
i##N* rp; r = m_i##N##arrv(&rp, RIA); \
|
i##N* rp; r = m_i##N##arrv(&rp, RIA); \
|
||||||
for (usz i=0; i<RIA; i++) rp[i]=0;
|
for (usz i=0; i<RIA; i++) rp[i]=0;
|
||||||
#define TRY_SMALL_OUT(N) \
|
#define TRY_SMALL_OUT(N) \
|
||||||
if (xp[0]<0) thrM("/⁼: Argument cannot contain negative numbers"); \
|
if (xp[0]<0) thrM("/⁼𝕩: 𝕩 cannot contain negative numbers"); \
|
||||||
usz a=1; while (a<xia && xp[a]>xp[a-1]) a++; \
|
usz a=1; while (a<xia && xp[a]>xp[a-1]) a++; \
|
||||||
u##N max=xp[a-1]; \
|
u##N max=xp[a-1]; \
|
||||||
usz rmax=xia; \
|
usz rmax=xia; \
|
||||||
@ -902,7 +902,7 @@ B slash_im(B t, B x) {
|
|||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
for (usz i=a; i<xia; i++) { u##N c=xp[i]; if (c>max) max=c; } \
|
for (usz i=a; i<xia; i++) { u##N c=xp[i]; if (c>max) max=c; } \
|
||||||
if ((i##N)max<0) thrM("/⁼: Argument cannot contain negative numbers"); \
|
if ((i##N)max<0) thrM("/⁼𝕩: 𝕩 cannot contain negative numbers"); \
|
||||||
usz ria = max + 1; \
|
usz ria = max + 1; \
|
||||||
if (xia < ria/8) { \
|
if (xia < ria/8) { \
|
||||||
u8 maxcount = 0; \
|
u8 maxcount = 0; \
|
||||||
@ -939,7 +939,7 @@ B slash_im(B t, B x) {
|
|||||||
usz os = xia>>15; \
|
usz os = xia>>15; \
|
||||||
TALLOC(u16, ov, os+1); \
|
TALLOC(u16, ov, os+1); \
|
||||||
i##N max = simd_count_i##N((u16*)rp, (u16*)ov, xp, xia, 0); \
|
i##N max = simd_count_i##N((u16*)rp, (u16*)ov, xp, xia, 0); \
|
||||||
if (max < 0) thrM("/⁼: Argument cannot contain negative numbers"); \
|
if (max < 0) thrM("/⁼𝕩: 𝕩 cannot contain negative numbers"); \
|
||||||
usz ria = (usz)max + 1; \
|
usz ria = (usz)max + 1; \
|
||||||
if (ria < sa) r = C2(take, m_f64(ria), r); \
|
if (ria < sa) r = C2(take, m_f64(ria), r); \
|
||||||
r = finish_small_count(r, ov); \
|
r = finish_small_count(r, ov); \
|
||||||
@ -951,7 +951,7 @@ B slash_im(B t, B x) {
|
|||||||
case el_i32: {
|
case el_i32: {
|
||||||
i32* xp = i32any_ptr(x);
|
i32* xp = i32any_ptr(x);
|
||||||
TRY_SMALL_OUT(32)
|
TRY_SMALL_OUT(32)
|
||||||
if (xia>I32_MAX) thrM("/⁼: Argument too large");
|
if (xia>I32_MAX) thrM("/⁼𝕩: 𝕩 too large");
|
||||||
INIT_RES(32,ria)
|
INIT_RES(32,ria)
|
||||||
simd_count_i32_i32(rp, xp, xia);
|
simd_count_i32_i32(rp, xp, xia);
|
||||||
r = num_squeeze(r); break;
|
r = num_squeeze(r); break;
|
||||||
@ -963,7 +963,7 @@ B slash_im(B t, B x) {
|
|||||||
i##N* xp = i##N##any_ptr(x); \
|
i##N* xp = i##N##any_ptr(x); \
|
||||||
u##N max=xp[0]; \
|
u##N max=xp[0]; \
|
||||||
for (usz i=1; i<xia; i++) { u##N c=xp[i]; if (c>max) max=c; } \
|
for (usz i=1; i<xia; i++) { u##N c=xp[i]; if (c>max) max=c; } \
|
||||||
if ((i##N)max<0) thrM("/⁼: Argument cannot contain negative numbers"); \
|
if ((i##N)max<0) thrM("/⁼𝕩: 𝕩 cannot contain negative numbers"); \
|
||||||
usz ria = max + 1; \
|
usz ria = max + 1; \
|
||||||
TALLOC(usz, t, ria); \
|
TALLOC(usz, t, ria); \
|
||||||
for (usz j=0; j<ria; j++) t[j]=0; \
|
for (usz j=0; j<ria; j++) t[j]=0; \
|
||||||
@ -978,14 +978,14 @@ B slash_im(B t, B x) {
|
|||||||
case el_f64: {
|
case el_f64: {
|
||||||
f64* xp = f64any_ptr(x);
|
f64* xp = f64any_ptr(x);
|
||||||
usz i,j; f64 max=-1;
|
usz i,j; f64 max=-1;
|
||||||
for (i = 0; i < xia; i++) { f64 c=xp[i]; if (c!=(usz)c) thrM("/⁼: Argument must consist of natural numbers"); if (c<=max) break; max=c; }
|
for (i = 0; i < xia; i++) { f64 c=xp[i]; if (c!=(usz)c) thrM("/⁼𝕩: 𝕩 must consist of natural numbers"); if (c<=max) break; max=c; }
|
||||||
for (j = i; j < xia; j++) { f64 c=xp[j]; if (c!=(usz)c) thrM("/⁼: Argument must consist of natural numbers"); max=c>max?c:max; if (c<0) thrM("/⁼: Argument cannot contain negative numbers"); }
|
for (j = i; j < xia; j++) { f64 c=xp[j]; if (c!=(usz)c) thrM("/⁼𝕩: 𝕩 must consist of natural numbers"); max=c>max?c:max; if (c<0) thrM("/⁼: Argument cannot contain negative numbers"); }
|
||||||
usz ria = max+1; if (ria==0) thrOOM();
|
usz ria = max+1; if (ria==0) thrOOM();
|
||||||
if (i==xia) {
|
if (i==xia) {
|
||||||
u64* rp; r = m_bitarrv(&rp, ria); for (usz i=0; i<BIT_N(ria); i++) rp[i]=0;
|
u64* rp; r = m_bitarrv(&rp, ria); for (usz i=0; i<BIT_N(ria); i++) rp[i]=0;
|
||||||
for (usz i = 0; i < xia; i++) bitp_set(rp, xp[i], 1);
|
for (usz i = 0; i < xia; i++) bitp_set(rp, xp[i], 1);
|
||||||
} else {
|
} else {
|
||||||
if (xia>I32_MAX) thrM("/⁼: Argument too large");
|
if (xia>I32_MAX) thrM("/⁼𝕩: 𝕩 too large");
|
||||||
i32* rp; r = m_i32arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=0;
|
i32* rp; r = m_i32arrv(&rp, ria); for (usz i=0; i<ria; i++) rp[i]=0;
|
||||||
for (usz i = 0; i < xia; i++) rp[(usz)xp[i]]++;
|
for (usz i = 0; i < xia; i++) rp[(usz)xp[i]]++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,7 +101,7 @@ B repr_c1(B t, B x) {
|
|||||||
#if FORMATTER
|
#if FORMATTER
|
||||||
return bqn_repr(x);
|
return bqn_repr(x);
|
||||||
#else
|
#else
|
||||||
thrM("•Repr: Cannot represent non-numbers with -DFORMATTER=0");
|
thrM("•Repr𝕩: Cannot represent non-numbers with -DFORMATTER=0");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,26 +110,26 @@ B fmt_c1(B t, B x) {
|
|||||||
#if FORMATTER
|
#if FORMATTER
|
||||||
return bqn_fmt(x);
|
return bqn_fmt(x);
|
||||||
#else
|
#else
|
||||||
thrM("•Fmt isn't supported with -DFORMATTER=0");
|
thrM("•Fmt𝕩: •Fmt isn't supported with -DFORMATTER=0");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NO_RYU
|
#if NO_RYU
|
||||||
B parseFloat_c1(B t, B x) { thrM("•ParseFloat: Not supported with Ryu disabled"); }
|
B parseFloat_c1(B t, B x) { thrM("•ParseFloat𝕩: Not supported with Ryu disabled"); }
|
||||||
#else
|
#else
|
||||||
B parseFloat_c1(B t, B x) {
|
B parseFloat_c1(B t, B x) {
|
||||||
if (isAtm(x)) thrM("•ParseFloat: Expected a character list argument");
|
if (isAtm(x)) thrM("•ParseFloat𝕩: Expected a character list argument");
|
||||||
if (TI(x,elType)!=el_c8) {
|
if (TI(x,elType)!=el_c8) {
|
||||||
x = chr_squeeze(x);
|
x = chr_squeeze(x);
|
||||||
if (TI(x,elType)!=el_c8) thrM("•ParseFloat: Expected a character list argument");
|
if (TI(x,elType)!=el_c8) thrM("•ParseFloat𝕩: Expected a character list argument");
|
||||||
}
|
}
|
||||||
usz ia = IA(x);
|
usz ia = IA(x);
|
||||||
if (RNK(x)!=1) thrM("•ParseFloat: Input must have rank 1");
|
if (RNK(x)!=1) thrM("•ParseFloat𝕩: Input must have rank 1");
|
||||||
if (ia==0) thrM("•ParseFloat: Input was empty");
|
if (ia==0) thrM("•ParseFloat𝕩: Input was empty");
|
||||||
if (ia >= (1<<20)) thrM("•ParseFloat: Input too long"); // assumption by ryu_s2d_n
|
if (ia >= (1<<20)) thrM("•ParseFloat𝕩: Input too long"); // assumption by ryu_s2d_n
|
||||||
u8* data = c8any_ptr(x);
|
u8* data = c8any_ptr(x);
|
||||||
f64 res;
|
f64 res;
|
||||||
if (!ryu_s2d_n(data, ia, &res)) thrM("•ParseFloat: Malformed input");
|
if (!ryu_s2d_n(data, ia, &res)) thrM("•ParseFloat𝕩: Malformed input");
|
||||||
decG(x);
|
decG(x);
|
||||||
return m_f64(res);
|
return m_f64(res);
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ B grOrd_c2(B t, B w, B x) { // assumes valid arguments
|
|||||||
for (usz i = 1; i < wia; i++) tmp[i] = tmp[i-1]+o2sG(GetU(w,i-1));
|
for (usz i = 1; i < wia; i++) tmp[i] = tmp[i-1]+o2sG(GetU(w,i-1));
|
||||||
usz ria = tmp[wia-1]+o2sG(GetU(w,wia-1));
|
usz ria = tmp[wia-1]+o2sG(GetU(w,wia-1));
|
||||||
i32* rp; B r = m_i32arrv(&rp, ria);
|
i32* rp; B r = m_i32arrv(&rp, ria);
|
||||||
if (xia>=I32_MAX) thrM("⊔: Too large");
|
if (xia>=I32_MAX) thrM("𝕨⊔𝕩: Too large");
|
||||||
for (usz i = 0; i < xia; i++) {
|
for (usz i = 0; i < xia; i++) {
|
||||||
i64 c = o2i64(GetU(x,i));
|
i64 c = o2i64(GetU(x,i));
|
||||||
if (c>=0) rp[tmp[c]++] = i;
|
if (c>=0) rp[tmp[c]++] = i;
|
||||||
@ -259,7 +259,7 @@ B casrt_c1(B t, B x) {
|
|||||||
|
|
||||||
B sys_c1(B t, B x);
|
B sys_c1(B t, B x);
|
||||||
B out_c1(B t, B x) {
|
B out_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) thrM("•Out: Argument must be a string");
|
if (isAtm(x) || RNK(x)!=1) thrM("•Out𝕩: 𝕩 must be a string");
|
||||||
printsB(x); printf("\n");
|
printsB(x); printf("\n");
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
@ -277,13 +277,13 @@ B show_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NOINLINE B vfyStr(B x, char* name, char* arg) {
|
NOINLINE B vfyStr(B x, char* name, char* arg) {
|
||||||
if (!isStr(x)) thrF("%U: %U must be a string", name, arg);
|
if (!isStr(x)) thrF("%U𝕩: %U must be a string", name, arg);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLOBAL B cdPath;
|
GLOBAL B cdPath;
|
||||||
static NOINLINE B prep_state(B w, char* name) { // consumes w, returns ⟨path,name,args⟩
|
static NOINLINE B prep_state(B w, char* name) { // consumes w, returns ⟨path,name,args⟩
|
||||||
if (!isArr(w) || RNK(w)!=1 || IA(w)>3) thrF("%U: 𝕨 must be a list with at most 3 items, but had shape %H", name, w);
|
if (!isArr(w) || RNK(w)!=1 || IA(w)>3) thrF("𝕨%U𝕩: 𝕨 must be a list with at most 3 items, but had shape %H", name, w);
|
||||||
usz ia = IA(w); SGet(w)
|
usz ia = IA(w); SGet(w)
|
||||||
HArr_p r = m_harr0v(3);
|
HArr_p r = m_harr0v(3);
|
||||||
r.a[0] = ia>0? vfyStr(Get(w,0),name,"Path" ) : inc(cdPath);
|
r.a[0] = ia>0? vfyStr(Get(w,0),name,"Path" ) : inc(cdPath);
|
||||||
@ -339,7 +339,7 @@ STATIC_GLOBAL B rand_subsetName; STATIC_GLOBAL NFnDesc* rand_subsetDesc;
|
|||||||
sc->vars[1].u = seed&0xFFFFFFFF;
|
sc->vars[1].u = seed&0xFFFFFFFF;
|
||||||
B rand_range_c1(B t, B x) {
|
B rand_range_c1(B t, B x) {
|
||||||
i64 xv = o2i64(x);
|
i64 xv = o2i64(x);
|
||||||
if (xv<0) thrM("(rand).Range: 𝕩 cannot be negative");
|
if (xv<0) thrM("(rand).Range𝕩: 𝕩 cannot be negative");
|
||||||
RAND_START;
|
RAND_START;
|
||||||
u64 rnd = wyrand(&seed);
|
u64 rnd = wyrand(&seed);
|
||||||
RAND_END;
|
RAND_END;
|
||||||
@ -349,7 +349,7 @@ B rand_range_c2(B t, B w, B x) {
|
|||||||
usz am = 1;
|
usz am = 1;
|
||||||
i64 max = o2i64(x);
|
i64 max = o2i64(x);
|
||||||
if (isArr(w)) {
|
if (isArr(w)) {
|
||||||
if (RNK(w) > 1) thrM("(rand).Range: 𝕨 must be a valid shape");
|
if (RNK(w) > 1) thrM("𝕨(rand).Range𝕩: 𝕨 must be a valid shape");
|
||||||
SGetU(w);
|
SGetU(w);
|
||||||
usz wia = IA(w);
|
usz wia = IA(w);
|
||||||
bool bad=false, good=false;
|
bool bad=false, good=false;
|
||||||
@ -370,11 +370,11 @@ B rand_range_c2(B t, B w, B x) {
|
|||||||
f64* rp; r = m_f64arrp(&rp, am);
|
f64* rp; r = m_f64arrp(&rp, am);
|
||||||
PLAINLOOP for (usz i = 0; i < am; i++) rp[i] = wy2u01(wyrand(&seed));
|
PLAINLOOP for (usz i = 0; i < am; i++) rp[i] = wy2u01(wyrand(&seed));
|
||||||
} else {
|
} else {
|
||||||
if (max!=1) thrM("(rand).Range: 𝕩 cannot be negative");
|
if (max!=1) thrM("𝕨(rand).Range𝕩: 𝕩 cannot be negative");
|
||||||
r = allZeroesFl(am);
|
r = allZeroesFl(am);
|
||||||
}
|
}
|
||||||
} else if (max > (1ULL<<31)) {
|
} else if (max > (1ULL<<31)) {
|
||||||
if (max >= 1LL<<53) thrM("(rand).Range: 𝕩 must be less than 2⋆53");
|
if (max >= 1LL<<53) thrM("𝕨(rand).Range𝕩: 𝕩 must be less than 2⋆53");
|
||||||
f64* rp; r = m_f64arrp(&rp, am);
|
f64* rp; r = m_f64arrp(&rp, am);
|
||||||
PLAINLOOP for (usz i = 0; i < am; i++) rp[i] = wy2u0k(wyrand(&seed), max);
|
PLAINLOOP for (usz i = 0; i < am; i++) rp[i] = wy2u0k(wyrand(&seed), max);
|
||||||
} else {
|
} else {
|
||||||
@ -416,7 +416,7 @@ B rand_range_c2(B t, B w, B x) {
|
|||||||
if (wia<2) {
|
if (wia<2) {
|
||||||
arr_rnk01(r, wia);
|
arr_rnk01(r, wia);
|
||||||
} else {
|
} else {
|
||||||
if (wia>UR_MAX) thrF("(rand).Range: Result rank too large (%s≡≢𝕨)", wia);
|
if (wia>UR_MAX) thrF("𝕨(rand).Range𝕩: Result rank too large (%s≡≢𝕨)", wia);
|
||||||
usz* sh = arr_shAlloc(r, wia);
|
usz* sh = arr_shAlloc(r, wia);
|
||||||
SGetU(w);
|
SGetU(w);
|
||||||
for (usz i = 0; i < wia; i++) sh[i] = o2sG(GetU(w, i));
|
for (usz i = 0; i < wia; i++) sh[i] = o2sG(GetU(w, i));
|
||||||
@ -437,7 +437,7 @@ void intRange32Fill(i32* xp, ux s, ux n);
|
|||||||
B rand_deal_c1(B t, B x) {
|
B rand_deal_c1(B t, B x) {
|
||||||
i32 xi = o2i(x);
|
i32 xi = o2i(x);
|
||||||
if (RARE(xi<=1)) {
|
if (RARE(xi<=1)) {
|
||||||
if (xi<0) thrM("(rand).Deal: Argument cannot be negative");
|
if (xi<0) thrM("(rand).Deal𝕩: 𝕩 cannot be negative");
|
||||||
return taga(ptr_inc(bitUD[xi]));
|
return taga(ptr_inc(bitUD[xi]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,10 +516,10 @@ B rand_deal_c1(B t, B x) {
|
|||||||
B rand_deal_c2(B t, B w, B x) {
|
B rand_deal_c2(B t, B w, B x) {
|
||||||
i32 wi = o2i(w);
|
i32 wi = o2i(w);
|
||||||
i32 xi = o2i(x);
|
i32 xi = o2i(x);
|
||||||
if (RARE(xi<0)) thrM("(rand).Deal: 𝕩 cannot be negative");
|
if (RARE(xi<0)) thrM("𝕨(rand).Deal𝕩: 𝕩 cannot be negative");
|
||||||
if (RARE(wi<0)) thrM("(rand).Deal: 𝕨 cannot be negative");
|
if (RARE(wi<0)) thrM("𝕨(rand).Deal𝕩: 𝕨 cannot be negative");
|
||||||
if (wi==0) return emptyIVec();
|
if (wi==0) return emptyIVec();
|
||||||
if (RARE(wi>xi)) thrM("(rand).Deal: 𝕨 cannot exceed 𝕩");
|
if (RARE(wi>xi)) thrM("𝕨(rand).Deal𝕩: 𝕨 cannot exceed 𝕩");
|
||||||
if (wi==xi) return rand_deal_c1(t, x);
|
if (wi==xi) return rand_deal_c1(t, x);
|
||||||
B r;
|
B r;
|
||||||
RAND_START;
|
RAND_START;
|
||||||
@ -578,9 +578,9 @@ extern void filter_ne_i32(i32* dst, i32* src, usz len, usz sum, i32 val); // sla
|
|||||||
B rand_subset_c2(B t, B w, B x) {
|
B rand_subset_c2(B t, B w, B x) {
|
||||||
i32 wi = o2i(w);
|
i32 wi = o2i(w);
|
||||||
i32 xi = o2i(x);
|
i32 xi = o2i(x);
|
||||||
if (RARE(wi<0)) thrM("(rand).Subset: 𝕨 cannot be negative");
|
if (RARE(wi<0)) thrM("𝕨(rand).Subset𝕩: 𝕨 cannot be negative");
|
||||||
if (RARE(xi<0)) thrM("(rand).Subset: 𝕩 cannot be negative");
|
if (RARE(xi<0)) thrM("𝕨(rand).Subset𝕩: 𝕩 cannot be negative");
|
||||||
if (RARE(wi>xi)) thrM("(rand).Subset: 𝕨 cannot exceed 𝕩");
|
if (RARE(wi>xi)) thrM("𝕨(rand).Subset𝕩: 𝕨 cannot exceed 𝕩");
|
||||||
if (wi==0) return emptyIVec();
|
if (wi==0) return emptyIVec();
|
||||||
if (wi==xi) return ud_c1(t, x); // Only one complete subset; will hang without this
|
if (wi==xi) return ud_c1(t, x); // Only one complete subset; will hang without this
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ static NOINLINE void rand_init() {
|
|||||||
rand_subsetName = m_c8vec_0("subset"); gc_add(rand_subsetName); rand_subsetDesc = registerNFn(m_c8vec_0("(rand).Subset"), c1_bad, rand_subset_c2);
|
rand_subsetName = m_c8vec_0("subset"); gc_add(rand_subsetName); rand_subsetDesc = registerNFn(m_c8vec_0("(rand).Subset"), c1_bad, rand_subset_c2);
|
||||||
}
|
}
|
||||||
B makeRand_c1(B t, B x) {
|
B makeRand_c1(B t, B x) {
|
||||||
if (!isNum(x)) thrM("•MakeRand: 𝕩 must be a number");
|
if (!isNum(x)) thrM("•MakeRand𝕩: 𝕩 must be a number");
|
||||||
if (rand_ns==NULL) rand_init();
|
if (rand_ns==NULL) rand_init();
|
||||||
B r = m_nns(rand_ns, b(x.u>>32), b(x.u&0xFFFFFFFF), m_nfn(rand_rangeDesc, bi_N), m_nfn(rand_dealDesc, bi_N), m_nfn(rand_subsetDesc, bi_N));
|
B r = m_nns(rand_ns, b(x.u>>32), b(x.u&0xFFFFFFFF), m_nfn(rand_rangeDesc, bi_N), m_nfn(rand_dealDesc, bi_N), m_nfn(rand_subsetDesc, bi_N));
|
||||||
Scope* sc = c(NS,r)->sc;
|
Scope* sc = c(NS,r)->sc;
|
||||||
@ -675,12 +675,12 @@ STATIC_GLOBAL NFnDesc* bqnDesc;
|
|||||||
STATIC_GLOBAL NFnDesc* rebqnDesc;
|
STATIC_GLOBAL NFnDesc* rebqnDesc;
|
||||||
STATIC_GLOBAL NFnDesc* rebqnResDesc;
|
STATIC_GLOBAL NFnDesc* rebqnResDesc;
|
||||||
B rebqn_c1(B t, B x) {
|
B rebqn_c1(B t, B x) {
|
||||||
if (!isNsp(x)) thrM("•ReBQN: Argument must be a namespace");
|
if (!isNsp(x)) thrM("•ReBQN𝕩: Argument must be a namespace");
|
||||||
B repl = ns_getC(x, "repl");
|
B repl = ns_getC(x, "repl");
|
||||||
B prim = ns_getC(x, "primitives");
|
B prim = ns_getC(x, "primitives");
|
||||||
B sys = ns_getC(x, "system");
|
B sys = ns_getC(x, "system");
|
||||||
i32 replVal = q_N(repl) || eqStr(repl,U"none")? 0 : eqStr(repl,U"strict")? 1 : eqStr(repl,U"loose")? 2 : 3;
|
i32 replVal = q_N(repl) || eqStr(repl,U"none")? 0 : eqStr(repl,U"strict")? 1 : eqStr(repl,U"loose")? 2 : 3;
|
||||||
if (replVal==3) thrM("•ReBQN: Invalid repl value");
|
if (replVal==3) thrM("•ReBQN𝕩: Invalid repl value");
|
||||||
B scVal;
|
B scVal;
|
||||||
if (replVal==0) {
|
if (replVal==0) {
|
||||||
scVal = bi_N;
|
scVal = bi_N;
|
||||||
@ -708,13 +708,13 @@ B repl_c1(B t, B x) {
|
|||||||
#if USE_SETJMP
|
#if USE_SETJMP
|
||||||
GLOBAL B lastErrMsg;
|
GLOBAL B lastErrMsg;
|
||||||
B currentError_c1(B t, B x) {
|
B currentError_c1(B t, B x) {
|
||||||
if (isNsp(x)) thrM("•CurrentError: Namespace 𝕩 is reserved");
|
if (isNsp(x)) thrM("•CurrentError𝕩: Namespace 𝕩 is reserved");
|
||||||
dec(x);
|
dec(x);
|
||||||
if (q_N(lastErrMsg)) thrM("•CurrentError: Not currently within any ⎊");
|
if (q_N(lastErrMsg)) thrM("•CurrentError𝕩: Not currently within any ⎊");
|
||||||
return inc(lastErrMsg);
|
return inc(lastErrMsg);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
B currentError_c1(B t, B x) { thrM("•CurrentError: No errors as error catching has been disabled"); }
|
B currentError_c1(B t, B x) { thrM("•CurrentError𝕩: No errors as error catching has been disabled"); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC_GLOBAL Body* hashmap_ns;
|
STATIC_GLOBAL Body* hashmap_ns;
|
||||||
@ -759,9 +759,9 @@ static NOINLINE void hashmap_init() {
|
|||||||
hashmap_valuesDesc = registerNFn(m_c8vec_0("(hashmap).Values"), hashmap_values_c1, c2_bad);
|
hashmap_valuesDesc = registerNFn(m_c8vec_0("(hashmap).Values"), hashmap_values_c1, c2_bad);
|
||||||
}
|
}
|
||||||
B hashMap_c2(B t, B w, B x) {
|
B hashMap_c2(B t, B w, B x) {
|
||||||
if (!isArr(w) || RNK(w)!=1 || !isArr(x) || RNK(x)!=1) thrF("•HashMap: Arguments must be lists (%H≡≢𝕨, %H≡≢𝕩)", w, x);
|
if (!isArr(w) || RNK(w)!=1 || !isArr(x) || RNK(x)!=1) thrF("𝕨•HashMap𝕩: Arguments must be lists (%H≡≢𝕨, %H≡≢𝕩)", w, x);
|
||||||
usz n = IA(w);
|
usz n = IA(w);
|
||||||
if (n != IA(x)) thrF("•HashMap: 𝕨 and 𝕩 must have the same length (%s≡≠𝕨, %s≡≠𝕩)", n, IA(x));
|
if (n != IA(x)) thrF("𝕨•HashMap𝕩: 𝕨 and 𝕩 must have the same length (%s≡≠𝕨, %s≡≠𝕩)", n, IA(x));
|
||||||
if (hashmap_ns==NULL) hashmap_init();
|
if (hashmap_ns==NULL) hashmap_init();
|
||||||
w = taga(toHArr(w)); x = taga(toHArr(x));
|
w = taga(toHArr(w)); x = taga(toHArr(x));
|
||||||
B h = hashmap_build(w, n);
|
B h = hashmap_build(w, n);
|
||||||
@ -786,7 +786,7 @@ B fchars_c1(B d, B x) {
|
|||||||
return path_chars(path_rel(nfn_objU(d), x, "•file.Chars"));
|
return path_chars(path_rel(nfn_objU(d), x, "•file.Chars"));
|
||||||
}
|
}
|
||||||
B fchars_c2(B d, B w, B x) {
|
B fchars_c2(B d, B w, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) thrM("•file.Chars: 𝕩 must be a list of characters");
|
if (isAtm(x) || RNK(x)!=1) thrM("𝕨•file.Chars𝕩: 𝕩 must be a list of characters");
|
||||||
B p = path_rel(nfn_objU(d), w, "•file.Chars");
|
B p = path_rel(nfn_objU(d), w, "•file.Chars");
|
||||||
path_wChars(incG(p), x);
|
path_wChars(incG(p), x);
|
||||||
decG(x);
|
decG(x);
|
||||||
@ -802,7 +802,7 @@ B fbytes_c1(B d, B x) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
B fbytes_c2(B d, B w, B x) {
|
B fbytes_c2(B d, B w, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) thrM("•file.Bytes: 𝕩 must be a list");
|
if (isAtm(x) || RNK(x)!=1) thrM("𝕨•file.Bytes𝕩: 𝕩 must be a list");
|
||||||
B p = path_rel(nfn_objU(d), w, "•file.Bytes");
|
B p = path_rel(nfn_objU(d), w, "•file.Bytes");
|
||||||
path_wBytes(incG(p), x);
|
path_wBytes(incG(p), x);
|
||||||
decG(x);
|
decG(x);
|
||||||
@ -813,13 +813,13 @@ B flines_c1(B d, B x) {
|
|||||||
return path_lines(path_rel(nfn_objU(d), x, "•file.Lines"));
|
return path_lines(path_rel(nfn_objU(d), x, "•file.Lines"));
|
||||||
}
|
}
|
||||||
B flines_c2(B d, B w, B x) {
|
B flines_c2(B d, B w, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) thrM("•file.Lines: 𝕩 must be a list");
|
if (isAtm(x) || RNK(x)!=1) thrM("𝕨•file.Lines𝕩: 𝕩 must be a list");
|
||||||
B s = emptyCVec();
|
B s = emptyCVec();
|
||||||
usz ia = IA(x);
|
usz ia = IA(x);
|
||||||
SGet(x)
|
SGet(x)
|
||||||
for (u64 i = 0; i < ia; i++) {
|
for (u64 i = 0; i < ia; i++) {
|
||||||
B l = Get(x, i);
|
B l = Get(x, i);
|
||||||
if (isAtm(l) || RNK(l)!=1) thrM("•file.Lines: Elements of 𝕩 must be lists of characters");
|
if (isAtm(l) || RNK(l)!=1) thrM("𝕨•file.Lines𝕩: Elements of 𝕩 must be lists of characters");
|
||||||
s = vec_join(s, l);
|
s = vec_join(s, l);
|
||||||
//if (windows) s = vec_add(s, m_c32('\r')); TODO figure out whether or not this is a thing that should be done
|
//if (windows) s = vec_add(s, m_c32('\r')); TODO figure out whether or not this is a thing that should be done
|
||||||
s = vec_addN(s, m_c32('\n'));
|
s = vec_addN(s, m_c32('\n'));
|
||||||
@ -850,7 +850,7 @@ B import_c1(B d, B x) {
|
|||||||
B tag_none = tagu64(100000000, C32_TAG);
|
B tag_none = tagu64(100000000, C32_TAG);
|
||||||
B tag_running = tagu64(100000001, C32_TAG);
|
B tag_running = tagu64(100000001, C32_TAG);
|
||||||
B prevVal = c2(ns_getC(map, "get"), tag_none, incG(path));
|
B prevVal = c2(ns_getC(map, "get"), tag_none, incG(path));
|
||||||
if (prevVal.u == tag_running.u) thrF("•Import: cyclic import of \"%R\"", path);
|
if (prevVal.u == tag_running.u) thrF("•Import𝕩: cyclic import of \"%R\"", path);
|
||||||
if (prevVal.u != tag_none.u) {
|
if (prevVal.u != tag_none.u) {
|
||||||
// print_fmt("cached: %R @ %i/%i\n", path, prevIdx, IA(importKeyList));
|
// print_fmt("cached: %R @ %i/%i\n", path, prevIdx, IA(importKeyList));
|
||||||
decG(path);
|
decG(path);
|
||||||
@ -892,7 +892,7 @@ B list_c1(B d, B x) {
|
|||||||
B createdir_c1(B d, B x) {
|
B createdir_c1(B d, B x) {
|
||||||
B p = path_rel(nfn_objU(d), x, "•file.CreateDir");
|
B p = path_rel(nfn_objU(d), x, "•file.CreateDir");
|
||||||
if (dir_create(p)) return p;
|
if (dir_create(p)) return p;
|
||||||
thrM("•file.CreateDir: Failed to create directory");
|
thrM("•file.CreateDir𝕩: Failed to create directory");
|
||||||
}
|
}
|
||||||
B realpath_c1(B d, B x) {
|
B realpath_c1(B d, B x) {
|
||||||
return path_abs(path_rel(nfn_objU(d), x, "•file.RealPath"));
|
return path_abs(path_rel(nfn_objU(d), x, "•file.RealPath"));
|
||||||
@ -902,17 +902,17 @@ B rename_c2(B d, B w, B x) {
|
|||||||
d = nfn_objU(d);
|
d = nfn_objU(d);
|
||||||
B p = path_rel(d, w, "•file.Rename");
|
B p = path_rel(d, w, "•file.Rename");
|
||||||
if (path_rename(path_rel(d, x, "•file.Rename"), p)) return p;
|
if (path_rename(path_rel(d, x, "•file.Rename"), p)) return p;
|
||||||
thrM("•file.Rename: Failed to rename file");
|
thrM("𝕨•file.Rename𝕩: Failed to rename file");
|
||||||
}
|
}
|
||||||
|
|
||||||
B remove_c1(B d, B x) {
|
B remove_c1(B d, B x) {
|
||||||
if (path_remove(path_rel(nfn_objU(d), x, "•file.Remove"))) return m_i32(1);
|
if (path_remove(path_rel(nfn_objU(d), x, "•file.Remove"))) return m_i32(1);
|
||||||
thrM("•file.Remove: Failed to remove file");
|
thrM("•file.Remove𝕩: Failed to remove file");
|
||||||
}
|
}
|
||||||
|
|
||||||
B ftype_c1(B d, B x) {
|
B ftype_c1(B d, B x) {
|
||||||
char ty = path_type(path_rel(nfn_objU(d), x, "•file.Type"));
|
char ty = path_type(path_rel(nfn_objU(d), x, "•file.Type"));
|
||||||
if (ty==0) thrM("•file.Type: Error while accessing file");
|
if (ty==0) thrM("•file.Type𝕩: Error while accessing file");
|
||||||
return m_c32(ty);
|
return m_c32(ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,11 +927,11 @@ B fexists_c1(B d, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B fName_c1(B t, B x) {
|
B fName_c1(B t, B x) {
|
||||||
if (!isStr(x)) thrM("•file.Name: Argument must be a string");
|
if (!isStr(x)) thrM("•file.Name𝕩: Argument must be a string");
|
||||||
return path_name(x);
|
return path_name(x);
|
||||||
}
|
}
|
||||||
B fParent_c1(B t, B x) {
|
B fParent_c1(B t, B x) {
|
||||||
if (!isStr(x)) thrM("•file.Parent: Argument must be a string");
|
if (!isStr(x)) thrM("•file.Parent𝕩: Argument must be a string");
|
||||||
return path_parent(x);
|
return path_parent(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -951,7 +951,7 @@ B monoTime_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
B delay_c1(B t, B x) {
|
B delay_c1(B t, B x) {
|
||||||
f64 sf = o2f(x);
|
f64 sf = o2f(x);
|
||||||
if (sf<0 || sf>1ULL<<63) thrF("•Delay: Bad argument: %f", sf);
|
if (sf<0 || sf>1ULL<<63) thrF("•Delay𝕩: Bad argument: %f", sf);
|
||||||
struct timespec ts,ts0;
|
struct timespec ts,ts0;
|
||||||
u64 s = (u64)sf;
|
u64 s = (u64)sf;
|
||||||
ts.tv_sec = (u64)sf;
|
ts.tv_sec = (u64)sf;
|
||||||
@ -985,7 +985,7 @@ B getLine_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B fromUtf8_c1(B t, B x) {
|
B fromUtf8_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) thrM("•FromUTF8: Argument must be a character or number list");
|
if (isAtm(x) || RNK(x)!=1) thrM("•FromUTF8𝕩: 𝕩 must be a character or number list");
|
||||||
usz ia = IA(x);
|
usz ia = IA(x);
|
||||||
TALLOC(char, chrs, ia);
|
TALLOC(char, chrs, ia);
|
||||||
SGetU(x)
|
SGetU(x)
|
||||||
@ -993,11 +993,11 @@ B fromUtf8_c1(B t, B x) {
|
|||||||
B c = GetU(x,i);
|
B c = GetU(x,i);
|
||||||
if (isC32(c)) {
|
if (isC32(c)) {
|
||||||
u32 v = o2cG(c);
|
u32 v = o2cG(c);
|
||||||
if (v>=256) thrF("•FromUTF8: Argument contained a character with codepoint %i", v);
|
if (v>=256) thrF("•FromUTF8𝕩: 𝕩 contained a character with codepoint %i", v);
|
||||||
chrs[i] = v;
|
chrs[i] = v;
|
||||||
} else {
|
} else {
|
||||||
i32 v = o2i(c);
|
i32 v = o2i(c);
|
||||||
if (v<=-128 | v>=256) thrF("•FromUTF8: Argument contained the number %i", v);
|
if (v<=-128 | v>=256) thrF("•FromUTF8𝕩: 𝕩 contained the number %i", v);
|
||||||
chrs[i] = v&0xff;
|
chrs[i] = v&0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1008,7 +1008,7 @@ B fromUtf8_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B toUtf8_c1(B t, B x) {
|
B toUtf8_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) thrM("•ToUTF8: Argument must be a character or number list");
|
if (isAtm(x) || RNK(x)!=1) thrM("•ToUTF8𝕩: 𝕩 must be a character or number list");
|
||||||
u64 len = utf8lenB(x);
|
u64 len = utf8lenB(x);
|
||||||
u8* rp; B r = m_c8arrv(&rp, len);
|
u8* rp; B r = m_c8arrv(&rp, len);
|
||||||
toUTF8(x, (char*)rp);
|
toUTF8(x, (char*)rp);
|
||||||
@ -1038,7 +1038,7 @@ static i32 sh_core(bool raw, B x, usz xia, B inObj, u64 iLen, B* s_outp, B* s_er
|
|||||||
SGetU(x)
|
SGetU(x)
|
||||||
for (u64 i = 0; i < xia; i++) {
|
for (u64 i = 0; i < xia; i++) {
|
||||||
B c = GetU(x, i);
|
B c = GetU(x, i);
|
||||||
if (isAtm(c) || RNK(c)!=1) thrM("•SH: 𝕩 must be a list of strings");
|
if (isAtm(c) || RNK(c)!=1) thrM("•SH𝕩: 𝕩 must be a list of strings");
|
||||||
u64 len = utf8lenB(c);
|
u64 len = utf8lenB(c);
|
||||||
TALLOC(char, cstr, len+1);
|
TALLOC(char, cstr, len+1);
|
||||||
toUTF8(c, cstr);
|
toUTF8(c, cstr);
|
||||||
@ -1051,7 +1051,7 @@ static i32 sh_core(bool raw, B x, usz xia, B inObj, u64 iLen, B* s_outp, B* s_er
|
|||||||
int p_in[2];
|
int p_in[2];
|
||||||
int p_out[2];
|
int p_out[2];
|
||||||
int p_err[2];
|
int p_err[2];
|
||||||
if (pipe(p_in) || pipe(p_out) || pipe(p_err)) thrM("•SH: Failed to create process: Couldn't create pipes"); // TODO these pipes will easily leak
|
if (pipe(p_in) || pipe(p_out) || pipe(p_err)) thrM("•SH𝕩: Failed to create process: Couldn't create pipes"); // TODO these pipes will easily leak
|
||||||
shDbg("pipes: %d %d %d %d %d %d\n", p_in[0], p_in[1], p_out[0], p_out[1], p_err[0], p_err[1]);
|
shDbg("pipes: %d %d %d %d %d %d\n", p_in[0], p_in[1], p_out[0], p_out[1], p_err[0], p_err[1]);
|
||||||
fcntl(p_in[1], F_SETFL, O_NONBLOCK); // make our side of pipes never block because we're working on multiple
|
fcntl(p_in[1], F_SETFL, O_NONBLOCK); // make our side of pipes never block because we're working on multiple
|
||||||
fcntl(p_out[0], F_SETFL, O_NONBLOCK);
|
fcntl(p_out[0], F_SETFL, O_NONBLOCK);
|
||||||
@ -1065,7 +1065,7 @@ static i32 sh_core(bool raw, B x, usz xia, B inObj, u64 iLen, B* s_outp, B* s_er
|
|||||||
|
|
||||||
// spawn the actual process
|
// spawn the actual process
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
if(posix_spawnp(&pid, argv[0], &a, NULL, argv, environ) != 0) thrF("•SH: Failed to create process: %S", strerror(errno));
|
if(posix_spawnp(&pid, argv[0], &a, NULL, argv, environ) != 0) thrF("•SH𝕩: Failed to create process: %S", strerror(errno));
|
||||||
posix_spawn_file_actions_destroy(&a); // used now
|
posix_spawn_file_actions_destroy(&a); // used now
|
||||||
shClose(p_in[0]); // close the useless pipes on this side
|
shClose(p_in[0]); // close the useless pipes on this side
|
||||||
shClose(p_out[1]);
|
shClose(p_out[1]);
|
||||||
@ -1163,7 +1163,7 @@ static i32 sh_core(bool raw, B x, usz xia, B inObj, u64 iLen, B* s_outp, B* s_er
|
|||||||
SGetU(x)
|
SGetU(x)
|
||||||
for (u64 i = 0; i < xia; i++) {
|
for (u64 i = 0; i < xia; i++) {
|
||||||
B c = GetU(x, i);
|
B c = GetU(x, i);
|
||||||
if (isAtm(c) || RNK(c)!=1) thrM("•SH: 𝕩 must be a list of strings");
|
if (isAtm(c) || RNK(c)!=1) thrM("•SH𝕩: 𝕩 must be a list of strings");
|
||||||
u64 len = utf16lenB(c);
|
u64 len = utf16lenB(c);
|
||||||
TALLOC(WCHAR, wstr, len);
|
TALLOC(WCHAR, wstr, len);
|
||||||
toUTF16(c, wstr);
|
toUTF16(c, wstr);
|
||||||
@ -1214,7 +1214,7 @@ static i32 sh_core(bool raw, B x, usz xia, B inObj, u64 iLen, B* s_outp, B* s_er
|
|||||||
if (iLen>0) { if (raw) free_chars(iBufRaw); else TFREE(iBuf); } // FREE_INPUT
|
if (iLen>0) { if (raw) free_chars(iBufRaw); else TFREE(iBuf); } // FREE_INPUT
|
||||||
TSFREE(arg);
|
TSFREE(arg);
|
||||||
if (dwResult != ERROR_SUCCESS) {
|
if (dwResult != ERROR_SUCCESS) {
|
||||||
thrF("•SH: Failed to run command: %S", winErrorEx(dwResult));
|
thrF("•SH𝕩: Failed to run command: %S", winErrorEx(dwResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepare output
|
// prepare output
|
||||||
@ -1242,17 +1242,17 @@ static i32 sh_core(bool raw, B x, usz xia, B inObj, u64 iLen, B* s_outp, B* s_er
|
|||||||
B inObj = bi_N;
|
B inObj = bi_N;
|
||||||
bool raw = false;
|
bool raw = false;
|
||||||
if (!q_N(w)) {
|
if (!q_N(w)) {
|
||||||
if (!isNsp(w)) thrM("•SH: 𝕨 must be a namespace");
|
if (!isNsp(w)) thrM("𝕨•SH𝕩: 𝕨 must be a namespace");
|
||||||
inObj = ns_getC(w, "stdin");
|
inObj = ns_getC(w, "stdin");
|
||||||
if (!q_N(inObj) && !isArr(inObj)) thrM("•SH: Invalid stdin value");
|
if (!q_N(inObj) && !isArr(inObj)) thrM("𝕨•SH𝕩: Invalid stdin value");
|
||||||
B rawObj = ns_getC(w, "raw");
|
B rawObj = ns_getC(w, "raw");
|
||||||
if (!q_N(rawObj)) raw = o2b(rawObj);
|
if (!q_N(rawObj)) raw = o2b(rawObj);
|
||||||
}
|
}
|
||||||
u64 iLen = q_N(inObj)? 0 : (raw? IA(inObj) : utf8lenB(inObj));
|
u64 iLen = q_N(inObj)? 0 : (raw? IA(inObj) : utf8lenB(inObj));
|
||||||
|
|
||||||
if (isAtm(x) || RNK(x)>1) thrM("•SH: 𝕩 must be a list of strings");
|
if (isAtm(x) || RNK(x)>1) thrM("𝕨•SH𝕩: 𝕩 must be a list of strings");
|
||||||
usz xia = IA(x);
|
usz xia = IA(x);
|
||||||
if (xia==0) thrM("•SH: 𝕩 must have at least one item");
|
if (xia==0) thrM("𝕨•SH𝕩: 𝕩 must have at least one item");
|
||||||
|
|
||||||
B s_out, s_err;
|
B s_out, s_err;
|
||||||
i32 code = sh_core(raw, x, xia, inObj, iLen, &s_out, &s_err);
|
i32 code = sh_core(raw, x, xia, inObj, iLen, &s_out, &s_err);
|
||||||
@ -1270,7 +1270,7 @@ static i32 sh_core(bool raw, B x, usz xia, B inObj, u64 iLen, B* s_outp, B* s_er
|
|||||||
return m_hvec3(m_i32(code), s_outObj, s_errObj);
|
return m_hvec3(m_i32(code), s_outObj, s_errObj);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
B sh_c2(B t, B w, B x) { thrM("•SH: CBQN was compiled without <spawn.h>"); }
|
B sh_c2(B t, B w, B x) { thrM("𝕨•SH𝕩: CBQN was compiled without <spawn.h>"); }
|
||||||
#endif
|
#endif
|
||||||
B sh_c1(B t, B x) { return sh_c2(t, bi_N, x); }
|
B sh_c1(B t, B x) { return sh_c2(t, bi_N, x); }
|
||||||
|
|
||||||
@ -1315,8 +1315,8 @@ B tCharN_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
B tRawMode_c1(B t, B x) { thrM("•term.RawMode not available"); }
|
B tRawMode_c1(B t, B x) { thrM("•term.RawMode𝕩: •term.RawMode not available"); }
|
||||||
B tCharN_c1(B t, B x) { thrM("•term.CharN not available"); }
|
B tCharN_c1(B t, B x) { thrM("•term.CharN𝕩: •term.CharN not available"); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
B tCharB_c1(B t, B x) {
|
B tCharB_c1(B t, B x) {
|
||||||
@ -1330,12 +1330,12 @@ B tFlush_c1(B t, B x) {
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
B tOutRaw_c1(B t, B x) {
|
B tOutRaw_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) thrM("•term.OutRaw: 𝕩 must be a list");
|
if (isAtm(x) || RNK(x)!=1) thrM("•term.OutRaw𝕩: 𝕩 must be a list");
|
||||||
file_wBytes(stdout, "stdout", x);
|
file_wBytes(stdout, "stdout", x);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
B tErrRaw_c1(B t, B x) {
|
B tErrRaw_c1(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) thrM("•term.ErrRaw: 𝕩 must be a list");
|
if (isAtm(x) || RNK(x)!=1) thrM("•term.ErrRaw𝕩: 𝕩 must be a list");
|
||||||
file_wBytes(stderr, "stderr", x);
|
file_wBytes(stderr, "stderr", x);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
@ -1374,7 +1374,7 @@ static NOINLINE B name_normalize(B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B nKeys_c1(B t, B x) {
|
B nKeys_c1(B t, B x) {
|
||||||
if (!isNsp(x)) thrM("•ns.Keys: 𝕩 must be a namespace");
|
if (!isNsp(x)) thrM("•ns.Keys𝕩: 𝕩 must be a namespace");
|
||||||
NSDesc* desc = c(NS,x)->desc;
|
NSDesc* desc = c(NS,x)->desc;
|
||||||
ux am = desc->varAm;
|
ux am = desc->varAm;
|
||||||
ux eam = 0;
|
ux eam = 0;
|
||||||
@ -1389,7 +1389,7 @@ B nKeys_c1(B t, B x) {
|
|||||||
return r.b;
|
return r.b;
|
||||||
}
|
}
|
||||||
B nGet_c2(B t, B w, B x) {
|
B nGet_c2(B t, B w, B x) {
|
||||||
if (!isNsp(w)) thrM("•ns.Get: 𝕨 must be a namespace");
|
if (!isNsp(w)) thrM("𝕨•ns.Get𝕩: 𝕨 must be a namespace");
|
||||||
vfyStr(x, "•ns.Get", "𝕩");
|
vfyStr(x, "•ns.Get", "𝕩");
|
||||||
x = name_normalize(x);
|
x = name_normalize(x);
|
||||||
B r = ns_getNU(w, x, true);
|
B r = ns_getNU(w, x, true);
|
||||||
@ -1397,7 +1397,7 @@ B nGet_c2(B t, B w, B x) {
|
|||||||
return inc(r);
|
return inc(r);
|
||||||
}
|
}
|
||||||
B nHas_c2(B t, B w, B x) {
|
B nHas_c2(B t, B w, B x) {
|
||||||
if (!isNsp(w)) thrM("•ns.Has: 𝕨 must be a namespace");
|
if (!isNsp(w)) thrM("𝕨•ns.Has𝕩: 𝕨 must be a namespace");
|
||||||
vfyStr(x, "•ns.Has", "𝕩");
|
vfyStr(x, "•ns.Has", "𝕩");
|
||||||
x = name_normalize(x);
|
x = name_normalize(x);
|
||||||
B r = ns_getNU(w, x, false);
|
B r = ns_getNU(w, x, false);
|
||||||
@ -1426,19 +1426,19 @@ static CastType getCastType(B e, bool hasVal, B val) { // returns a valid type (
|
|||||||
usz s; bool c;
|
usz s; bool c;
|
||||||
if (isNum(e)) {
|
if (isNum(e)) {
|
||||||
s = o2s(e);
|
s = o2s(e);
|
||||||
if (s!=1 && s!=8 && s!=16 && s!=32 && s!=64) thrF("•bit._cast: unsupported width %s", s);
|
if (s!=1 && s!=8 && s!=16 && s!=32 && s!=64) thrF("•bit._cast𝕩: unsupported width %s", s);
|
||||||
c = hasVal? isCharArr(val) : 0;
|
c = hasVal? isCharArr(val) : 0;
|
||||||
} else {
|
} else {
|
||||||
if (!isArr(e) || RNK(e)!=1 || IA(e)!=2) thrM("•bit._cast: 𝕗 elements must be numbers or two-element lists");
|
if (!isArr(e) || RNK(e)!=1 || IA(e)!=2) thrM("•bit._cast𝕩: 𝕗 elements must be numbers or two-element lists");
|
||||||
SGetU(e)
|
SGetU(e)
|
||||||
s = o2s(GetU(e,0));
|
s = o2s(GetU(e,0));
|
||||||
u32 t = o2c(GetU(e,1));
|
u32 t = o2c(GetU(e,1));
|
||||||
c = t=='c';
|
c = t=='c';
|
||||||
if (c ) { if (s!=8 && s!=16 && s!=32) { badWidth: thrF("•bit._cast: unsupported width %s for type '%c'", s, (char)t); } }
|
if (c ) { if (s!=8 && s!=16 && s!=32) { badWidth: thrF("•bit._cast𝕩: unsupported width %s for type '%c'", s, (char)t); } }
|
||||||
else if (t=='i') { if (s!=8 && s!=16 && s!=32) goto badWidth; }
|
else if (t=='i') { if (s!=8 && s!=16 && s!=32) goto badWidth; }
|
||||||
else if (t=='u') { if (s!=1) goto badWidth; }
|
else if (t=='u') { if (s!=1) goto badWidth; }
|
||||||
else if (t=='f') { if (s!=64) goto badWidth; }
|
else if (t=='f') { if (s!=64) goto badWidth; }
|
||||||
else thrM("•bit._cast: type descriptor in 𝕗 must be one of \"iufnc\"");
|
else thrM("•bit._cast𝕩: type descriptor in 𝕗 must be one of \"iufnc\"");
|
||||||
|
|
||||||
}
|
}
|
||||||
return (CastType) { s, c };
|
return (CastType) { s, c };
|
||||||
@ -1495,14 +1495,14 @@ static B set_bit_result(B r, u8 rt, ur rr, usz rl, usz *sh) {
|
|||||||
|
|
||||||
B bitcast_impl(B el0, B el1, B x) {
|
B bitcast_impl(B el0, B el1, B x) {
|
||||||
ur xr;
|
ur xr;
|
||||||
if (!isArr(x) || (xr=RNK(x))<1) thrM("•bit._cast: 𝕩 must have rank at least 1");
|
if (!isArr(x) || (xr=RNK(x))<1) thrM("•bit._cast𝕩: 𝕩 must have rank at least 1");
|
||||||
|
|
||||||
CastType xct = getCastType(el0, true, x);
|
CastType xct = getCastType(el0, true, x);
|
||||||
CastType rct = getCastType(el1, false, m_f64(0));
|
CastType rct = getCastType(el1, false, m_f64(0));
|
||||||
usz* sh = SH(x);
|
usz* sh = SH(x);
|
||||||
u64 s=xct.s*(u64)sh[xr-1], rl=s/rct.s;
|
u64 s=xct.s*(u64)sh[xr-1], rl=s/rct.s;
|
||||||
if (rl*rct.s != s) thrM("•bit._cast: incompatible lengths");
|
if (rl*rct.s != s) thrM("•bit._cast𝕩: incompatible lengths");
|
||||||
if (rl>=USZ_MAX) thrM("•bit._cast: output too large");
|
if (rl>=USZ_MAX) thrM("•bit._cast𝕩: output too large");
|
||||||
B r = convert(xct, x);
|
B r = convert(xct, x);
|
||||||
u8 rt = typeOfCast(rct);
|
u8 rt = typeOfCast(rct);
|
||||||
if (rt==t_bitarr && (v(r)->refc!=1 || IS_SLICE(TY(r)))) {
|
if (rt==t_bitarr && (v(r)->refc!=1 || IS_SLICE(TY(r)))) {
|
||||||
@ -1522,12 +1522,12 @@ B bitcast_impl(B el0, B el1, B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B bitcast_c1(Md1D* d, B x) { B f = d->f;
|
B bitcast_c1(Md1D* d, B x) { B f = d->f;
|
||||||
if (!isArr(f) || RNK(f)!=1 || IA(f)!=2) thrM("•bit._cast: 𝕗 must be a 2-element list (from‿to)");
|
if (!isArr(f) || RNK(f)!=1 || IA(f)!=2) thrM("•bit._cast𝕩: 𝕗 must be a 2-element list (from‿to)");
|
||||||
SGetU(f)
|
SGetU(f)
|
||||||
return bitcast_impl(GetU(f,0), GetU(f,1), x);
|
return bitcast_impl(GetU(f,0), GetU(f,1), x);
|
||||||
}
|
}
|
||||||
B bitcast_im(Md1D* d, B x) { B f = d->f;
|
B bitcast_im(Md1D* d, B x) { B f = d->f;
|
||||||
if (!isArr(f) || RNK(f)!=1 || IA(f)!=2) thrM("•bit._cast: 𝕗 must be a 2-element list (from‿to)");
|
if (!isArr(f) || RNK(f)!=1 || IA(f)!=2) thrM("•bit._cast𝕩: 𝕗 must be a 2-element list (from‿to)");
|
||||||
SGetU(f)
|
SGetU(f)
|
||||||
return bitcast_impl(GetU(f,1), GetU(f,0), x);
|
return bitcast_impl(GetU(f,1), GetU(f,0), x);
|
||||||
}
|
}
|
||||||
@ -1787,12 +1787,12 @@ B indexOf_c2(B t, B w, B x);
|
|||||||
GLOBAL bool fileInit;
|
GLOBAL bool fileInit;
|
||||||
|
|
||||||
|
|
||||||
B invalidFn_c1 (B t, B x) { thrM("Using an invalid function"); }
|
B invalidFn_c1 (B t, B x) { thrM("Fn𝕩: Using an invalid function"); }
|
||||||
B invalidFn_c2 (B t, B w, B x) { thrM("Using an invalid function"); }
|
B invalidFn_c2 (B t, B w, B x) { thrM("𝕨Fn𝕩: Using an invalid function"); }
|
||||||
B invalidMd1_c1(Md1D* d, B x) { thrM("Using an invalid 1-modifier"); }
|
B invalidMd1_c1(Md1D* d, B x) { thrM("_Mod𝕩: Using an invalid 1-modifier"); }
|
||||||
B invalidMd1_c2(Md1D* d, B w, B x) { thrM("Using an invalid 1-modifier"); }
|
B invalidMd1_c2(Md1D* d, B w, B x) { thrM("𝕨_Mod𝕩: Using an invalid 1-modifier"); }
|
||||||
B invalidMd2_c1(Md2D* d, B x) { thrM("Using an invalid 2-modifier"); }
|
B invalidMd2_c1(Md2D* d, B x) { thrM("_Mod_𝕩: Using an invalid 2-modifier"); }
|
||||||
B invalidMd2_c2(Md2D* d, B w, B x) { thrM("Using an invalid 2-modifier"); }
|
B invalidMd2_c2(Md2D* d, B w, B x) { thrM("𝕨_Mod_𝕩: Using an invalid 2-modifier"); }
|
||||||
|
|
||||||
static NOINLINE void initSysDesc() {
|
static NOINLINE void initSysDesc() {
|
||||||
if (fileInit) return;
|
if (fileInit) return;
|
||||||
|
|||||||
@ -269,26 +269,26 @@ static void shSet(Arr* ra, ur rr, ShArr* sh) {
|
|||||||
B transp_c2(B t, B w, B x) {
|
B transp_c2(B t, B w, B x) {
|
||||||
usz wia=1;
|
usz wia=1;
|
||||||
if (isArr(w)) {
|
if (isArr(w)) {
|
||||||
if (RNK(w)>1) thrM("⍉: 𝕨 must have rank at most 1");
|
if (RNK(w)>1) thrM("𝕨⍉𝕩: 𝕨 must have rank at most 1");
|
||||||
wia = IA(w);
|
wia = IA(w);
|
||||||
if (wia==0) { decG(w); return isArr(x)? x : m_unit(x); }
|
if (wia==0) { decG(w); return isArr(x)? x : m_unit(x); }
|
||||||
}
|
}
|
||||||
ur xr;
|
ur xr;
|
||||||
if (isAtm(x) || (xr=RNK(x))<wia) thrM("⍉: Length of 𝕨 must be at most rank of 𝕩");
|
if (isAtm(x) || (xr=RNK(x))<wia) thrM("𝕨⍉𝕩: Length of 𝕨 must be at most rank of 𝕩");
|
||||||
|
|
||||||
// Axis permutation
|
// Axis permutation
|
||||||
TALLOC(u8, alloc, xr*(sizeof(ur) + 3*sizeof(usz)) + sizeof(usz)); // ur* p, usz* rsh, usz* st, usz* ri
|
TALLOC(u8, alloc, xr*(sizeof(ur) + 3*sizeof(usz)) + sizeof(usz)); // ur* p, usz* rsh, usz* st, usz* ri
|
||||||
ur* p = (ur*)alloc;
|
ur* p = (ur*)alloc;
|
||||||
if (isAtm(w)) {
|
if (isAtm(w)) {
|
||||||
usz a=o2s(w);
|
usz a=o2s(w);
|
||||||
if (a>=xr) thrF("⍉: Axis %s does not exist (%i≡=𝕩)", a, xr);
|
if (a>=xr) thrF("𝕨⍉𝕩: Axis %s does not exist (%i≡=𝕩)", a, xr);
|
||||||
if (a==xr-1) { TFREE(alloc); return C1(transp, x); }
|
if (a==xr-1) { TFREE(alloc); return C1(transp, x); }
|
||||||
p[0] = a;
|
p[0] = a;
|
||||||
} else {
|
} else {
|
||||||
SGetU(w)
|
SGetU(w)
|
||||||
for (usz i=0; i<wia; i++) {
|
for (usz i=0; i<wia; i++) {
|
||||||
usz a=o2s(GetU(w, i));
|
usz a=o2s(GetU(w, i));
|
||||||
if (a>=xr) thrF("⍉: Axis %s does not exist (%i≡=𝕩)", a, xr);
|
if (a>=xr) thrF("𝕨⍉𝕩: Axis %s does not exist (%i≡=𝕩)", a, xr);
|
||||||
p[i] = a;
|
p[i] = a;
|
||||||
}
|
}
|
||||||
decG(w);
|
decG(w);
|
||||||
@ -314,7 +314,7 @@ B transp_c2(B t, B w, B x) {
|
|||||||
|
|
||||||
// Fill in remaining axes and check for missing ones
|
// Fill in remaining axes and check for missing ones
|
||||||
ur rr = xr-dup;
|
ur rr = xr-dup;
|
||||||
if (max >= rr) thrF("⍉: Skipped result axis");
|
if (max >= rr) thrF("𝕨⍉𝕩: Skipped result axis");
|
||||||
if (wia<xr) for (usz j=0, i=wia; j<rr; j++) if (rsh[j]==no_sh) {
|
if (wia<xr) for (usz j=0, i=wia; j<rr; j++) if (rsh[j]==no_sh) {
|
||||||
p[i] = j;
|
p[i] = j;
|
||||||
rsh[j] = xsh[i];
|
rsh[j] = xsh[i];
|
||||||
@ -461,7 +461,7 @@ B transp_c2(B t, B w, B x) {
|
|||||||
|
|
||||||
|
|
||||||
B transp_im(B t, B x) {
|
B transp_im(B t, B x) {
|
||||||
if (isAtm(x)) thrM("⍉⁼: 𝕩 must not be an atom");
|
if (isAtm(x)) thrM("⍉⁼𝕩: 𝕩 must not be an atom");
|
||||||
ur xr = RNK(x);
|
ur xr = RNK(x);
|
||||||
if (xr<=1) return x;
|
if (xr<=1) return x;
|
||||||
|
|
||||||
@ -493,23 +493,23 @@ B transp_uc1(B t, B o, B x) {
|
|||||||
// Consumes w; return bi_N if w contained duplicates
|
// Consumes w; return bi_N if w contained duplicates
|
||||||
static B invert_transp_w(B w, ur xr) {
|
static B invert_transp_w(B w, ur xr) {
|
||||||
if (isAtm(w)) {
|
if (isAtm(w)) {
|
||||||
if (xr<1) thrM("⍉⁼: Length of 𝕨 must be at most rank of 𝕩");
|
if (xr<1) thrM("𝕨⍉⁼𝕩: Length of 𝕨 must be at most rank of 𝕩");
|
||||||
usz a=o2s(w);
|
usz a=o2s(w);
|
||||||
if (a>=xr) thrF("⍉⁼: Axis %s does not exist (%i≡=𝕩)", a, xr);
|
if (a>=xr) thrF("𝕨⍉⁼𝕩: Axis %s does not exist (%i≡=𝕩)", a, xr);
|
||||||
i32* wp; w = m_i32arrv(&wp, a);
|
i32* wp; w = m_i32arrv(&wp, a);
|
||||||
PLAINLOOP for (usz i=0; i<a; i++) wp[i] = i+1;
|
PLAINLOOP for (usz i=0; i<a; i++) wp[i] = i+1;
|
||||||
} else {
|
} else {
|
||||||
if (RNK(w)>1) thrM("⍉⁼: 𝕨 must have rank at most 1");
|
if (RNK(w)>1) thrM("𝕨⍉⁼𝕩: 𝕨 must have rank at most 1");
|
||||||
usz wia = IA(w);
|
usz wia = IA(w);
|
||||||
if (wia==0) return w;
|
if (wia==0) return w;
|
||||||
if (xr<wia) thrM("⍉⁼: Length of 𝕨 must be at most rank of 𝕩");
|
if (xr<wia) thrM("𝕨⍉⁼𝕩: Length of 𝕨 must be at most rank of 𝕩");
|
||||||
SGetU(w)
|
SGetU(w)
|
||||||
TALLOC(ur, p, xr);
|
TALLOC(ur, p, xr);
|
||||||
for (usz i=0; i<xr; i++) p[i]=xr;
|
for (usz i=0; i<xr; i++) p[i]=xr;
|
||||||
usz max = 0;
|
usz max = 0;
|
||||||
for (usz i=0; i<wia; i++) {
|
for (usz i=0; i<wia; i++) {
|
||||||
usz a=o2s(GetU(w, i));
|
usz a=o2s(GetU(w, i));
|
||||||
if (a>=xr) thrF("⍉⁼: Axis %s does not exist (%i≡=𝕩)", a, xr);
|
if (a>=xr) thrF("𝕨⍉⁼𝕩: Axis %s does not exist (%i≡=𝕩)", a, xr);
|
||||||
if (p[a]!=xr) { TFREE(p); decG(w); return bi_N; } // Handled by caller
|
if (p[a]!=xr) { TFREE(p); decG(w); return bi_N; } // Handled by caller
|
||||||
max = a>max? a : max;
|
max = a>max? a : max;
|
||||||
p[a] = i;
|
p[a] = i;
|
||||||
@ -524,9 +524,9 @@ static B invert_transp_w(B w, ur xr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B transp_ix(B t, B w, B x) {
|
B transp_ix(B t, B w, B x) {
|
||||||
if (isAtm(x)) thrM("⍉⁼: 𝕩 must not be an atom");
|
if (isAtm(x)) thrM("𝕨⍉⁼𝕩: 𝕩 must not be an atom");
|
||||||
w = invert_transp_w(w, RNK(x));
|
w = invert_transp_w(w, RNK(x));
|
||||||
if (q_N(w)) thrM("⍉⁼: Duplicate axes");
|
if (q_N(w)) thrM("𝕨⍉⁼𝕩: Duplicate axes");
|
||||||
return C2(transp, w, x);
|
return C2(transp, w, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user