hof.gwat 486 B

12345678910111213
  1. ;; Extracted from
  2. ;; <https://github.com/WebAssembly/function-references/blob/main/proposals/function-references/Overview.md>
  3. (module
  4. (type $i32-i32 (func (param i32) (result i32)))
  5. (func $hof (param $f (ref $i32-i32)) (result i32)
  6. (i32.add (i32.const 10)
  7. (call_ref $i32-i32 (i32.const 42) (local.get $f))))
  8. (func $inc (param $i i32) (result i32)
  9. (i32.add (local.get $i) (i32.const 1)))
  10. (func $caller (result i32)
  11. (call $hof (ref.func $inc))))