add PIC_TT_SENV and PIC_TT_SYNTAX

This commit is contained in:
Yuichi Nishiwaki 2013-11-26 04:05:02 -08:00
parent 3c65025394
commit c59d8f601b
5 changed files with 44 additions and 2 deletions

View File

@ -89,7 +89,9 @@ enum pic_tt {
PIC_TT_PORT, PIC_TT_PORT,
PIC_TT_ERROR, PIC_TT_ERROR,
PIC_TT_ENV, PIC_TT_ENV,
PIC_TT_CONT PIC_TT_CONT,
PIC_TT_SENV,
PIC_TT_SYNTAX
}; };
#define PIC_OBJECT_HEADER \ #define PIC_OBJECT_HEADER \

View File

@ -658,7 +658,9 @@ codegen(codegen_state *state, pic_value obj, bool tailpos)
case PIC_TT_UNDEF: case PIC_TT_UNDEF:
case PIC_TT_EOF: case PIC_TT_EOF:
case PIC_TT_PORT: case PIC_TT_PORT:
case PIC_TT_ERROR: { case PIC_TT_ERROR:
case PIC_TT_SENV:
case PIC_TT_SYNTAX: {
pic_error(pic, "invalid expression given"); pic_error(pic, "invalid expression given");
} }
} }

View File

@ -8,6 +8,8 @@
#include "picrin/blob.h" #include "picrin/blob.h"
#include "picrin/cont.h" #include "picrin/cont.h"
#include "picrin/error.h" #include "picrin/error.h"
#include "picrin/macro.h"
#include "xhash/xhash.h"
#if GC_DEBUG #if GC_DEBUG
# include <stdio.h> # include <stdio.h>
@ -273,6 +275,24 @@ gc_mark_object(pic_state *pic, struct pic_object *obj)
gc_mark(pic, cont->result); gc_mark(pic, cont->result);
break; break;
} }
case PIC_TT_SYNTAX: {
break;
}
case PIC_TT_SENV: {
struct pic_senv *senv = (struct pic_senv *)obj;
if (senv->up) {
gc_mark_object(pic, (struct pic_object *)senv->up);
}
if (senv->stx) {
int i;
for (i = 0; i < 6; ++i) {
gc_mark_object(pic, (struct pic_object *)senv->stx[i]);
}
}
break;
}
case PIC_TT_NIL: case PIC_TT_NIL:
case PIC_TT_BOOL: case PIC_TT_BOOL:
case PIC_TT_FLOAT: case PIC_TT_FLOAT:
@ -397,6 +417,16 @@ gc_finalize_object(pic_state *pic, struct pic_object *obj)
PIC_BLK_DECREF(pic, cont->blk); PIC_BLK_DECREF(pic, cont->blk);
break; break;
} }
case PIC_TT_SENV: {
struct pic_senv *senv = (struct pic_senv *)obj;
xh_destory(senv->tbl);
if (senv->stx)
pic_free(pic, senv->stx);
break;
}
case PIC_TT_SYNTAX: {
break;
}
case PIC_TT_NIL: case PIC_TT_NIL:
case PIC_TT_BOOL: case PIC_TT_BOOL:
case PIC_TT_FLOAT: case PIC_TT_FLOAT:

View File

@ -162,6 +162,8 @@ expand(pic_state *pic, pic_value obj, struct syntactic_env *env)
case PIC_TT_ENV: case PIC_TT_ENV:
case PIC_TT_CONT: case PIC_TT_CONT:
case PIC_TT_UNDEF: case PIC_TT_UNDEF:
case PIC_TT_SENV:
case PIC_TT_SYNTAX:
pic_error(pic, "unexpected value type"); pic_error(pic, "unexpected value type");
return pic_undef_value(); /* unreachable */ return pic_undef_value(); /* unreachable */
} }

View File

@ -97,6 +97,12 @@ write(pic_state *pic, pic_value obj)
case PIC_TT_CONT: case PIC_TT_CONT:
printf("#<cont %p>", pic_ptr(obj)); printf("#<cont %p>", pic_ptr(obj));
break; break;
case PIC_TT_SENV:
printf("#<senv %p>", pic_ptr(obj));
break;
case PIC_TT_SYNTAX:
printf("#<senv %p>", pic_ptr(obj));
break;
} }
} }