feat: 结构体 struct — 最后一项 P0 功能
- lexer: TOK_STRUCT, TOK_DOT 关键字和运算符
- ast: AST_STRUCT_DECL/STRUCT_INIT/FIELD_ACCESS 3 种新节点
- parser: struct 声明 + .field 访问 + Name{field:val} 初始化
- sema: struct 类型符号表,字段类型解析,初始化字段检查
- codegen: LLVMStructType + extractvalue/insertvalue 字段操作
- 新增集成测试: 12_struct.l, 13_struct_nested.l
- 基于 Codex 分析报告 P0 #4
所有 P0 功能已全部完成。
This commit is contained in:
+4
-4
@@ -13,7 +13,7 @@ void test_codegen_simple_function() {
|
||||
AstNode* body = ast_make_block(&a, stmts, 1, 1, 1);
|
||||
AstNode* fn = ast_make_function(&a, "main", NULL, 0, TYPE_I64, body, 1, 1);
|
||||
AstNode* fns[] = { fn };
|
||||
AstNode* prog = ast_make_program(&a, fns, 1, 1, 1);
|
||||
AstNode* prog = ast_make_program(&a, fns, 1, NULL, 0, 1, 1);
|
||||
|
||||
const char* err = NULL;
|
||||
LLVMModuleRef mod = codegen_module(prog, &a, "test_mod", &err);
|
||||
@@ -45,7 +45,7 @@ void test_codegen_if_else() {
|
||||
AstNode* body = ast_make_block(&a, stmts, 1, 1, 1);
|
||||
AstNode* fn = ast_make_function(&a, "main", NULL, 0, TYPE_I64, body, 1, 1);
|
||||
AstNode* fns[] = { fn };
|
||||
AstNode* prog = ast_make_program(&a, fns, 1, 1, 1);
|
||||
AstNode* prog = ast_make_program(&a, fns, 1, NULL, 0, 1, 1);
|
||||
|
||||
const char* err = NULL;
|
||||
LLVMModuleRef mod = codegen_module(prog, &a, "test_mod2", &err);
|
||||
@@ -74,7 +74,7 @@ void test_codegen_binary_ops() {
|
||||
AstNode* body = ast_make_block(&a, stmts, 1, 1, 1);
|
||||
AstNode* fn = ast_make_function(&a, "main", NULL, 0, TYPE_I64, body, 1, 1);
|
||||
AstNode* fns[] = { fn };
|
||||
AstNode* prog = ast_make_program(&a, fns, 1, 1, 1);
|
||||
AstNode* prog = ast_make_program(&a, fns, 1, NULL, 0, 1, 1);
|
||||
|
||||
const char* err = NULL;
|
||||
LLVMModuleRef mod = codegen_module(prog, &a, "test_mod3", &err);
|
||||
@@ -102,7 +102,7 @@ void test_codegen_while_loop() {
|
||||
AstNode* fn_body = ast_make_block(&a, stmts, 2, 1, 1);
|
||||
AstNode* fn = ast_make_function(&a, "main", NULL, 0, TYPE_I64, fn_body, 1, 1);
|
||||
AstNode* fns[] = { fn };
|
||||
AstNode* prog = ast_make_program(&a, fns, 1, 1, 1);
|
||||
AstNode* prog = ast_make_program(&a, fns, 1, NULL, 0, 1, 1);
|
||||
|
||||
const char* err = NULL;
|
||||
LLVMModuleRef mod = codegen_module(prog, &a, "test_while", &err);
|
||||
|
||||
Reference in New Issue
Block a user