use errMd more
This commit is contained in:
parent
634cf82fbe
commit
d9007c3136
@ -208,7 +208,7 @@ B fold_c1(Md1D* d, B x) { B f = d->f;
|
||||
thrM("𝔽´𝕩: Identity not found");
|
||||
}
|
||||
}
|
||||
if (RARE(!isFun(f))) { decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); }
|
||||
if (RARE(!isFun(f))) { decG(x); return inc(errMd(f)); }
|
||||
u8 xe = TI(x,elType);
|
||||
if (RTID(f) != RTID_NONE) {
|
||||
u8 rtid = RTID(f);
|
||||
@ -279,7 +279,7 @@ B fold_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||
if (isAtm(x) || RNK(x)!=1) thrF("𝕨𝔽´𝕩: 𝕩 must be a list (%H ≡ ≢𝕩)", x);
|
||||
usz ia = IA(x);
|
||||
if (RARE(ia==0)) { decG(x); return w; }
|
||||
if (RARE(!isFun(f))) { dec(w); decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); }
|
||||
if (RARE(!isFun(f))) { dec(w); decG(x); return inc(errMd(f)); }
|
||||
|
||||
u8 xe = TI(x,elType);
|
||||
if (RTID(f) != RTID_NONE) {
|
||||
@ -477,7 +477,7 @@ B insert_c1(Md1D* d, B x) { B f = d->f;
|
||||
thrM("𝔽˝𝕩: Identity not found");
|
||||
}
|
||||
if (len==1) return C1(select, x);
|
||||
if (RARE(!isFun(f))) { decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); }
|
||||
if (RARE(!isFun(f))) { decG(x); return inc(errMd(f)); }
|
||||
if (isPervasiveDyExt(f)) {
|
||||
if (xr==1) return m_unit(fold_c1(d, x));
|
||||
usz xia = IA(x);
|
||||
@ -521,7 +521,7 @@ B insert_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||
if (isAtm(x) || (xr=RNK(x))==0) thrM("𝕨˝𝕩: 𝕩 must have rank at least 1");
|
||||
usz len = *SH(x);
|
||||
if (len==0) { decG(x); return w; }
|
||||
if (RARE(!isFun(f))) { dec(w); decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); }
|
||||
if (RARE(!isFun(f))) { dec(w); decG(x); return inc(errMd(f)); }
|
||||
if (isPervasiveDyExt(f)) {
|
||||
usz xia = IA(x);
|
||||
ur rr = xr - 1;
|
||||
|
||||
@ -247,7 +247,7 @@ B scan_c1(Md1D* d, B x) { B f = d->f;
|
||||
usz ia = IA(x); if (ia <= 1) { if (ia==1 && RNK(x)==0) goto unit; return x; }
|
||||
usz n = *SH(x); if (n <= 1) return x;
|
||||
if (RARE(!isFun(f))) {
|
||||
if (isMd(f)) thrM("Calling a modifier");
|
||||
errMd(f);
|
||||
B xf = getFillR(x);
|
||||
MAKE_MUT(rm, ia);
|
||||
usz csz = arr_csz(x);
|
||||
@ -367,8 +367,7 @@ B scan_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||
if (isArr(w)? !ptr_eqShape(SH(w), RNK(w), xsh+1, xr-1) : xr!=1) thrF("𝕨𝔽`𝕩: Shape of 𝕨 must match the cell of 𝕩 (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
|
||||
if (ia==0) { dec(w); return x; }
|
||||
if (RARE(!isFun(f))) {
|
||||
if (isMd(f)) thrM("Calling a modifier");
|
||||
Arr* ra = arr_shCopy(reshape_one(ia, inc(f)), x);
|
||||
Arr* ra = arr_shCopy(reshape_one(ia, inc(errMd(f))), x);
|
||||
B xf = getFillR(x);
|
||||
decG(x);
|
||||
return withFill(taga(ra), xf);
|
||||
|
||||
@ -40,12 +40,10 @@ NORETURN NOINLINE void fatal(char* s) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NOINLINE B c1F(B f, B x) { dec(x);
|
||||
if (isMd(f)) thrM("Calling a modifier");
|
||||
NOINLINE B c1F(B f, B x) { dec(x); errMd(f);
|
||||
return inc(VALIDATE(f));
|
||||
}
|
||||
NOINLINE B c2F(B f, B w, B x) { dec(w); dec(x);
|
||||
if (isMd(f)) thrM("Calling a modifier");
|
||||
NOINLINE B c2F(B f, B w, B x) { dec(w); dec(x); errMd(f);
|
||||
return inc(VALIDATE(f));
|
||||
}
|
||||
NOINLINE void value_freeF(Value* x) { value_free(x); }
|
||||
|
||||
16
src/h.h
16
src/h.h
@ -705,27 +705,25 @@ static B c2(B f, B w, B x) { // BQN-call f dyadically; consumes w,x
|
||||
if (isFun(f)) return VALIDATE(VRES(c(Fun,f)->c2(f, VRES(w), VRES(x))));
|
||||
return c2F(f, w, x);
|
||||
}
|
||||
static void errMd(B x) { if(RARE(isMd(x))) thrM("Calling a modifier"); }
|
||||
static B errMd(B x) { if (RARE(isMd(x))) thrM("Calling a modifier"); return x; }
|
||||
// like c1/c2, but with less overhead on non-functions
|
||||
SHOULD_INLINE B c1I(B f, B x) {
|
||||
if (isFun(f)) return VALIDATE(c(Fun,f)->c1(f, x));
|
||||
dec(x); errMd(f);
|
||||
return inc(f);
|
||||
dec(x);
|
||||
return inc(errMd(f));
|
||||
}
|
||||
SHOULD_INLINE B c2I(B f, B w, B x) {
|
||||
if (isFun(f)) return VALIDATE(c(Fun,f)->c2(f, w, x));
|
||||
dec(w); dec(x); errMd(f);
|
||||
return inc(f);
|
||||
dec(w); dec(x);
|
||||
return inc(errMd(f));
|
||||
}
|
||||
static B c1iX(B f, B x) { // c1 with inc(x)
|
||||
if (isFun(f)) return VALIDATE(c(Fun,f)->c1(f, inc(x)));
|
||||
errMd(f);
|
||||
return inc(f);
|
||||
return inc(errMd(f));
|
||||
}
|
||||
static B c2iWX(B f, B w, B x) { // c2 with inc(w), inc(x)
|
||||
if (isFun(f)) return VALIDATE(c(Fun,f)->c2(f, inc(w), inc(x)));
|
||||
errMd(f);
|
||||
return inc(f);
|
||||
return inc(errMd(f));
|
||||
}
|
||||
|
||||
static B c1G(B f, B x) { assert(isFun(f)); return c(Fun,f)->c1(f, x); }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user