more print function renaming
This commit is contained in:
parent
6f394c41ff
commit
86ae984af0
@ -38,7 +38,7 @@ B type_c1(B t, B x) {
|
|||||||
else if (isNsp(x)) r = 6;
|
else if (isNsp(x)) r = 6;
|
||||||
if (RARE(r==-1)) {
|
if (RARE(r==-1)) {
|
||||||
if (x.u == bi_optOut.u) thrM("Reading variable that was optimized out by F↩ after error");
|
if (x.u == bi_optOut.u) thrM("Reading variable that was optimized out by F↩ after error");
|
||||||
print(x); err(": getting type");
|
printI(x); err(": getting type");
|
||||||
}
|
}
|
||||||
decR(x);
|
decR(x);
|
||||||
return m_i32(r);
|
return m_i32(r);
|
||||||
@ -254,16 +254,16 @@ B sys_c1(B t, B x);
|
|||||||
B out_c1(B t, B x) {
|
B out_c1(B t, B x) {
|
||||||
if (isAtm(x)) thrM("•Out: Argument must be a list");
|
if (isAtm(x)) thrM("•Out: Argument must be a list");
|
||||||
if (RNK(x)>1) thrF("•Out: Argument cannot have rank %i", RNK(x));
|
if (RNK(x)>1) thrF("•Out: Argument cannot have rank %i", RNK(x));
|
||||||
printRaw(x); putchar('\n');
|
printsB(x); putchar('\n');
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
B show_c1(B t, B x) {
|
B show_c1(B t, B x) {
|
||||||
#ifndef NO_SHOW
|
#ifndef NO_SHOW
|
||||||
#if FORMATTER
|
#if FORMATTER
|
||||||
B fmt = bqn_fmt(inc(x));
|
B fmt = bqn_fmt(inc(x));
|
||||||
printRaw(fmt); dec(fmt);
|
printsB(fmt); dec(fmt);
|
||||||
#else
|
#else
|
||||||
print(x);
|
printI(x);
|
||||||
#endif
|
#endif
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -14,11 +14,11 @@ static void md2H_visit(Value* x) { mm_visitP(((Md2H*)x)->m2); mm_visit(((Md2H*)x
|
|||||||
static void fork_visit(Value* x) { mm_visit (((Fork*)x)->f ); mm_visit(((Fork*)x)->g); mm_visit(((Fork*)x)->h); }
|
static void fork_visit(Value* x) { mm_visit (((Fork*)x)->f ); mm_visit(((Fork*)x)->g); mm_visit(((Fork*)x)->h); }
|
||||||
static void atop_visit(Value* x) { mm_visit(((Atop*)x)->g); mm_visit(((Atop*)x)->h); }
|
static void atop_visit(Value* x) { mm_visit(((Atop*)x)->g); mm_visit(((Atop*)x)->h); }
|
||||||
|
|
||||||
static void md1D_print(FILE* f, B x) { fprintf(f,"(md1D ");fprint(f,c(Md1D,x)->f);fprintf(f," ");fprint(f,tag(c(Md1D,x)->m1,MD1_TAG)); fprintf(f,")"); }
|
static void md1D_print(FILE* f, B x) { fprintf(f,"(md1D ");fprintI(f,c(Md1D,x)->f);fprintf(f," ");fprintI(f,tag(c(Md1D,x)->m1,MD1_TAG)); fprintf(f,")"); }
|
||||||
static void md2D_print(FILE* f, B x) { fprintf(f,"(md2D ");fprint(f,c(Md2D,x)->f);fprintf(f," ");fprint(f,tag(c(Md2D,x)->m2,MD2_TAG));fprintf(f," ");fprint(f,c(Md2D,x)->g);fprintf(f,")"); }
|
static void md2D_print(FILE* f, B x) { fprintf(f,"(md2D ");fprintI(f,c(Md2D,x)->f);fprintf(f," ");fprintI(f,tag(c(Md2D,x)->m2,MD2_TAG));fprintf(f," ");fprintI(f,c(Md2D,x)->g);fprintf(f,")"); }
|
||||||
static void md2H_print(FILE* f, B x) { fprintf(f,"(md2H "); fprint(f,tag(c(Md2H,x)->m2,MD2_TAG));fprintf(f," ");fprint(f,c(Md2H,x)->g);fprintf(f,")"); }
|
static void md2H_print(FILE* f, B x) { fprintf(f,"(md2H "); fprintI(f,tag(c(Md2H,x)->m2,MD2_TAG));fprintf(f," ");fprintI(f,c(Md2H,x)->g);fprintf(f,")"); }
|
||||||
static void fork_print(FILE* f, B x) { fprintf(f,"(fork ");fprint(f,c(Fork,x)->f);fprintf(f," ");fprint(f, c(Fork,x)->g );fprintf(f," ");fprint(f,c(Fork,x)->h);fprintf(f,")"); }
|
static void fork_print(FILE* f, B x) { fprintf(f,"(fork ");fprintI(f,c(Fork,x)->f);fprintf(f," ");fprintI(f, c(Fork,x)->g );fprintf(f," ");fprintI(f,c(Fork,x)->h);fprintf(f,")"); }
|
||||||
static void atop_print(FILE* f, B x) { fprintf(f,"(atop "); fprint(f, c(Atop,x)->g );fprintf(f," ");fprint(f,c(Atop,x)->h);fprintf(f,")"); }
|
static void atop_print(FILE* f, B x) { fprintf(f,"(atop "); fprintI(f, c(Atop,x)->g );fprintf(f," ");fprintI(f,c(Atop,x)->h);fprintf(f,")"); }
|
||||||
|
|
||||||
B md1D_c1(B t, B x) { Md1D* tc = c(Md1D, t); return ((Md1*)tc->m1)->c1(tc, x); }
|
B md1D_c1(B t, B x) { Md1D* tc = c(Md1D, t); return ((Md1*)tc->m1)->c1(tc, x); }
|
||||||
B md1D_c2(B t, B w, B x) { Md1D* tc = c(Md1D, t); return ((Md1*)tc->m1)->c2(tc, w, x); }
|
B md1D_c2(B t, B w, B x) { Md1D* tc = c(Md1D, t); return ((Md1*)tc->m1)->c2(tc, w, x); }
|
||||||
|
|||||||
@ -123,7 +123,7 @@ static void harrP_print(FILE* f, B x) {
|
|||||||
for (usz i = 0; i < ia; i++) {
|
for (usz i = 0; i < ia; i++) {
|
||||||
if (i) fprintf(f, ", ");
|
if (i) fprintf(f, ", ");
|
||||||
if (i>=am) fprintf(f, "?");
|
if (i>=am) fprintf(f, "?");
|
||||||
else fprint(f, p[i]);
|
else fprintI(f, p[i]);
|
||||||
}
|
}
|
||||||
fprintf(f, "⟩)");
|
fprintf(f, "⟩)");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ void heapVerify_checkFn(Value* v) {
|
|||||||
printf("delta %d for %s @ %p: ", (i32)v->refc, type_repr(v->type), v);
|
printf("delta %d for %s @ %p: ", (i32)v->refc, type_repr(v->type), v);
|
||||||
#endif
|
#endif
|
||||||
heap_observed = v;
|
heap_observed = v;
|
||||||
print(tag(v,OBJ_TAG)); putchar('\n');
|
printI(tag(v,OBJ_TAG)); putchar('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ static bool heapVerify_visitP(void* x) {
|
|||||||
Value* v = x;
|
Value* v = x;
|
||||||
if (heapVerify_mode==0) v->refc--;
|
if (heapVerify_mode==0) v->refc--;
|
||||||
else if(heapVerify_mode==1) v->refc++;
|
else if(heapVerify_mode==1) v->refc++;
|
||||||
else if(heapVerify_mode==2) if (x==heap_observed) { printf("referee: %p ", heap_curr); print(tag(heap_curr,OBJ_TAG)); putchar('\n'); }
|
else if(heapVerify_mode==2) if (x==heap_observed) { printf("referee: %p ", heap_curr); printI(tag(heap_curr,OBJ_TAG)); putchar('\n'); }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void heapVerify(void);
|
void heapVerify(void);
|
||||||
|
|||||||
@ -95,14 +95,14 @@ NOINLINE TStack* ts_e(TStack* o, u32 elsz, u64 am) { u64 size = o->size;
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void farr_print(FILE* f, B x) { // should accept refc=0 arguments for debugging purposes
|
NOINLINE void farr_print(FILE* f, B x) { // should accept refc=0 arguments for debugging purposes
|
||||||
ur r = RNK(x);
|
ur r = RNK(x);
|
||||||
SGetU(x)
|
SGetU(x)
|
||||||
usz ia = IA(x);
|
usz ia = IA(x);
|
||||||
if (r!=1) {
|
if (r!=1) {
|
||||||
if (r==0) {
|
if (r==0) {
|
||||||
fprintf(f, "<");
|
fprintf(f, "<");
|
||||||
fprint(f, GetU(x,0));
|
fprintI(f, GetU(x,0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
usz* sh = SH(x);
|
usz* sh = SH(x);
|
||||||
@ -112,11 +112,9 @@ void farr_print(FILE* f, B x) { // should accept refc=0 arguments for debugging
|
|||||||
}
|
}
|
||||||
fprintCodepoint(f, U'⥊');
|
fprintCodepoint(f, U'⥊');
|
||||||
} else if (ia>0) {
|
} else if (ia>0) {
|
||||||
if (!elChr(TI(x,elType))) {
|
for (usz i = 0; i < ia; i++) {
|
||||||
for (usz i = 0; i < ia; i++) {
|
B c = GetU(x, i);
|
||||||
B c = GetU(x, i);
|
if (!isC32(c) || o2cG(c)<32) goto reg;
|
||||||
if (!isC32(c) || o2cG(c)<32) goto reg;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fprintf(f, "\"");
|
fprintf(f, "\"");
|
||||||
fprintsB(f, x);
|
fprintsB(f, x);
|
||||||
@ -127,12 +125,12 @@ void farr_print(FILE* f, B x) { // should accept refc=0 arguments for debugging
|
|||||||
fprintCodepoint(f, U'⟨');
|
fprintCodepoint(f, U'⟨');
|
||||||
for (usz i = 0; i < ia; i++) {
|
for (usz i = 0; i < ia; i++) {
|
||||||
if (i!=0) fprintf(f, ", ");
|
if (i!=0) fprintf(f, ", ");
|
||||||
fprint(f, GetU(x,i));
|
fprintI(f, GetU(x,i));
|
||||||
}
|
}
|
||||||
fprintCodepoint(f, U'⟩');
|
fprintCodepoint(f, U'⟩');
|
||||||
}
|
}
|
||||||
|
|
||||||
void fprint(FILE* f, B x) {
|
NOINLINE void fprintI(FILE* f, B x) {
|
||||||
if (isF64(x)) {
|
if (isF64(x)) {
|
||||||
NUM_FMT_BUF(buf, x.f);
|
NUM_FMT_BUF(buf, x.f);
|
||||||
fprintf(f, "%s", buf);
|
fprintf(f, "%s", buf);
|
||||||
@ -163,19 +161,9 @@ void fprint(FILE* f, B x) {
|
|||||||
else fprintf(f, "(todo tag "N64x")", x.u>>48);
|
else fprintf(f, "(todo tag "N64x")", x.u>>48);
|
||||||
}
|
}
|
||||||
|
|
||||||
NOINLINE void fprintRaw(FILE* f, B x) {
|
void printI (B x) { fprintI (stdout, x); }
|
||||||
fprintsB(f, x);
|
void printsB (B x) { fprintsB (stdout, x); }
|
||||||
}
|
void arr_print(B x) { farr_print(stdout, x); }
|
||||||
|
|
||||||
NOINLINE void printRaw(B x) {
|
|
||||||
fprintRaw(stdout, x);
|
|
||||||
}
|
|
||||||
NOINLINE void arr_print(B x) {
|
|
||||||
farr_print(stdout, x);
|
|
||||||
}
|
|
||||||
NOINLINE void print(B x) {
|
|
||||||
fprint(stdout, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
i32 num_fmt(char buf[30], f64 x) {
|
i32 num_fmt(char buf[30], f64 x) {
|
||||||
// for (int i = 0; i < 30; i++) buf[i] = 'a';
|
// for (int i = 0; i < 30; i++) buf[i] = 'a';
|
||||||
@ -343,7 +331,7 @@ NOINLINE void fprint_fmt(FILE* f, char* p, ...) {
|
|||||||
va_start(a, p);
|
va_start(a, p);
|
||||||
B r = do_fmt(emptyCVec(), p, a);
|
B r = do_fmt(emptyCVec(), p, a);
|
||||||
va_end(a);
|
va_end(a);
|
||||||
fprintRaw(f, r);
|
fprintsB(f, r);
|
||||||
decG(r);
|
decG(r);
|
||||||
}
|
}
|
||||||
NOINLINE void print_fmt(char* p, ...) {
|
NOINLINE void print_fmt(char* p, ...) {
|
||||||
@ -351,7 +339,7 @@ NOINLINE void print_fmt(char* p, ...) {
|
|||||||
va_start(a, p);
|
va_start(a, p);
|
||||||
B r = do_fmt(emptyCVec(), p, a);
|
B r = do_fmt(emptyCVec(), p, a);
|
||||||
va_end(a);
|
va_end(a);
|
||||||
printRaw(r);
|
printsB(r);
|
||||||
decG(r);
|
decG(r);
|
||||||
}
|
}
|
||||||
NOINLINE void thrF(char* p, ...) {
|
NOINLINE void thrF(char* p, ...) {
|
||||||
@ -783,10 +771,10 @@ B g_t (void* x) { return tag(x,OBJ_TAG); }
|
|||||||
B g_ta(void* x) { return tag(x,ARR_TAG); }
|
B g_ta(void* x) { return tag(x,ARR_TAG); }
|
||||||
B g_tf(void* x) { return tag(x,FUN_TAG); }
|
B g_tf(void* x) { return tag(x,FUN_TAG); }
|
||||||
bool ignore_bad_tag;
|
bool ignore_bad_tag;
|
||||||
void g_p(B x) { print(x); putchar(10); fflush(stdout); }
|
void g_p(B x) { printI(x); putchar(10); fflush(stdout); }
|
||||||
void g_i(B x) { B r = info_c2(x, m_f64(1), inc(x)); print(r); dec(r); putchar(10); fflush(stdout); }
|
void g_i(B x) { B r = info_c2(x, m_f64(1), inc(x)); printI(r); dec(r); putchar(10); fflush(stdout); }
|
||||||
void g_pv(void* x) { ignore_bad_tag=true; print(tag(x,OBJ_TAG)); putchar(10); fflush(stdout); ignore_bad_tag=false; }
|
void g_pv(void* x) { ignore_bad_tag=true; printI(tag(x,OBJ_TAG)); putchar(10); fflush(stdout); ignore_bad_tag=false; }
|
||||||
void g_iv(void* x) { ignore_bad_tag=true; B xo = tag(x, OBJ_TAG); B r = info_c2(xo, m_f64(1), inc(xo)); print(r); dec(r); putchar(10); fflush(stdout); ignore_bad_tag=false; }
|
void g_iv(void* x) { ignore_bad_tag=true; B xo = tag(x, OBJ_TAG); B r = info_c2(xo, m_f64(1), inc(xo)); printI(r); dec(r); putchar(10); fflush(stdout); ignore_bad_tag=false; }
|
||||||
void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -799,7 +787,7 @@ void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
|||||||
if (x->refc<=0 || (x->refc>>28) == 'a' || x->type==t_empty) {
|
if (x->refc<=0 || (x->refc>>28) == 'a' || x->type==t_empty) {
|
||||||
PRINT_ID(x);
|
PRINT_ID(x);
|
||||||
fprintf(stderr, "bad refcount for type %d: %d\nattempting to print: ", x->type, x->refc); fflush(stderr);
|
fprintf(stderr, "bad refcount for type %d: %d\nattempting to print: ", x->type, x->refc); fflush(stderr);
|
||||||
fprint(stderr, tag(x,OBJ_TAG)); fputc('\n', stderr); fflush(stderr);
|
fprintI(stderr, tag(x,OBJ_TAG)); fputc('\n', stderr); fflush(stderr);
|
||||||
err("");
|
err("");
|
||||||
}
|
}
|
||||||
if (TIv(x,isArr)) {
|
if (TIv(x,isArr)) {
|
||||||
@ -818,7 +806,7 @@ void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
|||||||
if(isArr(x)!=TI(x,isArr) && v(x)->type!=t_freed && v(x)->type!=t_harrPartial && !ignore_bad_tag) {
|
if(isArr(x)!=TI(x,isArr) && v(x)->type!=t_freed && v(x)->type!=t_harrPartial && !ignore_bad_tag) {
|
||||||
fprintf(stderr, "bad array tag/type: type=%d, obj=%p\n", v(x)->type, TOPTR(void, x.u));
|
fprintf(stderr, "bad array tag/type: type=%d, obj=%p\n", v(x)->type, TOPTR(void, x.u));
|
||||||
PRINT_ID(v(x));
|
PRINT_ID(v(x));
|
||||||
fprint(stderr, x);
|
fprintI(stderr, x);
|
||||||
err("\n");
|
err("\n");
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
@ -838,7 +826,7 @@ void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
|||||||
if (isArr(x)) fprint_fmt(stderr, "%s items, %S, shape=%H\n", IA(x), eltype_repr(TI(x,elType)), x);
|
if (isArr(x)) fprint_fmt(stderr, "%s items, %S, shape=%H\n", IA(x), eltype_repr(TI(x,elType)), x);
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "atom: ");
|
fprintf(stderr, "atom: ");
|
||||||
fprintRaw(stderr, x = bqn_fmt(inc(x))); dec(x);
|
fprintsB(stderr, x = bqn_fmt(inc(x))); dec(x);
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -243,7 +243,7 @@ typedef struct BQNFFIType {
|
|||||||
B vfyStr(B x, char* name, char* arg);
|
B vfyStr(B x, char* name, char* arg);
|
||||||
static void printFFIType(FILE* f, B x) {
|
static void printFFIType(FILE* f, B x) {
|
||||||
if (isC32(x)) fprintf(f, "%d", o2cG(x));
|
if (isC32(x)) fprintf(f, "%d", o2cG(x));
|
||||||
else fprint(f, x);
|
else fprintI(f, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FFI==2
|
#if FFI==2
|
||||||
@ -432,7 +432,7 @@ BQNFFIEnt ffi_parseType(B arg, bool forRes) { // doesn't consume; parse argument
|
|||||||
else side = 0;
|
else side = 0;
|
||||||
|
|
||||||
t = ffi_parseTypeStr(&xp, false);
|
t = ffi_parseTypeStr(&xp, false);
|
||||||
// print(arg); printf(": "); printFFIType(stdout, t.o); printf("\n");
|
// printI(arg); printf(": "); printFFIType(stdout, t.o); printf("\n");
|
||||||
if (xp!=xpN) thrM("FFI: Bad type descriptor");
|
if (xp!=xpN) thrM("FFI: Bad type descriptor");
|
||||||
t.onW = side;
|
t.onW = side;
|
||||||
// keep .mutates
|
// keep .mutates
|
||||||
@ -476,7 +476,7 @@ FORCE_INLINE u64 i64abs(i64 x) { return x<0?-x:x; }
|
|||||||
|
|
||||||
|
|
||||||
void genObj(B o, B c, bool anyMut, void* ptr) {
|
void genObj(B o, B c, bool anyMut, void* ptr) {
|
||||||
// printFFIType(stdout,o); printf(" = "); print(c); printf("\n");
|
// printFFIType(stdout,o); printf(" = "); printI(c); printf("\n");
|
||||||
if (isC32(o)) { // scalar
|
if (isC32(o)) { // scalar
|
||||||
u32 t = o2cG(o);
|
u32 t = o2cG(o);
|
||||||
f64 f = c.f;
|
f64 f = c.f;
|
||||||
|
|||||||
10
src/h.h
10
src/h.h
@ -363,12 +363,12 @@ static u64 mm_size(Value* x);
|
|||||||
static void dec(B x);
|
static void dec(B x);
|
||||||
static B inc(B x);
|
static B inc(B x);
|
||||||
static void ptr_dec(void* x);
|
static void ptr_dec(void* x);
|
||||||
void fprint (FILE* f, B x); // doesn't consume
|
void fprintI(FILE* f, B x); // doesn't consume
|
||||||
void fprintRaw (FILE* f, B x); // doesn't consume
|
void printI( B x); // doesn't consume
|
||||||
|
void fprintsB(FILE* f, B x); // doesn't consume
|
||||||
|
void printsB( B x); // doesn't consume
|
||||||
void farr_print(FILE* f, B x); // doesn't consume
|
void farr_print(FILE* f, B x); // doesn't consume
|
||||||
void print(B x); // doesn't consume
|
void arr_print( B x); // doesn't consume
|
||||||
void printRaw(B x); // doesn't consume
|
|
||||||
void arr_print(B x); // doesn't consume
|
|
||||||
bool equal(B w, B x); // doesn't consume
|
bool equal(B w, B x); // doesn't consume
|
||||||
bool eequal(B w, B x); // doesn't consume
|
bool eequal(B w, B x); // doesn't consume
|
||||||
B toCells(B x); // consumes
|
B toCells(B x); // consumes
|
||||||
|
|||||||
@ -511,7 +511,7 @@ static void onJIT(Body* body, u8* binEx, u64 sz) {
|
|||||||
if (!perf_map) {
|
if (!perf_map) {
|
||||||
B s = m_c8vec_0("/tmp/perf-"); AFMT("%l.map", getpid());
|
B s = m_c8vec_0("/tmp/perf-"); AFMT("%l.map", getpid());
|
||||||
perf_map = file_open(s, "open", "wa");
|
perf_map = file_open(s, "open", "wa");
|
||||||
print(s); printf(": map\n");
|
printsB(s); printf(": map\n");
|
||||||
dec(s);
|
dec(s);
|
||||||
}
|
}
|
||||||
u32 bcPos = body->bl->map[0];
|
u32 bcPos = body->bl->map[0];
|
||||||
|
|||||||
@ -467,7 +467,7 @@ void load_init() { // very last init function
|
|||||||
, bi_N, bi_N, bi_N, bi_N, NULL
|
, bi_N, bi_N, bi_N, bi_N, NULL
|
||||||
);
|
);
|
||||||
B interp = evalFunBlock(c, 0); ptr_dec(c);
|
B interp = evalFunBlock(c, 0); ptr_dec(c);
|
||||||
print(interp);
|
printI(interp);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
dec(interp);
|
dec(interp);
|
||||||
#ifdef HEAP_VERIFY
|
#ifdef HEAP_VERIFY
|
||||||
|
|||||||
14
src/main.c
14
src/main.c
@ -603,7 +603,7 @@ void cbqn_runLine0(char* ln, i64 read) {
|
|||||||
B* rp = harr_ptr(r);
|
B* rp = harr_ptr(r);
|
||||||
for (usz i = 0; i < ia; i++) {
|
for (usz i = 0; i < ia; i++) {
|
||||||
if (i!=0) printf(", ");
|
if (i!=0) printf(", ");
|
||||||
printRaw(rp[i]);
|
printsB(rp[i]);
|
||||||
}
|
}
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
@ -645,7 +645,7 @@ void cbqn_runLine0(char* ln, i64 read) {
|
|||||||
HArr* expla = toHArr(expl);
|
HArr* expla = toHArr(expl);
|
||||||
usz ia=PIA(expla);
|
usz ia=PIA(expla);
|
||||||
for(usz i=0; i<ia; i++) {
|
for(usz i=0; i<ia; i++) {
|
||||||
printRaw(expla->a[i]);
|
printsB(expla->a[i]);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
dec(expl);
|
dec(expl);
|
||||||
@ -697,10 +697,10 @@ void cbqn_runLine0(char* ln, i64 read) {
|
|||||||
if (output) {
|
if (output) {
|
||||||
if (output!=2 && FORMATTER) {
|
if (output!=2 && FORMATTER) {
|
||||||
B resFmt = bqn_fmt(res);
|
B resFmt = bqn_fmt(res);
|
||||||
printRaw(resFmt); dec(resFmt);
|
printsB(resFmt); dec(resFmt);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
} else {
|
} else {
|
||||||
print(res); putchar('\n'); fflush(stdout);
|
printI(res); putchar('\n'); fflush(stdout);
|
||||||
dec(res);
|
dec(res);
|
||||||
}
|
}
|
||||||
} else dec(res);
|
} else dec(res);
|
||||||
@ -735,7 +735,7 @@ void cbqn_evalSrc(char* src, i64 len) {
|
|||||||
B res = bqn_exec(code, bi_N, bi_N);
|
B res = bqn_exec(code, bi_N, bi_N);
|
||||||
|
|
||||||
B resFmt = bqn_fmt(res);
|
B resFmt = bqn_fmt(res);
|
||||||
printRaw(resFmt); dec(resFmt);
|
printsB(resFmt); dec(resFmt);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -790,13 +790,13 @@ int main(int argc, char* argv[]) {
|
|||||||
case 'L': { repl_init(); break; } // just initialize. mostly for perf testing
|
case 'L': { repl_init(); break; } // just initialize. mostly for perf testing
|
||||||
case 'p': { repl_init(); REQARG(p);
|
case 'p': { repl_init(); REQARG(p);
|
||||||
B r = bqn_fmt(gsc_exec_inline(utf8Decode0(argv[i++]), m_c8vec_0("(-p)"), emptySVec()));
|
B r = bqn_fmt(gsc_exec_inline(utf8Decode0(argv[i++]), m_c8vec_0("(-p)"), emptySVec()));
|
||||||
printRaw(r); dec(r);
|
printsB(r); dec(r);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'o': { repl_init(); REQARG(o);
|
case 'o': { repl_init(); REQARG(o);
|
||||||
B r = gsc_exec_inline(utf8Decode0(argv[i++]), m_c8vec_0("(-o)"), emptySVec());
|
B r = gsc_exec_inline(utf8Decode0(argv[i++]), m_c8vec_0("(-o)"), emptySVec());
|
||||||
printRaw(r); dec(r);
|
printsB(r); dec(r);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ B nfn_name(B x) { VTY(x, t_nfn);
|
|||||||
|
|
||||||
DEF_FREE(nfn) { dec(((NFn*)x)->obj); }
|
DEF_FREE(nfn) { dec(((NFn*)x)->obj); }
|
||||||
void nfn_visit(Value* x) { mm_visit(((NFn*)x)->obj); }
|
void nfn_visit(Value* x) { mm_visit(((NFn*)x)->obj); }
|
||||||
void nfn_print(FILE* f, B x) { fprintRaw(f, c(NFnDesc,IGetU(nfn_list,c(NFn,x)->id))->name); }
|
void nfn_print(FILE* f, B x) { fprintsB(f, c(NFnDesc,IGetU(nfn_list,c(NFn,x)->id))->name); }
|
||||||
DEF_FREE(nfnDesc) { err("nfnDesc shouldn't be freed!"); }
|
DEF_FREE(nfnDesc) { err("nfnDesc shouldn't be freed!"); }
|
||||||
void nfnDesc_visit(Value* x) { mm_visit(((NFnDesc*)x)->name); }
|
void nfnDesc_visit(Value* x) { mm_visit(((NFnDesc*)x)->name); }
|
||||||
void nfnDesc_print(FILE* f, B x) { fprintf(f, "(native function description)"); }
|
void nfnDesc_print(FILE* f, B x) { fprintf(f, "(native function description)"); }
|
||||||
|
|||||||
4
src/ns.c
4
src/ns.c
@ -187,9 +187,9 @@ static void ns_print(FILE* f, B x) {
|
|||||||
if (id>=0) {
|
if (id>=0) {
|
||||||
if (first) first=false;
|
if (first) first=false;
|
||||||
else fprintf(f," ⋄ ");
|
else fprintf(f," ⋄ ");
|
||||||
fprintRaw(f, gid2str(id));
|
fprintsB(f, gid2str(id));
|
||||||
fprintf(f, "⇐");
|
fprintf(f, "⇐");
|
||||||
fprint(f, sc->vars[i]);
|
fprintI(f, sc->vars[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fputc('}', f);
|
fputc('}', f);
|
||||||
|
|||||||
16
src/rtwrap.c
16
src/rtwrap.c
@ -58,12 +58,12 @@ B wfn_identity(B x) {
|
|||||||
#if RT_VERIFY
|
#if RT_VERIFY
|
||||||
B info_c2(B t, B w, B x);
|
B info_c2(B t, B w, B x);
|
||||||
#define CHK(EXP,GOT,W,X) { if (!eequal(EXP,GOT)) { \
|
#define CHK(EXP,GOT,W,X) { if (!eequal(EXP,GOT)) { \
|
||||||
print(f); printf(": failed RT_VERIFY\n"); fflush(stdout); \
|
printI(f); printf(": failed RT_VERIFY\n"); fflush(stdout); \
|
||||||
if (RT_VERIFY_ARGS) { \
|
if (RT_VERIFY_ARGS) { \
|
||||||
if(!q_N(W)){printf("𝕨:"); print(W); printf(" / "); printRaw(info_c2(bi_N, m_i32(1), inc(W))); putchar('\n'); fflush(stdout); } \
|
if(!q_N(W)){printf("𝕨:"); printI(W); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(W))); putchar('\n'); fflush(stdout); } \
|
||||||
{ printf("𝕩:"); print(X); printf(" / "); printRaw(info_c2(bi_N, m_i32(1), inc(X))); putchar('\n'); fflush(stdout); } \
|
{ printf("𝕩:"); printI(X); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(X))); putchar('\n'); fflush(stdout); } \
|
||||||
{ printf("got:"); print(GOT); printf(" / "); printRaw(info_c2(bi_N, m_i32(1), inc(GOT))); putchar('\n'); fflush(stdout); } \
|
{ printf("got:"); printI(GOT); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(GOT))); putchar('\n'); fflush(stdout); } \
|
||||||
{ printf("exp:"); print(EXP); printf(" / "); printRaw(info_c2(bi_N, m_i32(1), inc(EXP))); putchar('\n'); fflush(stdout); } \
|
{ printf("exp:"); printI(EXP); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(EXP))); putchar('\n'); fflush(stdout); } \
|
||||||
} \
|
} \
|
||||||
vm_pstLive(); exit(1); \
|
vm_pstLive(); exit(1); \
|
||||||
}}
|
}}
|
||||||
@ -294,19 +294,19 @@ void rtWrap_print() {
|
|||||||
#if RT_PERF
|
#if RT_PERF
|
||||||
WFun* cf = lastWF;
|
WFun* cf = lastWF;
|
||||||
while (cf) {
|
while (cf) {
|
||||||
printRaw(c1(bi_glyph, tag(cf,FUN_TAG)));
|
printsB(c1(bi_glyph, tag(cf,FUN_TAG)));
|
||||||
printf(": m=%d %.3fms | d=%d %.3fms\n", cf->c1a, cf->c1t/1e6, cf->c2a, cf->c2t/1e6);
|
printf(": m=%d %.3fms | d=%d %.3fms\n", cf->c1a, cf->c1t/1e6, cf->c2a, cf->c2t/1e6);
|
||||||
cf = cf->prev;
|
cf = cf->prev;
|
||||||
}
|
}
|
||||||
WMd1* cm1 = lastWM1;
|
WMd1* cm1 = lastWM1;
|
||||||
while (cm1) {
|
while (cm1) {
|
||||||
printRaw(c1(bi_glyph, tag(cm1,MD1_TAG)));
|
printsB(c1(bi_glyph, tag(cm1,MD1_TAG)));
|
||||||
printf(": m=%d %.3fms | d=%d %.3fms\n", cm1->c1a, cm1->c1t/1e6, cm1->c2a, cm1->c2t/1e6);
|
printf(": m=%d %.3fms | d=%d %.3fms\n", cm1->c1a, cm1->c1t/1e6, cm1->c2a, cm1->c2t/1e6);
|
||||||
cm1 = cm1->prev;
|
cm1 = cm1->prev;
|
||||||
}
|
}
|
||||||
WMd2* cm2 = lastWM2;
|
WMd2* cm2 = lastWM2;
|
||||||
while (cm2) {
|
while (cm2) {
|
||||||
printRaw(c1(bi_glyph, tag(cm2,MD2_TAG)));
|
printsB(c1(bi_glyph, tag(cm2,MD2_TAG)));
|
||||||
printf(": m=%d %.3fms | d=%d %.3fms\n", cm2->c1a, cm2->c1t/1e6, cm2->c2a, cm2->c2t/1e6);
|
printf(": m=%d %.3fms | d=%d %.3fms\n", cm2->c1a, cm2->c1t/1e6, cm2->c2a, cm2->c2t/1e6);
|
||||||
cm2 = cm2->prev;
|
cm2 = cm2->prev;
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/vm.c
28
src/vm.c
@ -72,7 +72,7 @@ void print_gStack() {
|
|||||||
printf("gStack %p, height "N64d":\n", gStackStart, (i64)(gStack-gStackStart));
|
printf("gStack %p, height "N64d":\n", gStackStart, (i64)(gStack-gStackStart));
|
||||||
while (c!=gStack) {
|
while (c!=gStack) {
|
||||||
printf(" %d: ", i); fflush(stdout);
|
printf(" %d: ", i); fflush(stdout);
|
||||||
print(*c); fflush(stdout);
|
printI(*c); fflush(stdout);
|
||||||
if (isVal(*c)) printf(", refc=%d", v(*c)->refc);
|
if (isVal(*c)) printf(", refc=%d", v(*c)->refc);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -160,7 +160,7 @@ Block* compileBlock(B block, Comp* comp, bool* bDone, u32* bc, usz bcIA, B allBl
|
|||||||
bool boArr = isArr(bodyObj);
|
bool boArr = isArr(bodyObj);
|
||||||
i32 boCount = boArr? IA(bodyObj) : 1;
|
i32 boCount = boArr? IA(bodyObj) : 1;
|
||||||
if (boCount<1 || boCount>5) thrM("VM compiler: Unexpected body list length");
|
if (boCount<1 || boCount>5) thrM("VM compiler: Unexpected body list length");
|
||||||
// if (boArr) { print(bodyObj); putchar('\n'); }
|
// if (boArr) { printI(bodyObj); putchar('\n'); }
|
||||||
i32 firstMPos = failBodyI;
|
i32 firstMPos = failBodyI;
|
||||||
|
|
||||||
for (i32 i = 0; i < 6; i+= 2) {
|
for (i32 i = 0; i < 6; i+= 2) {
|
||||||
@ -725,7 +725,7 @@ B evalBC(Body* b, Scope* sc, Block* bl) { // doesn't consume
|
|||||||
vmStack[stackNum] = bcPos;
|
vmStack[stackNum] = bcPos;
|
||||||
for(i32 i = 0; i < bcDepth; i++) printf(" ");
|
for(i32 i = 0; i < bcDepth; i++) printf(" ");
|
||||||
print_BC(sbc,20); printf("@%d in: ", bcPos);
|
print_BC(sbc,20); printf("@%d in: ", bcPos);
|
||||||
for (i32 i = 0; i < lgStack-origStack; i++) { if(i)printf("; "); print(origStack[i]); } putchar('\n'); fflush(stdout);
|
for (i32 i = 0; i < lgStack-origStack; i++) { if(i)printf("; "); printI(origStack[i]); } putchar('\n'); fflush(stdout);
|
||||||
bcCtr++;
|
bcCtr++;
|
||||||
for (i32 i = 0; i < sc->varAm; i++) VALIDATE(sc->vars[i]);
|
for (i32 i = 0; i < sc->varAm; i++) VALIDATE(sc->vars[i]);
|
||||||
#endif
|
#endif
|
||||||
@ -924,7 +924,7 @@ B evalBC(Body* b, Scope* sc, Block* bl) { // doesn't consume
|
|||||||
#ifdef DEBUG_VM
|
#ifdef DEBUG_VM
|
||||||
for(i32 i = 0; i < bcDepth; i++) printf(" ");
|
for(i32 i = 0; i < bcDepth; i++) printf(" ");
|
||||||
print_BC(sbc,20); printf("@%d out: ", BCPOS(b, sbc));
|
print_BC(sbc,20); printf("@%d out: ", BCPOS(b, sbc));
|
||||||
for (i32 i = 0; i < lgStack-origStack; i++) { if(i)printf("; "); print(origStack[i]); } putchar('\n'); fflush(stdout);
|
for (i32 i = 0; i < lgStack-origStack; i++) { if(i)printf("; "); printI(origStack[i]); } putchar('\n'); fflush(stdout);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
end:;
|
end:;
|
||||||
@ -1109,10 +1109,10 @@ void scExt_visit(Value* x) { ScopeExt* c = (ScopeExt*)x; u16 am = c->varAm*2; fo
|
|||||||
void comp_print (FILE* f, B x) { fprintf(f,"(%p: comp)",v(x)); }
|
void comp_print (FILE* f, B x) { fprintf(f,"(%p: comp)",v(x)); }
|
||||||
void body_print (FILE* f, B x) { fprintf(f,"(%p: body varam=%d)",v(x),c(Body,x)->varAm); }
|
void body_print (FILE* f, B x) { fprintf(f,"(%p: body varam=%d)",v(x),c(Body,x)->varAm); }
|
||||||
void block_print(FILE* f, B x) { fprintf(f,"(%p: block)",v(x)); }
|
void block_print(FILE* f, B x) { fprintf(f,"(%p: block)",v(x)); }
|
||||||
void scope_print(FILE* f, B x) { fprintf(f,"(%p: scope; vars:",v(x));Scope*sc=c(Scope,x);for(u64 i=0;i<sc->varAm;i++){fprintf(f," ");fprint(f,sc->vars[i]);}fprintf(f,")"); }
|
void scope_print(FILE* f, B x) { fprintf(f,"(%p: scope; vars:",v(x));Scope*sc=c(Scope,x);for(u64 i=0;i<sc->varAm;i++){fprintf(f," ");fprintI(f,sc->vars[i]);}fprintf(f,")"); }
|
||||||
void alias_print(FILE* f, B x) { fprintf(f,"(alias %d of ", c(FldAlias,x)->p); fprint(f,c(FldAlias,x)->obj); fprintf(f,")"); }
|
void alias_print(FILE* f, B x) { fprintf(f,"(alias %d of ", c(FldAlias,x)->p); fprintI(f,c(FldAlias,x)->obj); fprintf(f,")"); }
|
||||||
void vfymO_print(FILE* f, B x) { fprint(f,c(FldAlias,x)->obj); }
|
void vfymO_print(FILE* f, B x) { fprintI(f,c(FldAlias,x)->obj); }
|
||||||
void marrO_print(FILE* f, B x) { fprintf(f,"["); fprint(f,c(FldAlias,x)->obj); fprintf(f,"]"); }
|
void marrO_print(FILE* f, B x) { fprintf(f,"["); fprintI(f,c(FldAlias,x)->obj); fprintf(f,"]"); }
|
||||||
void bBlks_print(FILE* f, B x) { fprintf(f,"(block list)"); }
|
void bBlks_print(FILE* f, B x) { fprintf(f,"(block list)"); }
|
||||||
void scExt_print(FILE* f, B x) { fprintf(f,"(scope extension with %d vars)", c(ScopeExt,x)->varAm); }
|
void scExt_print(FILE* f, B x) { fprintf(f,"(scope extension with %d vars)", c(ScopeExt,x)->varAm); }
|
||||||
|
|
||||||
@ -1346,7 +1346,7 @@ NOINLINE void vm_printPos(Comp* comp, i32 bcPos, i64 pos) {
|
|||||||
|
|
||||||
B s = emptyCVec();
|
B s = emptyCVec();
|
||||||
B msg = vm_fmtPoint(src, s, comp->path, cs, ce);
|
B msg = vm_fmtPoint(src, s, comp->path, cs, ce);
|
||||||
fprintRaw(stderr, msg);
|
fprintsB(stderr, msg);
|
||||||
dec(msg);
|
dec(msg);
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
popCatch();
|
popCatch();
|
||||||
@ -1540,7 +1540,7 @@ void profiler_displayResults() {
|
|||||||
|
|
||||||
if (q_N(c->path)) printf("(anonymous)");
|
if (q_N(c->path)) printf("(anonymous)");
|
||||||
else if (isPathREPL(c->path)) printf("(REPL)");
|
else if (isPathREPL(c->path)) printf("(REPL)");
|
||||||
else printRaw(c->path);
|
else printsB(c->path);
|
||||||
if (q_N(c->src)) {
|
if (q_N(c->src)) {
|
||||||
printf(": "N64d" samples\n", sum);
|
printf(": "N64d" samples\n", sum);
|
||||||
} else {
|
} else {
|
||||||
@ -1557,7 +1557,7 @@ void profiler_displayResults() {
|
|||||||
Arr* sl = arr_shVec(TI(src,slice)(incG(src), pi, i-pi+(c=='\n'?0:1)));
|
Arr* sl = arr_shVec(TI(src,slice)(incG(src), pi, i-pi+(c=='\n'?0:1)));
|
||||||
if (curr==0) printf(" │");
|
if (curr==0) printf(" │");
|
||||||
else printf("%6d│", curr);
|
else printf("%6d│", curr);
|
||||||
printRaw(taga(sl));
|
printsB(taga(sl));
|
||||||
printf("\n");
|
printf("\n");
|
||||||
ptr_dec(sl);
|
ptr_dec(sl);
|
||||||
curr = 0;
|
curr = 0;
|
||||||
@ -1601,18 +1601,18 @@ NOINLINE void printErrMsg(B msg) {
|
|||||||
SGetU(msg)
|
SGetU(msg)
|
||||||
usz msgLen = IA(msg);
|
usz msgLen = IA(msg);
|
||||||
for (usz i = 0; i < msgLen; i++) if (!isC32(GetU(msg,i))) goto base;
|
for (usz i = 0; i < msgLen; i++) if (!isC32(GetU(msg,i))) goto base;
|
||||||
fprintRaw(stderr, msg);
|
fprintsB(stderr, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
base:
|
base:
|
||||||
fprint(stderr, msg);
|
fprintI(stderr, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void before_exit(void);
|
void before_exit(void);
|
||||||
NOINLINE NORETURN void throwImpl(bool rethrow) {
|
NOINLINE NORETURN void throwImpl(bool rethrow) {
|
||||||
// printf("gStack %p-%p:\n", gStackStart, gStack); B* c = gStack;
|
// printf("gStack %p-%p:\n", gStackStart, gStack); B* c = gStack;
|
||||||
// while (c>gStackStart) { print(*--c); putchar('\n'); } printf("gStack printed\n");
|
// while (c>gStackStart) { printI(*--c); putchar('\n'); } printf("gStack printed\n");
|
||||||
|
|
||||||
if (!rethrow) envPrevHeight = envCurr-envStart + 1;
|
if (!rethrow) envPrevHeight = envCurr-envStart + 1;
|
||||||
#if CATCH_ERRORS
|
#if CATCH_ERRORS
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user