static const tagged builtins

This commit is contained in:
dzaima 2021-05-27 18:07:02 +03:00
parent 48a9b786c9
commit 752a68cb2d
7 changed files with 17 additions and 17 deletions

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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)) {

View File

@ -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

View File

@ -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);

View File

@ -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); }

View File

@ -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) \