#ifndef __SCC_SEMA_H__ #define __SCC_SEMA_H__ #include #include typedef struct scc_sema_ctx scc_sema_ctx_t; /** * @brief 语义分析回调函数类型 */ typedef void (*scc_sema_callback_t)(scc_sema_ctx_t *context, scc_ast_node_kind_t node_type, void *node); typedef scc_ast_qual_type_t *(*scc_sema_got_type_t)(scc_sema_ctx_t *context, const char *name); typedef struct scc_label_scope { int function_scope_depth; scc_hashtable_t labels; // 标签名 -> scc_ast_stmt_t* (LABEL节点) scc_ast_stmt_vec_t pending_gotos; // 尚未找到目标的goto语句 } scc_sema_label_scope_t; /** * @brief 语义分析回调集合 */ struct scc_sema_ctx { scc_sema_callback_t on_decl; scc_sema_callback_t on_stmt; scc_sema_callback_t on_expr; scc_sema_callback_t on_type; scc_sema_got_type_t got_type; scc_ast_ctx_t *ast_ctx; scc_ast_stmt_vec_t break_stack; scc_ast_stmt_vec_t continue_stack; scc_sema_label_scope_t label_scope; void *context; }; void scc_sema_init(scc_sema_ctx_t *sema_ctx, scc_ast_ctx_t *ast_ctx); void scc_sema_drop(scc_sema_ctx_t *sema_ctx); #endif /* __SCC_SEMA_H__ */