feat: in/out 参数 — out 关键字引用传递
fn swap(out x: i64, out y: i64) 声明 out 参数,codegen 层面 函数签名变为 T* 指针,调用点自动传 &variable 地址。 in 是默认行为(值传递),无需显式标注。 Token → Parser → Sema → Codegen 全流水线: - TOK_OUT + "out" 关键字注册 - AST parameter.is_out 字段 - parse_function 解析 out 前缀 - Sema: out 参数注册为 SYM_VARIABLE+is_mut(可赋值) - Codegen: LLVM 函数签名使用 T*,调用点传 alloca Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@
|
||||
static const char* NAMES[] = {
|
||||
[TOK_FN] = "fn", [TOK_LET] = "let", [TOK_VAR] = "var", [TOK_CONST] = "const", [TOK_IF] = "if", [TOK_GUARD] = "guard",
|
||||
[TOK_PUB] = "pub", [TOK_MOD] = "mod", [TOK_USE] = "use",
|
||||
[TOK_TRAIT] = "trait", [TOK_SELF] = "Self",
|
||||
[TOK_TRAIT] = "trait", [TOK_SELF] = "Self", [TOK_OUT] = "out",
|
||||
[TOK_ELSE] = "else", [TOK_WHILE] = "while", [TOK_FOR] = "for", [TOK_IN] = "in", [TOK_RETURN] = "return",
|
||||
[TOK_STRUCT] = "struct", [TOK_TYPE] = "type", [TOK_ENUM] = "enum", [TOK_EXTEND] = "extend",
|
||||
[TOK_DEFER] = "defer", [TOK_MATCH] = "match",
|
||||
|
||||
Reference in New Issue
Block a user