#ifndef __SPL_SEMA_H__ #define __SPL_SEMA_H__ #include "spl_ast.h" #include "spl_type.h" typedef usize spl_scope_id_t; /* 0 is error */ typedef struct { spl_scope_id_t parent; MAP(const char *, spl_type_id_t) symbols; } spl_scope_node_t; typedef VEC(spl_scope_node_t) spl_scope_node_vec_t; typedef struct { spl_ast_t *ast; spl_type_t type; spl_scope_node_vec_t scopes; spl_scope_id_t root_scope; spl_scope_id_t current_scope; int error_count; } spl_sema_t; void spl_sema_init(spl_sema_t *sema); void spl_sema_drop(spl_sema_t *sema); void spl_sema_run(spl_sema_t *sema); spl_scope_id_t spl_sema_scope_alloc(spl_sema_t *sema); bool spl_sema_scope_insert(spl_sema_t *sema, spl_scope_id_t id, const char *symbol_name, spl_type_id_t symbol_val); typedef VEC(const char *) spl_symbol_path_t; spl_type_id_t spl_sema_scope_find(spl_sema_t *sema, spl_symbol_path_t path); #endif /* __SPL_SEMA_H__ */