decG more

found automatically via awful hack via GUARANTEED
This commit is contained in:
dzaima 2024-12-04 00:10:13 +02:00
parent 7a5f42a7f0
commit 162e6ff387
14 changed files with 42 additions and 42 deletions

View File

@ -842,7 +842,7 @@ NOINLINE B for_cells_AA(B f, B w, B x, ur wcr, ur xcr, u32 chr) { // w F⎉wcr
return c2(f, w, x); return c2(f, w, x);
} }
} else if (!isMd(f)) { } else if (!isMd(f)) {
dec(xkM? w : x); decG(xkM? w : x);
return const_cells(xkM? x : w, zk, zsh, inc(f), chr); return const_cells(xkM? x : w, zk, zsh, inc(f), chr);
} }
generic:; generic:;

View File

@ -197,7 +197,7 @@ B variation_c2(B t, B w, B x) {
if (slice) { if (slice) {
Arr* slice = TI(res,slice)(incG(res), 0, IA(res)); Arr* slice = TI(res,slice)(incG(res), 0, IA(res));
arr_shCopy(slice, res); arr_shCopy(slice, res);
dec(res); decG(res);
res = taga(slice); res = taga(slice);
} }
@ -218,7 +218,7 @@ B clearRefs_c1(B t, B x) {
dec(x); dec(x);
if (!isArr(variation_refs)) return m_f64(0); if (!isArr(variation_refs)) return m_f64(0);
usz res = IA(variation_refs); usz res = IA(variation_refs);
dec(variation_refs); decG(variation_refs);
variation_refs = m_f64(0); variation_refs = m_f64(0);
return m_f64(res); return m_f64(res);
} }
@ -396,7 +396,7 @@ B iProperties_c2(B t, B w, B x) {
B unshare_c1(B t, B x) { B unshare_c1(B t, B x) {
if (!isArr(x)) thrM("•internal.Unshare: Argument must be an array"); if (!isArr(x)) thrM("•internal.Unshare: Argument must be an array");
B r = unshare(x); B r = unshare(x);
dec(x); decG(x);
return r; return r;
} }
STATIC_GLOBAL B internalNS; STATIC_GLOBAL B internalNS;

View File

@ -427,7 +427,7 @@ static B recPick(B w, B x) { // doesn't consume
B pick_c2(B t, B w, B x) { B pick_c2(B t, B w, B x) {
if (RARE(isAtm(x))) { if (RARE(isAtm(x))) {
if (isArr(w) && RNK(w)==1 && IA(w)==0) { dec(w); return x; } if (isArr(w) && RNK(w)==1 && IA(w)==0) { decG(w); return x; }
x = m_unit(x); x = m_unit(x);
} }
if (isNum(w)) { if (isNum(w)) {
@ -465,7 +465,7 @@ FORCE_INLINE B affixes(B x, i32 post) {
shcpy(sh, csh, xr-1); shcpy(sh, csh, xr-1);
HARR_ADD(r, i, taga(c)); HARR_ADD(r, i, taga(c));
} }
dec(x); decG(x);
} }
B rf = incG(HARR_O(r).a[post? cam : 0]); B rf = incG(HARR_O(r).a[post? cam : 0]);
return withFill(HARR_FV(r), rf); return withFill(HARR_FV(r), rf);
@ -740,7 +740,7 @@ B join_c1(B t, B x) {
shcpy(sh+xr, fsh+xr, ir-xr); shcpy(sh+xr, fsh+xr, ir-xr);
} }
B xff = getFillR(xf); B xff = getFillR(xf);
dec(xf); decG(x); decG(xf); decG(x);
return withFill(r.b, xff); return withFill(r.b, xff);
} else if (xr==1) { } else if (xr==1) {
@ -1432,7 +1432,7 @@ static B takedrop_ucw(bool take, i64 wi, B o, u64 am, B x, ux xr) {
mut_copyG(r, tk, x, tk, lv); mut_copyG(r, tk, x, tk, lv);
} }
dec(rep); decG(rep);
return mut_fcd(r, x); return mut_fcd(r, x);
} }

View File

