diff --git a/src/builtins/cells.c b/src/builtins/cells.c index b41564b2..86efebec 100644 --- a/src/builtins/cells.c +++ b/src/builtins/cells.c @@ -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); } } else if (!isMd(f)) { - dec(xkM? w : x); + decG(xkM? w : x); return const_cells(xkM? x : w, zk, zsh, inc(f), chr); } generic:; diff --git a/src/builtins/internal.c b/src/builtins/internal.c index ac5c9861..d125b0ce 100644 --- a/src/builtins/internal.c +++ b/src/builtins/internal.c @@ -197,7 +197,7 @@ B variation_c2(B t, B w, B x) { if (slice) { Arr* slice = TI(res,slice)(incG(res), 0, IA(res)); arr_shCopy(slice, res); - dec(res); + decG(res); res = taga(slice); } @@ -218,7 +218,7 @@ B clearRefs_c1(B t, B x) { dec(x); if (!isArr(variation_refs)) return m_f64(0); usz res = IA(variation_refs); - dec(variation_refs); + decG(variation_refs); variation_refs = m_f64(0); return m_f64(res); } @@ -396,7 +396,7 @@ B iProperties_c2(B t, B w, B x) { B unshare_c1(B t, B x) { if (!isArr(x)) thrM("•internal.Unshare: Argument must be an array"); B r = unshare(x); - dec(x); + decG(x); return r; } STATIC_GLOBAL B internalNS; diff --git a/src/builtins/sfns.c b/src/builtins/sfns.c index 3c3ca3b2..4c89deb9 100644 --- a/src/builtins/sfns.c +++ b/src/builtins/sfns.c @@ -427,7 +427,7 @@ static B recPick(B w, B x) { // doesn't consume B pick_c2(B t, B w, B 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); } if (isNum(w)) { @@ -465,7 +465,7 @@ FORCE_INLINE B affixes(B x, i32 post) { shcpy(sh, csh, xr-1); HARR_ADD(r, i, taga(c)); } - dec(x); + decG(x); } B rf = incG(HARR_O(r).a[post? cam : 0]); return withFill(HARR_FV(r), rf); @@ -740,7 +740,7 @@ B join_c1(B t, B x) { shcpy(sh+xr, fsh+xr, ir-xr); } B xff = getFillR(xf); - dec(xf); decG(x); + decG(xf); decG(x); return withFill(r.b, xff); } 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); } - dec(rep); + decG(rep); return mut_fcd(r, x); } diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index e2846058..10f758d9 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -53,8 +53,8 @@ B decp_c1(B t, B x) { B primInd_c1(B t, B x) { if (!isVal(x)) return m_i32(RT_LEN); - if (isPrim(x)) { B r = m_i32(RTID(x)); dec(x); return r; } - dec(x); + if (isPrim(x)) { B r = m_i32(RTID(x)); decG(x); return r; } + decG(x); return m_i32(RT_LEN); } @@ -232,21 +232,21 @@ B casrt_c2(B t, B w, B x) { AFMT("\n"); usz pos = o2s(w0); s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, pos, pos+1); - dec(w); + decG(w); thr(s); } if (isArr(w0) && RNK(w0)==1 && IA(w0)>=1) { B s = IGet(w,1); AFMT("\n"); usz pos = o2s(IGetU(w0,0)); s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, pos, pos+1); - dec(w); + decG(w); thr(s); } if (isArr(w0) && RNK(w0)==2 && IA(w0)>=2) { B s = IGet(w,1); AFMT("\n"); SGetU(w0) s = vm_fmtPoint(COMPS_CREF(src), s, fullpath, o2s(GetU(w0,0)), o2s(GetU(w0,1))+1); - dec(w); + decG(w); 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"); B p = path_rel(nfn_objU(d), w, "•file.Chars"); path_wChars(incG(p), x); - dec(x); + decG(x); return p; } 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"); B p = path_rel(nfn_objU(d), w, "•file.Bytes"); path_wBytes(incG(p), x); - dec(x); + decG(x); return p; } 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 s = vec_addN(s, m_c32('\n')); } - dec(x); + decG(x); B p = path_rel(nfn_objU(d), w, "•file.Lines"); path_wChars(incG(p), s); decG(s); @@ -1012,7 +1012,7 @@ B toUtf8_c1(B t, B x) { u64 len = utf8lenB(x); u8* rp; B r = m_c8arrv(&rp, len); toUTF8(x, (char*)rp); - dec(x); + decG(x); 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; 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_errObj; B s_errRaw = toC8Any(s_err); if (raw) { s_outObj = s_outRaw; s_errObj = s_errRaw; } else { - s_outObj = utf8Decode((char*)c8any_ptr(s_outRaw), IA(s_outRaw)); dec(s_outRaw); - s_errObj = utf8Decode((char*)c8any_ptr(s_errRaw), IA(s_errRaw)); dec(s_errRaw); + 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)); decG(s_errRaw); } return m_hvec3(m_i32(code), s_outObj, s_errObj); } diff --git a/src/core/stuff.c b/src/core/stuff.c index c5a15e3d..2f9877dd 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -458,7 +458,7 @@ B bqn_merge(B x, u32 type) { shcpy (rsh , SH(x), xr); if(xfr)shcpy(rsh+xr, SH(xf), xfr); } - decG(x); dec(xf); + decG(x); decG(xf); return taga(r); } diff --git a/src/core/tyarrTemplate.c b/src/core/tyarrTemplate.c index c4cc047a..2db8d3bd 100644 --- a/src/core/tyarrTemplate.c +++ b/src/core/tyarrTemplate.c @@ -9,7 +9,7 @@ static Arr* TP(m_,slice) (Arr* p, TEl* ptr, usz ia) { 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(,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(,slice_get) (Arr* x, usz n) { assert(PTY(x)==T_SLICE); return TP(m_,) (((TEl*)((TySlice*)x)->a)[n]); } diff --git a/src/ffi.c b/src/ffi.c index bffeb9db..26f675d6 100644 --- a/src/ffi.c +++ b/src/ffi.c @@ -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); i32* rp; B r = m_i32arrv(&rp, ia); vfor (usz i=0; ia[0].o; @@ -1168,7 +1168,7 @@ B ffiload_c2(B t, B w, B x) { char* nameStr = toCStr(name); void* sym = dlsym(dl, nameStr); freeCStr(nameStr); - dec(x); + decG(x); if (sym==NULL) thrF("FFI: Failed to find symbol: %S", dlerror()); diff --git a/src/jit/nvm_x86_64.c b/src/jit/nvm_x86_64.c index a73094b5..5c185319 100644 --- a/src/jit/nvm_x86_64.c +++ b/src/jit/nvm_x86_64.c @@ -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; if (!isNsp(ns)) thrM("Trying to read a field from non-namespace"); B r = inc(ns_getU(ns, p)); - dec(ns); + decG(ns); return r; } 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; TSFREE(data); 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}; } #undef SREF diff --git a/src/load.c b/src/load.c index 4d6ff9f7..ad44f3fd 100644 --- a/src/load.c +++ b/src/load.c @@ -501,7 +501,7 @@ void load_init() { // very last init function B rtObjRaw = Get(rtRes,0); B setPrims = Get(rtRes,1); B setInv = Get(rtRes,2); - dec(rtRes); + decG(rtRes); 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); diff --git a/src/main.c b/src/main.c index 98c386dd..826afed7 100644 --- a/src/main.c +++ b/src/main.c @@ -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 } end: - dec(charObj); + decG(charObj); popCatch(); } B allNsFields(void); @@ -365,7 +365,7 @@ static NOINLINE i64 readInt(char** p) { if (failedCmd) goto not_cmd; } - dec(inpB); + decG(inpB); popCatch(); } 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); 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"); - printsB(r); dec(r); + printsB(r); decG(r); printf("\n"); break; } diff --git a/src/utils/file.c b/src/utils/file.c index 763cfec7..1588b27c 100644 --- a/src/utils/file.c +++ b/src/utils/file.c @@ -123,7 +123,7 @@ B path_rel(B base, B rel, char* name) { usz ria = IA(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 (ria==0) { dec(rel); return incG(base); } + if (ria==0) { decG(rel); return incG(base); } usz bia = IA(base); if (bia==0) return rel; SGetU(base) @@ -134,7 +134,7 @@ B path_rel(B base, B rel, char* name) { rp[ri++] = PREFERRED_SEP; SGetU(rel) for (usz i = 0; i < ria; i++) rp[ri++] = o2cG(GetU(rel, i)); - dec(rel); + decG(rel); 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 (isAbsolutePath(path)) return path; - dec(path); + decG(path); u32* rp; B r = m_c32arrv(&rp, 2); rp[0] = '.'; rp[1] = PREFERRED_SEP; return r; } diff --git a/src/utils/hash.c b/src/utils/hash.c index 248c507d..af2c72d4 100644 --- a/src/utils/hash.c +++ b/src/utils/hash.c @@ -41,7 +41,7 @@ NOINLINE u64 bqn_hashObj(B x, const u64 secret[4]) { // TODO manual separation o assert(bytes!=0); u64 r = wyhash(data, bytes, shHash, secret); if (isTemp) TFREE(data); - dec(x); + decG(x); return r; } diff --git a/src/utils/mut.c b/src/utils/mut.c index c1afaf82..1b70ec00 100644 --- a/src/utils/mut.c +++ b/src/utils/mut.c @@ -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); mut_copyG(r, 0, w, 0, wia); mut_setG(r, wia, x); - dec(w); + decG(w); return mut_fv(r); } 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) { 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"); } NOINLINE void apd_sh_fail(ApdMut* m, B x, u8 mode) { diff --git a/src/vm.c b/src/vm.c index a4123306..febf112c 100644 --- a/src/vm.c +++ b/src/vm.c @@ -533,9 +533,9 @@ FORCE_INLINE bool v_merge(Scope* pscs[], B s, B x, bool upd, bool hdr) { B* xp = harr_ptr(cells); for (usz i = 0; i < oia; i++) { 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; } @@ -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; if (!isNsp(ns)) thrM("Trying to read a field from non-namespace"); ADD(inc(ns_getU(ns, p))); - dec(ns); + decG(ns); break; } case ALIM: { P(o) GS_UPD; u32 l = *bc++; @@ -1651,8 +1651,8 @@ void profiler_displayResults(void) { } } } - dec(compList); - dec(mapList); + decG(compList); + decG(mapList); #if PROFILE_IP } else if (profiler_mode==2) { f64* rp; B r = m_f64arrv(&rp, count);