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