reordering functions

This commit is contained in:
Yuichi Nishiwaki 2014-01-16 21:32:22 +09:00
parent 41dea6c5d2
commit 5929020429
1 changed files with 32 additions and 33 deletions

View File

@ -4,8 +4,38 @@
#include "picrin/blob.h" #include "picrin/blob.h"
#include "picrin/macro.h" #include "picrin/macro.h"
static void write_pair(pic_state *pic, struct pic_pair *pair); static void write(pic_state *, pic_value);
static void write_str(pic_state *pic, struct pic_string *str);
static void
write_pair(pic_state *pic, struct pic_pair *pair)
{
write(pic, pair->car);
if (pic_nil_p(pair->cdr)) {
return;
}
if (pic_pair_p(pair->cdr)) {
printf(" ");
write_pair(pic, pic_pair_ptr(pair->cdr));
return;
}
printf(" . ");
write(pic, pair->cdr);
}
static void
write_str(pic_state *pic, struct pic_string *str)
{
int i;
const char *cstr = str->str;
for (i = 0; i < str->len; ++i) {
if (cstr[i] == '"' || cstr[i] == '\\') {
putchar('\\');
}
putchar(cstr[i]);
}
}
static void static void
write(pic_state *pic, pic_value obj) write(pic_state *pic, pic_value obj)
@ -115,37 +145,6 @@ write(pic_state *pic, pic_value obj)
} }
} }
static void
write_pair(pic_state *pic, struct pic_pair *pair)
{
write(pic, pair->car);
if (pic_nil_p(pair->cdr)) {
return;
}
if (pic_pair_p(pair->cdr)) {
printf(" ");
write_pair(pic, pic_pair_ptr(pair->cdr));
return;
}
printf(" . ");
write(pic, pair->cdr);
}
static void
write_str(pic_state *pic, struct pic_string *str)
{
int i;
const char *cstr = str->str;
for (i = 0; i < str->len; ++i) {
if (cstr[i] == '"' || cstr[i] == '\\') {
putchar('\\');
}
putchar(cstr[i]);
}
}
void void
pic_debug(pic_state *pic, pic_value obj) pic_debug(pic_state *pic, pic_value obj)
{ {