mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
Update ceval.c
This commit is contained in:
parent
d5bd9359d9
commit
0a44220f66
@ -88,12 +88,11 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
py_Frame* frame = self->top_frame;
|
py_Frame* frame = self->top_frame;
|
||||||
Bytecode* co_codes;
|
Bytecode* co_codes;
|
||||||
py_Name* co_names;
|
py_Name* co_names;
|
||||||
|
Bytecode byte;
|
||||||
|
|
||||||
const py_Frame* base_frame = frame;
|
const py_Frame* base_frame = frame;
|
||||||
|
|
||||||
while(true) {
|
__NEXT_FRAME:
|
||||||
Bytecode byte;
|
|
||||||
__NEXT_FRAME:
|
|
||||||
if(self->recursion_depth >= self->max_recursion_depth) {
|
if(self->recursion_depth >= self->max_recursion_depth) {
|
||||||
py_exception(tp_RecursionError, "maximum recursion depth exceeded");
|
py_exception(tp_RecursionError, "maximum recursion depth exceeded");
|
||||||
goto __ERROR;
|
goto __ERROR;
|
||||||
@ -101,7 +100,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
RESET_CO_CACHE();
|
RESET_CO_CACHE();
|
||||||
frame->ip++;
|
frame->ip++;
|
||||||
|
|
||||||
__NEXT_STEP:
|
__NEXT_STEP:
|
||||||
byte = co_codes[frame->ip];
|
byte = co_codes[frame->ip];
|
||||||
|
|
||||||
if(self->trace_info.func) {
|
if(self->trace_info.func) {
|
||||||
@ -1087,9 +1086,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
py_Name name = co_names[byte.arg];
|
py_Name name = co_names[byte.arg];
|
||||||
// TOP() can be a function, classmethod or custom decorator
|
// TOP() can be a function, classmethod or custom decorator
|
||||||
py_Ref actual_func = TOP();
|
py_Ref actual_func = TOP();
|
||||||
if(actual_func->type == tp_classmethod) {
|
if(actual_func->type == tp_classmethod) { actual_func = py_getslot(actual_func, 0); }
|
||||||
actual_func = py_getslot(actual_func, 0);
|
|
||||||
}
|
|
||||||
if(actual_func->type == tp_function) {
|
if(actual_func->type == tp_function) {
|
||||||
Function* ud = py_touserdata(actual_func);
|
Function* ud = py_touserdata(actual_func);
|
||||||
ud->clazz = self->curr_class->_obj;
|
ud->clazz = self->curr_class->_obj;
|
||||||
@ -1114,8 +1111,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
// [expr]
|
// [expr]
|
||||||
py_push(TOP());
|
py_push(TOP());
|
||||||
if(!py_pushmethod(__enter__)) {
|
if(!py_pushmethod(__enter__)) {
|
||||||
TypeError("'%t' object does not support the context manager protocol",
|
TypeError("'%t' object does not support the context manager protocol", TOP()->type);
|
||||||
TOP()->type);
|
|
||||||
goto __ERROR;
|
goto __ERROR;
|
||||||
}
|
}
|
||||||
vectorcall_opcall(0, 0);
|
vectorcall_opcall(0, 0);
|
||||||
@ -1125,8 +1121,7 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
// [expr]
|
// [expr]
|
||||||
py_push(TOP());
|
py_push(TOP());
|
||||||
if(!py_pushmethod(__exit__)) {
|
if(!py_pushmethod(__exit__)) {
|
||||||
TypeError("'%t' object does not support the context manager protocol",
|
TypeError("'%t' object does not support the context manager protocol", TOP()->type);
|
||||||
TOP()->type);
|
|
||||||
goto __ERROR;
|
goto __ERROR;
|
||||||
}
|
}
|
||||||
if(!py_vectorcall(0, 0)) goto __ERROR;
|
if(!py_vectorcall(0, 0)) goto __ERROR;
|
||||||
@ -1222,14 +1217,15 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
|
|
||||||
c11__unreachable();
|
c11__unreachable();
|
||||||
|
|
||||||
__ERROR:
|
__ERROR:
|
||||||
py_BaseException__stpush(&self->curr_exception,
|
py_BaseException__stpush(&self->curr_exception,
|
||||||
frame->co->src,
|
frame->co->src,
|
||||||
Frame__lineno(frame),
|
Frame__lineno(frame),
|
||||||
!frame->is_locals_special ? frame->co->name->data : NULL);
|
!frame->is_locals_special ? frame->co->name->data : NULL);
|
||||||
__ERROR_RE_RAISE:
|
__ERROR_RE_RAISE:
|
||||||
do {
|
do {
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
int target = Frame__prepare_jump_exception_handler(frame, &self->stack);
|
int target = Frame__prepare_jump_exception_handler(frame, &self->stack);
|
||||||
if(target >= 0) {
|
if(target >= 0) {
|
||||||
// 1. Exception can be handled inside the current frame
|
// 1. Exception can be handled inside the current frame
|
||||||
@ -1246,9 +1242,8 @@ FrameResult VM__run_top_frame(VM* self) {
|
|||||||
RESET_CO_CACHE();
|
RESET_CO_CACHE();
|
||||||
goto __ERROR;
|
goto __ERROR;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return RES_RETURN;
|
c11__unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* pk_op2str(py_Name op) {
|
const char* pk_op2str(py_Name op) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user