test.wast 594 B

123456789101112131415161718192021222324
  1. (module
  2. (data $string_data "asdf")
  3. (func $print (import "spectest" "print_i32") (param $i i32))
  4. (memory $memory (export "memory") 1)
  5. (type $string (array (mut i8)))
  6. (type $var (struct (field (ref null $string))))
  7. (func $test (param $param (ref $var))
  8. (local.get $param)
  9. (struct.get $var 0)
  10. (ref.as_non_null)
  11. (array.len)
  12. (call $print)
  13. )
  14. (func $init
  15. (local $str (ref $string))
  16. (array.new_data $string $string_data (i32.const 0) (i32.const 4))
  17. (local.set $str)
  18. (struct.new $var (local.get $str))
  19. (call $test)
  20. )
  21. (export "_start" (func $init))
  22. )