Import High Level improvement for stage2 lisp

This commit is contained in:
Jeremiah Orians 2017-05-20 14:01:46 -04:00
parent 7b5c8788b1
commit c800c14988
No known key found for this signature in database
GPG Key ID: 7457821534D2ACCD
1 changed files with 18 additions and 5 deletions

View File

@ -134,14 +134,27 @@ void mark_all_cells()
}
}
void unmark_cells(struct cell* list)
void unmark_cells(struct cell* list, struct cell* stop, int count)
{
if(count > 1) return;
for(; NULL != list; list = list->cdr)
{
if(list == stop) count = count + 1;
list->type = list->type & ~MARKED;
if((list->type & CONS)|| list->type & PROC )
if(list->type & PROC)
{
unmark_cells(list->car);
unmark_cells(list->car, stop, count);
if(NULL != list->env)
{
unmark_cells(list->env, stop, count);
}
}
if(list->type & CONS)
{
unmark_cells(list->car, stop, count);
}
}
}
@ -149,8 +162,8 @@ void unmark_cells(struct cell* list)
void garbage_collect()
{
mark_all_cells();
unmark_cells(all_symbols);
unmark_cells(top_env);
unmark_cells(all_symbols, all_symbols, 0);
unmark_cells(top_env, top_env, 0);
reclaim_marked();
update_remaining();
compact(all_symbols);