hold standard library references in pic_state

This commit is contained in:
Yuichi Nishiwaki 2014-09-01 13:01:17 +09:00
parent fb28cd003e
commit a227498f5b
3 changed files with 11 additions and 7 deletions

View File

@ -85,6 +85,9 @@ typedef struct {
pic_sym rDEFINE_SYNTAX, rIMPORT, rEXPORT;
pic_sym rDEFINE_LIBRARY, rIN_LIBRARY;
struct pic_lib *PICRIN_BASE;
struct pic_lib *PICRIN_USER;
xhash syms; /* name to symbol */
xhash sym_names; /* symbol to name */
int sym_cnt;

3
init.c
View File

@ -4,7 +4,6 @@
#include "picrin.h"
#include "picrin/pair.h"
#include "picrin/read.h"
#include "picrin/lib.h"
#include "picrin/macro.h"
#include "picrin/error.h"
@ -36,8 +35,6 @@ pic_init_core(pic_state *pic)
{
size_t ai = pic_gc_arena_preserve(pic);
pic_init_reader(pic);
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);

12
state.c
View File

@ -140,11 +140,15 @@ pic_open(int argc, char *argv[], char **envp)
pic->blk->depth = 0;
pic->blk->in = pic->blk->out = NULL;
pic_init_core(pic);
/* init readers */
pic_init_reader(pic);
/* set library */
pic_make_library(pic, pic_read_cstr(pic, "(picrin user)"));
pic_in_library(pic, pic_read_cstr(pic, "(picrin user)"));
/* standard libraries */
pic->PICRIN_BASE = pic_make_library(pic, pic_read_cstr(pic, "(picrin base)"));
pic->PICRIN_USER = pic_make_library(pic, pic_read_cstr(pic, "(picrin user)"));
pic->lib = pic->PICRIN_USER;
pic_init_core(pic);
return pic;
}