This commit is contained in:
blueloveTH 2023-09-10 13:05:39 +08:00
parent 874c009072
commit 742014c332
2 changed files with 15 additions and 13 deletions

View File

@ -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); }

View File

@ -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();