manage ireps by gc

This commit is contained in:
Yuichi Nishiwaki
2017-03-30 23:29:08 +09:00
parent 2d8980b2d0
commit d478affabd
10 changed files with 82 additions and 131 deletions
+2 -16
View File
@@ -643,9 +643,7 @@ codegen_context_destroy(pic_state *pic, codegen_context *cxt)
struct irep *irep;
/* create irep */
irep = pic_malloc(pic, sizeof(struct irep));
irep->list.next = irep->list.prev = 0;
irep->refc = 1;
irep = (struct irep *)pic_obj_alloc(pic, sizeof(struct irep), PIC_TYPE_IREP);
irep->varg = pic_sym_p(pic, cxt->rest);
irep->argc = pic_vec_len(pic, cxt->args) + 1;
irep->localc = pic_vec_len(pic, cxt->locals);
@@ -661,13 +659,6 @@ codegen_context_destroy(pic_state *pic, codegen_context *cxt)
irep->nnums = cxt->flen;
irep->npool = cxt->plen;
if (irep->npool > 0) {
irep->list.next = pic->ireps.next;
irep->list.prev = &pic->ireps;
irep->list.next->prev = &irep->list;
irep->list.prev->next = &irep->list;
}
return irep;
}
@@ -1072,7 +1063,6 @@ static pic_value
pic_compile(pic_state *pic, pic_value obj)
{
struct irep *irep;
pic_value proc;
size_t ai = pic_enter(pic);
#if 0
@@ -1106,11 +1096,7 @@ pic_compile(pic_state *pic, pic_value obj)
/* codegen */
irep = pic_codegen(pic, obj);
proc = pic_make_proc_irep(pic, irep, NULL);
pic_irep_decref(pic, irep);
return proc;
return pic_make_proc_irep(pic, irep, NULL);
}
pic_value
+3 -1
View File
@@ -448,8 +448,10 @@ typename(pic_state *pic, pic_value obj)
return "identifier";
case PIC_TYPE_CXT:
return "context";
case PIC_TYPE_FUNC:
case PIC_TYPE_IREP:
return "irep";
case PIC_TYPE_PROC_FUNC:
case PIC_TYPE_PROC_IREP:
return "procedure";
case PIC_TYPE_ENV:
return "environment";