This commit is contained in:
blueloveTH 2023-02-09 15:16:55 +08:00
parent d45e348340
commit 998e3e4249
5 changed files with 10 additions and 6 deletions

View File

@ -162,6 +162,8 @@ All kinds of contributions are welcome.
- any suggestions
- any questions
Check our [Coding Style Guide](https://pocketpy.dev/coding_style_guide/) if you want to contribute C++ code.
## Reference
+ [cpython](https://github.com/python/cpython)

View File

@ -254,12 +254,14 @@ struct Frame {
if(_next_ip >= co->codes.size()){
while(i>=0){
if(co->blocks[i].type == FOR_LOOP) pop();
else if(co->blocks[i].type == TRY_EXCEPT) on_try_block_exit();
i = co->blocks[i].parent;
}
}else{
const Bytecode& next = co->codes[target];
while(i>=0 && i!=next.block){
if(co->blocks[i].type == FOR_LOOP) pop();
else if(co->blocks[i].type == TRY_EXCEPT) on_try_block_exit();
i = co->blocks[i].parent;
}
if(i!=next.block) throw std::runtime_error("invalid jump");

View File

@ -35,11 +35,8 @@
#include <emscripten.h>
#endif
#define PK_VERSION "0.8.2"
#define PK_VERSION "0.8.3"
typedef int64_t i64;
typedef double f64;
#define DUMMY_VAL (i64)0
#define CPP_LAMBDA(x) ([](VM* vm, const pkpy::Args& args) { return x; })
#define CPP_NOT_IMPLEMENTED() ([](VM* vm, const pkpy::Args& args) { vm->NotImplementedError(); return vm->None; })

View File

@ -5,6 +5,9 @@
#include "repl.h"
#include "iter.h"
#define CPP_LAMBDA(x) ([](VM* vm, const pkpy::Args& args) { return x; })
#define CPP_NOT_IMPLEMENTED() ([](VM* vm, const pkpy::Args& args) { vm->NotImplementedError(); return vm->None; })
_Code VM::compile(_Str source, _Str filename, CompileMode mode) {
Compiler compiler(this, source.c_str(), filename, mode);
try{

View File

@ -253,7 +253,7 @@ class VM {
PyIter_AS_C(tmp)->var = var;
frame->push(std::move(tmp));
}else{
TypeError("'" + OBJ_TP_NAME(obj) + "' object is not iterable");
TypeError(OBJ_TP_NAME(obj).escape(true) + " object is not iterable");
}
} break;
case OP_FOR_ITER: