diff --git a/src/core/stuff.c b/src/core/stuff.c index f2c1f12f..bc81b34a 100644 --- a/src/core/stuff.c +++ b/src/core/stuff.c @@ -761,7 +761,12 @@ void g_pst() { vm_pstLive(); } if (TIv(x,isArr)) { Arr* a = (Arr*)x; if (prnk(x)<=1) assert(a->sh == &a->ia); - else VALIDATE(tag(shObjP(x),OBJ_TAG)); + else { + u64 p = 1; + for (usz i=0; i < prnk(x); i++) p*= a->sh[i]; + assert(p == a->ia); + VALIDATE(tag(shObjP(x),OBJ_TAG)); + } } return x; } diff --git a/src/h.h b/src/h.h index 73353cf5..fefa4f15 100644 --- a/src/h.h +++ b/src/h.h @@ -73,6 +73,7 @@ #include #ifdef HEAP_VERIFY #undef CATCH_ERRORS + #define CATCH_ERRORS 0 #endif #define rtLen 64 @@ -579,22 +580,22 @@ static B c2i(B f, B w, B x) { dec(w); dec(x); errMd(f); return inc(f); } -static B c1iX(B f, B x) { // c1 but implicit inc(x) +static B c1iX(B f, B x) { // c1 with inc(x) if (isFun(f)) return VALIDATE(c(Fun,f)->c1(f, inc(x))); errMd(f); return inc(f); } -static B c2iX(B f, B w, B x) { // c2 but implicit inc(x) - if (isFun(f)) return VALIDATE(c(Fun,f)->c2(f, inc(w), x)); +static B c2iX(B f, B w, B x) { // c2 with inc(x) + if (isFun(f)) return VALIDATE(c(Fun,f)->c2(f, w, inc(x))); dec(w); errMd(f); return inc(f); } -static B c2iW(B f, B w, B x) { // c2 but implicit inc(w) - if (isFun(f)) return VALIDATE(c(Fun,f)->c2(f, w, inc(x))); +static B c2iW(B f, B w, B x) { // c2 with inc(w) + if (isFun(f)) return VALIDATE(c(Fun,f)->c2(f, inc(w), x)); dec(x); errMd(f); return inc(f); } -static B c2iWX(B f, B w, B x) { // c2 but implicit inc(w);inc(x) +static B c2iWX(B f, B w, B x) { // c2 with inc(w), inc(x) if (isFun(f)) return VALIDATE(c(Fun,f)->c2(f, inc(w), inc(x))); errMd(f); return inc(f); diff --git a/src/main.c b/src/main.c index 7e32ab8e..cabccd4f 100644 --- a/src/main.c +++ b/src/main.c @@ -169,7 +169,7 @@ int main(int argc, char* argv[]) { if (ln[0]==10) { cont: free(ln); continue; } if (ln[read-1]==10) ln[--read] = 0; B code; - bool output; + int output; // 0-no; 1-formatter; 2-internal i32 time = 0; if (ln[0] == ')') { char* cmdS = ln+1; @@ -177,11 +177,11 @@ int main(int argc, char* argv[]) { if (isCmd(cmdS, &cmdE, "ex ")) { B path = fromUTF8l(cmdE); code = file_chars(path); - output = false; + output = 0; } else if (isCmd(cmdS, &cmdE, "t ") || isCmd(cmdS, &cmdE, "time ")) { code = fromUTF8l(cmdE); time = -1; - output = false; + output = 0; } else if (isCmd(cmdS, &cmdE, "t:") || isCmd(cmdS, &cmdE, "time:")) { char* repE = cmdE; i64 am = 0; @@ -193,7 +193,7 @@ int main(int argc, char* argv[]) { if (am==0) { printf("repetition count was zero\n"); goto cont; } code = fromUTF8l(repE); time = am; - output = false; + output = 0; } else if (isCmd(cmdS, &cmdE, "mem ")) { bool sizes = 0; bool types = 0; @@ -247,13 +247,16 @@ int main(int argc, char* argv[]) { printf("Macro ENABLE_GC was false at compile-time, cannot GC\n"); #endif goto cont; + } else if (isCmd(cmdS, &cmdE, "internalPrint ")) { + code = fromUTF8l(cmdE); + output = 2; } else { printf("Unknown REPL command\n"); goto cont; } } else { code = fromUTF8l(ln); - output = true; + output = 1; } Block* block = bqn_compSc(code, inc(replPath), emptySVec(), gsc, true); @@ -285,14 +288,14 @@ int main(int argc, char* argv[]) { ptr_dec(block); if (output) { - #if FORMATTER + if (output!=2 && FORMATTER) { B resFmt = bqn_fmt(res); printRaw(resFmt); dec(resFmt); putchar('\n'); - #else + } else { print(res); putchar('\n'); fflush(stdout); dec(res); - #endif + } } else dec(res); #ifdef HEAP_VERIFY