cleanup
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
struct pic_string {
|
||||
PIC_OBJECT_HEADER
|
||||
const char *str;
|
||||
char *str;
|
||||
size_t len;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ struct sym_tbl {
|
||||
size_t size;
|
||||
};
|
||||
|
||||
struct sym_tbl * sym_tbl_new();
|
||||
pic_value sym_tbl_get(struct sym_tbl *, const char *);
|
||||
|
||||
#endif
|
||||
|
||||
+22
-4
@@ -17,12 +17,28 @@ new_empty_env()
|
||||
return env;
|
||||
}
|
||||
|
||||
struct sym_tbl *
|
||||
sym_tbl_new()
|
||||
{
|
||||
struct sym_tbl *s_tbl;
|
||||
int i;
|
||||
|
||||
s_tbl = (struct sym_tbl *)malloc(sizeof(struct sym_tbl));
|
||||
s_tbl->size = PIC_SYM_TBL_SIZE;
|
||||
|
||||
for (i = 0; i < PIC_SYM_TBL_SIZE; ++i) {
|
||||
s_tbl->tbl[i] = pic_nil_value();
|
||||
}
|
||||
return s_tbl;
|
||||
}
|
||||
|
||||
void pic_init_core(pic_state *);
|
||||
|
||||
pic_state *
|
||||
pic_open()
|
||||
{
|
||||
pic_state *pic;
|
||||
int ai;
|
||||
|
||||
pic = (pic_state *)malloc(sizeof(pic_state));
|
||||
|
||||
@@ -63,6 +79,11 @@ pic_open()
|
||||
/* GC arena */
|
||||
pic->arena_idx = 0;
|
||||
|
||||
/* global environment */
|
||||
pic->global_env = new_empty_env();
|
||||
pic_init_core(pic);
|
||||
|
||||
ai = pic_gc_arena_preserve(pic);
|
||||
pic->sDEFINE = pic_intern_cstr(pic, "define");
|
||||
pic->sLAMBDA = pic_intern_cstr(pic, "lambda");
|
||||
pic->sIF = pic_intern_cstr(pic, "if");
|
||||
@@ -76,10 +97,7 @@ pic_open()
|
||||
pic->sSUB = pic_intern_cstr(pic, "-");
|
||||
pic->sMUL = pic_intern_cstr(pic, "*");
|
||||
pic->sDIV = pic_intern_cstr(pic, "/");
|
||||
|
||||
/* global environment */
|
||||
pic->global_env = new_empty_env();
|
||||
pic_init_core(pic);
|
||||
pic_gc_arena_restore(pic, ai);
|
||||
|
||||
return pic;
|
||||
}
|
||||
|
||||
@@ -17,21 +17,6 @@ str_hash(const char *str)
|
||||
return hash;
|
||||
}
|
||||
|
||||
struct sym_tbl *
|
||||
sym_tbl_new()
|
||||
{
|
||||
struct sym_tbl *s_tbl;
|
||||
int i;
|
||||
|
||||
s_tbl = (struct sym_tbl *)malloc(sizeof(struct sym_tbl));
|
||||
s_tbl->size = PIC_SYM_TBL_SIZE;
|
||||
|
||||
for (i = 0; i < PIC_SYM_TBL_SIZE; ++i) {
|
||||
s_tbl->tbl[i] = pic_nil_value();
|
||||
}
|
||||
return s_tbl;
|
||||
}
|
||||
|
||||
pic_value
|
||||
sym_tbl_get(struct sym_tbl *s_tbl, const char *key)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user