@ -53,8 +53,8 @@ B decp_c1(B t, B x) {
B primInd_c1(B t, B x) { B primInd_c1(B t, B x) {
if (!isVal(x)) return m_i32(RT_LEN); if (!isVal(x)) return m_i32(RT_LEN);
if (isPrim(x)) { B r = m_i32(RTID(x)); dec(x); return r; } if (isPrim(x)) { B r = m_i32(RTID(x)); decG(x); return r; }
dec(x); decG(x);
return m_i32(RT_LEN); return m_i32(RT_LEN);
} }
@ -232,21 +232,21 @@ B casrt_c2(B t, B w, B x) {
AFMT("\n"); AFMT("\n");
usz pos = o2s(w0); usz pos = o2s(w0);
s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, pos, pos+1); s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, pos, pos+1);
dec(w); decG(w);
thr(s); thr(s);
} }
if (isArr(w0) && RNK(w0)==1 && IA(w0)>=1) { if (isArr(w0) && RNK(w0)==1 && IA(w0)>=1) {
B s = IGet(w,1); AFMT("\n"); B s = IGet(w,1); AFMT("\n");
usz pos = o2s(IGetU(w0,0)); usz pos = o2s(IGetU(w0,0));
s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, pos, pos+1); s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, pos, pos+1);
dec(w); decG(w);
thr(s); thr(s);
} }
if (isArr(w0) && RNK(w0)==2 && IA(w0)>=2) { if (isArr(w0) && RNK(w0)==2 && IA(w0)>=2) {
B s = IGet(w,1); AFMT("\n"); B s = IGet(w,1); AFMT("\n");
SGetU(w0) SGetU(w0)
s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, o2s(GetU(w0,0)), o2s(GetU(w0,1))+1); s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, o2s(GetU(w0,0)), o2s(GetU(w0,1))+1);
dec(w); decG(w);
thr(s); thr(s);
} }
} }
@ -789,7 +789,7 @@ 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);
dec(x); decG(x);
return p; return p;
} }
STATIC_GLOBAL NFnDesc* fBytesDesc; STATIC_GLOBAL NFnDesc* fBytesDesc;
@ -805,7 +805,7 @@ 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);
dec(x); decG(x);
return p; return p;
} }
STATIC_GLOBAL NFnDesc* fLinesDesc; STATIC_GLOBAL NFnDesc* fLinesDesc;
@ -824,7 +824,7 @@ B flines_c2(B d, B w, B x) {
//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'));
} }
dec(x); decG(x);
B p = path_rel(nfn_objU(d), w, "•file.Lines"); B p = path_rel(nfn_objU(d), w, "•file.Lines");
path_wChars(incG(p), s); path_wChars(incG(p), s);
decG(s); decG(s);
@ -1012,7 +1012,7 @@ B toUtf8_c1(B t, B x) {
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);
dec(x); decG(x);
return r; return r;
} }
@ -1245,15 +1245,15 @@ static i32 sh_core(bool raw, B x, usz xia, B inObj, u64 iLen, B* s_outp, B* s_er
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);
dec(w); dec(x); dec(w); decG(x);
B s_outObj; B s_outRaw = toC8Any(s_out); B s_outObj; B s_outRaw = toC8Any(s_out);
B s_errObj; B s_errRaw = toC8Any(s_err); B s_errObj; B s_errRaw = toC8Any(s_err);
if (raw) { if (raw) {
s_outObj = s_outRaw; s_outObj = s_outRaw;
s_errObj = s_errRaw; s_errObj = s_errRaw;
} else { } else {
s_outObj = utf8Decode((char*)c8any_ptr(s_outRaw), IA(s_outRaw)); dec(s_outRaw); s_outObj = utf8Decode((char*)c8any_ptr(s_outRaw), IA(s_outRaw)); decG(s_outRaw);
s_errObj = utf8Decode((char*)c8any_ptr(s_errRaw), IA(s_errRaw)); dec(s_errRaw); s_errObj = utf8Decode((char*)c8any_ptr(s_errRaw), IA(s_errRaw)); decG(s_errRaw);
} }
return m_hvec3(m_i32(code), s_outObj, s_errObj); return m_hvec3(m_i32(code), s_outObj, s_errObj);
} }

View File

@ -458,7 +458,7 @@ B bqn_merge(B x, u32 type) {
shcpy (rsh , SH(x), xr); shcpy (rsh , SH(x), xr);
if(xfr)shcpy(rsh+xr, SH(xf), xfr); if(xfr)shcpy(rsh+xr, SH(xf), xfr);
} }
decG(x); dec(xf); decG(x); decG(xf);
return taga(r); return taga(r);
} }

View File

