don't rename each symbol more than a time
This commit is contained in:
parent
62e52be061
commit
45c49fdec3
18
src/macro.c
18
src/macro.c
|
@ -36,6 +36,20 @@ new_uniq_sym(pic_state *pic, pic_sym base)
|
||||||
return uniq;
|
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 *
|
struct pic_senv *
|
||||||
pic_null_syntactic_env(pic_state *pic)
|
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: {
|
case PIC_TT_SYMBOL: {
|
||||||
struct xh_entry *e;
|
struct xh_entry *e;
|
||||||
pic_sym uniq;
|
pic_sym uniq;
|
||||||
|
|
||||||
|
if (uniq_sym_p(pic, pic_sym(expr))) {
|
||||||
|
return expr;
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
if ((e = xh_get(senv->tbl, pic_symbol_name(pic, pic_sym(expr)))) != NULL) {
|
if ((e = xh_get(senv->tbl, pic_symbol_name(pic, pic_sym(expr)))) != NULL) {
|
||||||
if (e->val >= 0)
|
if (e->val >= 0)
|
||||||
|
|
Loading…
Reference in New Issue