add pic_ungensym
This commit is contained in:
parent
6966cdfa31
commit
5ba0c56308
|
@ -153,6 +153,7 @@ pic_sym pic_intern(pic_state *, const char *, size_t);
|
||||||
pic_sym pic_intern_cstr(pic_state *, const char *);
|
pic_sym pic_intern_cstr(pic_state *, const char *);
|
||||||
const char *pic_symbol_name(pic_state *, pic_sym);
|
const char *pic_symbol_name(pic_state *, pic_sym);
|
||||||
pic_sym pic_gensym(pic_state *, pic_sym);
|
pic_sym pic_gensym(pic_state *, pic_sym);
|
||||||
|
pic_sym pic_ungensym(pic_state *, pic_sym);
|
||||||
bool pic_interned_p(pic_state *, pic_sym);
|
bool pic_interned_p(pic_state *, pic_sym);
|
||||||
|
|
||||||
char *pic_strdup(pic_state *, const char *);
|
char *pic_strdup(pic_state *, const char *);
|
||||||
|
|
16
src/symbol.c
16
src/symbol.c
|
@ -61,6 +61,22 @@ pic_gensym(pic_state *pic, pic_sym base)
|
||||||
return uniq;
|
return uniq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pic_sym
|
||||||
|
pic_ungensym(pic_state *pic, pic_sym base)
|
||||||
|
{
|
||||||
|
const char *name, *occr;
|
||||||
|
|
||||||
|
if (pic_interned_p(pic, base)) {
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
name = pic_symbol_name(pic, base);
|
||||||
|
if ((occr = strrchr(name, '@')) == NULL) {
|
||||||
|
pic_abort(pic, "logic flaw");
|
||||||
|
}
|
||||||
|
return pic_intern(pic, name, occr - name);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pic_interned_p(pic_state *pic, pic_sym sym)
|
pic_interned_p(pic_state *pic, pic_sym sym)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue