fix: P0审查修复 — CLAUDE.md数据更新 + load_module malloc→arena
This commit is contained in:
@@ -132,14 +132,14 @@ L Language/
|
||||
├── src/
|
||||
│ ├── lexer/
|
||||
│ │ ├── token.h/c Token {kind, start, length, line, col}
|
||||
│ │ └── lexer.h/c 手写状态机,67 种 Token 类型
|
||||
│ │ └── lexer.h/c 手写状态机,72 种 Token 类型
|
||||
│ ├── parser/
|
||||
│ │ └── parser.h/c Pratt 表达式 (9 级优先级) + 递归下降语句
|
||||
│ ├── ast/
|
||||
│ │ └── ast.h/c 14 种节点 (PROGRAM..IDENT_EXPR) + 工厂函数
|
||||
│ │ └── ast.h/c 27 种 AST 节点 + 工厂函数
|
||||
│ ├── sema/
|
||||
│ │ ├── symbol.h/c 作用域链 (Scope* parent 链表)
|
||||
│ │ └── sema.h/c 类型推断 + 类型检查 + 3 个内建函数注册
|
||||
│ │ └── sema.h/c 类型推断 + 类型检查 + 5 个内建函数注册
|
||||
│ ├── codegen/
|
||||
│ │ └── codegen.h/c AST → LLVM-C API → LLVMModuleRef
|
||||
│ ├── driver/
|
||||
@@ -151,8 +151,8 @@ L Language/
|
||||
│ ├── test_utils.h 断言宏 (ASSERT / TEST_RUN / test_summary)
|
||||
│ ├── test_lexer.c 词法测试 (41 tests)
|
||||
│ ├── test_parser.c 语法测试 (15 tests)
|
||||
│ ├── test_sema.c 语义测试 (9 tests)
|
||||
│ └── programs/ .l 集成测试 (5 个程序)
|
||||
│ ├── test_sema.c 语义测试 (74 tests)
|
||||
│ └── programs/ .l 集成测试 (34 个程序)
|
||||
├── docs/
|
||||
│ ├── PRD.md 产品需求文档
|
||||
│ └── superpowers/plans/ 实现计划
|
||||
|
||||
+1
-2
@@ -1008,14 +1008,13 @@ static AstNode* load_module(Arena* a, const char* parent_file,
|
||||
}
|
||||
fseek(f, 0, SEEK_END);
|
||||
size_t sz = ftell(f); fseek(f, 0, SEEK_SET);
|
||||
char* src = malloc(sz + 1);
|
||||
char* src = arena_alloc_impl(a, sz + 1);
|
||||
if (!src) { fclose(f); return NULL; }
|
||||
fread(src, 1, sz, f); src[sz] = '\0'; fclose(f);
|
||||
|
||||
size_t tc;
|
||||
ErrorInfo lex_err = {0};
|
||||
Token* toks = lex(a, src, mod_path, &tc, &lex_err);
|
||||
free(src);
|
||||
if (!toks) { *error = lex_err; return NULL; }
|
||||
|
||||
AstNode* ast = parse(a, toks, tc, mod_path, error);
|
||||
|
||||
Reference in New Issue
Block a user