diff --git a/src/builtins/md1.c b/src/builtins/md1.c index ee6b947e..cc3ef91b 100644 --- a/src/builtins/md1.c +++ b/src/builtins/md1.c @@ -136,8 +136,9 @@ B timed_c2(Md1D* d, B w, B x) { B f = d->f; i64 am = o2i64(w); if (am<=0) thrM("•_timed: 𝕨 must be an integer greater than 1"); incBy(x, am); + FC1 fc1 = c1fn(f); u64 sns = nsTime(); - for (i64 i = 0; i < am; i++) dec(c1(f, x)); + for (i64 i = 0; i < am; i++) dec(fc1(f, x)); u64 ens = nsTime(); return m_f64((ens-sns)/(1e9*am)); } diff --git a/src/builtins/md2.c b/src/builtins/md2.c index 3432d4e6..d7d60799 100644 --- a/src/builtins/md2.c +++ b/src/builtins/md2.c @@ -128,8 +128,8 @@ B repeat_c2(Md2D* d, B w, B x) { REPEAT_T(c2,dec(w), inc(w), ); } #undef REPEAT_T -NOINLINE B before_c1F(Md2D* d, B x, B f) { errMd(f); return c2(d->g, c(Fun,f)->c1(f,inc(x)), x); } -NOINLINE B after_c1F (Md2D* d, B x, B g) { errMd(g); return c2(d->f, x, c(Fun,g)->c1(g,inc(x))); } +NOINLINE B before_c1F(Md2D* d, B x, B f) { errMd(f); return c2(d->g, c1G(f,inc(x)), x); } +NOINLINE B after_c1F (Md2D* d, B x, B g) { errMd(g); return c2(d->f, x, c1G(g,inc(x))); } B before_c1(Md2D* d, B x) { B f=d->f; return isCallable(f)? before_c1F(d, x, f) : c2(d->g, inc(f), x); } B after_c1 (Md2D* d, B x) { B g=d->g; return isCallable(g)? after_c1F (d, x, g) : c2(d->f, x, inc(g)); } B before_c2(Md2D* d, B w, B x) { return c2(d->g, c1I(d->f, w), x); } diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index f74a7313..026ea316 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -660,9 +660,9 @@ static B randNS; B getRandNS(void) { if (randNS.u == 0) { #if RANDSEED==0 - randNS = c1(bi_makeRand, m_f64(nsTime())); + randNS = c1G(bi_makeRand, m_f64(nsTime())); #else - randNS = c1(bi_makeRand, m_f64(RANDSEED)); + randNS = c1G(bi_makeRand, m_f64(RANDSEED)); #endif gc_add(randNS); } diff --git a/src/core/derv.c b/src/core/derv.c index e363ddfb..7df91f09 100644 --- a/src/core/derv.c +++ b/src/core/derv.c @@ -28,7 +28,7 @@ B fork_c1(B t, B x) { B h = c(Fork,t)->h; if (isFun(f)) { B hr = c1(h, inc(x)); - return c2(c(Fork,t)->g, c(Fun,f)->c1(f,x), hr); + return c2(c(Fork,t)->g, c1G(f,x), hr); } else { return c2(c(Fork,t)->g, inc(f), c1(h,x)); } @@ -38,7 +38,7 @@ B fork_c2(B t, B w, B x) { B h = c(Fork,t)->h; if (isFun(f)) { B hr = c2(h, inc(w), inc(x)); - return c2(c(Fork,t)->g, c(Fun,f)->c2(f,w,x), hr); + return c2(c(Fork,t)->g, c2G(f,w,x), hr); } else { return c2(c(Fork,t)->g, inc(f), c2(h,w,x)); } diff --git a/src/h.h b/src/h.h index d5cb187b..f59929b7 100644 --- a/src/h.h +++ b/src/h.h @@ -686,9 +686,6 @@ typedef struct Fun { B c1F(B f, B x); B c2F(B f, B w, B x); - -#define c1rt(N, X) ({ B x_=(X); SLOW1("!rt_" #N, x_); c1(rt_##N, x_); }) -#define c2rt(N, W, X) ({ B w_=(W); B x_=(X); SLOW2("!rt_" #N,w_,x_); c2(rt_##N, w_, x_); }) static B c1(B f, B x) { // BQN-call f monadically; consumes x if (isFun(f)) return VALIDATE(VRES(c(Fun,f)->c1(f, VRES(x)))); return c1F(f, x); @@ -720,6 +717,11 @@ static B c2iWX(B f, B w, B x) { // c2 with inc(w), inc(x) return inc(f); } +static B c1G(B f, B x) { assert(isFun(f)); return c(Fun,f)->c1(f, x); } +static B c2G(B f, B w, B x) { assert(isFun(f)); return c(Fun,f)->c2(f, w, x); } +#define c1rt(N, X) ({ B x_=(X); SLOW1("!rt_" #N, x_); c1G(rt_##N, x_); }) +#define c2rt(N, W, X) ({ B w_=(W); B x_=(X); SLOW2("!rt_" #N,w_,x_); c2G(rt_##N, w_, x_); }) + struct Md1 { struct Value; diff --git a/src/load.c b/src/load.c index fe7cbd38..5edf4886 100644 --- a/src/load.c +++ b/src/load.c @@ -158,10 +158,10 @@ B compObj_c2(B t, B w, B x) { #if FORMATTER B load_fmt, load_repr; B bqn_fmt(B x) { // consumes - return c1(load_fmt, x); + return c1G(load_fmt, x); } B bqn_repr(B x) { // consumes - return c1(load_repr, x); + return c1G(load_repr, x); } #else B bqn_fmt(B x) { @@ -187,7 +187,7 @@ B bqn_repr(B x) { static NOINLINE Block* bqn_compc(B str, B path, B args, B comp, B compArg) { // consumes str,path,args PUSH_COMP; - Block* r = load_compObj(c2(comp, incG(compArg), inc(str)), str, path, NULL); + Block* r = load_compObj(c2G(comp, incG(compArg), inc(str)), str, path, NULL); dec(path); dec(args); POP_COMP; popCatch(); return r; @@ -210,7 +210,7 @@ Block* bqn_compScc(B str, B path, B args, Scope* sc, B comp, B rt, bool repl) { csc = csc->psc; depth++; } - Block* r = load_compObj(c2(comp, m_hvec4(incG(rt), incG(bi_sys), vName, vDepth), inc(str)), str, path, sc); + Block* r = load_compObj(c2G(comp, m_hvec4(incG(rt), incG(bi_sys), vName, vDepth), inc(str)), str, path, sc); dec(path); dec(args); POP_COMP; popCatch(); return r; @@ -433,8 +433,8 @@ void load_init() { // very last init function B setPrims = Get(rtRes,1); B setInv = Get(rtRes,2); dec(rtRes); - dec(c1(setPrims, m_hvec2(incG(bi_decp), incG(bi_primInd)))); decG(setPrims); - dec(c2(setInv, incG(bi_setInvSwap), incG(bi_setInvReg))); decG(setInv); + dec(c1G(setPrims, m_hvec2(incG(bi_decp), incG(bi_primInd)))); decG(setPrims); + dec(c2G(setInv, incG(bi_setInvSwap), incG(bi_setInvReg))); decG(setInv);