reserve the 0 symbol for system use
This commit is contained in:
parent
514937662e
commit
816343bd31
|
@ -9,6 +9,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pic_sym is just an alias to int.
|
||||||
|
* the value 0 for pic_sym is guaranteed to resolve to no symbol.
|
||||||
|
* if you are defining a function that returns optional<pic_sym>,
|
||||||
|
* the zero symbol would be useful for such situation.
|
||||||
|
*/
|
||||||
|
|
||||||
typedef int pic_sym;
|
typedef int pic_sym;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -75,6 +75,9 @@ pic_open(int argc, char *argv[], char **envp)
|
||||||
/* native stack marker */
|
/* native stack marker */
|
||||||
pic->native_stack_start = &t;
|
pic->native_stack_start = &t;
|
||||||
|
|
||||||
|
/* symbol 0 is reserved for system */
|
||||||
|
xh_put_int(pic->sym_names, pic->sym_cnt++, (long)"<system-reserved-symbol>");
|
||||||
|
|
||||||
#define register_core_symbol(pic,slot,name) do { \
|
#define register_core_symbol(pic,slot,name) do { \
|
||||||
pic->slot = pic_intern_cstr(pic, name); \
|
pic->slot = pic_intern_cstr(pic, name); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -155,6 +158,8 @@ pic_close(pic_state *pic)
|
||||||
|
|
||||||
/* free symbol names */
|
/* free symbol names */
|
||||||
for (xh_begin(pic->sym_names, &it); ! xh_isend(&it); xh_next(&it)) {
|
for (xh_begin(pic->sym_names, &it); ! xh_isend(&it); xh_next(&it)) {
|
||||||
|
if (it.e->key == 0)
|
||||||
|
continue;
|
||||||
free((void *)it.e->val);
|
free((void *)it.e->val);
|
||||||
}
|
}
|
||||||
free(pic->sym_names);
|
free(pic->sym_names);
|
||||||
|
|
Loading…
Reference in New Issue