Guest User

Untitled

a guest
Nov 24th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. (module
  2. (type $_type (func (param f32) (param f32) (result f32))) ;; we need a signature for the indirect call
  3. (memory 256 256)
  4.  
  5. (table 128 anyfunc) ;; Table with function pointers
  6. (elem (i32.const 0) $div) ;; function pointer with index 0 points to $div function
  7.  
  8. (func $div (param $p1 f32) (param $p2 f32) (result f32)
  9. (f32.div
  10. (get_local $p1)
  11. (get_local $p2)
  12. )
  13. )
  14.  
  15. (func $div2 (param $p1 f32) (param $p2 f32) (result f32)
  16. (call $div
  17. (get_local $p1)
  18. (get_local $p2)
  19. )
  20. )
  21.  
  22. (func $div2 (param $p1 f32) (param $p2 f32) (result f32)
  23. (call_indirect $_type ;; we need the signature of the function for validation
  24. (get_local $p1)
  25. (get_local $p2)
  26. (i32.const 0) ;; this is the index into the table!!
  27. )
  28. )
  29.  
  30. (global $STACKTOP (mut i32) (i32.const 0))
  31. (export "testdiv" (func $div))
  32. (export "testdivB" (func $div2))
  33. )
Add Comment
Please, Sign In to add comment