From 998e3e4249968dd2c27d7fb7ce81349764b97a4e Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 9 Feb 2023 15:16:55 +0800 Subject: [PATCH] up --- README.md | 2 ++ src/codeobject.h | 2 ++ src/common.h | 7 ++----- src/pocketpy.h | 3 +++ src/vm.h | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 559fccc2..256683be 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/codeobject.h b/src/codeobject.h index 07a0752c..3cd7a94a 100644 --- a/src/codeobject.h +++ b/src/codeobject.h @@ -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"); diff --git a/src/common.h b/src/common.h index 4b1d4622..3ccfd0c0 100644 --- a/src/common.h +++ b/src/common.h @@ -35,11 +35,8 @@ #include #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; }) \ No newline at end of file +#define DUMMY_VAL (i64)0 \ No newline at end of file diff --git a/src/pocketpy.h b/src/pocketpy.h index 71a7d9b5..0bbf0e24 100644 --- a/src/pocketpy.h +++ b/src/pocketpy.h @@ -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{ diff --git a/src/vm.h b/src/vm.h index a9f54b66..103413a9 100644 --- a/src/vm.h +++ b/src/vm.h @@ -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: