Ejemplo n.º 1
0
static pic_value
reg_get(pic_state *pic, struct pic_reg *reg, void *key)
{
  if (! pic_reg_has(pic, reg, key)) {
    return pic_false_value();
  }
  return pic_cons(pic, pic_obj_value(key), pic_reg_ref(pic, reg, key));
}
Ejemplo n.º 2
0
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();
}
Ejemplo n.º 3
0
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)));
}