mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some refactor
This commit is contained in:
parent
1d16d1a6f7
commit
33be8e869a
@ -11,12 +11,9 @@ typedef struct ValueStack {
|
|||||||
py_TValue* sp;
|
py_TValue* sp;
|
||||||
py_TValue* end;
|
py_TValue* end;
|
||||||
// We allocate extra places to keep `_sp` valid to detect stack overflow
|
// We allocate extra places to keep `_sp` valid to detect stack overflow
|
||||||
py_TValue begin[PK_VM_STACK_SIZE + PK_MAX_CO_VARNAMES * 2];
|
py_TValue begin[PK_VM_STACK_SIZE + PK_MAX_CO_VARNAMES];
|
||||||
} ValueStack;
|
} ValueStack;
|
||||||
|
|
||||||
void ValueStack__ctor(ValueStack* self);
|
|
||||||
void ValueStack__dtor(ValueStack* self);
|
|
||||||
|
|
||||||
typedef struct UnwindTarget {
|
typedef struct UnwindTarget {
|
||||||
struct UnwindTarget* next;
|
struct UnwindTarget* next;
|
||||||
int iblock;
|
int iblock;
|
||||||
|
@ -7,12 +7,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
void ValueStack__ctor(ValueStack* self) {
|
|
||||||
self->sp = self->begin;
|
|
||||||
self->end = self->begin + PK_VM_STACK_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ValueStack__dtor(ValueStack* self) { self->sp = self->begin; }
|
|
||||||
|
|
||||||
void FastLocals__to_dict(py_TValue* locals, const CodeObject* co) {
|
void FastLocals__to_dict(py_TValue* locals, const CodeObject* co) {
|
||||||
py_StackRef dict = py_pushtmp();
|
py_StackRef dict = py_pushtmp();
|
||||||
|
@ -110,7 +110,8 @@ void VM__ctor(VM* self) {
|
|||||||
FixedMemoryPool__ctor(&self->pool_frame, sizeof(py_Frame), 32);
|
FixedMemoryPool__ctor(&self->pool_frame, sizeof(py_Frame), 32);
|
||||||
|
|
||||||
ManagedHeap__ctor(&self->heap);
|
ManagedHeap__ctor(&self->heap);
|
||||||
ValueStack__ctor(&self->stack);
|
self->stack.sp = self->stack.begin;
|
||||||
|
self->stack.end = self->stack.begin + PK_VM_STACK_SIZE;
|
||||||
|
|
||||||
CachedNames__ctor(&self->cached_names);
|
CachedNames__ctor(&self->cached_names);
|
||||||
NameDict__ctor(&self->compile_time_funcs, PK_TYPE_ATTR_LOAD_FACTOR);
|
NameDict__ctor(&self->compile_time_funcs, PK_TYPE_ATTR_LOAD_FACTOR);
|
||||||
@ -288,11 +289,11 @@ void VM__dtor(VM* self) {
|
|||||||
// destroy all objects
|
// destroy all objects
|
||||||
ManagedHeap__dtor(&self->heap);
|
ManagedHeap__dtor(&self->heap);
|
||||||
// clear frames
|
// clear frames
|
||||||
while(self->top_frame)
|
while(self->top_frame) {
|
||||||
VM__pop_frame(self);
|
VM__pop_frame(self);
|
||||||
|
}
|
||||||
BinTree__dtor(&self->modules);
|
BinTree__dtor(&self->modules);
|
||||||
FixedMemoryPool__dtor(&self->pool_frame);
|
FixedMemoryPool__dtor(&self->pool_frame);
|
||||||
ValueStack__dtor(&self->stack);
|
|
||||||
CachedNames__dtor(&self->cached_names);
|
CachedNames__dtor(&self->cached_names);
|
||||||
NameDict__dtor(&self->compile_time_funcs);
|
NameDict__dtor(&self->compile_time_funcs);
|
||||||
c11_vector__dtor(&self->types);
|
c11_vector__dtor(&self->types);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user