add pic_sym macro
This commit is contained in:
parent
229555fa83
commit
e050da8af1
|
@ -10,7 +10,7 @@
|
|||
|
||||
static pic_value pic_compile(pic_state *, pic_value);
|
||||
|
||||
#define EQ(sym, lit) (strcmp(pic_str(pic, pic_sym_name(pic, sym)), lit) == 0)
|
||||
#define EQ(sym, lit) (strcmp(pic_sym(pic, sym), lit) == 0)
|
||||
#define S(lit) (pic_intern_lit(pic, lit))
|
||||
|
||||
static void
|
||||
|
|
|
@ -122,6 +122,7 @@ double pic_float(pic_state *, pic_value f);
|
|||
char pic_char(pic_state *, pic_value c);
|
||||
#define pic_bool(pic,b) (! pic_false_p(pic, b))
|
||||
const char *pic_str(pic_state *, pic_value str);
|
||||
#define pic_sym(pic,s) (pic_str(pic, pic_sym_name(pic, (s))))
|
||||
unsigned char *pic_blob(pic_state *, pic_value blob, int *len);
|
||||
void *pic_data(pic_state *, pic_value data);
|
||||
|
||||
|
|
|
@ -339,10 +339,10 @@ read_minus(pic_state *pic, xFILE *file, int c, struct reader_control *p)
|
|||
}
|
||||
else {
|
||||
sym = read_symbol(pic, file, c, p);
|
||||
if (strcaseeq(pic_str(pic, pic_sym_name(pic, sym)), "-inf.0")) {
|
||||
if (strcaseeq(pic_sym(pic, sym), "-inf.0")) {
|
||||
return pic_float_value(pic, -(1.0 / 0.0));
|
||||
}
|
||||
if (strcaseeq(pic_str(pic, pic_sym_name(pic, sym)), "-nan.0")) {
|
||||
if (strcaseeq(pic_sym(pic, sym), "-nan.0")) {
|
||||
return pic_float_value(pic, -(0.0 / 0.0));
|
||||
}
|
||||
return sym;
|
||||
|
@ -359,10 +359,10 @@ read_plus(pic_state *pic, xFILE *file, int c, struct reader_control *p)
|
|||
}
|
||||
else {
|
||||
sym = read_symbol(pic, file, c, p);
|
||||
if (strcaseeq(pic_str(pic, pic_sym_name(pic, sym)), "+inf.0")) {
|
||||
if (strcaseeq(pic_sym(pic, sym), "+inf.0")) {
|
||||
return pic_float_value(pic, 1.0 / 0.0);
|
||||
}
|
||||
if (strcaseeq(pic_str(pic, pic_sym_name(pic, sym)), "+nan.0")) {
|
||||
if (strcaseeq(pic_sym(pic, sym), "+nan.0")) {
|
||||
return pic_float_value(pic, 0.0 / 0.0);
|
||||
}
|
||||
return sym;
|
||||
|
|
|
@ -195,7 +195,7 @@ write_pair_help(pic_state *pic, pic_value pair, xFILE *file, struct writer_contr
|
|||
}
|
||||
}
|
||||
|
||||
#define EQ(sym, lit) (strcmp(pic_str(pic, pic_sym_name(pic, sym)), lit) == 0)
|
||||
#define EQ(sym, lit) (strcmp(pic_sym(pic, sym), lit) == 0)
|
||||
|
||||
static void
|
||||
write_pair(pic_state *pic, pic_value pair, xFILE *file, struct writer_control *p)
|
||||
|
@ -273,7 +273,7 @@ write_dict(pic_state *pic, pic_value dict, xFILE *file, struct writer_control *p
|
|||
|
||||
xfprintf(pic, file, "#.(dictionary");
|
||||
while (pic_dict_next(pic, dict, &it, &key, &val)) {
|
||||
xfprintf(pic, file, " '%s ", pic_str(pic, pic_sym_name(pic, key)));
|
||||
xfprintf(pic, file, " '%s ", pic_sym(pic, key));
|
||||
write_core(pic, val, file, p);
|
||||
}
|
||||
xfprintf(pic, file, ")");
|
||||
|
@ -319,7 +319,7 @@ write_core(pic_state *pic, pic_value obj, xFILE *file, struct writer_control *p)
|
|||
xfprintf(pic, file, "%d", pic_int(pic, obj));
|
||||
break;
|
||||
case PIC_TYPE_SYMBOL:
|
||||
xfprintf(pic, file, "%s", pic_str(pic, pic_sym_name(pic, obj)));
|
||||
xfprintf(pic, file, "%s", pic_sym(pic, obj));
|
||||
break;
|
||||
case PIC_TYPE_FLOAT:
|
||||
write_float(pic, obj, file);
|
||||
|
|
Loading…
Reference in New Issue