/// Record with two fields. record R: Copy { a: i32, b: i32 } /// Record returned through a hidden slot. record Big: Copy { a: u64, b: u64, c: u64, d: u64 } fn five() -> i32 { return 5; } fn pair() -> R { return R { a: 3, b: 4 }; } fn big() -> Big { return Big { a: 1, b: 2, c: 3, d: 4 }; } fn readI(v: &i32) -> i32 { return *v; } fn readBig(b: &Big) -> u64 { return b.d; } fn readR(r: &R) -> i32 { return r.a; } /// A scalar call result is stored in a stack slot. fn callResult() -> i32 { return readI(&five()); } /// A computed value is stored in a stack slot. fn arithmetic(x: i32) -> i32 { return readI(&(x + 1)); } /// A call result returned in registers is stored in a stack slot. fn registerResult() -> i32 { return readR(&pair()); } /// A call result returned through a hidden slot is addressed in that slot. fn slotResult() -> u64 { return readBig(&big()); } /// A field of an aggregate call result is addressed inside the slot. fn fieldResult() -> i32 { return readI(&pair().b); } /// A cast of a place is copied, so the temporary does not alias the place. fn castCopy(r: R) -> i32 { return readR(&(r as R)); }