don't rename each symbol more than a time

This commit is contained in:
Yuichi Nishiwaki 2014-01-10 17:55:58 +09:00
parent 62e52be061
commit 45c49fdec3
1 changed files with 18 additions and 0 deletions

View File

@ -36,6 +36,20 @@ new_uniq_sym(pic_state *pic, pic_sym base)
return uniq;
}
static bool
uniq_sym_p(pic_state *pic, pic_sym sym)
{
const char *name;
assert(sym >= 0);
name = pic->sym_pool[sym];
if (sym == pic_intern_cstr(pic, name))
return false;
else
return true;
}
struct pic_senv *
pic_null_syntactic_env(pic_state *pic)
{
@ -293,6 +307,10 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv)
case PIC_TT_SYMBOL: {
struct xh_entry *e;
pic_sym uniq;
if (uniq_sym_p(pic, pic_sym(expr))) {
return expr;
}
while (true) {
if ((e = xh_get(senv->tbl, pic_symbol_name(pic, pic_sym(expr)))) != NULL) {
if (e->val >= 0)