diff --git a/include/picrin/lib.h b/include/picrin/lib.h index 30ee5a5d..5432fbe6 100644 --- a/include/picrin/lib.h +++ b/include/picrin/lib.h @@ -3,6 +3,7 @@ struct pic_lib { PIC_OBJECT_HEADER + pic_value name; struct pic_senv *senv; struct xhash *exports; }; diff --git a/src/gc.c b/src/gc.c index 4c6ac3f0..0759093f 100644 --- a/src/gc.c +++ b/src/gc.c @@ -399,6 +399,7 @@ gc_mark_object(pic_state *pic, struct pic_object *obj) } case PIC_TT_LIB: { struct pic_lib *lib = (struct pic_lib *)obj; + gc_mark(pic, lib->name); gc_mark_object(pic, (struct pic_object *)lib->senv); break; } diff --git a/src/lib.c b/src/lib.c index a99bdf70..55ed775c 100644 --- a/src/lib.c +++ b/src/lib.c @@ -12,6 +12,7 @@ pic_make_library(pic_state *pic, pic_value name) lib = (struct pic_lib *)pic_obj_alloc(pic, sizeof(struct pic_lib), PIC_TT_LIB); lib->senv = pic_core_syntactic_env(pic); lib->exports = xh_new(); + lib->name = name; /* register! */ pic->lib_tbl = pic_acons(pic, name, pic_obj_value(lib), pic->lib_tbl);