defer explain loading to when it's invoked
This commit is contained in:
parent
87a8aacbc5
commit
59f0aaa732
@ -18,6 +18,10 @@ Clear the cache of monadic `•Import` calls, resulting in re-evaluating the sou
|
||||
|
||||
Time the argument expression. `n` specifies the number of times to repeat. Exists to allow not escaping quotes and less overhead for timing very fast & small expressions.
|
||||
|
||||
## `)explain expr` / `)e expr`
|
||||
|
||||
Display a syntax breakdown of the expression
|
||||
|
||||
## `)profile expr` / `)profile@frequency expr`
|
||||
|
||||
Profile the expression at the given sampling frequency, or 5000 samples/second by default
|
||||
|
||||
39
src/load.c
39
src/load.c
@ -170,15 +170,6 @@ void load_gcFn() {
|
||||
i64 prevEnvPos = comp_currEnvPos; comp_currEnvPos = envCurr-envStart; \
|
||||
if (CATCH) { POP_COMP; rethrow(); }
|
||||
|
||||
B bqn_explain(B str, B path) {
|
||||
B args = bi_N;
|
||||
PUSH_COMP;
|
||||
B c = c2(load_comp, incG(load_compArg), inc(str));
|
||||
POP_COMP;
|
||||
B ret = c2(load_explain, c, str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -489,12 +480,7 @@ void load_init() { // very last init function
|
||||
load_repr = Get(fmtR, 1); gc_add(load_repr);
|
||||
decG(fmtR);
|
||||
#endif
|
||||
Block* expl_b = load_compImport("(explain)",
|
||||
#include "gen/explain"
|
||||
);
|
||||
load_explain = evalFunBlock(expl_b, 0); ptr_dec(expl_b);
|
||||
gc_add(load_explain);
|
||||
|
||||
|
||||
gc_enable();
|
||||
#endif // PRECOMP
|
||||
}
|
||||
@ -513,6 +499,29 @@ void bqn_exit(i32 code) {
|
||||
exit(code);
|
||||
}
|
||||
|
||||
B bqn_explain(B str, B path) {
|
||||
#if NO_EXPLAIN
|
||||
thrM("Explainer not included in this CBQN build");
|
||||
#else
|
||||
if (load_explain.u==0) {
|
||||
B* runtime = harr_ptr(load_rtObj);
|
||||
Block* expl_b = load_compImport("(explain)",
|
||||
#include "gen/explain"
|
||||
);
|
||||
load_explain = evalFunBlock(expl_b, 0); ptr_dec(expl_b);
|
||||
gc_add(load_explain);
|
||||
}
|
||||
|
||||
B args = bi_N;
|
||||
PUSH_COMP;
|
||||
B c = c2(load_comp, incG(load_compArg), inc(str));
|
||||
POP_COMP;
|
||||
B ret = c2(load_explain, c, str);
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void freed_visit(Value* x) {
|
||||
#if CATCH_ERRORS
|
||||
|
||||
Loading…
Reference in New Issue
Block a user