- 在ABI类型计算中添加FLOAT和DOUBLE类型的映射 - 修复AST操作符注释中的歧义描述 - 为ast2ir上下文添加类型缓存以解决递归结构体定义问题 - 实现复合初始化表达式的支持,包括数组和结构体初始化 - 添加前置和后置自增/自减操作符的IR转换 - 实现三元条件表达式的IR生成 - 添加类型转换(cast)和sizeof操作符的支持 - 重构数组长度推断逻辑并添加类型大小计算函数 - 实现结构体和联合体的递归类型解析 - 添加函数指针调用相关的IR节点类型定义 fix(ast): 修正间接操作符的注释说明 refactor(ast2ir): 优化代码结构并添加必要的断言验证
38 lines
1.5 KiB
C
38 lines
1.5 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 break_cache; ///< break cache
|
|
scc_hashtable_t continue_cache; ///< continue cache
|
|
scc_hashtable_t symtab; ///< symbol to ir_ref
|
|
scc_hashtable_t type_cache; ///< scc_ast_canon_type_t* -> scc_hir_type_ref_t
|
|
// scc_strpool_t strpool; ///< string pool
|
|
const scc_abi_type_calc_t *abi;
|
|
cbool hint_using_value; // 转换时尽可能使用value而不是alloc
|
|
|
|
scc_ast_ctx_t *ast_ctx;
|
|
} scc_ast2ir_ctx_t;
|
|
|
|
void scc_ast2ir_ctx_init(scc_ast2ir_ctx_t *ctx, const scc_abi_type_calc_t *abi,
|
|
scc_ast_ctx_t *ast_ctx, 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__ */
|