@ -9,7 +9,7 @@ static Arr* TP(m_,slice) (Arr* p, TEl* ptr, usz ia) {
return (Arr*)r; return (Arr*)r;
} }
static Arr* TP(,arr_slice) (B x, usz s, usz ia) { return TP(m_,slice) (a(x), ((TEl*)c(TyArr,x)->a)+s, ia); } static Arr* TP(,arr_slice) (B x, usz s, usz ia) { return TP(m_,slice) (a(x), ((TEl*)c(TyArr,x)->a)+s, ia); }
static Arr* TP(,slice_slice) (B x, usz s, usz ia) { Arr* p = ptr_inc(c(Slice,x)->p); Arr* r = TP(m_,slice) (p, ((TEl*)c(TySlice,x)->a)+s, ia); dec(x); return r; } static Arr* TP(,slice_slice) (B x, usz s, usz ia) { Arr* p = ptr_inc(c(Slice,x)->p); Arr* r = TP(m_,slice) (p, ((TEl*)c(TySlice,x)->a)+s, ia); decG(x); return r; }
static B TP(,arr_get) (Arr* x, usz n) { assert(PTY(x)==T_ARR ); return TP(m_,) (((TEl*)((TyArr* )x)->a)[n]); } static B TP(,arr_get) (Arr* x, usz n) { assert(PTY(x)==T_ARR ); return TP(m_,) (((TEl*)((TyArr* )x)->a)[n]); }
static B TP(,slice_get) (Arr* x, usz n) { assert(PTY(x)==T_SLICE); return TP(m_,) (((TEl*)((TySlice*)x)->a)[n]); } static B TP(,slice_get) (Arr* x, usz n) { assert(PTY(x)==T_SLICE); return TP(m_,) (((TEl*)((TySlice*)x)->a)[n]); }

View File

