Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (module
- (type $_type (func (param f32) (param f32) (result f32))) ;; we need a signature for the indirect call
- (memory 256 256)
- (table 128 anyfunc) ;; Table with function pointers
- (elem (i32.const 0) $div) ;; function pointer with index 0 points to $div function
- (func $div (param $p1 f32) (param $p2 f32) (result f32)
- (f32.div
- (get_local $p1)
- (get_local $p2)
- )
- )
- (func $div2 (param $p1 f32) (param $p2 f32) (result f32)
- (call $div
- (get_local $p1)
- (get_local $p2)
- )
- )
- (func $div2 (param $p1 f32) (param $p2 f32) (result f32)
- (call_indirect $_type ;; we need the signature of the function for validation
- (get_local $p1)
- (get_local $p2)
- (i32.const 0) ;; this is the index into the table!!
- )
- )
- (global $STACKTOP (mut i32) (i32.const 0))
- (export "testdiv" (func $div))
- (export "testdivB" (func $div2))
- )
Add Comment
Please, Sign In to add comment