feat: add support for structs and member access

This commit is contained in:
2026-04-22 23:49:13 +02:00
parent f3c93fa516
commit ec2aa771fa
12 changed files with 1006 additions and 101 deletions
+38
View File
@@ -0,0 +1,38 @@
[code]
foreign fn putchar(c: i32) -> i32;
struct Rect {
width: i32,
height: i32
}
fn modify_rect(r: *Rect) {
let temp: Rect = *r;
temp.width = temp.width + 10;
temp.height = temp.height + 20;
*r = temp;
}
fn print_num(n: i32) {
putchar(48 + (n / 10));
putchar(48 + (n % 10));
putchar(10);
}
fn main() -> i32 {
let r = Rect { width: 15, height: 25 };
modify_rect(&r);
print_num(r.width);
print_num(r.height);
return 0;
}
[expected_return_code]
0
[expected_output]
25
45