refactor port.c

This commit is contained in:
Yuichi Nishiwaki 2013-10-17 17:57:27 +09:00
parent 5671c43a77
commit 87aae8dd8f
1 changed files with 11 additions and 5 deletions

View File

@ -4,8 +4,8 @@
#include "picrin.h" #include "picrin.h"
#include "picrin/proc.h" #include "picrin/proc.h"
void static void
pic_debug(pic_state *pic, pic_value obj) write(pic_state *pic, pic_value obj)
{ {
switch (pic_type(obj)) { switch (pic_type(obj)) {
case PIC_TT_NIL: case PIC_TT_NIL:
@ -19,9 +19,9 @@ pic_debug(pic_state *pic, pic_value obj)
break; break;
case PIC_TT_PAIR: case PIC_TT_PAIR:
printf("("); printf("(");
pic_debug(pic, pic_car(pic, obj)); write(pic, pic_car(pic, obj));
printf(" . "); printf(" . ");
pic_debug(pic, pic_cdr(pic, obj)); write(pic, pic_cdr(pic, obj));
printf(")"); printf(")");
break; break;
case PIC_TT_SYMBOL: case PIC_TT_SYMBOL:
@ -39,13 +39,19 @@ pic_debug(pic_state *pic, pic_value obj)
} }
} }
void
pic_debug(pic_state *pic, pic_value obj)
{
write(pic, obj);
}
static pic_value static pic_value
pic_port_write(pic_state *pic) pic_port_write(pic_state *pic)
{ {
pic_value v; pic_value v;
pic_get_args(pic, "o", &v); pic_get_args(pic, "o", &v);
pic_debug(pic, v); write(pic, v);
return pic_false_value(); return pic_false_value();
} }