From 8277895502e0155c81219c06d3aa1003e6f09e61 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 2 Sep 2024 23:11:06 +0800 Subject: [PATCH] fix a bug --- src/interpreter/vm.c | 15 +++++++++++++-- src/public/modules.c | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/interpreter/vm.c b/src/interpreter/vm.c index aae73055..6b6108f6 100644 --- a/src/interpreter/vm.c +++ b/src/interpreter/vm.c @@ -603,8 +603,19 @@ static void mark_object(PyObject* obj) { } void CodeObject__gc_mark(const CodeObject* self) { - c11__foreach(py_TValue, &self->consts, i) { pk__mark_value(i); } - c11__foreach(FuncDecl_, &self->func_decls, i) { CodeObject__gc_mark(&(*i)->code); } + for(int i = 0; i < self->consts.length; i++) { + py_TValue* p = c11__at(py_TValue, &self->consts, i); + pk__mark_value(p); + } + for(int i = 0; i < self->func_decls.length; i++) { + FuncDecl_ decl = c11__getitem(FuncDecl_, &self->func_decls, i); + CodeObject__gc_mark(&decl->code); + + for(int j = 0; j < decl->kwargs.length; j++) { + FuncDeclKwArg* kw = c11__at(FuncDeclKwArg, &decl->kwargs, j); + pk__mark_value(&kw->value); + } + } } void ManagedHeap__mark(ManagedHeap* self) { diff --git a/src/public/modules.c b/src/public/modules.c index 23906a02..e2fda4a7 100644 --- a/src/public/modules.c +++ b/src/public/modules.c @@ -278,6 +278,7 @@ static bool builtins_round(int argc, py_Ref argv) { } static bool builtins_print(int argc, py_Ref argv) { + // print(*args, sep=' ', end='\n') py_TValue* args; int length = pk_arrayview(argv, &args); assert(length != -1);