This commit is contained in:
blueloveTH 2024-08-12 13:41:42 +08:00
parent a5725824b4
commit 26c553eb9a
2 changed files with 9 additions and 0 deletions

View File

@ -281,6 +281,9 @@ void py_setslot(py_Ref self, int i, py_Ref val);
/// Get the current `function` object from the stack.
/// Return `NULL` if not available.
py_StackRef py_inspect_currentfunction();
/// Get the current `module` object where the code is executed.
/// Return `NULL` if not available.
py_GlobalRef py_inspect_currentmodule();
/************* Bindings *************/

View File

@ -64,6 +64,12 @@ py_StackRef py_inspect_currentfunction(){
return frame->p0;
}
py_GlobalRef py_inspect_currentmodule(){
Frame* frame = pk_current_vm->top_frame;
if(!frame) return NULL;
return frame->module;
}
void py_assign(py_Ref dst, py_Ref src) { *dst = *src; }
/* Stack References */