wa-lang.org/wazero@v1.0.2/experimental/logging/testdata/listener.wat (about)

     1  (module $listener
     2    (import "wasi_snapshot_preview1" "random_get"
     3      (func $wasi.random_get (param $buf i32) (param $buf_len i32) (result (;errno;) i32)))
     4  
     5    (table 8 funcref) ;; Define a function table with a single element at index 3.
     6    (elem (i32.const 3) $wasi.random_get)
     7  
     8    (memory 1 1) ;; Memory is needed for WASI
     9  
    10    (func $wasi_rand (param $len i32)
    11      i32.const 4 local.get 0 ;; buf, buf_len
    12      call $wasi.random_get
    13      drop ;; errno
    14  
    15      i32.const 8 local.get 0 ;; buf, buf_len
    16      i32.const 3 call_indirect (type 0) ;; element 3, func type 0
    17      drop ;; errno
    18    )
    19  
    20    (func $rand (export "rand") (param $len i32)
    21      local.get 0 ;; buf_len
    22      call $wasi_rand
    23    )
    24  )