add #<undef>
This commit is contained in:
+12
@@ -8,6 +8,8 @@ pic_type(pic_value v)
|
||||
return PIC_TT_NIL;
|
||||
case PIC_VTYPE_INT:
|
||||
return PIC_TT_INT;
|
||||
case PIC_VTYPE_UNDEF:
|
||||
return PIC_TT_UNDEF;
|
||||
case PIC_VTYPE_HEAP:
|
||||
return ((struct pic_object *)v.u.data)->tt;
|
||||
}
|
||||
@@ -42,3 +44,13 @@ pic_int_value(int i)
|
||||
v.u.i = i;
|
||||
return v;
|
||||
}
|
||||
|
||||
pic_value
|
||||
pic_undef_value()
|
||||
{
|
||||
pic_value v;
|
||||
|
||||
v.type = PIC_VTYPE_UNDEF;
|
||||
v.u.data = NULL;
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
enum pic_instruction {
|
||||
OP_PUSHNIL,
|
||||
OP_PUSHI,
|
||||
OP_PUSHUNDEF,
|
||||
OP_CONS,
|
||||
OP_ADD,
|
||||
OP_STOP
|
||||
@@ -114,6 +115,10 @@ pic_run(pic_state *pic, struct pic_proc *proc, pic_value args)
|
||||
*++sp = pic_int_value(pc->u.i);
|
||||
break;
|
||||
}
|
||||
case OP_PUSHUNDEF: {
|
||||
*++sp = pic_undef_value();
|
||||
break;
|
||||
}
|
||||
case OP_CONS: {
|
||||
pic_value a, b;
|
||||
a = *sp--;
|
||||
|
||||
@@ -23,5 +23,8 @@ pic_debug(pic_state *pic, pic_value obj)
|
||||
case PIC_TT_INT:
|
||||
printf("%d", pic_int(obj));
|
||||
break;
|
||||
case PIC_TT_UNDEF:
|
||||
printf("#<undef>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user