MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / regalloc_pointers_structs_and_arrays

Function regalloc_pointers_structs_and_arrays

tests/integration/regalloc.rs:200–236  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

198#[test]
199fn regalloc_pointers_structs_and_arrays() {
200 assert_equivalent(
201 r#"
202external free: (p: i64*) -> void
203
204struct Point {
205 x: i64,
206 y: i64,
207}
208
209sum_buffer: (buf: i64*, len: i64) -> i64 {
210 total: i64 = 0
211 i: i64 = 0
212 while i < len {
213 total = total + buf[i]
214 i = i + 1
215 }
216 return total
217}
218
219main: () -> i32 {
220 p: Point = { .x = 17 as i64, .y = 25 as i64 }
221 arr: i64[4] = [1 as i64, 2 as i64, 3 as i64, 4 as i64]
222 local: i64 = arr[0] + arr[1] + arr[2] + arr[3]
223 buf: i64* = new(i64, 4)
224 i: i64 = 0
225 while i < 4 {
226 buf[i] = i * 10
227 i = i + 1
228 }
229 s: i64 = sum_buffer(buf, 4)
230 free(buf)
231 return (p.x + p.y + local + s) as i32
232}
233"#,
234 );
235}
236
237#[test]
238fn regalloc_mixed_float_and_int() {
239 // Floats stay slot-based while their integer neighbors are allocated; the

Callers

nothing calls this directly

Calls 1

assert_equivalentFunction · 0.85

Tested by

no test coverage detected