properly restore compilation globals in case compiler errors
This commit is contained in:
parent
8ad7b6149f
commit
f8447d9b5f
33
src/load.c
33
src/load.c
@ -156,27 +156,31 @@ void load_gcFn() {
|
|||||||
mm_visit(rt_invFnReg);
|
mm_visit(rt_invFnReg);
|
||||||
mm_visit(rt_invFnSwap);
|
mm_visit(rt_invFnSwap);
|
||||||
}
|
}
|
||||||
|
#define POP_COMP ({ \
|
||||||
|
comp_currPath = prevPath; \
|
||||||
|
comp_currArgs = prevArgs; \
|
||||||
|
comp_currSrc = prevSrc; \
|
||||||
|
comp_currEnvPos = prevEnvPos; })
|
||||||
|
|
||||||
|
#define PUSH_COMP \
|
||||||
|
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; \
|
||||||
|
if (CATCH) { POP_COMP; rethrow(); }
|
||||||
|
|
||||||
static NOINLINE Block* bqn_compc(B str, B path, B args, B comp, B compArg) { // consumes str,path,args
|
static NOINLINE Block* bqn_compc(B str, B path, B args, B comp, B compArg) { // consumes str,path,args
|
||||||
B prevPath = comp_currPath ; comp_currPath = path;
|
PUSH_COMP;
|
||||||
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(comp, incG(compArg), inc(str)), str, path, NULL);
|
Block* r = load_compObj(c2(comp, incG(compArg), inc(str)), str, path, NULL);
|
||||||
dec(path); dec(args);
|
dec(path); dec(args);
|
||||||
comp_currPath = prevPath;
|
POP_COMP; popCatch();
|
||||||
comp_currArgs = prevArgs;
|
|
||||||
comp_currSrc = prevSrc;
|
|
||||||
comp_currEnvPos = prevEnvPos;
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
Block* bqn_comp(B str, B path, B args) { // consumes all
|
Block* bqn_comp(B str, B path, B args) { // consumes all
|
||||||
return bqn_compc(str, path, args, load_comp, load_compArg);
|
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
|
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;
|
PUSH_COMP;
|
||||||
B prevArgs = comp_currArgs ; comp_currArgs = args;
|
|
||||||
B prevSrc = comp_currSrc ; comp_currSrc = str;
|
|
||||||
i64 prevEnvPos = comp_currEnvPos; comp_currEnvPos = envCurr-envStart;
|
|
||||||
B vName = emptyHVec();
|
B vName = emptyHVec();
|
||||||
B vDepth = emptyIVec();
|
B vDepth = emptyIVec();
|
||||||
if (repl && (!sc || sc->psc)) thrM("VM compiler: REPL mode must be used at top level scope");
|
if (repl && (!sc || sc->psc)) thrM("VM compiler: REPL mode must be used at top level scope");
|
||||||
@ -192,10 +196,7 @@ Block* bqn_compScc(B str, B path, B args, Scope* sc, B comp, B rt, bool repl) {
|
|||||||
}
|
}
|
||||||
Block* r = load_compObj(c2(comp, m_hVec4(incG(rt), incG(bi_sys), vName, vDepth), inc(str)), str, path, sc);
|
Block* r = load_compObj(c2(comp, m_hVec4(incG(rt), incG(bi_sys), vName, vDepth), inc(str)), str, path, sc);
|
||||||
dec(path); dec(args);
|
dec(path); dec(args);
|
||||||
comp_currPath = prevPath;
|
POP_COMP; popCatch();
|
||||||
comp_currArgs = prevArgs;
|
|
||||||
comp_currSrc = prevSrc;
|
|
||||||
comp_currEnvPos = prevEnvPos;
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
NOINLINE Block* bqn_compSc(B str, B path, B args, Scope* sc, bool repl) { // consumes str,path,args
|
NOINLINE Block* bqn_compSc(B str, B path, B args, Scope* sc, bool repl) { // consumes str,path,args
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user