#ifndef SK_SYM_H #define SK_SYM_H #include "commons.h" #define SK_NO_CLOSURE (-1) #define SK_NO_NATIVE (-1) struct symbol { int id; int closure_id; int native_id; char* name; bool is_const; struct env* env; }; struct env { struct vec symbols; struct env* parent; }; struct sym { int id_counter; int closure_counter; int native_counter; struct env* env; }; void env_init(struct env* self); struct env* env_new_clone(struct env* self); void env_free(struct env* self); struct symbol* env_try_get(struct env* self, char const* name); void symbol_init(struct symbol* self, int id, char const* name, struct env* env); void symbol_free(struct symbol* self); void sym_init(struct sym* self); struct sym* sym_new_clone(struct sym* self); void sym_free(struct sym* self); int sym_decl_var(struct sym* self, char const* name); int sym_decl_const(struct sym* self, char const* name); int sym_decl_closure(struct sym* self, int id, char const* name); int sym_decl_native(struct sym* self, char const* name, int addr); void sym_open_scope(struct sym* self); void sym_close_scope(struct sym* self); struct symbol* sym_try_get(struct sym* self, char const* name); #endif