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)
|
|
|
|
{
|
2013-10-10 04:54:35 -04:00
|
|
|
switch (v.type) {
|
2013-10-10 04:48:01 -04:00
|
|
|
case PIC_VTYPE_NIL:
|
|
|
|
return PIC_TT_NIL;
|
|
|
|
case PIC_VTYPE_HEAP:
|
2013-10-10 04:54:35 -04:00
|
|
|
return ((struct pic_object *)v.u.data)->tt;
|
2013-10-10 04:48:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-10 04:08:54 -04:00
|
|
|
pic_value
|
|
|
|
pic_nil_value()
|
|
|
|
{
|
|
|
|
pic_value v;
|
|
|
|
|
2013-10-10 04:54:35 -04:00
|
|
|
v.type = PIC_VTYPE_NIL;
|
2013-10-10 04:08:54 -04:00
|
|
|
v.u.data = NULL;
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2013-10-10 04:05:58 -04:00
|
|
|
pic_value
|
2013-10-10 04:54:35 -04:00
|
|
|
pic_obj_value(void *ptr)
|
2013-10-10 04:05:58 -04:00
|
|
|
{
|
|
|
|
pic_value v;
|
|
|
|
|
2013-10-10 04:54:35 -04:00
|
|
|
v.type = PIC_VTYPE_HEAP;
|
|
|
|
v.u.data = ptr;
|
2013-10-10 04:05:58 -04:00
|
|
|
return v;
|
|
|
|
}
|