linking1.wat 633 B

12345678910111213141516171819202122
  1. (module
  2. (import "linking2" "double" (func $double (param i32) (result i32)))
  3. (import "linking2" "log" (func $log (param i32 i32)))
  4. (import "linking2" "memory" (memory 1))
  5. (import "linking2" "memory_offset" (global $offset i32))
  6. (func (export "run")
  7. ;; Call into the other module to double our number, and we could print it
  8. ;; here but for now we just drop it
  9. i32.const 2
  10. call $double
  11. drop
  12. ;; Our `data` segment initialized our imported memory, so let's print the
  13. ;; string there now.
  14. global.get $offset
  15. i32.const 14
  16. call $log
  17. )
  18. (data (global.get $offset) "Hello, world!\n")
  19. )