add global identifier table
This commit is contained in:
parent
ce3e2b939c
commit
a2e1f21b29
|
@ -52,13 +52,17 @@ typedef struct {
|
||||||
size_t slen, scapa;
|
size_t slen, scapa;
|
||||||
int uniq_sym_count;
|
int uniq_sym_count;
|
||||||
|
|
||||||
/* positive for variables, negative for macros (bitwise-not) */
|
|
||||||
struct xhash *global_tbl;
|
struct xhash *global_tbl;
|
||||||
pic_value *globals;
|
pic_value *globals;
|
||||||
size_t glen, gcapa;
|
size_t glen, gcapa;
|
||||||
struct pic_proc **macros;
|
struct pic_proc **macros;
|
||||||
size_t mlen, mcapa;
|
size_t mlen, mcapa;
|
||||||
|
|
||||||
|
/* positive for variables, negative for macros (bitwise-not) */
|
||||||
|
struct xhash *var_tbl;
|
||||||
|
struct pic_syntax **stx;
|
||||||
|
size_t xlen, xcapa;
|
||||||
|
|
||||||
struct pic_irep **irep;
|
struct pic_irep **irep;
|
||||||
size_t ilen, icapa;
|
size_t ilen, icapa;
|
||||||
pic_value *pool;
|
pic_value *pool;
|
||||||
|
|
2
src/gc.c
2
src/gc.c
|
@ -357,6 +357,8 @@ gc_mark_phase(pic_state *pic)
|
||||||
/* macros */
|
/* macros */
|
||||||
for (i = 0; i < pic->mlen; ++i) {
|
for (i = 0; i < pic->mlen; ++i) {
|
||||||
gc_mark_object(pic, (struct pic_object *)pic->macros[i]);
|
gc_mark_object(pic, (struct pic_object *)pic->macros[i]);
|
||||||
|
for (i = 0; i < pic->xlen; ++i) {
|
||||||
|
gc_mark_object(pic, (struct pic_object *)pic->stx[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pool */
|
/* pool */
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "picrin.h"
|
#include "picrin.h"
|
||||||
#include "picrin/gc.h"
|
#include "picrin/gc.h"
|
||||||
#include "picrin/proc.h"
|
#include "picrin/proc.h"
|
||||||
|
#include "picrin/macro.h"
|
||||||
#include "xhash/xhash.h"
|
#include "xhash/xhash.h"
|
||||||
|
|
||||||
void pic_init_core(pic_state *);
|
void pic_init_core(pic_state *);
|
||||||
|
@ -67,6 +68,12 @@ pic_open(int argc, char *argv[], char **envp)
|
||||||
pic->mlen = 0;
|
pic->mlen = 0;
|
||||||
pic->mcapa = PIC_MACROS_SIZE;
|
pic->mcapa = PIC_MACROS_SIZE;
|
||||||
|
|
||||||
|
/* identifier table */
|
||||||
|
pic->var_tbl = xh_new();
|
||||||
|
pic->stx = (struct pic_syntax **)calloc(PIC_MACROS_SIZE, sizeof(struct pic_syntax *));
|
||||||
|
pic->xlen = 0;
|
||||||
|
pic->xcapa = PIC_MACROS_SIZE;
|
||||||
|
|
||||||
/* pool */
|
/* pool */
|
||||||
pic->pool = (pic_value *)calloc(PIC_POOL_SIZE, sizeof(pic_value));
|
pic->pool = (pic_value *)calloc(PIC_POOL_SIZE, sizeof(pic_value));
|
||||||
pic->plen = 0;
|
pic->plen = 0;
|
||||||
|
|
Loading…
Reference in New Issue