Files
l-language/test/programs/19_struct_method.l
T
Serendipity 9f6e695ba8 feat: struct方法 impl (P1 #9)
- lexer: TOK_IMPL 关键字
- ast: AST_IMPL_BLOCK, AST_METHOD_CALL + AST_PROGRAM impls数组
- parser: impl StructName { fn ... } + p.method() 方法调用
- sema: 方法名mangle(StructName$method), self参数, 类型检查
- codegen: METHOD_CALL→mangled函数调用(recv为第一参数)
- 新增集成测试: 19_struct_method.l

P1 4项全部完成: type alias + enum + array + impl
测试: 145 通过 (41+15+65+24)
2026-06-05 14:30:24 +08:00

14 lines
216 B
Plaintext

struct Point { x: i64, y: i64 }
impl Point {
fn get_x(self: Point) -> i64 {
return self.x;
}
}
fn main() -> i64 {
let p: Point = Point { x: 42, y: 0 };
print_i64(p.get_x());
return 0;
}