#ifndef __SCC_IR_CTX_H__ #define __SCC_IR_CTX_H__ #include "ir_def.h" #include "ir_prog.h" #include typedef struct { scc_ir_module_t *module; // 关联的模块(用于实际存储) scc_hashtable_t type_uniquing; // 类型哈希表:hash -> type_ref scc_hashtable_t const_pool; // 常量哈希表:hash -> node_ref scc_hashtable_t func_decl_set; // 函数声明集合:name -> func_ref } scc_ir_ctx_t; void scc_ir_ctx_init(scc_ir_ctx_t *ctx, scc_ir_module_t *module); void scc_ir_ctx_drop(scc_ir_ctx_t *ctx); // 获取唯一类型,若不存在则创建并返回新引用 scc_ir_type_ref_t scc_ir_ctx_get_type(scc_ir_ctx_t *ctx, const scc_ir_type_t *type_desc); // 注册函数声明,若已存在则返回已有引用 scc_ir_func_ref_t scc_ir_ctx_declare_func(scc_ir_ctx_t *ctx, scc_ir_type_ref_t type, const char *name); #endif /* __SCC_IR_CTX_H__ */