add pic_export and pic_export_as

This commit is contained in:
Yuichi Nishiwaki 2013-12-07 20:44:39 -08:00
parent 0110370cc4
commit 01e60b5d8e
2 changed files with 16 additions and 1 deletions

View File

@ -127,6 +127,9 @@ void pic_in_library(pic_state *, pic_value);
struct pic_lib *pic_make_library(pic_state *, pic_value);
struct pic_lib *pic_find_library(pic_state *, pic_value);
void pic_export(pic_state *, pic_sym);
void pic_export_as(pic_state *, pic_sym, pic_sym);
void pic_abort(pic_state *, const char *);
void pic_raise(pic_state *, pic_value);
void pic_error(pic_state *, const char *);

View File

@ -176,6 +176,18 @@ pic_identifier_p(pic_value obj)
return false;
}
void
pic_export(pic_state *pic, pic_sym sym)
{
pic_export_as(pic, sym, sym);
}
void
pic_export_as(pic_state *pic, pic_sym sym, pic_sym alias)
{
xh_put(pic->lib->exports, pic_symbol_name(pic, sym), (int)alias);
}
static void
pic_defsyntax(pic_state *pic, const char *name, struct pic_proc *macro, struct pic_senv *mac_env)
{
@ -276,7 +288,7 @@ macroexpand(pic_state *pic, pic_value expr, struct pic_senv *senv)
if (pic_symbol_p(v)) {
ren = pic_sym(v);
}
xh_put(pic->lib->exports, pic_symbol_name(pic, orig), (int)ren);
pic_export_as(pic, orig, ren);
return pic_false_value();
}
case PIC_STX_DEFSYNTAX: {