This commit is contained in:
blueloveTH 2023-01-28 01:59:28 +08:00
parent 4a3176ba74
commit b2a64c47b8
2 changed files with 5 additions and 5 deletions

View File

@ -253,9 +253,7 @@ public:
if(code->co_blocks[i].type == FOR_LOOP) pop(); if(code->co_blocks[i].type == FOR_LOOP) pop();
i = code->co_blocks[i].parent; i = code->co_blocks[i].parent;
} }
if(i!=next.block) throw std::runtime_error( if(i!=next.block) throw std::runtime_error("invalid jump");
"invalid jump from " + code->co_blocks[prev.block].to_string() + " to " + code->co_blocks[next.block].to_string()
);
} }
} }

View File

@ -22,6 +22,7 @@ public:
} }
InputResult input(std::string line){ InputResult input(std::string line){
CompileMode mode = SINGLE_MODE;
if(need_more_lines){ if(need_more_lines){
buffer += line; buffer += line;
buffer += '\n'; buffer += '\n';
@ -33,6 +34,7 @@ public:
need_more_lines = 0; need_more_lines = 0;
line = buffer; line = buffer;
buffer.clear(); buffer.clear();
mode = EXEC_MODE;
}else{ }else{
__NOT_ENOUGH_LINES: __NOT_ENOUGH_LINES:
return NEED_MORE_LINES; return NEED_MORE_LINES;
@ -42,7 +44,7 @@ __NOT_ENOUGH_LINES:
} }
try{ try{
vm->compile(line, "<stdin>", SINGLE_MODE); vm->compile(line, "<stdin>", mode);
}catch(NeedMoreLines& ne){ }catch(NeedMoreLines& ne){
buffer += line; buffer += line;
buffer += '\n'; buffer += '\n';
@ -51,7 +53,7 @@ __NOT_ENOUGH_LINES:
}catch(...){ }catch(...){
// do nothing // do nothing
} }
vm->exec(line, "<stdin>", SINGLE_MODE); vm->exec(line, "<stdin>", mode);
return EXEC_STARTED; return EXEC_STARTED;
} }
}; };