diff --git a/src/builtins/fns.c b/src/builtins/fns.c index 9138c056..c51b16ac 100644 --- a/src/builtins/fns.c +++ b/src/builtins/fns.c @@ -5,7 +5,7 @@ #include "../nfns.h" -void print_funBI(B x) { printf("%s", format_pf(c(Fun,x)->extra)); } +void print_funBI(B x) { printf("%s", pfn_repr(c(Fun,x)->extra)); } B funBI_uc1(B t, B o, B x) { return c(BFn,t)->uc1(t, o, x); } B funBI_ucw(B t, B o, B w, B x) { return c(BFn,t)->ucw(t, o, w, x); } B funBI_identity(B x) { return inc(c(BFn,x)->ident); } diff --git a/src/builtins/internal.c b/src/builtins/internal.c index 33f0a691..e6a52ebd 100644 --- a/src/builtins/internal.c +++ b/src/builtins/internal.c @@ -5,7 +5,7 @@ B itype_c1(B t, B x) { B r; if(isVal(x)) { - r = m_str8l(format_type(v(x)->type)); + r = m_str8l(type_repr(v(x)->type)); } else { if (isF64(x)) r = m_str8l("tagged f64"); else if (isC32(x)) r = m_str8l("tagged c32"); @@ -45,7 +45,7 @@ B info_c2(B t, B w, B x) { AFMT("flags:%i ", xv->flags); AFMT("extra:%i ", xv->extra); } - AFMT("type:%i=%S ", xv->type, format_type(xv->type)); + AFMT("type:%i=%S ", xv->type, type_repr(xv->type)); AFMT("alloc:%l", mm_size(xv)); dec(x); } else { @@ -239,7 +239,7 @@ static B unshare(B x) { for (usz i = 0; i < xia; i++) rp[i] = unshare(xp[i]); return taga(r); } - default: thrF("•internal.Unshare: Cannot unshare array with type %i=%S", v(x)->type, format_type((v(x)->type))); + default: thrF("•internal.Unshare: Cannot unshare array with type %i=%S", v(x)->type, type_repr((v(x)->type))); } } diff --git a/src/builtins/md1.c b/src/builtins/md1.c index 732d9bee..47e10e7e 100644 --- a/src/builtins/md1.c +++ b/src/builtins/md1.c @@ -350,7 +350,7 @@ B cell_c2(Md1D* d, B w, B x) { B f = d->f; -static void print_md1BI(B x) { printf("%s", format_pm1(c(Md1,x)->extra)); } +static void print_md1BI(B x) { printf("%s", pm1_repr(c(Md1,x)->extra)); } void md1_init() { TIi(t_md1BI,print) = print_md1BI; } diff --git a/src/builtins/md2.c b/src/builtins/md2.c index cb169eab..21f85e56 100644 --- a/src/builtins/md2.c +++ b/src/builtins/md2.c @@ -149,7 +149,7 @@ B before_uc1(B t, B o, B f, B g, B x) { -static void print_md2BI(B x) { printf("%s", format_pm2(c(Md1,x)->extra)); } +static void print_md2BI(B x) { printf("%s", pm2_repr(c(Md1,x)->extra)); } void md2_init() { TIi(t_md2BI,print) = print_md2BI; TIi(t_md2BI,m2_uc1) = md2BI_uc1; diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index 3ea6189c..6f460711 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -68,9 +68,9 @@ B glyph_c1(B t, B x) { return r; } u8 ty = v(x)->type; - if (ty==t_funBI) { B r = fromUTF8l(format_pf (c(Fun,x)->extra)); dec(x); return r; } - if (ty==t_md1BI) { B r = fromUTF8l(format_pm1(c(Md1,x)->extra)); dec(x); return r; } - if (ty==t_md2BI) { B r = fromUTF8l(format_pm2(c(Md2,x)->extra)); dec(x); return r; } + if (ty==t_funBI) { B r = fromUTF8l(pfn_repr(c(Fun,x)->extra)); dec(x); return r; } + if (ty==t_md1BI) { B r = fromUTF8l(pm1_repr(c(Md1,x)->extra)); dec(x); return r; } + if (ty==t_md2BI) { B r = fromUTF8l(pm2_repr(c(Md2,x)->extra)); dec(x); return r; } if (ty==t_nfn) { B r = nfn_name(x); dec(x); return r; } if (ty==t_fun_block) { dec(x); return m_str8l("(function block)"); } if (ty==t_md1_block) { dec(x); return m_str8l("(1-modifier block)"); } diff --git a/src/core/heap.c b/src/core/heap.c index 3d3d719f..fa6caf87 100644 --- a/src/core/heap.c +++ b/src/core/heap.c @@ -8,9 +8,9 @@ Value* heap_curr; void heapVerify_checkFn(Value* v) { if (v->refc!=0) { #ifdef OBJ_COUNTER - printf("delta %d for %s, uid "N64d": ", v->refc, format_type(v->type), v->uid); + printf("delta %d for %s, uid "N64d": ", v->refc, type_repr(v->type), v->uid); #else - printf("delta %d for %s: ", (i32)v->refc, format_type(v->type)); + printf("delta %d for %s: ", (i32)v->refc, type_repr(v->type)); #endif heap_observed = v; print(tag(v,OBJ_TAG)); putchar('\n'); diff --git a/src/core/stuff.c b/src/core/stuff.c index 24058568..45c21f85 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -442,7 +442,7 @@ void slice_freeF(Value* x) { slice_freeO(x); mm_free(x); } void slice_visit(Value* x) { mm_visitP(((Slice*)x)->p); } void slice_print(B x) { arr_print(x); } -char* format_type(u8 u) { +char* type_repr(u8 u) { switch(u) { default: return"(unknown type)"; #define F(X) case t_##X: return #X; FOR_TYPE(F) @@ -658,7 +658,7 @@ NOINLINE void printAllocStats() { ctr_a[t_harrPartial] = 0; printf("ctrA←"); for (i64 i = 0; i < t_COUNT; i++) { if(i)printf("‿"); printf(N64u, ctr_a[i]); } printf("\n"); printf("ctrF←"); for (i64 i = 0; i < t_COUNT; i++) { if(i)printf("‿"); printf(N64u, ctr_f[i]); } printf("\n"); - printf("names←⟨"); for (i64 i = 0; i < t_COUNT; i++) { if(i)printf(","); printf("\"%s\"", format_type(i)); } printf("⟩\n"); + printf("names←⟨"); for (i64 i = 0; i < t_COUNT; i++) { if(i)printf(","); printf("\"%s\"", type_repr(i)); } printf("⟩\n"); u64 leakedCount = 0; for (i64 i = 0; i < t_COUNT; i++) leakedCount+= ctr_a[i]-ctr_f[i]; printf("leaked object count: "N64u"\n", leakedCount); diff --git a/src/core/stuff.h b/src/core/stuff.h index d4718749..fe6f708f 100644 --- a/src/core/stuff.h +++ b/src/core/stuff.h @@ -131,10 +131,10 @@ B make_fmt(char* p, ...); // function stuff -char* format_type(u8 u); -char* format_pf(u8 u); -char* format_pm1(u8 u); -char* format_pm2(u8 u); +char* type_repr(u8 u); +char* pfn_repr(u8 u); +char* pm1_repr(u8 u); +char* pm2_repr(u8 u); bool isPureFn(B x); // doesn't consume B bqn_merge(B x); // consumes diff --git a/src/load.c b/src/load.c index 54698889..7a9685c1 100644 --- a/src/load.c +++ b/src/load.c @@ -63,21 +63,21 @@ FOR_PM2(FA,FM,FD) #define F(N) u64 N; CTR_FOR(F) #undef F -char* format_pf(u8 u) { +char* pfn_repr(u8 u) { switch(u) { default: return "(unknown function)"; #define F(N,X) case pf_##N: return X; FOR_PFN(F,F,F) #undef F } } -char* format_pm1(u8 u) { +char* pm1_repr(u8 u) { switch(u) { default: return"(unknown 1-modifier)"; #define F(N,X) case pm1_##N: return X; FOR_PM1(F,F,F) #undef F } } -char* format_pm2(u8 u) { +char* pm2_repr(u8 u) { switch(u) { default: return"(unknown 2-modifier)"; #define F(N,X) case pm2_##N: return X; FOR_PM2(F,F,F) @@ -378,8 +378,8 @@ static void freed_visit(Value* x) { static void empty_free(Value* x) { err("FREEING EMPTY\n"); } static void builtin_free(Value* x) { err("FREEING BUILTIN\n"); } DEF_FREE(def) { } -static void def_visit(Value* x) { printf("(no visit for %d=%s)\n", x->type, format_type(x->type)); } -static void def_print(B x) { printf("(%d=%s)", v(x)->type, format_type(v(x)->type)); } +static void def_visit(Value* x) { printf("(no visit for %d=%s)\n", x->type, type_repr(x->type)); } +static void def_print(B x) { printf("(%d=%s)", v(x)->type, type_repr(v(x)->type)); } static bool def_canStore(B x) { return false; } static B def_identity(B f) { return bi_N; } static B def_get(Arr* x, usz n) { err("def_get"); } diff --git a/src/utils/mut.h b/src/utils/mut.h index ef3ec58a..03e79f9b 100644 --- a/src/utils/mut.h +++ b/src/utils/mut.h @@ -162,7 +162,7 @@ static void mut_fill(Mut* m, usz ms, B x, usz l) { // mut_copy but x is guaranteed to be a subtype of m static void mut_copyG(Mut* m, usz ms, B x, usz xs, usz l) { assert(isArr(x)); - // printf("mut_%d[%d…%d] ← %s[%d…%d]\n", m->type, ms, ms+l, format_type(xt), xs, xs+l); fflush(stdout); + // printf("mut_%d[%d…%d] ← %s[%d…%d]\n", m->type, ms, ms+l, type_repr(xt), xs, xs+l); fflush(stdout); u8 xt = v(x)->type; switch(m->type) { default: UD; case el_i8: { i8* rp = m->ai8+ms; i8* xp = i8any_ptr(x); for (usz i = 0; i < l; i++) rp[i] = xp[i+xs]; return; }