添加了对未知长度数组的自动长度推导功能,支持字符串字面量和复合 初始化的数组长度计算。新增辅助函数resolve_array_length用于计算 数组实际长度,以及emit_array_initialization用于生成数组初始化 代码。 同时将AST转IR过程中的参数改为const引用,提高代码安全性。 新增IR构建器的借用检查机制,防止在借用期间进行重分配操作。 fix(ast): 为AST结构体添加详细注释说明字段用途
32 lines
1.2 KiB
C
32 lines
1.2 KiB
C
#ifndef __SCC_AST2IR_H__
|
|
#define __SCC_AST2IR_H__
|
|
|
|
#include "scc_type_abi.h"
|
|
#include <ir_builder.h>
|
|
#include <scc_ast.h>
|
|
#include <scc_ir.h>
|
|
|
|
typedef struct {
|
|
scc_ir_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;
|
|
} scc_ast2ir_ctx_t;
|
|
|
|
void scc_ast2ir_ctx_init(scc_ast2ir_ctx_t *ctx, const scc_abi_type_calc_t *abi,
|
|
scc_ir_cprog_t *cprog);
|
|
void scc_ast2ir_ctx_drop(scc_ast2ir_ctx_t *ctx);
|
|
|
|
void scc_ast2ir_translation_unit(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_ir_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_ir_type_ref_t scc_ast2ir_type(scc_ast2ir_ctx_t *ctx,
|
|
const scc_ast_type_t *ast_type);
|
|
|
|
#endif /* __SCC_AST2IR_H__ */
|