code wiki / _attic / _offc_weaver_smoke.nx

_offc_weaver_smoke.nx source

↩ module page · 27 lines · 503 B

1// Weaver-coverage smoke test. Three forms (if, while, return) so 2// we can grep the produced asm for narr_func_exit / narr_moment 3// auto-injected calls. 4 5import "syscalls.nx" 6import "nx_narr.nx" 7 8func tiny(x: i64) -> i64 { 9 if x > 0 { 10 return 1 11 } 12 return 0 13} 14 15func loopy(n: i64) -> i64 { 16 var i: i64 = 0 17 while i < n { 18 i = i + 1 19 } 20 return i 21} 22 23func main() -> i64 { 24 let a: i64 = tiny(5) 25 let b: i64 = loopy(3) 26 return a + b 27}