From 3ac392628e99211b26c26c4cc76874aec7808649 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 9 Apr 2017 17:34:56 +0900 Subject: [PATCH] recurd-type must be of symbol type --- lib/gc.c | 6 ++---- lib/object.h | 2 +- lib/record.c | 6 +++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/gc.c b/lib/gc.c index 81ea3c6d..310de7f4 100644 --- a/lib/gc.c +++ b/lib/gc.c @@ -401,10 +401,8 @@ gc_mark_object(pic_state *pic, struct object *obj) break; } case PIC_TYPE_RECORD: { - gc_mark(pic, obj->u.rec.type); - if (obj_p(pic, obj->u.rec.datum)) { - LOOP(obj_ptr(pic, obj->u.rec.datum)); - } + gc_mark(pic, obj->u.rec.datum); + LOOP(obj->u.rec.type); break; } case PIC_TYPE_SYMBOL: { diff --git a/lib/object.h b/lib/object.h index 3e8b549b..d1ab9d09 100644 --- a/lib/object.h +++ b/lib/object.h @@ -77,7 +77,7 @@ struct data { struct record { OBJECT_HEADER - pic_value type; + struct symbol *type; pic_value datum; }; diff --git a/lib/record.c b/lib/record.c index 2a2dccb7..d98707fc 100644 --- a/lib/record.c +++ b/lib/record.c @@ -11,7 +11,7 @@ pic_make_record(pic_state *pic, pic_value type, pic_value datum) struct record *rec; rec = (struct record *)pic_obj_alloc(pic, sizeof(struct record), PIC_TYPE_RECORD); - rec->type = type; + rec->type = sym_ptr(pic, type); rec->datum = datum; return obj_value(pic, rec); @@ -20,7 +20,7 @@ pic_make_record(pic_state *pic, pic_value type, pic_value datum) pic_value pic_record_type(pic_state *pic, pic_value rec) { - return rec_ptr(pic, rec)->type; + return obj_value(pic, rec_ptr(pic, rec)->type); } pic_value @@ -34,7 +34,7 @@ pic_rec_make_record(pic_state *pic) { pic_value type, datum; - pic_get_args(pic, "oo", &type, &datum); + pic_get_args(pic, "mo", &type, &datum); return pic_make_record(pic, type, datum); }