mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
up
This commit is contained in:
parent
4bb967d426
commit
76d167437c
@ -220,10 +220,6 @@ public:
|
||||
this->ip = i;
|
||||
}
|
||||
|
||||
inline void jumpRelative(int i){
|
||||
this->ip += i;
|
||||
}
|
||||
|
||||
void jumpAbsoluteSafe(int target){
|
||||
const ByteCode& prev = code->co_code[this->ip];
|
||||
int i = prev.block;
|
||||
|
@ -837,14 +837,10 @@ __LISTCOMP:
|
||||
void compileTryExcept() {
|
||||
getCode()->__enterBlock(TRY_EXCEPT);
|
||||
compileBlockBody();
|
||||
getCode()->__exitBlock();
|
||||
int patch = emitCode(OP_JUMP_ABSOLUTE);
|
||||
getCode()->__exitBlock();
|
||||
consume(TK("except"));
|
||||
if(match(TK("@id"))){ // exception name
|
||||
if(match(TK("as"))){ // exception name as alias
|
||||
consume(TK("@id"));
|
||||
exprName();
|
||||
}
|
||||
compileBlockBody();
|
||||
}
|
||||
if(match(TK("finally"))){
|
||||
@ -915,7 +911,12 @@ __LISTCOMP:
|
||||
} else if(match(TK("raise"))){
|
||||
consume(TK("@id")); // dummy exception type
|
||||
emitCode(OP_LOAD_CONST, getCode()->addConst(vm->PyStr(parser->previous.str())));
|
||||
consume(TK("("));EXPR();consume(TK(")"));
|
||||
if(match(TK("("))){
|
||||
EXPR();
|
||||
consume(TK(")"));
|
||||
}else{
|
||||
emitCode(OP_LOAD_NONE); // ...?
|
||||
}
|
||||
emitCode(OP_RAISE_ERROR);
|
||||
consumeEndStatement();
|
||||
} else if(match(TK("del"))){
|
||||
|
@ -72,8 +72,6 @@ OPCODE(GOTO)
|
||||
OPCODE(WITH_ENTER)
|
||||
OPCODE(WITH_EXIT)
|
||||
|
||||
OPCODE(JUMP_RELATIVE)
|
||||
|
||||
OPCODE(RAISE_VARARGS)
|
||||
|
||||
OPCODE(LOOP_BREAK)
|
||||
|
6
src/vm.h
6
src/vm.h
@ -246,7 +246,6 @@ protected:
|
||||
frame->push(std::move(ret));
|
||||
} break;
|
||||
case OP_JUMP_ABSOLUTE: frame->jumpAbsolute(byte.arg); break;
|
||||
case OP_JUMP_RELATIVE: frame->jumpRelative(byte.arg); break;
|
||||
case OP_SAFE_JUMP_ABSOLUTE: frame->jumpAbsoluteSafe(byte.arg); break;
|
||||
case OP_GOTO: {
|
||||
PyVar obj = frame->popValue(this);
|
||||
@ -277,8 +276,7 @@ protected:
|
||||
auto& it = PyIter_AS_C(frame->__top());
|
||||
if(it->hasNext()){
|
||||
PyRef_AS_C(it->var)->set(this, frame, it->next());
|
||||
}
|
||||
else{
|
||||
}else{
|
||||
int blockEnd = frame->code->co_blocks[byte.block].end;
|
||||
frame->jumpAbsoluteSafe(blockEnd);
|
||||
}
|
||||
@ -405,7 +403,7 @@ public:
|
||||
return asRepr(obj);
|
||||
}
|
||||
|
||||
Frame* topFrame(){
|
||||
inline Frame* topFrame() const {
|
||||
if(callstack.size() == 0) UNREACHABLE();
|
||||
return callstack.back().get();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user