add pic_senv_new
This commit is contained in:
parent
baeb5f6174
commit
d6b6376408
|
@ -32,6 +32,8 @@ struct pic_senv *pic_null_syntactic_environment(pic_state *);
|
||||||
bool pic_identifier_p(pic_state *pic, pic_value obj);
|
bool pic_identifier_p(pic_state *pic, pic_value obj);
|
||||||
bool pic_identifier_eq_p(pic_state *, struct pic_senv *, pic_sym, struct pic_senv *, pic_sym);
|
bool pic_identifier_eq_p(pic_state *, struct pic_senv *, pic_sym, struct pic_senv *, pic_sym);
|
||||||
|
|
||||||
|
struct pic_senv *pic_senv_new(pic_state *, struct pic_senv *);
|
||||||
|
|
||||||
pic_sym pic_add_rename(pic_state *, struct pic_senv *, pic_sym);
|
pic_sym pic_add_rename(pic_state *, struct pic_senv *, pic_sym);
|
||||||
bool pic_find_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym * /* = NULL */);
|
bool pic_find_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym * /* = NULL */);
|
||||||
void pic_put_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym);
|
void pic_put_rename(pic_state *, struct pic_senv *, pic_sym, pic_sym);
|
||||||
|
|
22
src/macro.c
22
src/macro.c
|
@ -210,9 +210,7 @@ macroexpand_lambda(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
pic_error(pic, "syntax error");
|
pic_error(pic, "syntax error");
|
||||||
}
|
}
|
||||||
|
|
||||||
in = (struct pic_senv *)pic_obj_alloc(pic, sizeof(struct pic_senv), PIC_TT_SENV);
|
in = pic_senv_new(pic, senv);
|
||||||
in->up = senv;
|
|
||||||
xh_init_int(&in->map, sizeof(pic_sym));
|
|
||||||
|
|
||||||
for (a = pic_cadr(pic, expr); pic_pair_p(a); a = pic_cdr(pic, a)) {
|
for (a = pic_cadr(pic, expr); pic_pair_p(a); a = pic_cdr(pic, a)) {
|
||||||
pic_value v = pic_car(pic, a);
|
pic_value v = pic_car(pic, a);
|
||||||
|
@ -372,9 +370,7 @@ macroexpand_let_syntax(pic_state *pic, pic_value expr, struct pic_senv *senv)
|
||||||
pic_value formal, v, var, val;
|
pic_value formal, v, var, val;
|
||||||
pic_sym sym, rename;
|
pic_sym sym, rename;
|
||||||
|
|
||||||
in = (struct pic_senv *)pic_obj_alloc(pic, sizeof(struct pic_senv), PIC_TT_SENV);
|
in = pic_senv_new(pic, senv);
|
||||||
in->up = senv;
|
|
||||||
xh_init_int(&in->map, sizeof(pic_sym));
|
|
||||||
|
|
||||||
if (pic_length(pic, expr) < 2) {
|
if (pic_length(pic, expr) < 2) {
|
||||||
pic_error(pic, "syntax error");
|
pic_error(pic, "syntax error");
|
||||||
|
@ -563,14 +559,24 @@ pic_macroexpand(pic_state *pic, pic_value expr)
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pic_senv *
|
struct pic_senv *
|
||||||
pic_null_syntactic_environment(pic_state *pic)
|
pic_senv_new(pic_state *pic, struct pic_senv *up)
|
||||||
{
|
{
|
||||||
struct pic_senv *senv;
|
struct pic_senv *senv;
|
||||||
|
|
||||||
senv = (struct pic_senv *)pic_obj_alloc(pic, sizeof(struct pic_senv), PIC_TT_SENV);
|
senv = (struct pic_senv *)pic_obj_alloc(pic, sizeof(struct pic_senv), PIC_TT_SENV);
|
||||||
senv->up = NULL;
|
senv->up = up;
|
||||||
xh_init_int(&senv->map, sizeof(pic_sym));
|
xh_init_int(&senv->map, sizeof(pic_sym));
|
||||||
|
|
||||||
|
return senv;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct pic_senv *
|
||||||
|
pic_null_syntactic_environment(pic_state *pic)
|
||||||
|
{
|
||||||
|
struct pic_senv *senv;
|
||||||
|
|
||||||
|
senv = pic_senv_new(pic, NULL);
|
||||||
|
|
||||||
pic_define_syntactic_keyword(pic, senv, pic->sDEFINE_LIBRARY, pic->rDEFINE_LIBRARY);
|
pic_define_syntactic_keyword(pic, senv, pic->sDEFINE_LIBRARY, pic->rDEFINE_LIBRARY);
|
||||||
pic_define_syntactic_keyword(pic, senv, pic->sIMPORT, pic->rIMPORT);
|
pic_define_syntactic_keyword(pic, senv, pic->sIMPORT, pic->rIMPORT);
|
||||||
pic_define_syntactic_keyword(pic, senv, pic->sEXPORT, pic->rEXPORT);
|
pic_define_syntactic_keyword(pic, senv, pic->sEXPORT, pic->rEXPORT);
|
||||||
|
|
Loading…
Reference in New Issue