diff --git a/src/codeobject.h b/src/codeobject.h index 95a8b436..e90f4a49 100644 --- a/src/codeobject.h +++ b/src/codeobject.h @@ -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; diff --git a/src/compiler.h b/src/compiler.h index 8e598025..d4e5b264 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -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"))){ diff --git a/src/opcodes.h b/src/opcodes.h index 65eff463..7e129999 100644 --- a/src/opcodes.h +++ b/src/opcodes.h @@ -72,8 +72,6 @@ OPCODE(GOTO) OPCODE(WITH_ENTER) OPCODE(WITH_EXIT) -OPCODE(JUMP_RELATIVE) - OPCODE(RAISE_VARARGS) OPCODE(LOOP_BREAK) diff --git a/src/vm.h b/src/vm.h index 138a0cc6..de2cc943 100644 --- a/src/vm.h +++ b/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(); }