Allow custom compiler/runtime for non-REPL •ReBQN too
This commit is contained in:
parent
4d394ea441
commit
9e5f488642
@ -561,7 +561,7 @@ B repl_c2(B t, B w, B x) {
|
||||
res = execBlockInline(block, sc);
|
||||
ptr_dec(block);
|
||||
} else {
|
||||
res = bqn_exec(x, fullpath, args);
|
||||
res = rebqn_exec(x, fullpath, args, op[2], op[3]);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
21
src/load.c
21
src/load.c
@ -124,6 +124,7 @@ Block* load_compImport(B bc, B objs, B blocks, B bodies) { // consumes all
|
||||
#endif
|
||||
|
||||
B load_comp;
|
||||
B load_compgen;
|
||||
B load_rtObj;
|
||||
B load_compArg;
|
||||
|
||||
@ -151,12 +152,12 @@ void load_gcFn() {
|
||||
mm_visit(rt_invFnReg);
|
||||
mm_visit(rt_invFnSwap);
|
||||
}
|
||||
NOINLINE Block* bqn_comp(B str, B path, B args) { // consumes all
|
||||
static Block* bqn_compc(B str, B path, B args, B comp, B compArg) { // consumes str,path,args
|
||||
B prevPath = comp_currPath ; comp_currPath = path;
|
||||
B prevArgs = comp_currArgs ; comp_currArgs = args;
|
||||
B prevSrc = comp_currSrc ; comp_currSrc = str;
|
||||
i64 prevEnvPos = comp_currEnvPos; comp_currEnvPos = envCurr-envStart;
|
||||
Block* r = load_compObj(c2(load_comp, incG(load_compArg), inc(str)), str, path, NULL);
|
||||
Block* r = load_compObj(c2(comp, incG(compArg), inc(str)), str, path, NULL);
|
||||
dec(path); dec(args);
|
||||
comp_currPath = prevPath;
|
||||
comp_currArgs = prevArgs;
|
||||
@ -164,6 +165,9 @@ NOINLINE Block* bqn_comp(B str, B path, B args) { // consumes all
|
||||
comp_currEnvPos = prevEnvPos;
|
||||
return r;
|
||||
}
|
||||
NOINLINE Block* bqn_comp(B str, B path, B args) { // consumes all
|
||||
return bqn_compc(str, path, args, load_comp, load_compArg);
|
||||
}
|
||||
Block* bqn_compScc(B str, B path, B args, Scope* sc, B comp, B rt, bool repl) { // consumes str,path,args
|
||||
B prevPath = comp_currPath ; comp_currPath = path;
|
||||
B prevArgs = comp_currArgs ; comp_currArgs = args;
|
||||
@ -217,6 +221,14 @@ B bqn_exec(B str, B path, B args) { // consumes all
|
||||
ptr_dec(block);
|
||||
return res;
|
||||
}
|
||||
B rebqn_exec(B str, B path, B args, B comp, B rt) { // consumes str,path,args
|
||||
B rtsys = m_hVec2(rt, incG(bi_sys));
|
||||
Block* block = bqn_compc(str, path, args, comp, rtsys);
|
||||
dec(rtsys);
|
||||
B res = m_funBlock(block, 0);
|
||||
ptr_dec(block);
|
||||
return res;
|
||||
}
|
||||
void bqn_setComp(B comp) { // consumes; doesn't unload old comp, but whatever
|
||||
load_comp = comp;
|
||||
gc_add(load_comp);
|
||||
@ -371,8 +383,9 @@ void load_init() { // very last init function
|
||||
);
|
||||
runtime[n_asrt] = prevAsrt;
|
||||
B glyphs = m_hVec3(m_str32(U"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍⋈↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!"), m_str32(U"˙˜˘¨⌜⁼´˝`"), m_str32(U"∘○⊸⟜⌾⊘◶⎉⚇⍟⎊"));
|
||||
load_comp = c1(m_funBlock(comp_b, 0), glyphs); ptr_dec(comp_b);
|
||||
gc_add(load_comp);
|
||||
load_compgen = m_funBlock(comp_b, 0);
|
||||
load_comp = c1(load_compgen, glyphs); ptr_dec(comp_b);
|
||||
gc_add(load_compgen); gc_add(load_comp);
|
||||
|
||||
|
||||
#if FORMATTER
|
||||
|
||||
1
src/vm.h
1
src/vm.h
@ -148,6 +148,7 @@ Block* compile(B bcq, B objs, B blocks, B bodies, B indices, B tokenInfo, B src,
|
||||
Scope* m_scope(Body* body, Scope* psc, u16 varAm, i32 initVarAm, B* initVars);
|
||||
Body* m_body(i32 vam, i32 pos, u32 maxStack, u16 maxPSC); // leaves varIDs and nsDesc uninitialized
|
||||
void init_comp(B* set, B prim);
|
||||
B rebqn_exec(B str, B path, B args, B comp, B rt);
|
||||
|
||||
typedef struct Nvm_res { u8* p; B refs; } Nvm_res;
|
||||
Nvm_res m_nvm(Body* b);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user