static pic_value reg_set(pic_state *pic, struct pic_reg *reg, void *key, pic_value val) { if (pic_undef_p(val)) { if (pic_reg_has(pic, reg, key)) { pic_reg_del(pic, reg, key); } } else { pic_reg_set(pic, reg, key, val); } return pic_undef_value(); }
struct pic_dict * pic_attr(pic_state *pic, pic_value obj) { struct pic_dict *dict; if (! pic_obj_p(obj)) { pic_errorf(pic, "attribute: expected heap object, but got immediate value ~s", obj); } if (! pic_reg_has(pic, pic->attrs, pic_ptr(obj))) { dict = pic_make_dict(pic); pic_reg_set(pic, pic->attrs, pic_ptr(obj), pic_obj_value(dict)); return dict; } return pic_dict_ptr(pic_reg_ref(pic, pic->attrs, pic_ptr(obj))); }