diff --git a/src/builtins/sfns.c b/src/builtins/sfns.c index 493e0d75..36ab5231 100644 --- a/src/builtins/sfns.c +++ b/src/builtins/sfns.c @@ -400,13 +400,13 @@ B join_c2(B t, B w, B x) { HArr_p r = m_harrUv(2); r.a[0] = TI(w).get(w,0); dec(w); r.a[1] = TI(x).get(x,0); dec(x); - return withFill(r.b, f); + return qWithFill(r.b, f); } if (c-wr > 1 || c-xr > 1) thrF("∾: Argument ranks must differ by 1 or less (%i≡=𝕨, %i≡=𝕩)", wr, xr); if (c==1) { B r = vec_join(w, x); if (rnk(r)==0) srnk(r,1); - return withFill(r, f); + return qWithFill(r, f); } MAKE_MUT(r, wia+xia); mut_to(r, el_or(TI(w).elType, TI(x).elType)); @@ -468,7 +468,7 @@ B couple_c2(B t, B w, B x) { } -static void shift_check(B w, B x) { +static inline void shift_check(B w, B x) { ur wr = rnk(w); usz* wsh = a(w)->sh; ur xr = rnk(x); usz* xsh = a(x)->sh; if (wr+1!=xr & wr!=xr) thrF("shift: =𝕨 must be =𝕩 or ¯1+=𝕩 (%i≡=𝕨, %i≡=𝕩)", wr, xr); diff --git a/src/core/fillarr.c b/src/core/fillarr.c index 7869dbf1..273bf808 100644 --- a/src/core/fillarr.c +++ b/src/core/fillarr.c @@ -195,8 +195,4 @@ B withFill(B x, B fill) { // consumes both for (usz i = 0; i < ia; i++) a[i] = xget(x,i); dec(x); return r; -} -B qWithFill(B x, B fill) { // consumes both - if (noFill(fill)) return x; - return withFill(x, fill); -} +} \ No newline at end of file diff --git a/src/core/fillarr.h b/src/core/fillarr.h index 15967d0f..12f70374 100644 --- a/src/core/fillarr.h +++ b/src/core/fillarr.h @@ -12,7 +12,11 @@ B asFill(B x); // consumes void validateFill(B x); bool fillEqual(B w, B x); B withFill(B x, B fill); // consumes both -B qWithFill(B x, B fill); // consumes both +static B qWithFill(B x, B fill) { // consumes both + if (noFill(fill)) return x; + return withFill(x, fill); +} + static B getFillR(B x) { // doesn't consume; can return bi_noFill if (isArr(x)) { diff --git a/src/core/stuff.c b/src/core/stuff.c index 5b9a56db..d22dea9e 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -3,7 +3,7 @@ #include "../utils/utf.h" u64 allocB; // currently allocated number of bytes -B bi_N, bi_noVar, bi_badHdr, bi_optOut, bi_noFill, bi_emptyHVec, bi_emptyIVec, bi_emptyCVec; +B bi_emptyHVec, bi_emptyIVec, bi_emptyCVec; #define F(N) u64 N; CTR_FOR(F) #undef F diff --git a/src/h.h b/src/h.h index c9f9dcda..cb0c40b0 100644 --- a/src/h.h +++ b/src/h.h @@ -234,7 +234,12 @@ void gc_forceGC(); // force a gc; who knows what happens if gc is disabled (prob void gc_visitRoots(); // some primitive actions -extern B bi_N, bi_noVar, bi_badHdr, bi_optOut, bi_noFill, bi_emptyHVec, bi_emptyIVec, bi_emptyCVec; +static const B bi_N = tag(0, TAG_TAG); +static const B bi_noVar = tag(1, TAG_TAG); +static const B bi_badHdr = tag(2, TAG_TAG); +static const B bi_optOut = tag(3, TAG_TAG); +static const B bi_noFill = tag(5, TAG_TAG); +extern B bi_emptyHVec, bi_emptyIVec, bi_emptyCVec; static void dec(B x); static B inc(B x); static void ptr_dec(void* x); diff --git a/src/load.c b/src/load.c index e48639e4..f5388932 100644 --- a/src/load.c +++ b/src/load.c @@ -313,11 +313,6 @@ static inline void base_init() { // very first init function ti[t_shape].visit = noop_visit; ti[t_funBI].visit = ti[t_md1BI].visit = ti[t_md2BI].visit = noop_visit; ti[t_funBI].free = ti[t_md1BI].free = ti[t_md2BI].free = builtin_free; - bi_N = tag(0, TAG_TAG); - bi_noVar = tag(1, TAG_TAG); - bi_badHdr = tag(2, TAG_TAG); - bi_optOut = tag(3, TAG_TAG); - bi_noFill = tag(5, TAG_TAG); assert((MD1_TAG>>1) == (MD2_TAG>>1)); // just to be sure it isn't changed incorrectly, `isMd` depends on this #define FA(N,X) { B t=bi_##N = mm_alloc(sizeof(BFn), t_funBI, ftag(FUN_TAG)); BFn*f=c(BFn,t); f->c2=N##_c2 ; f->c1=N##_c1 ; f->extra=pf_##N; f->ident=bi_N; f->uc1=def_fn_uc1; f->ucw=def_fn_ucw; gc_add(t); } diff --git a/src/vm.c b/src/vm.c index 31cab2dd..1c92607e 100644 --- a/src/vm.c +++ b/src/vm.c @@ -39,7 +39,7 @@ enum { LOCU = 31, // N0,N1; like LOCO but overrides the slot with bi_optOut EXTO, EXTM, EXTU, // alternate versions of LOC_ for extended variables ADDI, ADDU, // PUSH with required increment & not required increment - BC_SIZE = 32 + BC_SIZE }; #define FOR_BC(F) F(PUSH) F(VARO) F(VARM) F(ARRO) F(ARRM) F(FN1C) F(FN2C) F(OP1D) F(OP2D) F(TR2D) \