@ -650,7 +650,7 @@ NOINLINE B cpyF32Bits(B x) { // copy x to a 32-bit float array (output being an
B t = toF64Any(x); f64* tp = f64any_ptr(t); B t = toF64Any(x); f64* tp = f64any_ptr(t);
i32* rp; B r = m_i32arrv(&rp, ia); i32* rp; B r = m_i32arrv(&rp, ia);
vfor (usz i=0; i<ia; i++) ((f32*)rp)[i] = tp[i]; vfor (usz i=0; i<ia; i++) ((f32*)rp)[i] = tp[i];
dec(t); return r; decG(t); return r;
} }
// versions of cpyU(8|16|32)Bits, but without a guarantee of returning a new array; consumes argument // versions of cpyU(8|16|32)Bits, but without a guarantee of returning a new array; consumes argument
@ -792,7 +792,7 @@ void genObj(B o, B c, void* ptr, B* sourceObjs) { // doesn't consume
if (IA(c) != mul) thrF("FFI: Bad array corresponding to %R: expected %s elements, got %s", ty_fmt(o), (usz)mul, IA(c)); if (IA(c) != mul) thrF("FFI: Bad array corresponding to %R: expected %s elements, got %s", ty_fmt(o), (usz)mul, IA(c));
B cG = toW(reT, reW, incG(c)); B cG = toW(reT, reW, incG(c));
memcpy(ptr, tyany_ptr(cG), 8); // may over-read, but CBQN-allocations allow that; may write past the end, but that's fine too? maybe? idk actually; TODO memcpy(ptr, tyany_ptr(cG), 8); // may over-read, but CBQN-allocations allow that; may write past the end, but that's fine too? maybe? idk actually; TODO
dec(cG); decG(cG);
} else { // *scalar:any / &scalar:any / *:any / **:any } else { // *scalar:any / &scalar:any / *:any / **:any
BQNFFIType* t2 = c(BQNFFIType, o2); BQNFFIType* t2 = c(BQNFFIType, o2);
B ore = t2->a[0].o; B ore = t2->a[0].o;
@ -1168,7 +1168,7 @@ B ffiload_c2(B t, B w, B x) {
char* nameStr = toCStr(name); char* nameStr = toCStr(name);
void* sym = dlsym(dl, nameStr); void* sym = dlsym(dl, nameStr);
freeCStr(nameStr); freeCStr(nameStr);
dec(x); decG(x);
if (sym==NULL) thrF("FFI: Failed to find symbol: %S", dlerror()); if (sym==NULL) thrF("FFI: Failed to find symbol: %S", dlerror());

View File

@ -230,7 +230,7 @@ INS void i_SETCv(B f, Scope* sc, u32 p, u32* bc) { POS_UPD; B r = c1(f,v_ge
INS B i_FLDG(B ns, u32 p, Scope* sc, u32* bc) { POS_UPD; INS B i_FLDG(B ns, u32 p, Scope* sc, u32* bc) { POS_UPD;
if (!isNsp(ns)) thrM("Trying to read a field from non-namespace"); if (!isNsp(ns)) thrM("Trying to read a field from non-namespace");
B r = inc(ns_getU(ns, p)); B r = inc(ns_getU(ns, p));
dec(ns); decG(ns);
return r; return r;
} }
INS B i_VFYM(B o) { // TODO this and ALIM allocate and thus can error on OOM INS B i_VFYM(B o) { // TODO this and ALIM allocate and thus can error on OOM
@ -488,7 +488,7 @@ static OptRes opt(u32* bc0) {
bc = bc0; pos = 0; bc = bc0; pos = 0;
TSFREE(data); TSFREE(data);
TSFREE(actions); TSFREE(actions);
if (IA(refs)==0) { dec(refs); refs=m_f64(0); } if (IA(refs)==0) { decG(refs); refs=m_f64(0); }
return (OptRes){.bc = rbc, .offset = roff, .refs = refs}; return (OptRes){.bc = rbc, .offset = roff, .refs = refs};
} }
#undef SREF #undef SREF

View File

@ -501,7 +501,7 @@ void load_init() { // very last init function
B rtObjRaw = Get(rtRes,0); B rtObjRaw = Get(rtRes,0);
B setPrims = Get(rtRes,1); B setPrims = Get(rtRes,1);
B setInv = Get(rtRes,2); B setInv = Get(rtRes,2);
dec(rtRes); decG(rtRes);
dec(c1G(setPrims, m_lvB_2(incG(bi_decp), incG(bi_primInd)))); decG(setPrims); dec(c1G(setPrims, m_lvB_2(incG(bi_decp), incG(bi_primInd)))); decG(setPrims);
dec(c2G(setInv, incG(bi_setInvSwap), incG(bi_setInvReg))); decG(setInv); dec(c2G(setInv, incG(bi_setInvSwap), incG(bi_setInvReg))); decG(setInv);

View File

@ -232,7 +232,7 @@ static NOINLINE i64 readInt(char** p) {
if (i<=i0) break; // in case the above code fails to progress forward, at least don't get in an infinite loop if (i<=i0) break; // in case the above code fails to progress forward, at least don't get in an infinite loop
} }
end: end:
dec(charObj); decG(charObj);
popCatch(); popCatch();
} }
B allNsFields(void); B allNsFields(void);
@ -365,7 +365,7 @@ static NOINLINE i64 readInt(char** p) {
if (failedCmd) goto not_cmd; if (failedCmd) goto not_cmd;
} }
dec(inpB); decG(inpB);
popCatch(); popCatch();
} }
void complete_replxx(const char* inp, replxx_completions* res, int* dist, void* data) { void complete_replxx(const char* inp, replxx_completions* res, int* dist, void* data) {
@ -991,7 +991,7 @@ int main(int argc, char* argv[]) {
case 'o': { repl_init(); REQARG(o); case 'o': { repl_init(); REQARG(o);
B r = gsc_exec_inplace(utf8Decode0(argv[i++]), "(-o)", emptySVec()); B r = gsc_exec_inplace(utf8Decode0(argv[i++]), "(-o)", emptySVec());
if (isAtm(r) || RNK(r)!=1) thrM("(-o): Value to print must be a string"); if (isAtm(r) || RNK(r)!=1) thrM("(-o): Value to print must be a string");
printsB(r); dec(r); printsB(r); decG(r);
printf("\n"); printf("\n");
break; break;
} }

View File

@ -123,7 +123,7 @@ B path_rel(B base, B rel, char* name) {
usz ria = IA(rel); usz ria = IA(rel);
if (ria>0 && isAbsolutePath(rel)) return rel; if (ria>0 && isAbsolutePath(rel)) return rel;
if (q_N(base)) thrF("%U: Using relative path with no absolute base path known", name); if (q_N(base)) thrF("%U: Using relative path with no absolute base path known", name);
if (ria==0) { dec(rel); return incG(base); } if (ria==0) { decG(rel); return incG(base); }
usz bia = IA(base); usz bia = IA(base);
if (bia==0) return rel; if (bia==0) return rel;
SGetU(base) SGetU(base)
@ -134,7 +134,7 @@ B path_rel(B base, B rel, char* name) {
rp[ri++] = PREFERRED_SEP; rp[ri++] = PREFERRED_SEP;
SGetU(rel) SGetU(rel)
for (usz i = 0; i < ria; i++) rp[ri++] = o2cG(GetU(rel, i)); for (usz i = 0; i < ria; i++) rp[ri++] = o2cG(GetU(rel, i));
dec(rel); decG(rel);
return r; return r;
} }
@ -147,7 +147,7 @@ B path_parent(B path) {
if (isPathSep(o2cG(GetU(path, i)))) return taga(arr_shVec(TI(path,slice)(path, 0, i+1))); if (isPathSep(o2cG(GetU(path, i)))) return taga(arr_shVec(TI(path,slice)(path, 0, i+1)));
} }
if (isAbsolutePath(path)) return path; if (isAbsolutePath(path)) return path;
dec(path); decG(path);
u32* rp; B r = m_c32arrv(&rp, 2); rp[0] = '.'; rp[1] = PREFERRED_SEP; u32* rp; B r = m_c32arrv(&rp, 2); rp[0] = '.'; rp[1] = PREFERRED_SEP;
return r; return r;
} }

