bugfix: recursive record objects break the write procedure

This commit is contained in:
Yuichi Nishiwaki 2017-04-09 17:49:45 +09:00
parent 3ac392628e
commit 8e1d16e961
2 changed files with 20 additions and 16 deletions

View File

@ -172,7 +172,8 @@ traverse(pic_state *pic, pic_value obj, struct writer_control *p)
switch (pic_type(pic, obj)) {
case PIC_TYPE_PAIR:
case PIC_TYPE_VECTOR:
case PIC_TYPE_DICT: {
case PIC_TYPE_DICT:
case PIC_TYPE_RECORD: {
if (! pic_weak_has(pic, shared, obj)) {
/* first time */
@ -188,13 +189,16 @@ traverse(pic_state *pic, pic_value obj, struct writer_control *p)
for (i = 0; i < len; ++i) {
traverse(pic, pic_vec_ref(pic, obj, i), p);
}
} else {
} else if (pic_dict_p(pic, obj)) {
/* dictionary */
int it = 0;
pic_value val;
while (pic_dict_next(pic, obj, &it, NULL, &val)) {
traverse(pic, val, p);
}
} else {
/* record */
traverse(pic, pic_record_datum(pic, obj), p);
}
if (p->op == OP_WRITE) {

View File

@ -21,21 +21,21 @@ enum {
PIC_TYPE_FALSE = 9,
PIC_IVAL_END = 10,
/* -------------------- */
PIC_TYPE_STRING = 16,
PIC_TYPE_VECTOR = 17,
PIC_TYPE_SYMBOL = 16,
PIC_TYPE_STRING = 17,
PIC_TYPE_BLOB = 18,
PIC_TYPE_PORT = 20,
PIC_TYPE_ERROR = 21,
PIC_TYPE_DATA = 24,
PIC_TYPE_DICT = 25,
PIC_TYPE_WEAK = 26,
PIC_TYPE_RECORD = 27,
PIC_TYPE_SYMBOL = 28,
PIC_TYPE_PAIR = 29,
PIC_TYPE_FRAME = 30,
PIC_TYPE_PROC_FUNC = 32,
PIC_TYPE_PROC_IREP = 33,
PIC_TYPE_IREP = 34,
PIC_TYPE_DATA = 19,
PIC_TYPE_PAIR = 20,
PIC_TYPE_VECTOR = 21,
PIC_TYPE_DICT = 22,
PIC_TYPE_RECORD = 23,
PIC_TYPE_WEAK = 24,
PIC_TYPE_PORT = 25,
PIC_TYPE_ERROR = 26,
PIC_TYPE_IREP = 27,
PIC_TYPE_FRAME = 28,
PIC_TYPE_PROC_FUNC = 29,
PIC_TYPE_PROC_IREP = 30,
PIC_TYPE_MAX = 63
};