- 将scc_ast_type_t替换为scc_ast_qual_type_t,引入规范类型概念 - 添加scc_ast_canonical_type_t联合体用于表示规范类型 - 修改头文件结构,移除大量内联初始化函数,改为使用AST上下文分配器 - 添加SCC_AST_ALLOC宏用于统一节点分配管理 - 更新builtin类型枚举定义,添加类型计数常量 feat(ast): 引入AST上下文管理器 - 创建scc_ast_ctx_t结构体用于管理AST节点生命周期 - 实现类型池化机制,支持内置类型的统一管理 - 添加canonical类型获取和分配接口 refactor(abi): 适配新的AST类型系统 - 更新头文件包含,从<scc_ir.h>改为<scc_hir.h> - 适配函数参数类型,使用qual_type替代原始type - 使用scc_ast_canon_type()函数获取规范类型进行处理 Co-authored-by: Copilot <copilot@github.com>
33 lines
1.3 KiB
C
33 lines
1.3 KiB
C
#ifndef __SCC_AST2IR_H__
|
|
#define __SCC_AST2IR_H__
|
|
|
|
#include <scc_ast.h>
|
|
#include <scc_hir_builder.h>
|
|
#include <scc_type_abi.h>
|
|
|
|
typedef struct {
|
|
scc_hir_builder_t builder;
|
|
scc_hashtable_t ast2ir_cache; ///< ast node to ir ref cache
|
|
scc_hashtable_t symtab; ///< symbol to ir_ref
|
|
// scc_strpool_t strpool; ///< string pool
|
|
const scc_abi_type_calc_t *abi;
|
|
cbool hint_using_value; // 转换时尽可能使用value而不是alloc
|
|
} scc_ast2ir_ctx_t;
|
|
|
|
void scc_ast2ir_ctx_init(scc_ast2ir_ctx_t *ctx, const scc_abi_type_calc_t *abi,
|
|
scc_hir_cprog_t *cprog);
|
|
void scc_ast2ir_ctx_drop(scc_ast2ir_ctx_t *ctx);
|
|
|
|
void scc_ast2ir_run(scc_ast2ir_ctx_t *ctx,
|
|
const scc_ast_translation_unit_t *tu);
|
|
void scc_ast2ir_decl(scc_ast2ir_ctx_t *ctx, const scc_ast_decl_t *decl,
|
|
cbool is_global);
|
|
scc_hir_value_ref_t scc_ast2ir_expr(scc_ast2ir_ctx_t *ctx,
|
|
const scc_ast_expr_t *expr,
|
|
cbool is_lvalue);
|
|
void scc_ast2ir_stmt(scc_ast2ir_ctx_t *ctx, const scc_ast_stmt_t *stmt);
|
|
scc_hir_type_ref_t scc_ast2ir_type(scc_ast2ir_ctx_t *ctx,
|
|
const scc_ast_qual_type_t *ast_type);
|
|
|
|
#endif /* __SCC_AST2IR_H__ */
|