diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index ead2c4c6..15247737 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -38,7 +38,7 @@ B type_c1(B t, B x) { else if (isNsp(x)) r = 6; if (RARE(r==-1)) { 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); return m_i32(r); @@ -254,16 +254,16 @@ B sys_c1(B t, B x); B out_c1(B t, B x) { if (isAtm(x)) thrM("•Out: Argument must be a list"); if (RNK(x)>1) thrF("•Out: Argument cannot have rank %i", RNK(x)); - printRaw(x); putchar('\n'); + printsB(x); putchar('\n'); return x; } B show_c1(B t, B x) { #ifndef NO_SHOW #if FORMATTER B fmt = bqn_fmt(inc(x)); - printRaw(fmt); dec(fmt); + printsB(fmt); dec(fmt); #else - print(x); + printI(x); #endif putchar('\n'); #endif diff --git a/src/core/derv.c b/src/core/derv.c index eac982f8..3d51fb55 100644 --- a/src/core/derv.c +++ b/src/core/derv.c @@ -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 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 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 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 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 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 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 ");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 "); 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 ");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 "); 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_c2(B t, B w, B x) { Md1D* tc = c(Md1D, t); return ((Md1*)tc->m1)->c2(tc, w, x); } diff --git a/src/core/harr.c b/src/core/harr.c index fc0e4da0..9f6b326d 100644 --- a/src/core/harr.c +++ b/src/core/harr.c @@ -123,7 +123,7 @@ static void harrP_print(FILE* f, B x) { for (usz i = 0; i < ia; i++) { if (i) fprintf(f, ", "); if (i>=am) fprintf(f, "?"); - else fprint(f, p[i]); + else fprintI(f, p[i]); } fprintf(f, "⟩)"); } diff --git a/src/core/heap.c b/src/core/heap.c index 0bdc35bc..474ade44 100644 --- a/src/core/heap.c +++ b/src/core/heap.c @@ -13,7 +13,7 @@ void heapVerify_checkFn(Value* v) { printf("delta %d for %s @ %p: ", (i32)v->refc, type_repr(v->type), v); #endif heap_observed = v; - print(tag(v,OBJ_TAG)); putchar('\n'); + printI(tag(v,OBJ_TAG)); putchar('\n'); } } diff --git a/src/core/heap.h b/src/core/heap.h index d3d1ece9..5c834052 100644 --- a/src/core/heap.h +++ b/src/core/heap.h @@ -15,7 +15,7 @@ static bool heapVerify_visitP(void* x) { Value* v = x; if (heapVerify_mode==0) 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; } void heapVerify(void); diff --git a/src/core/stuff.c b/src/core/stuff.c index 256befa6..148ddc4c 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -95,14 +95,14 @@ NOINLINE TStack* ts_e(TStack* o, u32 elsz, u64 am) { u64 size = o->size; 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); SGetU(x) usz ia = IA(x); if (r!=1) { if (r==0) { fprintf(f, "<"); - fprint(f, GetU(x,0)); + fprintI(f, GetU(x,0)); return; } 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'⥊'); } else if (ia>0) { - if (!elChr(TI(x,elType))) { - for (usz i = 0; i < ia; i++) { - B c = GetU(x, i); - if (!isC32(c) || o2cG(c)<32) goto reg; - } + for (usz i = 0; i < ia; i++) { + B c = GetU(x, i); + if (!isC32(c) || o2cG(c)<32) goto reg; } fprintf(f, "\""); fprintsB(f, x); @@ -127,12 +125,12 @@ void farr_print(FILE* f, B x) { // should accept refc=0 arguments for debugging fprintCodepoint(f, U'⟨'); for (usz i = 0; i < ia; i++) { if (i!=0) fprintf(f, ", "); - fprint(f, GetU(x,i)); + fprintI(f, GetU(x,i)); } fprintCodepoint(f, U'⟩'); } -void fprint(FILE* f, B x) { +NOINLINE void fprintI(FILE* f, B x) { if (isF64(x)) { NUM_FMT_BUF(buf, x.f); fprintf(f, "%s", buf); @@ -163,19 +161,9 @@ void fprint(FILE* f, B x) { else fprintf(f, "(todo tag "N64x")", x.u>>48); } -NOINLINE void fprintRaw(FILE* f, B x) { - fprintsB(f, 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); -} +void printI (B x) { fprintI (stdout, x); } +void printsB (B x) { fprintsB (stdout, x); } +void arr_print(B x) { farr_print(stdout, x); } i32 num_fmt(char buf[30], f64 x) { // 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); B r = do_fmt(emptyCVec(), p, a); va_end(a); - fprintRaw(f, r); + fprintsB(f, r); decG(r); } NOINLINE void print_fmt(char* p, ...) { @@ -351,7 +339,7 @@ NOINLINE void print_fmt(char* p, ...) { va_start(a, p); B r = do_fmt(emptyCVec(), p, a); va_end(a); - printRaw(r); + printsB(r); decG(r); } 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_tf(void* x) { return tag(x,FUN_TAG); } bool ignore_bad_tag; -void g_p(B x) { print(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_pv(void* x) { ignore_bad_tag=true; print(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_p(B x) { printI(x); 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; 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)); printI(r); dec(r); putchar(10); fflush(stdout); ignore_bad_tag=false; } void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); } #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) { PRINT_ID(x); 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(""); } 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) { fprintf(stderr, "bad array tag/type: type=%d, obj=%p\n", v(x)->type, TOPTR(void, x.u)); PRINT_ID(v(x)); - fprint(stderr, x); + fprintI(stderr, x); err("\n"); } 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); else { fprintf(stderr, "atom: "); - fprintRaw(stderr, x = bqn_fmt(inc(x))); dec(x); + fprintsB(stderr, x = bqn_fmt(inc(x))); dec(x); fputc('\n', stderr); } } diff --git a/src/ffi.c b/src/ffi.c index 9964a7f3..1359a2e1 100644 --- a/src/ffi.c +++ b/src/ffi.c @@ -243,7 +243,7 @@ typedef struct BQNFFIType { B vfyStr(B x, char* name, char* arg); static void printFFIType(FILE* f, B x) { if (isC32(x)) fprintf(f, "%d", o2cG(x)); - else fprint(f, x); + else fprintI(f, x); } #if FFI==2 @@ -432,7 +432,7 @@ BQNFFIEnt ffi_parseType(B arg, bool forRes) { // doesn't consume; parse argument else side = 0; 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"); t.onW = side; // 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) { - // printFFIType(stdout,o); printf(" = "); print(c); printf("\n"); + // printFFIType(stdout,o); printf(" = "); printI(c); printf("\n"); if (isC32(o)) { // scalar u32 t = o2cG(o); f64 f = c.f; diff --git a/src/h.h b/src/h.h index 6f5aa9c8..2ece6e3b 100644 --- a/src/h.h +++ b/src/h.h @@ -363,12 +363,12 @@ static u64 mm_size(Value* x); static void dec(B x); static B inc(B x); static void ptr_dec(void* x); -void fprint (FILE* f, B x); // doesn't consume -void fprintRaw (FILE* f, B x); // doesn't consume +void fprintI(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 print(B x); // doesn't consume -void printRaw(B x); // doesn't consume -void arr_print(B x); // doesn't consume +void arr_print( B x); // doesn't consume bool equal(B w, B x); // doesn't consume bool eequal(B w, B x); // doesn't consume B toCells(B x); // consumes diff --git a/src/jit/nvm_x86_64.c b/src/jit/nvm_x86_64.c index a49d5eb9..dc4a77c4 100644 --- a/src/jit/nvm_x86_64.c +++ b/src/jit/nvm_x86_64.c @@ -511,7 +511,7 @@ static void onJIT(Body* body, u8* binEx, u64 sz) { if (!perf_map) { B s = m_c8vec_0("/tmp/perf-"); AFMT("%l.map", getpid()); perf_map = file_open(s, "open", "wa"); - print(s); printf(": map\n"); + printsB(s); printf(": map\n"); dec(s); } u32 bcPos = body->bl->map[0]; diff --git a/src/load.c b/src/load.c index 36522721..0ba8e739 100644 --- a/src/load.c +++ b/src/load.c @@ -467,7 +467,7 @@ void load_init() { // very last init function , bi_N, bi_N, bi_N, bi_N, NULL ); B interp = evalFunBlock(c, 0); ptr_dec(c); - print(interp); + printI(interp); printf("\n"); dec(interp); #ifdef HEAP_VERIFY diff --git a/src/main.c b/src/main.c index c7e6b11f..97a52e7a 100644 --- a/src/main.c +++ b/src/main.c @@ -603,7 +603,7 @@ void cbqn_runLine0(char* ln, i64 read) { B* rp = harr_ptr(r); for (usz i = 0; i < ia; i++) { if (i!=0) printf(", "); - printRaw(rp[i]); + printsB(rp[i]); } putchar('\n'); } @@ -645,7 +645,7 @@ void cbqn_runLine0(char* ln, i64 read) { HArr* expla = toHArr(expl); usz ia=PIA(expla); for(usz i=0; ia[i]); + printsB(expla->a[i]); putchar('\n'); } dec(expl); @@ -697,10 +697,10 @@ void cbqn_runLine0(char* ln, i64 read) { if (output) { if (output!=2 && FORMATTER) { B resFmt = bqn_fmt(res); - printRaw(resFmt); dec(resFmt); + printsB(resFmt); dec(resFmt); putchar('\n'); } else { - print(res); putchar('\n'); fflush(stdout); + printI(res); putchar('\n'); fflush(stdout); 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 resFmt = bqn_fmt(res); - printRaw(resFmt); dec(resFmt); + printsB(resFmt); dec(resFmt); putchar('\n'); } #endif @@ -790,13 +790,13 @@ int main(int argc, char* argv[]) { case 'L': { repl_init(); break; } // just initialize. mostly for perf testing case 'p': { repl_init(); REQARG(p); 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"); break; } case 'o': { repl_init(); REQARG(o); B r = gsc_exec_inline(utf8Decode0(argv[i++]), m_c8vec_0("(-o)"), emptySVec()); - printRaw(r); dec(r); + printsB(r); dec(r); printf("\n"); break; } diff --git a/src/nfns.c b/src/nfns.c index 402a4fa7..aec08570 100644 --- a/src/nfns.c +++ b/src/nfns.c @@ -29,7 +29,7 @@ B nfn_name(B x) { VTY(x, t_nfn); DEF_FREE(nfn) { dec(((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!"); } void nfnDesc_visit(Value* x) { mm_visit(((NFnDesc*)x)->name); } void nfnDesc_print(FILE* f, B x) { fprintf(f, "(native function description)"); } diff --git a/src/ns.c b/src/ns.c index 5c6dadc6..6194af3a 100644 --- a/src/ns.c +++ b/src/ns.c @@ -187,9 +187,9 @@ static void ns_print(FILE* f, B x) { if (id>=0) { if (first) first=false; else fprintf(f," ⋄ "); - fprintRaw(f, gid2str(id)); + fprintsB(f, gid2str(id)); fprintf(f, "⇐"); - fprint(f, sc->vars[i]); + fprintI(f, sc->vars[i]); } } fputc('}', f); diff --git a/src/rtwrap.c b/src/rtwrap.c index 9e928c24..b7a4f893 100644 --- a/src/rtwrap.c +++ b/src/rtwrap.c @@ -58,12 +58,12 @@ B wfn_identity(B x) { #if RT_VERIFY B info_c2(B t, B w, B x); #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(!q_N(W)){printf("𝕨:"); print(W); printf(" / "); printRaw(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("got:"); print(GOT); printf(" / "); printRaw(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); } \ + if(!q_N(W)){printf("𝕨:"); printI(W); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(W))); putchar('\n'); fflush(stdout); } \ + { printf("𝕩:"); printI(X); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(X))); 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:"); printI(EXP); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(EXP))); putchar('\n'); fflush(stdout); } \ } \ vm_pstLive(); exit(1); \ }} @@ -294,19 +294,19 @@ void rtWrap_print() { #if RT_PERF WFun* cf = lastWF; 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); cf = cf->prev; } WMd1* cm1 = lastWM1; 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); cm1 = cm1->prev; } WMd2* cm2 = lastWM2; 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); cm2 = cm2->prev; } diff --git a/src/vm.c b/src/vm.c index 98b12123..56a4e2f6 100644 --- a/src/vm.c +++ b/src/vm.c @@ -72,7 +72,7 @@ void print_gStack() { printf("gStack %p, height "N64d":\n", gStackStart, (i64)(gStack-gStackStart)); while (c!=gStack) { printf(" %d: ", i); fflush(stdout); - print(*c); fflush(stdout); + printI(*c); fflush(stdout); if (isVal(*c)) printf(", refc=%d", v(*c)->refc); printf("\n"); fflush(stdout); @@ -160,7 +160,7 @@ Block* compileBlock(B block, Comp* comp, bool* bDone, u32* bc, usz bcIA, B allBl bool boArr = isArr(bodyObj); i32 boCount = boArr? IA(bodyObj) : 1; 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; 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; for(i32 i = 0; i < bcDepth; i++) printf(" "); 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++; for (i32 i = 0; i < sc->varAm; i++) VALIDATE(sc->vars[i]); #endif @@ -924,7 +924,7 @@ B evalBC(Body* b, Scope* sc, Block* bl) { // doesn't consume #ifdef DEBUG_VM for(i32 i = 0; i < bcDepth; i++) printf(" "); 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 } 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 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 scope_print(FILE* f, B x) { fprintf(f,"(%p: scope; vars:",v(x));Scope*sc=c(Scope,x);for(u64 i=0;ivarAm;i++){fprintf(f," ");fprint(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 vfymO_print(FILE* f, B x) { fprint(f,c(FldAlias,x)->obj); } -void marrO_print(FILE* f, B x) { fprintf(f,"["); fprint(f,c(FldAlias,x)->obj); 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;ivarAm;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); fprintI(f,c(FldAlias,x)->obj); fprintf(f,")"); } +void vfymO_print(FILE* f, B x) { fprintI(f,c(FldAlias,x)->obj); } +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 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 msg = vm_fmtPoint(src, s, comp->path, cs, ce); - fprintRaw(stderr, msg); + fprintsB(stderr, msg); dec(msg); fputc('\n', stderr); popCatch(); @@ -1540,7 +1540,7 @@ void profiler_displayResults() { if (q_N(c->path)) printf("(anonymous)"); else if (isPathREPL(c->path)) printf("(REPL)"); - else printRaw(c->path); + else printsB(c->path); if (q_N(c->src)) { printf(": "N64d" samples\n", sum); } else { @@ -1557,7 +1557,7 @@ void profiler_displayResults() { Arr* sl = arr_shVec(TI(src,slice)(incG(src), pi, i-pi+(c=='\n'?0:1))); if (curr==0) printf(" │"); else printf("%6d│", curr); - printRaw(taga(sl)); + printsB(taga(sl)); printf("\n"); ptr_dec(sl); curr = 0; @@ -1601,18 +1601,18 @@ NOINLINE void printErrMsg(B msg) { SGetU(msg) usz msgLen = IA(msg); for (usz i = 0; i < msgLen; i++) if (!isC32(GetU(msg,i))) goto base; - fprintRaw(stderr, msg); + fprintsB(stderr, msg); return; } base: - fprint(stderr, msg); + fprintI(stderr, msg); } void before_exit(void); NOINLINE NORETURN void throwImpl(bool rethrow) { // 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 CATCH_ERRORS