View File

@ -41,7 +41,7 @@ NOINLINE u64 bqn_hashObj(B x, const u64 secret[4]) { // TODO manual separation o
assert(bytes!=0); assert(bytes!=0);
u64 r = wyhash(data, bytes, shHash, secret); u64 r = wyhash(data, bytes, shHash, secret);
if (isTemp) TFREE(data); if (isTemp) TFREE(data);
dec(x); decG(x);
return r; return r;
} }

View File

@ -95,7 +95,7 @@ NOINLINE B vec_addF(B w, B x) {
MAKE_MUT_INIT(r, wia+1, el_or(TI(w,elType), selfElType(x))); MUTG_INIT(r); MAKE_MUT_INIT(r, wia+1, el_or(TI(w,elType), selfElType(x))); MUTG_INIT(r);
mut_copyG(r, 0, w, 0, wia); mut_copyG(r, 0, w, 0, wia);
mut_setG(r, wia, x); mut_setG(r, wia, x);
dec(w); decG(w);
return mut_fv(r); return mut_fv(r);
} }
NOINLINE B vec_addN(B w, B x) { NOINLINE B vec_addN(B w, B x) {
@ -568,7 +568,7 @@ Arr* apd_sh_err(ApdMut* m, u32 ty) {
} }
Arr* apd_rnk_err(ApdMut* m, u32 ty) { Arr* apd_rnk_err(ApdMut* m, u32 ty) {
ur er = RNK(m->failEl); // if it were atom, rank couldn't overflow ur er = RNK(m->failEl); // if it were atom, rank couldn't overflow
dec(m->failEl); decG(m->failEl);
thrF("%U: Result rank too large (%i ≡ =𝕩, %s ≡ =%U)", apd_ty_base(ty), m->rr0, er, ty==1? "⊑𝕩" : "𝔽v"); thrF("%U: Result rank too large (%i ≡ =𝕩, %s ≡ =%U)", apd_ty_base(ty), m->rr0, er, ty==1? "⊑𝕩" : "𝔽v");
} }
NOINLINE void apd_sh_fail(ApdMut* m, B x, u8 mode) { NOINLINE void apd_sh_fail(ApdMut* m, B x, u8 mode) {

View File

@ -533,9 +533,9 @@ FORCE_INLINE bool v_merge(Scope* pscs[], B s, B x, bool upd, bool hdr) {
B* xp = harr_ptr(cells); B* xp = harr_ptr(cells);
for (usz i = 0; i < oia; i++) { for (usz i = 0; i < oia; i++) {
if (!hdr) v_set (pscs, op[i], xp[i], upd, true, false, false); if (!hdr) v_set (pscs, op[i], xp[i], upd, true, false, false);
else if (!v_seth(pscs, op[i], xp[i])) { dec(cells); return false; } else if (!v_seth(pscs, op[i], xp[i])) { decG(cells); return false; }
} }
dec(cells); decG(cells);
} }
return true; return true;
} }
@ -899,7 +899,7 @@ B evalBC(Body* b, Scope* sc, Block* bl) { // doesn't consume
case FLDG: { P(ns) GS_UPD; u32 p = *bc++; POS_UPD; case FLDG: { P(ns) GS_UPD; u32 p = *bc++; POS_UPD;
if (!isNsp(ns)) thrM("Trying to read a field from non-namespace"); if (!isNsp(ns)) thrM("Trying to read a field from non-namespace");
ADD(inc(ns_getU(ns, p))); ADD(inc(ns_getU(ns, p)));
dec(ns); decG(ns);
break; break;
} }
case ALIM: { P(o) GS_UPD; u32 l = *bc++; case ALIM: { P(o) GS_UPD; u32 l = *bc++;
@ -1651,8 +1651,8 @@ void profiler_displayResults(void) {
} }
} }
} }
dec(compList); decG(compList);
dec(mapList); decG(mapList);
#if PROFILE_IP #if PROFILE_IP
} else if (profiler_mode==2) { } else if (profiler_mode==2) {
f64* rp; B r = m_f64arrv(&rp, count); f64* rp; B r = m_f64arrv(&rp, count);