fix REPL top-level errors
This commit is contained in:
parent
345a0bfc8b
commit
ed46ec7a44
@ -127,7 +127,7 @@ int main(int argc, char* argv[]) {
|
|||||||
if (startREPL) {
|
if (startREPL) {
|
||||||
INIT;
|
INIT;
|
||||||
B replPath = m_str32(U"REPL"); gc_add(replPath);
|
B replPath = m_str32(U"REPL"); gc_add(replPath);
|
||||||
Block* gscInit = bqn_comp(m_str32(U"1"), inc(replPath), m_f64(0));
|
Block* gscInit = bqn_comp(m_str32(U"\"(REPL initializer)\""), inc(replPath), m_f64(0));
|
||||||
Scope* gsc = m_scope(gscInit->body, NULL, 0); gc_add(tag(gsc,OBJ_TAG));
|
Scope* gsc = m_scope(gscInit->body, NULL, 0); gc_add(tag(gsc,OBJ_TAG));
|
||||||
ptr_dec(gscInit);
|
ptr_dec(gscInit);
|
||||||
while (CATCH) {
|
while (CATCH) {
|
||||||
@ -147,6 +147,9 @@ int main(int argc, char* argv[]) {
|
|||||||
Block* block = bqn_compSc(fromUTF8(ln, strlen(ln)), inc(replPath), inc(bi_emptyHVec), gsc, true);
|
Block* block = bqn_compSc(fromUTF8(ln, strlen(ln)), inc(replPath), inc(bi_emptyHVec), gsc, true);
|
||||||
free(ln);
|
free(ln);
|
||||||
|
|
||||||
|
ptr_dec(gsc->body); ptr_inc(block->body); // redirect new errors to the newly executed code; initial scope had 0 vars, so this is safe
|
||||||
|
gsc->body = block->body;
|
||||||
|
|
||||||
#ifdef TIME
|
#ifdef TIME
|
||||||
u64 sns = nsTime();
|
u64 sns = nsTime();
|
||||||
B res = evalBC(block->body, gsc);
|
B res = evalBC(block->body, gsc);
|
||||||
|
|||||||
4
src/vm.h
4
src/vm.h
@ -52,9 +52,9 @@ struct ScopeExt {
|
|||||||
struct Scope {
|
struct Scope {
|
||||||
struct Value;
|
struct Value;
|
||||||
Scope* psc;
|
Scope* psc;
|
||||||
Body* body;
|
Body* body; // last place where code was executed in this scope; also used for variable name resolution, so can only safely be replaced if varAm==0
|
||||||
u16 varAm;
|
u16 varAm;
|
||||||
ScopeExt* ext;
|
ScopeExt* ext; // will probably be NULL
|
||||||
B vars[];
|
B vars[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user