diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index 9eedea93..ba055e0b 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -49,9 +49,9 @@ namespace pkpy{ typedef PyObject* (*BinaryFuncC)(VM*, PyObject*, PyObject*); struct PyTypeInfo{ - PyObject* obj; + PyObject* obj; // never be garbage collected Type base; - PyObject* mod; + PyObject* mod; // never be garbage collected Str name; bool subclass_enabled; @@ -353,17 +353,7 @@ public: _error(Exception(name, msg)); } - void _raise(bool re_raise=false){ - Frame* top = top_frame().get(); - if(!re_raise){ - Exception& e = PK_OBJ_GET(Exception, s_data.top()); - e._ip_on_error = top->_ip; - e._code_on_error = (void*)top->co; - } - bool ok = top->jump_to_exception_handler(); - if(ok) throw HandledException(); - else throw UnhandledException(); - } + void _raise(bool re_raise=false); void StackOverflowError() { _error("StackOverflowError", ""); } void IOError(const Str& msg) { _error("IOError", msg); } diff --git a/src/vm.cpp b/src/vm.cpp index e44d2cdf..f192579c 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -1078,6 +1078,18 @@ void VM::_error(Exception e){ _raise(); } +void VM::_raise(bool re_raise){ + Frame* top = top_frame().get(); + if(!re_raise){ + Exception& e = PK_OBJ_GET(Exception, s_data.top()); + e._ip_on_error = top->_ip; + e._code_on_error = (void*)top->co; + } + bool ok = top->jump_to_exception_handler(); + if(ok) throw HandledException(); + else throw UnhandledException(); +} + void ManagedHeap::mark() { for(PyObject* obj: _no_gc) PK_OBJ_MARK(obj); for(auto& frame : vm->callstack.data()) frame._gc_mark();