reid-llvm/examples/associated_functions.reid
2025-07-28 21:23:51 +03:00

35 lines
605 B
Plaintext

import std::print;
import std::from_str;
import std::String;
struct Otus {
field: u32,
}
impl Otus {
fn test(&self) -> u32 {
*self.field
}
}
impl i32 {
fn test(self) -> u32 {
43
}
}
fn main() -> u32 {
let otus = Otus { field: 17 };
print(from_str("otus: ") + Otus::test(&otus) as u64);
print(from_str("i32: ") + i32::test(54) as u64);
print(from_str("sizeof i32: ") + i32::sizeof());
let nullptr = i32::null();
let mut list = u64::malloc(15);
list[4] = 17;
print(from_str("value: ") + list[4]);
return i32::sizeof() as u32;
}