From 7a98c3619a728121bfee62bd586b751984ca91fa Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 6 Aug 2014 11:36:36 +0900 Subject: [PATCH] store rectype information to slot hash --- include/picrin/record.h | 1 - src/gc.c | 1 - src/record.c | 7 +++---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/picrin/record.h b/include/picrin/record.h index 0c183977..bf8698f1 100644 --- a/include/picrin/record.h +++ b/include/picrin/record.h @@ -11,7 +11,6 @@ extern "C" { struct pic_record { PIC_OBJECT_HEADER - pic_value rectype; xhash hash; }; diff --git a/src/gc.c b/src/gc.c index c302fd0d..9fc02c7d 100644 --- a/src/gc.c +++ b/src/gc.c @@ -506,7 +506,6 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) struct pic_record *rec = (struct pic_record *)obj; xh_iter it; - gc_mark(pic, rec->rectype); xh_begin(&it, &rec->hash); while (xh_next(&it)) { gc_mark(pic, xh_val(it.e, pic_value)); diff --git a/src/record.c b/src/record.c index f97a6ff0..d62776ca 100644 --- a/src/record.c +++ b/src/record.c @@ -11,18 +11,17 @@ pic_record_new(pic_state *pic, pic_value rectype) struct pic_record *rec; rec = (struct pic_record *)pic_obj_alloc(pic, sizeof(struct pic_record), PIC_TT_RECORD); - rec->rectype = rectype; xh_init_int(&rec->hash, sizeof(pic_value)); + pic_record_set(pic, rec, pic_intern_cstr(pic, "@@type"), rectype); + return rec; } pic_value pic_record_type(pic_state *pic, struct pic_record *rec) { - UNUSED(pic); - - return rec->rectype; + return pic_record_ref(pic, rec, pic_intern_cstr(pic, "@@type")); } pic_value