picrin/src/value.c

33 lines
411 B
C
Raw Normal View History

2013-10-10 04:05:58 -04:00
#include "picrin.h"
2013-10-10 04:48:01 -04:00
enum pic_tt
pic_type(pic_value v)
{
switch (v->type) {
case PIC_VTYPE_NIL:
return PIC_TT_NIL;
case PIC_VTYPE_HEAP:
return v->u->data->tt;
}
}
2013-10-10 04:08:54 -04:00
pic_value
pic_nil_value()
{
pic_value v;
v.vtype = PIC_VTYPE_NIL;
v.u.data = NULL;
return v;
}
2013-10-10 04:05:58 -04:00
pic_value
pic_obj_value(struct pic_object *obj)
{
pic_value v;
v.vtype = PIC_VTYPE_HEAP;
v.u.data = obj;
return v;
}