table_imports.wast 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ;;-------------------------------------------------------------------------------------------------------
  2. ;; Copyright (C) Microsoft. All rights reserved.
  3. ;; Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. ;;-------------------------------------------------------------------------------------------------------
  5. (module
  6. (type $binopI32 (func (param i32 i32) (result i32)))
  7. (type $binopI64 (func (param i64 i64) (result i64)))
  8. (type $binopF32 (func (param f32 f32) (result f32)))
  9. (type $binopF64 (func (param f64 f64) (result f64)))
  10. (import "math" "addI32" (func $_addI32 (type $binopI32)))
  11. (import "math" "addI64" (func $_addI64 (type $binopI64)))
  12. (import "math" "addF32" (func $_addF32 (type $binopF32)))
  13. (import "math" "addF64" (func $_addF64 (type $binopF64)))
  14. (func $addI32 (export "addI32") (type $binopI32)
  15. (return (i32.add (get_local 0) (get_local 1)))
  16. )
  17. (func $addI64 (export "addI64") (type $binopI64)
  18. (return (i64.add (get_local 0) (get_local 1)))
  19. )
  20. (func $addF32 (export "addF32") (type $binopF32)
  21. (return (f32.add (get_local 0) (get_local 1)))
  22. )
  23. (func $addF64 (export "addF64") (type $binopF64)
  24. (return (f64.add (get_local 0) (get_local 1)))
  25. )
  26. (func (export "binopI32") (param i32 i32 i32) (result i32)
  27. (call_indirect (type $binopI32) (get_local 0) (get_local 1) (get_local 2))
  28. )
  29. (func (export "binopI64") (param i64 i64 i32) (result i64)
  30. (call_indirect (type $binopI64) (get_local 0) (get_local 1) (get_local 2))
  31. )
  32. (func (export "binopF32") (param f32 f32 i32) (result f32)
  33. (call_indirect (type $binopF32) (get_local 0) (get_local 1) (get_local 2))
  34. )
  35. (func (export "binopF64") (param f64 f64 i32) (result f64)
  36. (call_indirect (type $binopF64) (get_local 0) (get_local 1) (get_local 2))
  37. )
  38. (table anyfunc (elem
  39. $addI32 $_addI32
  40. $addI64 $_addI64
  41. $addF32 $_addF32
  42. $addF64 $_addF64
  43. ))
  44. )