rename formatting functions
This commit is contained in:
parent
749b3e1e81
commit
a15f66c43b
@ -5,7 +5,7 @@
|
|||||||
#include "../nfns.h"
|
#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_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_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); }
|
B funBI_identity(B x) { return inc(c(BFn,x)->ident); }
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
B itype_c1(B t, B x) {
|
B itype_c1(B t, B x) {
|
||||||
B r;
|
B r;
|
||||||
if(isVal(x)) {
|
if(isVal(x)) {
|
||||||
r = m_str8l(format_type(v(x)->type));
|
r = m_str8l(type_repr(v(x)->type));
|
||||||
} else {
|
} else {
|
||||||
if (isF64(x)) r = m_str8l("tagged f64");
|
if (isF64(x)) r = m_str8l("tagged f64");
|
||||||
else if (isC32(x)) r = m_str8l("tagged c32");
|
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("flags:%i ", xv->flags);
|
||||||
AFMT("extra:%i ", xv->extra);
|
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));
|
AFMT("alloc:%l", mm_size(xv));
|
||||||
dec(x);
|
dec(x);
|
||||||
} else {
|
} else {
|
||||||
@ -239,7 +239,7 @@ static B unshare(B x) {
|
|||||||
for (usz i = 0; i < xia; i++) rp[i] = unshare(xp[i]);
|
for (usz i = 0; i < xia; i++) rp[i] = unshare(xp[i]);
|
||||||
return taga(r);
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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() {
|
void md1_init() {
|
||||||
TIi(t_md1BI,print) = print_md1BI;
|
TIi(t_md1BI,print) = print_md1BI;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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() {
|
void md2_init() {
|
||||||
TIi(t_md2BI,print) = print_md2BI;
|
TIi(t_md2BI,print) = print_md2BI;
|
||||||
TIi(t_md2BI,m2_uc1) = md2BI_uc1;
|
TIi(t_md2BI,m2_uc1) = md2BI_uc1;
|
||||||
|
|||||||
@ -68,9 +68,9 @@ B glyph_c1(B t, B x) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
u8 ty = v(x)->type;
|
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_funBI) { B r = fromUTF8l(pfn_repr(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_md1BI) { B r = fromUTF8l(pm1_repr(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_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_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_fun_block) { dec(x); return m_str8l("(function block)"); }
|
||||||
if (ty==t_md1_block) { dec(x); return m_str8l("(1-modifier block)"); }
|
if (ty==t_md1_block) { dec(x); return m_str8l("(1-modifier block)"); }
|
||||||
|
|||||||
@ -8,9 +8,9 @@ Value* heap_curr;
|
|||||||
void heapVerify_checkFn(Value* v) {
|
void heapVerify_checkFn(Value* v) {
|
||||||
if (v->refc!=0) {
|
if (v->refc!=0) {
|
||||||
#ifdef OBJ_COUNTER
|
#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
|
#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
|
#endif
|
||||||
heap_observed = v;
|
heap_observed = v;
|
||||||
print(tag(v,OBJ_TAG)); putchar('\n');
|
print(tag(v,OBJ_TAG)); putchar('\n');
|
||||||
|
|||||||
@ -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_visit(Value* x) { mm_visitP(((Slice*)x)->p); }
|
||||||
void slice_print(B x) { arr_print(x); }
|
void slice_print(B x) { arr_print(x); }
|
||||||
|
|
||||||
char* format_type(u8 u) {
|
char* type_repr(u8 u) {
|
||||||
switch(u) { default: return"(unknown type)";
|
switch(u) { default: return"(unknown type)";
|
||||||
#define F(X) case t_##X: return #X;
|
#define F(X) case t_##X: return #X;
|
||||||
FOR_TYPE(F)
|
FOR_TYPE(F)
|
||||||
@ -658,7 +658,7 @@ NOINLINE void printAllocStats() {
|
|||||||
ctr_a[t_harrPartial] = 0;
|
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("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("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;
|
u64 leakedCount = 0;
|
||||||
for (i64 i = 0; i < t_COUNT; i++) leakedCount+= ctr_a[i]-ctr_f[i];
|
for (i64 i = 0; i < t_COUNT; i++) leakedCount+= ctr_a[i]-ctr_f[i];
|
||||||
printf("leaked object count: "N64u"\n", leakedCount);
|
printf("leaked object count: "N64u"\n", leakedCount);
|
||||||
|
|||||||
@ -131,10 +131,10 @@ B make_fmt(char* p, ...);
|
|||||||
|
|
||||||
// function stuff
|
// function stuff
|
||||||
|
|
||||||
char* format_type(u8 u);
|
char* type_repr(u8 u);
|
||||||
char* format_pf(u8 u);
|
char* pfn_repr(u8 u);
|
||||||
char* format_pm1(u8 u);
|
char* pm1_repr(u8 u);
|
||||||
char* format_pm2(u8 u);
|
char* pm2_repr(u8 u);
|
||||||
bool isPureFn(B x); // doesn't consume
|
bool isPureFn(B x); // doesn't consume
|
||||||
B bqn_merge(B x); // consumes
|
B bqn_merge(B x); // consumes
|
||||||
|
|
||||||
|
|||||||
10
src/load.c
10
src/load.c
@ -63,21 +63,21 @@ FOR_PM2(FA,FM,FD)
|
|||||||
#define F(N) u64 N;
|
#define F(N) u64 N;
|
||||||
CTR_FOR(F)
|
CTR_FOR(F)
|
||||||
#undef F
|
#undef F
|
||||||
char* format_pf(u8 u) {
|
char* pfn_repr(u8 u) {
|
||||||
switch(u) { default: return "(unknown function)";
|
switch(u) { default: return "(unknown function)";
|
||||||
#define F(N,X) case pf_##N: return X;
|
#define F(N,X) case pf_##N: return X;
|
||||||
FOR_PFN(F,F,F)
|
FOR_PFN(F,F,F)
|
||||||
#undef F
|
#undef F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char* format_pm1(u8 u) {
|
char* pm1_repr(u8 u) {
|
||||||
switch(u) { default: return"(unknown 1-modifier)";
|
switch(u) { default: return"(unknown 1-modifier)";
|
||||||
#define F(N,X) case pm1_##N: return X;
|
#define F(N,X) case pm1_##N: return X;
|
||||||
FOR_PM1(F,F,F)
|
FOR_PM1(F,F,F)
|
||||||
#undef F
|
#undef F
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char* format_pm2(u8 u) {
|
char* pm2_repr(u8 u) {
|
||||||
switch(u) { default: return"(unknown 2-modifier)";
|
switch(u) { default: return"(unknown 2-modifier)";
|
||||||
#define F(N,X) case pm2_##N: return X;
|
#define F(N,X) case pm2_##N: return X;
|
||||||
FOR_PM2(F,F,F)
|
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 empty_free(Value* x) { err("FREEING EMPTY\n"); }
|
||||||
static void builtin_free(Value* x) { err("FREEING BUILTIN\n"); }
|
static void builtin_free(Value* x) { err("FREEING BUILTIN\n"); }
|
||||||
DEF_FREE(def) { }
|
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_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, format_type(v(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 bool def_canStore(B x) { return false; }
|
||||||
static B def_identity(B f) { return bi_N; }
|
static B def_identity(B f) { return bi_N; }
|
||||||
static B def_get(Arr* x, usz n) { err("def_get"); }
|
static B def_get(Arr* x, usz n) { err("def_get"); }
|
||||||
|
|||||||
@ -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
|
// 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));
|
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;
|
u8 xt = v(x)->type;
|
||||||
switch(m->type) { default: UD;
|
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; }
|
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; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user