var gvar = 20 fn SomeFunc(s str) { var ptr = __WAC_UNSAFE_strptr(s) __print_str("Hello world!") __hello($cstr("STRPTR inside"), ptr) __hello($cstr("REFCNT inside"), __read(ptr)) } fn SomeOtherFunc() i32 { var s = "Hello world!" var id_s id = s __hello($cstr("STRPTR == split a =="), 0) var ptr = __WAC_UNSAFE_strptr(s) __hello($cstr("STRPTR before"), ptr) __hello($cstr("REFCNT before"), __read(ptr)) __hello($cstr("STRPTR == split b =="), 0) SomeFunc(s) __hello($cstr("STRPTR after"), ptr) __hello($cstr("REFCNT after"), __read(ptr)) ptr } fn StringStuff() { var s = "Hello world" var x id = s var x_raw = $asm([], i64, "local.get $l_1_x") var s_raw = $asm([], i32, "local.get $l_0_s") var val = __WAC_id_value(x_raw) __hello($cstr("x id val"), val) __hello($cstr("s_raw"), s_raw) } fn Main() { var list = [1, 2, 3] var llen = __listlen(list) __hello($cstr("llen"), llen) StringStuff() var ptr = SomeOtherFunc() __hello($cstr("STRPTR outside"), ptr) __hello($cstr("REFCNT outside"), __read(ptr)) # OldMain() } fn OldMain() { # __print_i32(__WAC_page_count()) __print_f32(1 / 2) __print_i32(-1 >> 1) __print_i32((-1 >> 1) + 1) __print_i32((1 << 22) - (1 << 21)) __print_i32(1 << 22) if true or false { __print_cstr($cstr("true or false")) } else { __print_cstr($cstr("not true or false")) } if true and false { __print_cstr($cstr("true and false")) } else { __print_cstr($cstr("not true and false")) } __print_cstr($cstr("heap start ->")) __print_i32(__WAC_heap_start) __print_cstr($cstr("")) __print_cstr($cstr("heap mul ->")) __print_i32(5 * 7) __print_cstr($cstr("")) { __print_cstr($cstr("global var ->")) __print_i32(gvar) gvar = 82 + 5 __print_cstr($cstr("global var ->")) __print_i32(gvar) __print_cstr($cstr("")) } var x = 4 __print_i32(x) # __hello() { var x = 942 __print_cstr($cstr("Inside block, x = ")) __print_i32(x) __print_cstr($cstr("Exiting block\n")) } __print_i32(x) x = 842 __print_i32(x) { __print_cstr($cstr("\nadd4(55) -> ")) __print_i32(add4(55)) __print_cstr($cstr("")) } var cstr = $cstr("Hello world!") __print_i32(cstr) __print_cstr(cstr) __print_cstr($cstr("Hello again")) if false { __print_cstr($cstr("1 is true")) } else { __print_cstr($cstr("1 is false")) } if false { __print_cstr($cstr("1 is true XX")) } cstr = if false { $cstr("str a") } else { $cstr("str b") } __print_cstr(cstr) var total = 0 var i = 0 while i < 1000 { # __print_i32(i) i = i + 1 total = total + i } __print_cstr($cstr("total: ")) __print_i32(total) } fn add4(x i32) i32 { x + 4 }