blueloveTH 3 лет назад
Родитель
Сommit
998e3e4249
5 измененных файлов с 10 добавлено и 6 удалено
  1. 2 0
      README.md
  2. 2 0
      src/codeobject.h
  3. 2 5
      src/common.h
  4. 3 0
      src/pocketpy.h
  5. 1 1
      src/vm.h

+ 2 - 0
README.md

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

+ 2 - 0
src/codeobject.h

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

+ 2 - 5
src/common.h

@@ -35,11 +35,8 @@
 #include <emscripten.h>
 #include <emscripten.h>
 #endif
 #endif
 
 
-#define PK_VERSION "0.8.2"
+#define PK_VERSION "0.8.3"
 
 
 typedef int64_t i64;
 typedef int64_t i64;
 typedef double f64;
 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; })
+#define DUMMY_VAL (i64)0

+ 3 - 0
src/pocketpy.h

@@ -5,6 +5,9 @@
 #include "repl.h"
 #include "repl.h"
 #include "iter.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) {
 _Code VM::compile(_Str source, _Str filename, CompileMode mode) {
     Compiler compiler(this, source.c_str(), filename, mode);
     Compiler compiler(this, source.c_str(), filename, mode);
     try{
     try{

+ 1 - 1
src/vm.h

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