blueloveTH 1 год назад
Родитель
Сommit
8277895502
2 измененных файлов с 14 добавлено и 2 удалено
  1. 13 2
      src/interpreter/vm.c
  2. 1 0
      src/public/modules.c

+ 13 - 2
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) {

+ 1 - 0
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);