add pic->feature
This commit is contained in:
parent
a0687e29e0
commit
d0abe2d193
2
gc.c
2
gc.c
|
@ -618,6 +618,8 @@ gc_mark_phase(pic_state *pic)
|
|||
}
|
||||
}
|
||||
|
||||
gc_mark(pic, pic->features);
|
||||
|
||||
/* readers */
|
||||
gc_mark_trie(pic, pic->reader->trie);
|
||||
|
||||
|
|
|
@ -87,6 +87,8 @@ typedef struct {
|
|||
struct pic_lib *PICRIN_BASE;
|
||||
struct pic_lib *PICRIN_USER;
|
||||
|
||||
pic_value features;
|
||||
|
||||
xhash syms; /* name to symbol */
|
||||
xhash sym_names; /* symbol to name */
|
||||
int sym_cnt;
|
||||
|
@ -137,10 +139,11 @@ void pic_gc_arena_restore(pic_state *, size_t);
|
|||
pic_state *pic_open(int argc, char *argv[], char **envp);
|
||||
void pic_close(pic_state *);
|
||||
|
||||
void pic_add_feature(pic_state *, const char *);
|
||||
|
||||
void pic_define(pic_state *, const char *, pic_value); /* automatic export */
|
||||
pic_value pic_ref(pic_state *, struct pic_lib *, const char *);
|
||||
void pic_set(pic_state *, struct pic_lib *, const char *, pic_value);
|
||||
|
||||
pic_value pic_funcall(pic_state *pic, const char *name, pic_list args);
|
||||
|
||||
struct pic_proc *pic_get_proc(pic_state *);
|
||||
|
|
9
init.c
9
init.c
|
@ -8,6 +8,12 @@
|
|||
#include "picrin/macro.h"
|
||||
#include "picrin/error.h"
|
||||
|
||||
void
|
||||
pic_add_feature(pic_state *pic, const char *feature)
|
||||
{
|
||||
pic_push(pic, pic_sym_value(pic_intern_cstr(pic, feature)), pic->features);
|
||||
}
|
||||
|
||||
void pic_init_bool(pic_state *);
|
||||
void pic_init_pair(pic_state *);
|
||||
void pic_init_port(pic_state *);
|
||||
|
@ -42,6 +48,9 @@ pic_init_core(pic_state *pic)
|
|||
{
|
||||
size_t ai = pic_gc_arena_preserve(pic);
|
||||
|
||||
pic_add_feature(pic, "picrin");
|
||||
pic_add_feature(pic, "ieee-float");
|
||||
|
||||
pic_deflibrary (pic, "(picrin base)") {
|
||||
pic_define_syntactic_keyword(pic, pic->lib->env, pic->sDEFINE, pic->rDEFINE);
|
||||
pic_define_syntactic_keyword(pic, pic->lib->env, pic->sSETBANG, pic->rSETBANG);
|
||||
|
|
4
state.c
4
state.c
|
@ -57,6 +57,9 @@ pic_open(int argc, char *argv[], char **envp)
|
|||
/* macros */
|
||||
xh_init_int(&pic->macros, sizeof(struct pic_macro *));
|
||||
|
||||
/* features */
|
||||
pic->features = pic_nil_value();
|
||||
|
||||
/* libraries */
|
||||
pic->libs = pic_nil_value();
|
||||
pic->lib = NULL;
|
||||
|
@ -184,6 +187,7 @@ pic_close(pic_state *pic)
|
|||
pic->arena_idx = 0;
|
||||
pic->err = NULL;
|
||||
xh_clear(&pic->macros);
|
||||
pic->features = pic_nil_value();
|
||||
pic->libs = pic_nil_value();
|
||||
|
||||
/* free all heap objects */
|
||||
|
|
Loading…
Reference in New Issue