kh_s_t -> kh_oblist_t
This commit is contained in:
parent
b084a20390
commit
294477ff13
|
@ -645,7 +645,7 @@ gc_sweep_phase(pic_state *pic)
|
||||||
struct heap_page *page;
|
struct heap_page *page;
|
||||||
khiter_t it;
|
khiter_t it;
|
||||||
khash_t(weak) *h;
|
khash_t(weak) *h;
|
||||||
khash_t(s) *s = &pic->oblist;
|
khash_t(oblist) *s = &pic->oblist;
|
||||||
pic_sym *sym;
|
pic_sym *sym;
|
||||||
struct pic_object *obj;
|
struct pic_object *obj;
|
||||||
size_t total = 0, inuse = 0;
|
size_t total = 0, inuse = 0;
|
||||||
|
@ -670,7 +670,7 @@ gc_sweep_phase(pic_state *pic)
|
||||||
continue;
|
continue;
|
||||||
sym = kh_val(s, it);
|
sym = kh_val(s, it);
|
||||||
if (sym->gc_mark == PIC_GC_UNMARK) {
|
if (sym->gc_mark == PIC_GC_UNMARK) {
|
||||||
kh_del(s, s, it);
|
kh_del(oblist, s, it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ extern "C" {
|
||||||
#include "picrin/read.h"
|
#include "picrin/read.h"
|
||||||
#include "picrin/gc.h"
|
#include "picrin/gc.h"
|
||||||
|
|
||||||
KHASH_DECLARE(s, struct pic_string *, pic_sym *)
|
KHASH_DECLARE(oblist, struct pic_string *, pic_sym *)
|
||||||
|
|
||||||
typedef struct pic_checkpoint {
|
typedef struct pic_checkpoint {
|
||||||
PIC_OBJECT_HEADER
|
PIC_OBJECT_HEADER
|
||||||
|
@ -73,7 +73,7 @@ struct pic_state {
|
||||||
|
|
||||||
pic_value features;
|
pic_value features;
|
||||||
|
|
||||||
khash_t(s) oblist; /* string to symbol */
|
khash_t(oblist) oblist; /* string to symbol */
|
||||||
int ucnt;
|
int ucnt;
|
||||||
struct pic_weak *globals;
|
struct pic_weak *globals;
|
||||||
struct pic_weak *macros;
|
struct pic_weak *macros;
|
||||||
|
|
|
@ -252,7 +252,7 @@ pic_open(pic_allocf allocf, void *userdata)
|
||||||
pic->heap = pic_heap_open(pic);
|
pic->heap = pic_heap_open(pic);
|
||||||
|
|
||||||
/* symbol table */
|
/* symbol table */
|
||||||
kh_init(s, &pic->oblist);
|
kh_init(oblist, &pic->oblist);
|
||||||
|
|
||||||
/* unique symbol count */
|
/* unique symbol count */
|
||||||
pic->ucnt = 0;
|
pic->ucnt = 0;
|
||||||
|
@ -376,7 +376,7 @@ pic_open(pic_allocf allocf, void *userdata)
|
||||||
void
|
void
|
||||||
pic_close(pic_state *pic)
|
pic_close(pic_state *pic)
|
||||||
{
|
{
|
||||||
khash_t(s) *h = &pic->oblist;
|
khash_t(oblist) *h = &pic->oblist;
|
||||||
pic_allocf allocf = pic->allocf;
|
pic_allocf allocf = pic->allocf;
|
||||||
|
|
||||||
/* clear out root objects */
|
/* clear out root objects */
|
||||||
|
@ -420,7 +420,7 @@ pic_close(pic_state *pic)
|
||||||
allocf(pic->userdata, pic->xpbase, 0);
|
allocf(pic->userdata, pic->xpbase, 0);
|
||||||
|
|
||||||
/* free global stacks */
|
/* free global stacks */
|
||||||
kh_destroy(s, h);
|
kh_destroy(oblist, h);
|
||||||
|
|
||||||
/* free GC arena */
|
/* free GC arena */
|
||||||
allocf(pic->userdata, pic->arena, 0);
|
allocf(pic->userdata, pic->arena, 0);
|
||||||
|
|
|
@ -7,17 +7,17 @@
|
||||||
#define kh_pic_str_hash(a) (pic_str_hash(pic, (a)))
|
#define kh_pic_str_hash(a) (pic_str_hash(pic, (a)))
|
||||||
#define kh_pic_str_cmp(a, b) (pic_str_cmp(pic, (a), (b)) == 0)
|
#define kh_pic_str_cmp(a, b) (pic_str_cmp(pic, (a), (b)) == 0)
|
||||||
|
|
||||||
KHASH_DEFINE(s, struct pic_string *, pic_sym *, kh_pic_str_hash, kh_pic_str_cmp)
|
KHASH_DEFINE(oblist, struct pic_string *, pic_sym *, kh_pic_str_hash, kh_pic_str_cmp)
|
||||||
|
|
||||||
pic_sym *
|
pic_sym *
|
||||||
pic_intern(pic_state *pic, struct pic_string *str)
|
pic_intern(pic_state *pic, struct pic_string *str)
|
||||||
{
|
{
|
||||||
khash_t(s) *h = &pic->oblist;
|
khash_t(oblist) *h = &pic->oblist;
|
||||||
pic_sym *sym;
|
pic_sym *sym;
|
||||||
khiter_t it;
|
khiter_t it;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
it = kh_put(s, h, str, &ret);
|
it = kh_put(oblist, h, str, &ret);
|
||||||
if (ret == 0) { /* if exists */
|
if (ret == 0) { /* if exists */
|
||||||
sym = kh_val(h, it);
|
sym = kh_val(h, it);
|
||||||
pic_gc_protect(pic, pic_obj_value(sym));
|
pic_gc_protect(pic, pic_obj_value(sym));
|
||||||
|
|
Loading…
Reference in New Issue