rename to py_Frame

This commit is contained in:
blueloveTH 2025-03-06 12:02:57 +08:00
parent db7c577c94
commit a9955cd210
11 changed files with 62 additions and 62 deletions

View File

@ -28,8 +28,8 @@ typedef struct UnwindTarget {
UnwindTarget* UnwindTarget__new(UnwindTarget* next, int iblock, int offset); UnwindTarget* UnwindTarget__new(UnwindTarget* next, int iblock, int offset);
void UnwindTarget__delete(UnwindTarget* self); void UnwindTarget__delete(UnwindTarget* self);
typedef struct Frame { typedef struct py_Frame {
struct Frame* f_back; struct py_Frame* f_back;
const CodeObject* co; const CodeObject* co;
py_StackRef p0; // unwinding base py_StackRef p0; // unwinding base
py_GlobalRef module; py_GlobalRef module;
@ -38,35 +38,35 @@ typedef struct Frame {
bool is_locals_special; bool is_locals_special;
int ip; int ip;
UnwindTarget* uw_list; UnwindTarget* uw_list;
} Frame; } py_Frame;
typedef struct SourceLocation { typedef struct SourceLocation {
SourceData_ src; SourceData_ src;
int lineno; int lineno;
} SourceLocation; } SourceLocation;
Frame* Frame__new(const CodeObject* co, py_Frame* Frame__new(const CodeObject* co,
py_StackRef p0, py_StackRef p0,
py_GlobalRef module, py_GlobalRef module,
py_Ref globals, py_Ref globals,
py_Ref locals, py_Ref locals,
bool is_locals_special); bool is_locals_special);
void Frame__delete(Frame* self); void Frame__delete(py_Frame* self);
int Frame__lineno(const Frame* self); int Frame__lineno(const py_Frame* self);
int Frame__iblock(const Frame* self); int Frame__iblock(const py_Frame* self);
int Frame__getglobal(Frame* self, py_Name name) PY_RAISE PY_RETURN; int Frame__getglobal(py_Frame* self, py_Name name) PY_RAISE PY_RETURN;
bool Frame__setglobal(Frame* self, py_Name name, py_TValue* val) PY_RAISE; bool Frame__setglobal(py_Frame* self, py_Name name, py_TValue* val) PY_RAISE;
int Frame__delglobal(Frame* self, py_Name name) PY_RAISE; int Frame__delglobal(py_Frame* self, py_Name name) PY_RAISE;
py_Ref Frame__getclosure(Frame* self, py_Name name); py_Ref Frame__getclosure(py_Frame* self, py_Name name);
py_StackRef Frame__getlocal_noproxy(Frame* self, py_Name name); py_StackRef Frame__getlocal_noproxy(py_Frame* self, py_Name name);
int Frame__prepare_jump_exception_handler(Frame* self, ValueStack*); int Frame__prepare_jump_exception_handler(py_Frame* self, ValueStack*);
UnwindTarget* Frame__find_unwind_target(Frame* self, int iblock); UnwindTarget* Frame__find_unwind_target(py_Frame* self, int iblock);
void Frame__set_unwind_target(Frame* self, py_TValue* sp); void Frame__set_unwind_target(py_Frame* self, py_TValue* sp);
void Frame__gc_mark(Frame* self); void Frame__gc_mark(py_Frame* self);
SourceLocation Frame__source_location(Frame* self); SourceLocation Frame__source_location(py_Frame* self);

View File

@ -4,10 +4,10 @@
#include "pocketpy/pocketpy.h" #include "pocketpy/pocketpy.h"
typedef struct Generator{ typedef struct Generator{
Frame* frame; py_Frame* frame;
int state; int state;
} Generator; } Generator;
void pk_newgenerator(py_Ref out, Frame* frame, py_TValue* begin, py_TValue* end); void pk_newgenerator(py_Ref out, py_Frame* frame, py_TValue* begin, py_TValue* end);
void Generator__dtor(Generator* ud); void Generator__dtor(Generator* ud);

View File

@ -24,7 +24,7 @@ typedef struct TraceInfo {
} TraceInfo; } TraceInfo;
typedef struct VM { typedef struct VM {
Frame* top_frame; py_Frame* top_frame;
ModuleDict modules; ModuleDict modules;
TypeList types; TypeList types;
@ -57,7 +57,7 @@ typedef struct VM {
void VM__ctor(VM* self); void VM__ctor(VM* self);
void VM__dtor(VM* self); void VM__dtor(VM* self);
void VM__push_frame(VM* self, Frame* frame); void VM__push_frame(VM* self, py_Frame* frame);
void VM__pop_frame(VM* self); void VM__pop_frame(VM* self);
bool pk__parse_int_slice(py_Ref slice, int length, int* restrict start, int* restrict stop, int* restrict step); bool pk__parse_int_slice(py_Ref slice, int length, int* restrict start, int* restrict stop, int* restrict step);
@ -108,7 +108,7 @@ bool pk_execdyn(CodeObject* co, py_Ref module, py_Ref globals, py_Ref locals);
/// The stack remains unchanged. /// The stack remains unchanged.
bool pk_stack_binaryop(VM* self, py_Name op, py_Name rop); bool pk_stack_binaryop(VM* self, py_Name op, py_Name rop);
void pk_print_stack(VM* self, Frame* frame, Bytecode byte); void pk_print_stack(VM* self, py_Frame* frame, Bytecode byte);
// type registration // type registration
void pk_object__register(); void pk_object__register();

View File

@ -69,7 +69,7 @@ static bool stack_format_object(VM* self, c11_sv spec);
case RES_CALL: { \ case RES_CALL: { \
frame = self->top_frame; \ frame = self->top_frame; \
if(self->trace_info.tracefunc) { \ if(self->trace_info.tracefunc) { \
self->trace_info.tracefunc((py_Frame*)frame, TRACE_EVENT_CALL); \ self->trace_info.tracefunc(frame, TRACE_EVENT_CALL); \
} \ } \
goto __NEXT_FRAME; \ goto __NEXT_FRAME; \
} \ } \
@ -91,10 +91,10 @@ static bool unpack_dict_to_buffer(py_Ref key, py_Ref val, void* ctx) {
} }
FrameResult VM__run_top_frame(VM* self) { FrameResult VM__run_top_frame(VM* self) {
Frame* frame = self->top_frame; py_Frame* frame = self->top_frame;
Bytecode* codes; Bytecode* codes;
const Frame* base_frame = frame; const py_Frame* base_frame = frame;
while(true) { while(true) {
Bytecode byte; Bytecode byte;
@ -112,7 +112,7 @@ FrameResult VM__run_top_frame(VM* self) {
if(prev_loc.src) PK_DECREF(prev_loc.src); if(prev_loc.src) PK_DECREF(prev_loc.src);
PK_INCREF(loc.src); PK_INCREF(loc.src);
self->trace_info.prev_loc = loc; self->trace_info.prev_loc = loc;
self->trace_info.tracefunc((py_Frame*)frame, TRACE_EVENT_LINE); self->trace_info.tracefunc(frame, TRACE_EVENT_LINE);
} }
} }
@ -225,7 +225,7 @@ FrameResult VM__run_top_frame(VM* self) {
// locals // locals
switch(frame->locals->type) { switch(frame->locals->type) {
case tp_locals: { case tp_locals: {
Frame* noproxy = frame->locals->_ptr; py_Frame* noproxy = frame->locals->_ptr;
py_Ref slot = Frame__getlocal_noproxy(noproxy, name); py_Ref slot = Frame__getlocal_noproxy(noproxy, name);
if(slot == NULL) break; if(slot == NULL) break;
if(py_isnil(slot)) { if(py_isnil(slot)) {
@ -376,7 +376,7 @@ FrameResult VM__run_top_frame(VM* self) {
py_Name name = byte.arg; py_Name name = byte.arg;
switch(frame->locals->type) { switch(frame->locals->type) {
case tp_locals: { case tp_locals: {
Frame* noproxy = frame->locals->_ptr; py_Frame* noproxy = frame->locals->_ptr;
py_Ref slot = Frame__getlocal_noproxy(noproxy, name); py_Ref slot = Frame__getlocal_noproxy(noproxy, name);
if(slot == NULL) { if(slot == NULL) {
UnboundLocalError(name); UnboundLocalError(name);
@ -443,7 +443,7 @@ FrameResult VM__run_top_frame(VM* self) {
py_Name name = byte.arg; py_Name name = byte.arg;
switch(frame->locals->type) { switch(frame->locals->type) {
case tp_locals: { case tp_locals: {
Frame* noproxy = frame->locals->_ptr; py_Frame* noproxy = frame->locals->_ptr;
py_Ref slot = Frame__getlocal_noproxy(noproxy, name); py_Ref slot = Frame__getlocal_noproxy(noproxy, name);
if(slot == NULL || py_isnil(slot)) { if(slot == NULL || py_isnil(slot)) {
UnboundLocalError(name); UnboundLocalError(name);
@ -758,7 +758,7 @@ FrameResult VM__run_top_frame(VM* self) {
py_newnone(&self->last_retval); py_newnone(&self->last_retval);
} }
if(self->trace_info.tracefunc) { if(self->trace_info.tracefunc) {
self->trace_info.tracefunc((py_Frame*)frame, TRACE_EVENT_RETURN); self->trace_info.tracefunc(frame, TRACE_EVENT_RETURN);
} }
VM__pop_frame(self); VM__pop_frame(self);
if(frame == base_frame) { // [ frameBase<- ] if(frame == base_frame) { // [ frameBase<- ]

View File

@ -47,7 +47,7 @@ UnwindTarget* UnwindTarget__new(UnwindTarget* next, int iblock, int offset) {
void UnwindTarget__delete(UnwindTarget* self) { PK_FREE(self); } void UnwindTarget__delete(UnwindTarget* self) { PK_FREE(self); }
Frame* Frame__new(const CodeObject* co, py_Frame* Frame__new(const CodeObject* co,
py_StackRef p0, py_StackRef p0,
py_GlobalRef module, py_GlobalRef module,
py_Ref globals, py_Ref globals,
@ -58,7 +58,7 @@ Frame* Frame__new(const CodeObject* co,
if(is_locals_special) { if(is_locals_special) {
assert(locals->type == tp_nil || locals->type == tp_locals || locals->type == tp_dict); assert(locals->type == tp_nil || locals->type == tp_locals || locals->type == tp_dict);
} }
Frame* self = FixedMemoryPool__alloc(&pk_current_vm->pool_frame); py_Frame* self = FixedMemoryPool__alloc(&pk_current_vm->pool_frame);
self->f_back = NULL; self->f_back = NULL;
self->co = co; self->co = co;
self->p0 = p0; self->p0 = p0;
@ -71,7 +71,7 @@ Frame* Frame__new(const CodeObject* co,
return self; return self;
} }
void Frame__delete(Frame* self) { void Frame__delete(py_Frame* self) {
while(self->uw_list) { while(self->uw_list) {
UnwindTarget* p = self->uw_list; UnwindTarget* p = self->uw_list;
self->uw_list = p->next; self->uw_list = p->next;
@ -80,7 +80,7 @@ void Frame__delete(Frame* self) {
FixedMemoryPool__dealloc(&pk_current_vm->pool_frame, self); FixedMemoryPool__dealloc(&pk_current_vm->pool_frame, self);
} }
int Frame__prepare_jump_exception_handler(Frame* self, ValueStack* _s) { int Frame__prepare_jump_exception_handler(py_Frame* self, ValueStack* _s) {
// try to find a parent try block // try to find a parent try block
int iblock = Frame__iblock(self); int iblock = Frame__iblock(self);
while(iblock >= 0) { while(iblock >= 0) {
@ -94,7 +94,7 @@ int Frame__prepare_jump_exception_handler(Frame* self, ValueStack* _s) {
return c11__at(CodeBlock, &self->co->blocks, iblock)->end; return c11__at(CodeBlock, &self->co->blocks, iblock)->end;
} }
UnwindTarget* Frame__find_unwind_target(Frame* self, int iblock) { UnwindTarget* Frame__find_unwind_target(py_Frame* self, int iblock) {
UnwindTarget* uw; UnwindTarget* uw;
for(uw = self->uw_list; uw; uw = uw->next) { for(uw = self->uw_list; uw; uw = uw->next) {
if(uw->iblock == iblock) return uw; if(uw->iblock == iblock) return uw;
@ -102,7 +102,7 @@ UnwindTarget* Frame__find_unwind_target(Frame* self, int iblock) {
return NULL; return NULL;
} }
void Frame__set_unwind_target(Frame* self, py_TValue* sp) { void Frame__set_unwind_target(py_Frame* self, py_TValue* sp) {
int iblock = Frame__iblock(self); int iblock = Frame__iblock(self);
UnwindTarget* existing = Frame__find_unwind_target(self, iblock); UnwindTarget* existing = Frame__find_unwind_target(self, iblock);
if(existing) { if(existing) {
@ -113,23 +113,23 @@ void Frame__set_unwind_target(Frame* self, py_TValue* sp) {
} }
} }
void Frame__gc_mark(Frame* self) { void Frame__gc_mark(py_Frame* self) {
pk__mark_value(self->globals); pk__mark_value(self->globals);
if(self->is_locals_special) pk__mark_value(self->locals); if(self->is_locals_special) pk__mark_value(self->locals);
CodeObject__gc_mark(self->co); CodeObject__gc_mark(self->co);
} }
int Frame__lineno(const Frame* self) { int Frame__lineno(const py_Frame* self) {
int ip = self->ip; int ip = self->ip;
return c11__getitem(BytecodeEx, &self->co->codes_ex, ip).lineno; return c11__getitem(BytecodeEx, &self->co->codes_ex, ip).lineno;
} }
int Frame__iblock(const Frame* self) { int Frame__iblock(const py_Frame* self) {
int ip = self->ip; int ip = self->ip;
return c11__getitem(BytecodeEx, &self->co->codes_ex, ip).iblock; return c11__getitem(BytecodeEx, &self->co->codes_ex, ip).iblock;
} }
int Frame__getglobal(Frame* self, py_Name name) { int Frame__getglobal(py_Frame* self, py_Name name) {
if(self->globals->type == tp_module) { if(self->globals->type == tp_module) {
py_ItemRef item = py_getdict(self->globals, name); py_ItemRef item = py_getdict(self->globals, name);
if(item != NULL) { if(item != NULL) {
@ -142,7 +142,7 @@ int Frame__getglobal(Frame* self, py_Name name) {
} }
} }
bool Frame__setglobal(Frame* self, py_Name name, py_TValue* val) { bool Frame__setglobal(py_Frame* self, py_Name name, py_TValue* val) {
if(self->globals->type == tp_module) { if(self->globals->type == tp_module) {
py_setdict(self->globals, name, val); py_setdict(self->globals, name, val);
return true; return true;
@ -151,7 +151,7 @@ bool Frame__setglobal(Frame* self, py_Name name, py_TValue* val) {
} }
} }
int Frame__delglobal(Frame* self, py_Name name) { int Frame__delglobal(py_Frame* self, py_Name name) {
if(self->globals->type == tp_module) { if(self->globals->type == tp_module) {
bool found = py_deldict(self->globals, name); bool found = py_deldict(self->globals, name);
return found ? 1 : 0; return found ? 1 : 0;
@ -160,14 +160,14 @@ int Frame__delglobal(Frame* self, py_Name name) {
} }
} }
py_StackRef Frame__getlocal_noproxy(Frame* self, py_Name name) { py_StackRef Frame__getlocal_noproxy(py_Frame* self, py_Name name) {
assert(!self->is_locals_special); assert(!self->is_locals_special);
int index = c11_smallmap_n2i__get(&self->co->varnames_inv, name, -1); int index = c11_smallmap_n2i__get(&self->co->varnames_inv, name, -1);
if(index == -1) return NULL; if(index == -1) return NULL;
return &self->locals[index]; return &self->locals[index];
} }
py_Ref Frame__getclosure(Frame* self, py_Name name) { py_Ref Frame__getclosure(py_Frame* self, py_Name name) {
if(self->is_locals_special) return NULL; if(self->is_locals_special) return NULL;
assert(self->p0->type == tp_function); assert(self->p0->type == tp_function);
Function* ud = py_touserdata(self->p0); Function* ud = py_touserdata(self->p0);
@ -175,7 +175,7 @@ py_Ref Frame__getclosure(Frame* self, py_Name name) {
return NameDict__try_get(ud->closure, name); return NameDict__try_get(ud->closure, name);
} }
SourceLocation Frame__source_location(Frame* self) { SourceLocation Frame__source_location(py_Frame* self) {
SourceLocation loc; SourceLocation loc;
loc.lineno = Frame__lineno(self); loc.lineno = Frame__lineno(self);
loc.src = self->co->src; loc.src = self->co->src;

View File

@ -5,7 +5,7 @@
#include "pocketpy/pocketpy.h" #include "pocketpy/pocketpy.h"
#include <stdbool.h> #include <stdbool.h>
void pk_newgenerator(py_Ref out, Frame* frame, py_TValue* begin, py_TValue* end) { void pk_newgenerator(py_Ref out, py_Frame* frame, py_TValue* begin, py_TValue* end) {
Generator* ud = py_newobject(out, tp_generator, 1, sizeof(Generator)); Generator* ud = py_newobject(out, tp_generator, 1, sizeof(Generator));
ud->frame = frame; ud->frame = frame;
ud->state = 0; ud->state = 0;

View File

@ -78,7 +78,7 @@ void VM__ctor(VM* self) {
self->curr_function = NULL; self->curr_function = NULL;
memset(&self->trace_info, 0, sizeof(TraceInfo)); memset(&self->trace_info, 0, sizeof(TraceInfo));
FixedMemoryPool__ctor(&self->pool_frame, sizeof(Frame), 32); FixedMemoryPool__ctor(&self->pool_frame, sizeof(py_Frame), 32);
ManagedHeap__ctor(&self->heap); ManagedHeap__ctor(&self->heap);
ValueStack__ctor(&self->stack); ValueStack__ctor(&self->stack);
@ -262,14 +262,14 @@ void VM__dtor(VM* self) {
InternedNames__dtor(&self->names); InternedNames__dtor(&self->names);
} }
void VM__push_frame(VM* self, Frame* frame) { void VM__push_frame(VM* self, py_Frame* frame) {
frame->f_back = self->top_frame; frame->f_back = self->top_frame;
self->top_frame = frame; self->top_frame = frame;
} }
void VM__pop_frame(VM* self) { void VM__pop_frame(VM* self) {
assert(self->top_frame); assert(self->top_frame);
Frame* frame = self->top_frame; py_Frame* frame = self->top_frame;
// reset stack pointer // reset stack pointer
self->stack.sp = frame->p0; self->stack.sp = frame->p0;
@ -532,7 +532,7 @@ FrameResult VM__vectorcall(VM* self, uint16_t argc, uint16_t kwargc, bool opcall
// copy buffer back to stack // copy buffer back to stack
self->stack.sp = argv + co->nlocals; self->stack.sp = argv + co->nlocals;
memcpy(argv, self->vectorcall_buffer, co->nlocals * sizeof(py_TValue)); memcpy(argv, self->vectorcall_buffer, co->nlocals * sizeof(py_TValue));
Frame* frame = Frame__new(co, p0, fn->module, fn->globals, argv, false); py_Frame* frame = Frame__new(co, p0, fn->module, fn->globals, argv, false);
pk_newgenerator(py_retval(), frame, p0, self->stack.sp); pk_newgenerator(py_retval(), frame, p0, self->stack.sp);
self->stack.sp = p0; // reset the stack self->stack.sp = p0; // reset the stack
return RES_RETURN; return RES_RETURN;
@ -717,7 +717,7 @@ void ManagedHeap__mark(ManagedHeap* self) {
pk__mark_value(&ti->annotations); pk__mark_value(&ti->annotations);
} }
// mark frame // mark frame
for(Frame* frame = vm->top_frame; frame; frame = frame->f_back) { for(py_Frame* frame = vm->top_frame; frame; frame = frame->f_back) {
Frame__gc_mark(frame); Frame__gc_mark(frame);
} }
// mark vm's registers // mark vm's registers
@ -733,7 +733,7 @@ void ManagedHeap__mark(ManagedHeap* self) {
} }
} }
void pk_print_stack(VM* self, Frame* frame, Bytecode byte) { void pk_print_stack(VM* self, py_Frame* frame, Bytecode byte) {
return; return;
if(frame == NULL || py_isnil(&self->main)) return; if(frame == NULL || py_isnil(&self->main)) return;

View File

@ -53,7 +53,7 @@ bool pk_exec(CodeObject* co, py_Ref module) {
assert(module->type == tp_module); assert(module->type == tp_module);
py_StackRef sp = vm->stack.sp; py_StackRef sp = vm->stack.sp;
Frame* frame = Frame__new(co, sp, module, module, py_NIL(), true); py_Frame* frame = Frame__new(co, sp, module, module, py_NIL(), true);
VM__push_frame(vm, frame); VM__push_frame(vm, frame);
FrameResult res = VM__run_top_frame(vm); FrameResult res = VM__run_top_frame(vm);
if(res == RES_ERROR) return false; if(res == RES_ERROR) return false;
@ -84,7 +84,7 @@ bool pk_execdyn(CodeObject* co, py_Ref module, py_Ref globals, py_Ref locals) {
default: return TypeError("locals must be a dict object"); default: return TypeError("locals must be a dict object");
} }
Frame* frame = Frame__new(co, sp, module, globals, locals, true); py_Frame* frame = Frame__new(co, sp, module, globals, locals, true);
VM__push_frame(vm, frame); VM__push_frame(vm, frame);
FrameResult res = VM__run_top_frame(vm); FrameResult res = VM__run_top_frame(vm);
if(res == RES_ERROR) return false; if(res == RES_ERROR) return false;

View File

@ -493,7 +493,7 @@ static bool builtins_locals(int argc, py_Ref argv) {
} }
void py_newglobals(py_Ref out) { void py_newglobals(py_Ref out) {
Frame* frame = pk_current_vm->top_frame; py_Frame* frame = pk_current_vm->top_frame;
if(!frame) { if(!frame) {
pk_mappingproxy__namedict(out, &pk_current_vm->main); pk_mappingproxy__namedict(out, &pk_current_vm->main);
return; return;
@ -506,7 +506,7 @@ void py_newglobals(py_Ref out) {
} }
void py_newlocals(py_Ref out) { void py_newlocals(py_Ref out) {
Frame* frame = pk_current_vm->top_frame; py_Frame* frame = pk_current_vm->top_frame;
if(!frame) { if(!frame) {
py_newdict(out); py_newdict(out);
return; return;
@ -524,7 +524,7 @@ void py_newlocals(py_Ref out) {
} }
static void pk_push_special_locals() { static void pk_push_special_locals() {
Frame* frame = pk_current_vm->top_frame; py_Frame* frame = pk_current_vm->top_frame;
if(!frame) { if(!frame) {
py_pushnil(); py_pushnil();
return; return;
@ -588,7 +588,7 @@ static bool _builtins_execdyn(const char* title, int argc, py_Ref argv, enum py_
return TypeError("%s() expected 'str' or 'code', got '%t'", title, argv->type); return TypeError("%s() expected 'str' or 'code', got '%t'", title, argv->type);
} }
Frame* frame = pk_current_vm->top_frame; py_Frame* frame = pk_current_vm->top_frame;
// [globals, locals, code] // [globals, locals, code]
CodeObject* code = py_touserdata(py_peek(-1)); CodeObject* code = py_touserdata(py_peek(-1));
if(code->src->is_dynamic) { if(code->src->is_dynamic) {
@ -818,7 +818,7 @@ py_Type pk_nativefunc__register() {
static bool super__new__(int argc, py_Ref argv) { static bool super__new__(int argc, py_Ref argv) {
py_Type class_arg = 0; py_Type class_arg = 0;
Frame* frame = pk_current_vm->top_frame; py_Frame* frame = pk_current_vm->top_frame;
py_Ref self_arg = NULL; py_Ref self_arg = NULL;
if(argc == 1) { if(argc == 1) {
// super() // super()

View File

@ -252,8 +252,8 @@ bool py_raise(py_Ref exc) {
vm->curr_exception = *exc; vm->curr_exception = *exc;
vm->is_curr_exc_handled = false; vm->is_curr_exc_handled = false;
if(vm->trace_info.tracefunc && !py_istype(exc, tp_StopIteration)) { if(vm->trace_info.tracefunc && !py_istype(exc, tp_StopIteration)) {
Frame* frame = vm->top_frame; py_Frame* frame = vm->top_frame;
vm->trace_info.tracefunc((py_Frame*)frame, TRACE_EVENT_EXCEPTION); vm->trace_info.tracefunc(frame, TRACE_EVENT_EXCEPTION);
} }
return false; return false;
} }

View File

@ -73,7 +73,7 @@ py_StackRef py_inspect_currentfunction(){
} }
py_GlobalRef py_inspect_currentmodule(){ py_GlobalRef py_inspect_currentmodule(){
Frame* frame = pk_current_vm->top_frame; py_Frame* frame = pk_current_vm->top_frame;
if(!frame) return NULL; if(!frame) return NULL;
return frame->module; return frame->module;
} }