Update ceval.c

This commit is contained in:
blueloveTH 2025-06-30 01:46:28 +08:00
parent d5bd9359d9
commit 0a44220f66

View File

@ -88,11 +88,10 @@ FrameResult VM__run_top_frame(VM* self) {
py_Frame* frame = self->top_frame;
Bytecode* co_codes;
py_Name* co_names;
Bytecode byte;
const py_Frame* base_frame = frame;
while(true) {
Bytecode byte;
__NEXT_FRAME:
if(self->recursion_depth >= self->max_recursion_depth) {
py_exception(tp_RecursionError, "maximum recursion depth exceeded");
@ -1087,9 +1086,7 @@ FrameResult VM__run_top_frame(VM* self) {
py_Name name = co_names[byte.arg];
// TOP() can be a function, classmethod or custom decorator
py_Ref actual_func = TOP();
if(actual_func->type == tp_classmethod) {
actual_func = py_getslot(actual_func, 0);
}
if(actual_func->type == tp_classmethod) { actual_func = py_getslot(actual_func, 0); }
if(actual_func->type == tp_function) {
Function* ud = py_touserdata(actual_func);
ud->clazz = self->curr_class->_obj;
@ -1114,8 +1111,7 @@ FrameResult VM__run_top_frame(VM* self) {
// [expr]
py_push(TOP());
if(!py_pushmethod(__enter__)) {
TypeError("'%t' object does not support the context manager protocol",
TOP()->type);
TypeError("'%t' object does not support the context manager protocol", TOP()->type);
goto __ERROR;
}
vectorcall_opcall(0, 0);
@ -1125,8 +1121,7 @@ FrameResult VM__run_top_frame(VM* self) {
// [expr]
py_push(TOP());
if(!py_pushmethod(__exit__)) {
TypeError("'%t' object does not support the context manager protocol",
TOP()->type);
TypeError("'%t' object does not support the context manager protocol", TOP()->type);
goto __ERROR;
}
if(!py_vectorcall(0, 0)) goto __ERROR;
@ -1230,6 +1225,7 @@ FrameResult VM__run_top_frame(VM* self) {
__ERROR_RE_RAISE:
do {
} while(0);
int target = Frame__prepare_jump_exception_handler(frame, &self->stack);
if(target >= 0) {
// 1. Exception can be handled inside the current frame
@ -1246,9 +1242,8 @@ FrameResult VM__run_top_frame(VM* self) {
RESET_CO_CACHE();
goto __ERROR;
}
}
return RES_RETURN;
c11__unreachable();
}
const char* pk_op2str(py_Name op) {