decG round 2
This commit is contained in:
parent
9b8f8f3725
commit
69067b8fcc
@ -35,27 +35,27 @@
|
||||
if (xe==el_i32) { i32* xp = i32any_ptr(ox); for (usz i = 0; i < ia; i++) {w.f=wp[i];x.f=xp[i];rp[i]=EXPR;} } \
|
||||
else { f64* xp = f64any_ptr(ox); for (usz i = 0; i < ia; i++) {w.f=wp[i];x.f=xp[i];rp[i]=EXPR;} } \
|
||||
} \
|
||||
dec(w); dec(x); return num_squeeze(r); \
|
||||
decG(w); decG(x); return num_squeeze(r); \
|
||||
} \
|
||||
} else if (isF64(w)&isArr(x)) { usz ia = a(x)->ia; \
|
||||
u8 xe = TI(x,elType); f64*rp; \
|
||||
if (xe==el_i32) { B r=m_f64arrc(&rp, x); i32*xp=i32any_ptr(x); \
|
||||
for (usz i = 0; i < ia; i++) {B x/*shadow*/;x.f=xp[i];rp[i]=EXPR;} \
|
||||
dec(x); return num_squeeze(r); \
|
||||
decG(x); return num_squeeze(r); \
|
||||
} \
|
||||
if (xe==el_f64) { B r=m_f64arrc(&rp, x); f64*xp=f64any_ptr(x); \
|
||||
for (usz i = 0; i < ia; i++) {B x/*shadow*/;x.f=xp[i];rp[i]=EXPR;} \
|
||||
dec(x); return num_squeeze(r); \
|
||||
decG(x); return num_squeeze(r); \
|
||||
} \
|
||||
} else if (isF64(x)&isArr(w)) { usz ia = a(w)->ia; \
|
||||
u8 we = TI(w,elType); f64*rp; \
|
||||
if (we==el_i32) { B r=m_f64arrc(&rp, w); i32*wp=i32any_ptr(w); \
|
||||
for (usz i = 0; i < ia; i++) {B w/*shadow*/;w.f=wp[i];rp[i]=EXPR;} \
|
||||
dec(w); return num_squeeze(r); \
|
||||
decG(w); return num_squeeze(r); \
|
||||
} \
|
||||
if (we==el_f64) { B r=m_f64arrc(&rp, w); f64*wp=f64any_ptr(w); \
|
||||
for (usz i = 0; i < ia; i++) {B w/*shadow*/;w.f=wp[i];rp[i]=EXPR;} \
|
||||
dec(w); return num_squeeze(r); \
|
||||
decG(w); return num_squeeze(r); \
|
||||
} \
|
||||
} \
|
||||
P2(NAME) \
|
||||
@ -109,29 +109,29 @@
|
||||
rp[i] = EXPR; \
|
||||
} \
|
||||
}
|
||||
#define DOI16(EXPR,A,W,X,BASE) { Ri16(A) \
|
||||
for (usz i = 0; i < ia; i++) { \
|
||||
i32 wv = W; i32 xv = X; i32 rv = EXPR; \
|
||||
if (RARE(rv!=(i16)rv)) { dec(r); goto BASE; } \
|
||||
rp[i] = rv; \
|
||||
} \
|
||||
dec(w); dec(x); return r; \
|
||||
#define DOI16(EXPR,A,W,X,BASE) { Ri16(A) \
|
||||
for (usz i = 0; i < ia; i++) { \
|
||||
i32 wv = W; i32 xv = X; i32 rv = EXPR; \
|
||||
if (RARE(rv!=(i16)rv)) { decG(r); goto BASE; } \
|
||||
rp[i] = rv; \
|
||||
} \
|
||||
dec(w); dec(x); return r; \
|
||||
}
|
||||
#define DOI8(EXPR,A,W,X,BASE) { Ri8(A) \
|
||||
for (usz i = 0; i < ia; i++) { \
|
||||
i16 wv = W; i16 xv = X; i16 rv = EXPR; \
|
||||
if (RARE(rv!=(i8)rv)) { dec(r); goto BASE; } \
|
||||
if (RARE(rv!=(i8)rv)) { decG(r); goto BASE; } \
|
||||
rp[i] = rv; \
|
||||
} \
|
||||
dec(w); dec(x); return r; \
|
||||
}
|
||||
#define DOI32(EXPR,A,W,X,BASE) { Ri32(A) \
|
||||
for (usz i = 0; i < ia; i++) { \
|
||||
i64 wv = W; i64 xv = X; i64 rv = EXPR; \
|
||||
if (RARE(rv!=(i32)rv)) { dec(r); goto BASE; } \
|
||||
rp[i] = rv; \
|
||||
} \
|
||||
dec(w); dec(x); return r; \
|
||||
#define DOI32(EXPR,A,W,X,BASE) { Ri32(A) \
|
||||
for (usz i = 0; i < ia; i++) { \
|
||||
i64 wv = W; i64 xv = X; i64 rv = EXPR; \
|
||||
if (RARE(rv!=(i32)rv)) { decG(r); goto BASE; } \
|
||||
rp[i] = rv; \
|
||||
} \
|
||||
dec(w); dec(x); return r; \
|
||||
}
|
||||
|
||||
static B bitAA0(B w, B x, usz ia) { UD; }
|
||||
@ -139,13 +139,13 @@
|
||||
u64* rp; B r = m_bitarrc(&rp, x);
|
||||
u64* wp=bitarr_ptr(w); u64* xp=bitarr_ptr(x);
|
||||
for (usz i=0; i<BIT_N(ia); i++) rp[i] = wp[i]|xp[i];
|
||||
dec(w); dec(x); return r;
|
||||
decG(w); decG(x); return r;
|
||||
}
|
||||
static NOINLINE B bitAA2(B w, B x, usz ia) {
|
||||
u64* rp; B r = m_bitarrc(&rp, x);
|
||||
u64* wp=bitarr_ptr(w); u64* xp=bitarr_ptr(x);
|
||||
for (usz i=0; i<BIT_N(ia); i++) rp[i] = wp[i]&xp[i];
|
||||
dec(w); dec(x); return r;
|
||||
decG(w); decG(x); return r;
|
||||
}
|
||||
|
||||
#define GC2i(SYMB, NAME, EXPR, EXTRA1, EXTRA2, BIT, SI_AA, DO_AS, DO_SA) \
|
||||
@ -171,13 +171,13 @@
|
||||
if ((we==el_i32|we==el_f64)&(xe==el_i32|xe==el_f64)) { \
|
||||
bool wei = we==el_i32; bool xei = xe==el_i32; \
|
||||
if (wei&xei) { PI32(w)PI32(x)SI_AA(NAME,i32,rcf64) DOI32(EXPR,w,wp[i],xp[i],rcf64) } \
|
||||
if (!wei&!xei) {PF(w)PF(x) { SI_AA(NAME,f64,base) } Rf64(x) DOF(EXPR,w,wp[i],xp[i]) dec(w);dec(x);return r; } \
|
||||
if (!wei&!xei) {PF(w)PF(x) { SI_AA(NAME,f64,base) } Rf64(x) DOF(EXPR,w,wp[i],xp[i]) decG(w);decG(x);return r; } \
|
||||
rcf64:; Rf64(x) \
|
||||
if (wei) { PI32(w) \
|
||||
if (xei) { PI32(x) DOF(EXPR,w,wp[i],xp[i]) } \
|
||||
else { PF (x) DOF(EXPR,w,wp[i],xp[i]) } \
|
||||
} else {PF(w)PI32(x) DOF(EXPR,w,wp[i],xp[i]) } \
|
||||
dec(w); dec(x); return num_squeeze(r); \
|
||||
decG(w); decG(x); return num_squeeze(r); \
|
||||
} \
|
||||
if(we==el_i8 & xe==el_i8 ) { PI8 (w) PI8 (x) SI_AA(NAME, i8,base) DOI8 (EXPR,w,wp[i],xp[i],base) } \
|
||||
if(we==el_i16 & xe==el_i16) { PI16(w) PI16(x) SI_AA(NAME,i16,base) DOI16(EXPR,w,wp[i],xp[i],base) } \
|
||||
@ -221,18 +221,18 @@ static f64 pfmod(f64 a, f64 b) {
|
||||
if (xe==el_i8 && q_i8 (w)) { PI8 (x) i8 wc=o2iu(w); DOI8 (EXPR,x,wc,xp[i],sa8B ) } sa8B :; \
|
||||
if (xe==el_i16 && q_i16(w)) { PI16(x) i16 wc=o2iu(w); DOI16(EXPR,x,wc,xp[i],sa16B) } sa16B:; \
|
||||
if (xe==el_i32 && q_i32(w)) { PI32(x) i32 wc=o2iu(w); DOI32(EXPR,x,wc,xp[i],sa32B) } sa32B:; \
|
||||
if (xe==el_f64) { Rf64(x) PF(x) DOF(EXPR,w,w.f,xp[i]) dec(x); return num_squeeze(r); }
|
||||
if (xe==el_f64) { Rf64(x) PF(x) DOF(EXPR,w,w.f,xp[i]) decG(x); return num_squeeze(r); }
|
||||
#define REG_AS(NAME, EXPR) \
|
||||
if (we==el_bit) return bit_sel1Fn(NAME##_c2,w,x,0); \
|
||||
if (we==el_i8 && q_i8 (x)) { PI8 (w) i8 xc=o2iu(x); DOI8 (EXPR,w,wp[i],xc,as8B ) } as8B :; \
|
||||
if (we==el_i16 && q_i16(x)) { PI16(w) i16 xc=o2iu(x); DOI16(EXPR,w,wp[i],xc,as16B) } as16B:; \
|
||||
if (we==el_i32 && q_i32(x)) { PI32(w) i32 xc=o2iu(x); DOI32(EXPR,w,wp[i],xc,as32B) } as32B:; \
|
||||
if (we==el_f64) { Rf64(w) PF(w) DOF(EXPR,x,wp[i],x.f) dec(w); return num_squeeze(r); }
|
||||
if (we==el_f64) { Rf64(w) PF(w) DOF(EXPR,x,wp[i],x.f) decG(w); return num_squeeze(r); }
|
||||
|
||||
#if SINGELI
|
||||
#define SI_AA(N,S,BASE) R##S(x); usz rlen=avx2_##N##AA##_##S((void*)wp, (void*)xp, (void*)rp, ia); if(RARE(rlen!=ia)) { dec(r); goto BASE; } dec(w);dec(x);return r;
|
||||
#define SI_SA_I(N,S,W,BASE) R##S(x); usz rlen=avx2_##N##SA##_##S((W).u, (void*)xp, (void*)rp, ia); if(RARE(rlen!=ia)) { dec(r); goto BASE; } dec(w);dec(x);return r;
|
||||
#define SI_AS_I(N,S,X,BASE) R##S(w); usz rlen=avx2_##N##AS##_##S((void*)wp, (X).u, (void*)rp, ia); if(RARE(rlen!=ia)) { dec(r); goto BASE; } dec(w);dec(x);return r;
|
||||
#define SI_AA(N,S,BASE) R##S(x); usz rlen=avx2_##N##AA##_##S((void*)wp, (void*)xp, (void*)rp, ia); if(RARE(rlen!=ia)) { decG(r); goto BASE; } decG(w);decG(x);return r;
|
||||
#define SI_SA_I(N,S,W,BASE) R##S(x); usz rlen=avx2_##N##SA##_##S((W).u, (void*)xp, (void*)rp, ia); if(RARE(rlen!=ia)) { decG(r); goto BASE; } dec (w);decG(x);return r;
|
||||
#define SI_AS_I(N,S,X,BASE) R##S(w); usz rlen=avx2_##N##AS##_##S((void*)wp, (X).u, (void*)rp, ia); if(RARE(rlen!=ia)) { decG(r); goto BASE; } decG(w);dec (x);return r;
|
||||
#define SI_SA(NAME, EXPR) \
|
||||
void* xp = tyany_ptr(x); \
|
||||
switch(xe) { default: UD; \
|
||||
@ -272,7 +272,7 @@ GC2i("+", add, wv+xv, {
|
||||
rp[i] = (u32)(xp[i]+(i32)wv);
|
||||
if (rp[i]>CHR_MAX) thrM("+: Invalid character"); // safe to only check this as wv already must be below CHR_MAX, which is less than U32_MAX/2
|
||||
}
|
||||
dec(x);
|
||||
decG(x);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@ -288,7 +288,7 @@ GC2i("-", sub, wv-xv, {
|
||||
u32* wp = c32any_ptr(w); usz wia = a(w)->ia;
|
||||
i32* rp; B r = m_i32arrc(&rp, w);
|
||||
for (usz i = 0; i < wia; i++) rp[i] = (i32)wp[i] - xv;
|
||||
dec(w);
|
||||
decG(w);
|
||||
return r;
|
||||
}
|
||||
if (isArr(x) && eqShape(w, x)) {
|
||||
@ -300,7 +300,7 @@ GC2i("-", sub, wv-xv, {
|
||||
rp[i] = (u32)((i32)wp[i] - (i32)xp[i]);
|
||||
if (rp[i]>CHR_MAX) thrM("-: Invalid character"); // safe - see add
|
||||
}
|
||||
dec(w); dec(x);
|
||||
decG(w); decG(x);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ B bit_negate(B x) { // consumes
|
||||
u64* rp; B r = m_bitarrc(&rp, x);
|
||||
usz ia = BIT_N(a(x)->ia);
|
||||
for (usz i = 0; i < ia; i++) rp[i] = ~xp[i];
|
||||
dec(x);
|
||||
decG(x);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -25,22 +25,22 @@ B bit_negate(B x) { // consumes
|
||||
if (RARE(!isArr(x))) thrM(SYMB ": Expected argument to be a number"); \
|
||||
u8 xe = TI(x,elType); \
|
||||
i64 sz = a(x)->ia; BX \
|
||||
if (xe==el_i8) { i8 MAX=I8_MAX; i8 MIN=I8_MIN; i8* xp=i8any_ptr(x); i8* rp; B r=m_i8arrc(&rp,x); \
|
||||
for (i64 i = 0; i < sz; i++) { i8 v = xp[i]; if (RARE(IBAD)) { dec(r); goto base; } rp[i] = IEXPR; } \
|
||||
dec(x); (void)MIN;(void)MAX; return r; \
|
||||
} \
|
||||
if (xe==el_i8) { i8 MAX=I8_MAX; i8 MIN=I8_MIN; i8* xp=i8any_ptr(x); i8* rp; B r=m_i8arrc(&rp,x); \
|
||||
for (i64 i = 0; i < sz; i++) { i8 v = xp[i]; if (RARE(IBAD)) { decG(r); goto base; } rp[i] = IEXPR; } \
|
||||
decG(x); (void)MIN;(void)MAX; return r; \
|
||||
} \
|
||||
if (xe==el_i16) { i16 MAX=I16_MAX; i16 MIN=I16_MIN; i16* xp=i16any_ptr(x); i16* rp; B r=m_i16arrc(&rp,x); \
|
||||
for (i64 i = 0; i < sz; i++) { i16 v = xp[i]; if (RARE(IBAD)) { dec(r); goto base; } rp[i] = IEXPR; } \
|
||||
dec(x); (void)MIN;(void)MAX; return r; \
|
||||
} \
|
||||
for (i64 i = 0; i < sz; i++) { i16 v = xp[i]; if (RARE(IBAD)) { decG(r); goto base; } rp[i] = IEXPR; } \
|
||||
decG(x); (void)MIN;(void)MAX; return r; \
|
||||
} \
|
||||
if (xe==el_i32) { i32 MAX=I32_MAX; i32 MIN=I32_MIN; i32* xp=i32any_ptr(x); i32* rp; B r=m_i32arrc(&rp,x); \
|
||||
for (i64 i = 0; i < sz; i++) { i32 v = xp[i]; if (RARE(IBAD)) { dec(r); goto base; } rp[i] = IEXPR; } \
|
||||
dec(x); (void)MIN;(void)MAX; return r; \
|
||||
} \
|
||||
for (i64 i = 0; i < sz; i++) { i32 v = xp[i]; if (RARE(IBAD)) { decG(r); goto base; } rp[i] = IEXPR; } \
|
||||
decG(x); (void)MIN;(void)MAX; return r; \
|
||||
} \
|
||||
if (xe==el_f64) { f64* xp = f64any_ptr(x); \
|
||||
f64* rp; B r = m_f64arrc(&rp, x); \
|
||||
for (i64 i = 0; i < sz; i++) { f64 v = xp[i]; rp[i] = FEXPR; } \
|
||||
dec(x); return r; \
|
||||
decG(x); return r; \
|
||||
} \
|
||||
base: SLOW1(SYMB"𝕩", x); return arith_recm(NAME##_c1, x); \
|
||||
}
|
||||
@ -71,8 +71,8 @@ B atan_c1(B t, B x) { if (isF64(x)) return m_f64( atan(x.f)); P1( atan); thrM("
|
||||
#undef P1
|
||||
|
||||
B lt_c1(B t, B x) { return m_atomUnit(x); }
|
||||
B eq_c1(B t, B x) { B r = m_i32(isArr(x)? rnk(x) : 0); dec(x); return r; }
|
||||
B ne_c1(B t, B x) { B r = m_f64(isArr(x)&&rnk(x)? *a(x)->sh : 1); dec(x); return r; }
|
||||
B eq_c1(B t, B x) { if (isAtm(x)) { decA(x); return m_i32(0); } B r = m_i32(rnk(x) ); decG(x); return r; }
|
||||
B ne_c1(B t, B x) { if (isAtm(x)) { decA(x); return m_i32(1); } B r = m_f64(rnk(x)==0? 1 : *a(x)->sh); decG(x); return r; }
|
||||
|
||||
|
||||
static B mathNS;
|
||||
|
||||
@ -55,7 +55,7 @@ B ud_c1(B t, B x) {
|
||||
if (c*(u64)ria >= U32_MAX) thrM("↕: Result too large");
|
||||
ria*= c;
|
||||
}
|
||||
dec(x);
|
||||
decG(x);
|
||||
|
||||
Arr* r = m_fillarrp(ria); fillarr_setFill(r, m_f64(0));
|
||||
B* rp = fillarr_ptr(r);
|
||||
@ -100,7 +100,7 @@ B fne_c1(B t, B x) {
|
||||
else if (or<=I16_MAX) { i16* rp; r = m_i16arrv(&rp, xr); for (i32 i = 0; i < xr; i++) rp[i] = sh[i]; }
|
||||
else if (or<=I32_MAX) { i32* rp; r = m_i32arrv(&rp, xr); for (i32 i = 0; i < xr; i++) rp[i] = sh[i]; }
|
||||
else { f64* rp; r = m_f64arrv(&rp, xr); for (i32 i = 0; i < xr; i++) rp[i] = sh[i]; }
|
||||
dec(x); return r;
|
||||
decG(x); return r;
|
||||
}
|
||||
B feq_c1(B t, B x) {
|
||||
u64 r = depth(x);
|
||||
@ -125,7 +125,7 @@ extern B rt_indexOf;
|
||||
B indexOf_c1(B t, B x) {
|
||||
if (isAtm(x)) thrM("⊐: 𝕩 cannot have rank 0");
|
||||
usz xia = a(x)->ia;
|
||||
if (xia==0) { dec(x); return emptyIVec(); }
|
||||
if (xia==0) { decG(x); return emptyIVec(); }
|
||||
if (rnk(x)==1 && TI(x,elType)==el_i32) {
|
||||
i32* xp = i32any_ptr(x);
|
||||
i32 min=I32_MAX, max=I32_MIN;
|
||||
@ -146,7 +146,7 @@ B indexOf_c1(B t, B x) {
|
||||
if (tc[c]==I32_MIN) tc[c] = ctr++;
|
||||
rp[i] = tc[c];
|
||||
}
|
||||
dec(x); TFREE(tmp);
|
||||
decG(x); TFREE(tmp);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@ -180,7 +180,7 @@ B indexOf_c1(B t, B x) {
|
||||
if (had) rp[i] = map->a[p].val;
|
||||
else rp[i] = map->a[p].val = ctr++;
|
||||
}
|
||||
free_b2i(map); dec(x);
|
||||
free_b2i(map); decG(x);
|
||||
// u64 e = nsTime(); q1+= e-s;
|
||||
return r;
|
||||
}
|
||||
@ -207,7 +207,7 @@ B indexOf_c2(B t, B w, B x) {
|
||||
if (equal(GetU(w,i), el)) { res = i; break; }
|
||||
}
|
||||
}
|
||||
dec(w); dec(x);
|
||||
decG(w); dec(x);
|
||||
i32* rp; Arr* r = m_i32arrp(&rp, 1);
|
||||
arr_shAlloc(r, 0);
|
||||
rp[0] = res;
|
||||
@ -225,7 +225,7 @@ B indexOf_c2(B t, B w, B x) {
|
||||
if (!had) map->a[p].val = i;
|
||||
}
|
||||
for (usz i = 0; i < xia; i++) rp[i] = getD_b2i(map, GetU(x,i), wia);
|
||||
free_b2i(map); dec(w); dec(x);
|
||||
free_b2i(map); decG(w); decG(x);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@ -242,7 +242,7 @@ B memberOf_c1(B t, B x) {
|
||||
H_Sb* set = m_Sb(64);
|
||||
SGetU(x)
|
||||
for (usz i = 0; i < xia; i++) bitp_set(rp, i, !ins_Sb(&set, GetU(x,i)));
|
||||
free_Sb(set); dec(x);
|
||||
free_Sb(set); decG(x);
|
||||
return r;
|
||||
}
|
||||
B memberOf_c2(B t, B w, B x) {
|
||||
@ -257,7 +257,7 @@ B memberOf_c2(B t, B w, B x) {
|
||||
for (usz i = 0; i < xia; i++) mk_Sb(&set, GetU(x,i), &had);
|
||||
u64* rp; B r = m_bitarrv(&rp, wia);
|
||||
for (usz i = 0; i < wia; i++) bitp_set(rp, i, has_Sb(set, GetU(w,i)));
|
||||
free_Sb(set); dec(w);dec(x);
|
||||
free_Sb(set); decG(w);decG(x);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ B find_c1(B t, B x) {
|
||||
B c = GetU(x,i);
|
||||
if (!ins_Sb(&set, c)) r = vec_add(r, inc(c));
|
||||
}
|
||||
free_Sb(set); dec(x);
|
||||
free_Sb(set); decG(x);
|
||||
return withFill(r, xf);
|
||||
}
|
||||
B find_c2(B t, B w, B x) {
|
||||
@ -294,7 +294,7 @@ B count_c1(B t, B x) {
|
||||
bool had; u64 p = mk_b2i(&map, GetU(x,i), &had);
|
||||
rp[i] = had? ++map->a[p].val : (map->a[p].val = 0);
|
||||
}
|
||||
dec(x); free_b2i(map);
|
||||
decG(x); free_b2i(map);
|
||||
return r;
|
||||
}
|
||||
B count_c2(B t, B w, B x) {
|
||||
|
||||
@ -15,7 +15,7 @@ B GRADE_CAT(c1)(B t, B x) {
|
||||
if (rnk(x)>1) x = toCells(x);
|
||||
usz ia = a(x)->ia;
|
||||
if (ia>I32_MAX) thrM(GRADE_CHR": Argument too large");
|
||||
if (ia==0) { dec(x); return emptyIVec(); }
|
||||
if (ia==0) { decG(x); return emptyIVec(); }
|
||||
|
||||
u8 xe = TI(x,elType);
|
||||
i32* rp; B r = m_i32arrv(&rp, ia);
|
||||
@ -28,7 +28,7 @@ B GRADE_CAT(c1)(B t, B x) {
|
||||
if (bitp_get(xp,i)^GRADE_UD(0,1)) rp[r1++] = i;
|
||||
else rp[r0++] = i;
|
||||
}
|
||||
dec(x); return r;
|
||||
decG(x); return r;
|
||||
} else if (xe==el_i8) {
|
||||
i8* xp = i8any_ptr(x);
|
||||
i32 min=-128, range=256;
|
||||
@ -43,7 +43,7 @@ B GRADE_CAT(c1)(B t, B x) {
|
||||
for (i64 i = range-2; i >= 0; i--) tmp[i]+= tmp[i+1];
|
||||
for (usz i = 0; i < ia; i++) rp[(tmp-min+1)[xp[i]]++] = i;
|
||||
)
|
||||
TFREE(tmp); dec(x);
|
||||
TFREE(tmp); decG(x);
|
||||
return r;
|
||||
}
|
||||
if (xe==el_i32) {
|
||||
@ -67,7 +67,7 @@ B GRADE_CAT(c1)(B t, B x) {
|
||||
for (i64 i = range-2; i >= 0; i--) tmp[i]+= tmp[i+1];
|
||||
for (usz i = 0; i < ia; i++) rp[(tmp-min+1)[xp[i]]++] = i;
|
||||
)
|
||||
TFREE(tmp); dec(x);
|
||||
TFREE(tmp); decG(x);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ B GRADE_CAT(c1)(B t, B x) {
|
||||
}
|
||||
CAT(GRADE_CAT(IP),tim_sort)(tmp, ia);
|
||||
for (usz i = 0; i < ia; i++) rp[i] = tmp[i].v;
|
||||
TFREE(tmp); dec(x);
|
||||
TFREE(tmp); decG(x);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ B GRADE_CAT(c1)(B t, B x) {
|
||||
}
|
||||
CAT(GRADE_CAT(BP),tim_sort)(tmp, ia);
|
||||
for (usz i = 0; i < ia; i++) rp[i] = tmp[i].v;
|
||||
TFREE(tmp); dec(x);
|
||||
TFREE(tmp); decG(x);
|
||||
return r;
|
||||
}
|
||||
B GRADE_CAT(c2)(B t, B w, B x) {
|
||||
@ -158,7 +158,7 @@ B GRADE_CAT(c2)(B t, B w, B x) {
|
||||
rp[i] = s;
|
||||
}
|
||||
}
|
||||
dec(w);dec(x);
|
||||
decG(w);decG(x);
|
||||
return r;
|
||||
}
|
||||
#undef GRADE_CAT
|
||||
|
||||
@ -57,7 +57,7 @@ B info_c2(B t, B w, B x) {
|
||||
}
|
||||
AFMT("type:%i=%S ", xv->type, type_repr(xv->type));
|
||||
AFMT("alloc:%l", mm_size(xv));
|
||||
dec(x);
|
||||
decG(x);
|
||||
} else {
|
||||
AFMT("%xl: ", x.u);
|
||||
A8("not heap-allocated");
|
||||
@ -97,7 +97,7 @@ B listVariations_c2(B t, B w, B x) {
|
||||
else if (c=='f') c_rmFill=true;
|
||||
else thrF("internal.ListVariations: Unknown option '%c' in 𝕨", c);
|
||||
}
|
||||
dec(w);
|
||||
decG(w);
|
||||
|
||||
u8 xe = TI(x,elType);
|
||||
B xf = getFillQ(x);
|
||||
@ -142,7 +142,7 @@ B listVariations_c2(B t, B w, B x) {
|
||||
if(af64) { r=vec_add(r,inc(v_Af64));r=vec_add(r,inc(v_Sf64)); if(c_incr) { r=vec_add(r,inc(v_Af64Inc));r=vec_add(r,inc(v_Sf64Inc)); } }
|
||||
if(ah) { r=vec_add(r,inc(v_Ah ));r=vec_add(r,inc(v_Sh )); if(c_incr) { r=vec_add(r,inc(v_AhInc ));r=vec_add(r,inc(v_ShInc )); } }
|
||||
{ r=vec_add(r,inc(v_Af ));r=vec_add(r,inc(v_Sf )); if(c_incr) { r=vec_add(r,inc(v_AfInc ));r=vec_add(r,inc(v_SfInc )); } }
|
||||
dec(x);
|
||||
decG(x);
|
||||
dec(xf);
|
||||
return r;
|
||||
}
|
||||
@ -216,7 +216,7 @@ B variation_c2(B t, B w, B x) {
|
||||
}
|
||||
if (wp!=wpE) thrM("•internal.Variation: Bad 𝕨");
|
||||
} else thrM("•internal.Variation: Bad start of 𝕨");
|
||||
dec(x);
|
||||
decG(x);
|
||||
ptr_dec(wc);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ NOINLINE B m_str32(u32* s) {
|
||||
if (xp!=NULL) { for (usz i=0; i<ia; i++) rp[i]=o2fu(xp[i] ); } \
|
||||
else { SGetU(x) for (usz i=0; i<ia; i++) rp[i]=o2fu(GetU(x,i)); } \
|
||||
} \
|
||||
dec(x); \
|
||||
decG(x); \
|
||||
return (T##Arr*)r; \
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ T##Arr* cpy##T##Arr(B x) { \
|
||||
if (xp!=NULL) { for (usz i=0; i<ia; i++) rp[i]=o2cu(xp[i] ); } \
|
||||
else { SGetU(x) for (usz i=0; i<ia; i++) rp[i]=o2cu(GetU(x,i)); } \
|
||||
} \
|
||||
dec(x); \
|
||||
decG(x); \
|
||||
return (T##Arr*)r; \
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ BitArr* cpyBitArr(B x) {
|
||||
if (xp!=NULL) { for (usz i=0; i<ia; i++) bitp_set(rp,i,o2fu(xp[i] )); }
|
||||
else { SGetU(x) for (usz i=0; i<ia; i++) bitp_set(rp,i,o2fu(GetU(x,i))); }
|
||||
}
|
||||
dec(x);
|
||||
decG(x);
|
||||
return (BitArr*)r;
|
||||
}
|
||||
|
||||
|
||||
3
src/h.h
3
src/h.h
@ -556,6 +556,9 @@ static B inc(B x) {
|
||||
return x;
|
||||
}
|
||||
static void decG(B x) {
|
||||
#if DEBUG
|
||||
assert(isVal(x));
|
||||
#endif
|
||||
Value* vx = v(x);
|
||||
if(!--vx->refc) value_free(vx);
|
||||
}
|
||||
|
||||
18
src/load.c
18
src/load.c
@ -111,7 +111,7 @@ Block* load_compObj(B x, B src, B path, Scope* sc) { // consumes x,src
|
||||
if (xia!=6 & xia!=4) thrM("load_compObj: bad item count");
|
||||
Block* r = xia==6? compile(Get(x,0),Get(x,1),Get(x,2),Get(x,3),Get(x,4),Get(x,5), src, inc(path), sc)
|
||||
: compile(Get(x,0),Get(x,1),Get(x,2),Get(x,3),bi_N, bi_N, src, inc(path), sc);
|
||||
dec(x);
|
||||
decG(x);
|
||||
return r;
|
||||
}
|
||||
#include "gen/src"
|
||||
@ -294,12 +294,12 @@ B rebqn_exec(B str, B path, B args, B o) {
|
||||
} else {
|
||||
B rtsys = m_hVec2(inc(op[3]), incG(bi_sys));
|
||||
Block* block = bqn_compc(str, path, args, op[2], rtsys);
|
||||
dec(rtsys);
|
||||
decG(rtsys);
|
||||
comp_currRe = prevRe;
|
||||
res = m_funBlock(block, 0);
|
||||
ptr_dec(block);
|
||||
}
|
||||
dec(o);
|
||||
decG(o);
|
||||
|
||||
popCatch();
|
||||
return res;
|
||||
@ -371,8 +371,8 @@ void load_init() { // very last init function
|
||||
B setPrims = Get(rtRes,1);
|
||||
B setInv = Get(rtRes,2);
|
||||
dec(rtRes);
|
||||
dec(c1(setPrims, m_hVec2(incG(bi_decp), incG(bi_primInd)))); dec(setPrims);
|
||||
dec(c2(setInv, incG(bi_setInvSwap), incG(bi_setInvReg))); dec(setInv);
|
||||
dec(c1(setPrims, m_hVec2(incG(bi_decp), incG(bi_primInd)))); decG(setPrims);
|
||||
dec(c2(setInv, incG(bi_setInvSwap), incG(bi_setInvReg))); decG(setInv);
|
||||
|
||||
|
||||
|
||||
@ -423,7 +423,7 @@ void load_init() { // very last init function
|
||||
#endif
|
||||
runtimeH.a[i] = r;
|
||||
}
|
||||
dec(rtObjRaw);
|
||||
decG(rtObjRaw);
|
||||
B* runtime = runtimeH.a;
|
||||
B rtObj = runtimeH.b;
|
||||
load_rtObj = FAKE_RUNTIME? frtObj : rtObj;
|
||||
@ -447,7 +447,7 @@ void load_init() { // very last init function
|
||||
B interp = m_funBlock(c, 0); ptr_dec(c);
|
||||
print(interp);
|
||||
printf("\n");
|
||||
dec(interp);
|
||||
decG(interp);
|
||||
#ifdef HEAP_VERIFY
|
||||
heapVerify();
|
||||
#endif
|
||||
@ -474,11 +474,11 @@ void load_init() { // very last init function
|
||||
);
|
||||
B fmtM = m_funBlock(fmt_b, 0); ptr_dec(fmt_b);
|
||||
B fmtR = c1(fmtM, m_caB(4, (B[]){incG(bi_type), incG(bi_decp), incG(bi_glyph), incG(bi_repr)}));
|
||||
decG(fmtM);
|
||||
SGet(fmtR)
|
||||
load_fmt = Get(fmtR, 0); gc_add(load_fmt);
|
||||
load_repr = Get(fmtR, 1); gc_add(load_repr);
|
||||
dec(fmtR);
|
||||
dec(fmtM);
|
||||
decG(fmtR);
|
||||
#endif
|
||||
gc_enable();
|
||||
#endif // PRECOMP
|
||||
|
||||
4
src/ns.c
4
src/ns.c
@ -70,7 +70,7 @@ B ns_getNU(B ns, B name, bool thrEmpty) { VTY(ns, t_ns);
|
||||
B ns_getC(B ns, char* name) {
|
||||
B field = m_str8l(name);
|
||||
B r = ns_getNU(ns, field, false);
|
||||
dec(field);
|
||||
decG(field);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ B nsFmt(B x) { // consumes
|
||||
}
|
||||
}
|
||||
AU("⇐}");
|
||||
dec(x);
|
||||
decG(x);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
2
src/vm.c
2
src/vm.c
@ -461,7 +461,7 @@ NOINLINE Block* compile(B bcq, B objs, B allBlocks, B allBodies, B indices, B to
|
||||
for (usz i = 0; i < bIA; i++) bDone[i] = false;
|
||||
Block* ret = compileBlock(IGetU(allBlocks, 0), comp, bDone, bc, bcIA, allBlocks, allBodies, nameList, sc, 0, 0);
|
||||
TFREE(bDone);
|
||||
ptr_dec(comp); dec(allBlocks); dec(allBodies); dec(tokenInfo);
|
||||
ptr_dec(comp); decG(allBlocks); decG(allBodies); dec(tokenInfo);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user