1
This commit is contained in:
Christoph
2021-09-02 18:26:54 +02:00
parent 305eec02e1
commit cf92bc7804
3 changed files with 45 additions and 4 deletions

View File

@ -1,12 +1,14 @@
def mark(w_context):
if w_context.mark: # skip cycles
return
w_context.mark = True
if not hasattr(w_context, "slots"): # skip primitive objects
return
for name, obj in w_context.slots.items():
if name != "__parent__": # only descent
mark(obj)
mark(obj)
def sweep(objects):

View File

@ -44,7 +44,8 @@ class ObjectSpace(object):
else:
slots = {'__parent__': self.getbuiltins()}
return W_NormalObject(name=name, slots=slots) # lobby isn't collected
self.objects.append(W_NormalObject(name=name, slots=slots)) # needed, otherwise marking skips the root
return self.objects[-1]
def newobject(self, name, slots, parentnames):
self.objects.append(W_NormalObject(space=self, name=name,