signatures.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. function sign(input, output) {
  2. return [input, output];
  3. }
  4. var u32 = "u32";
  5. var i32 = "i32";
  6. var i64 = "i64";
  7. var f32 = "f32";
  8. var f64 = "f64";
  9. var vector = function vector(t) {
  10. var vecType = [t]; // $FlowIgnore
  11. vecType.vector = true;
  12. return vecType;
  13. };
  14. var controlInstructions = {
  15. unreachable: sign([], []),
  16. nop: sign([], []),
  17. // block ?
  18. // loop ?
  19. // if ?
  20. // if else ?
  21. br: sign([u32], []),
  22. br_if: sign([u32], []),
  23. br_table: sign(vector(u32), []),
  24. return: sign([], []),
  25. call: sign([u32], []),
  26. call_indirect: sign([u32], [])
  27. };
  28. var parametricInstructions = {
  29. drop: sign([], []),
  30. select: sign([], [])
  31. };
  32. var variableInstructions = {
  33. get_local: sign([u32], []),
  34. set_local: sign([u32], []),
  35. tee_local: sign([u32], []),
  36. get_global: sign([u32], []),
  37. set_global: sign([u32], [])
  38. };
  39. var memoryInstructions = {
  40. "i32.load": sign([u32, u32], [i32]),
  41. "i64.load": sign([u32, u32], []),
  42. "f32.load": sign([u32, u32], []),
  43. "f64.load": sign([u32, u32], []),
  44. "i32.load8_s": sign([u32, u32], [i32]),
  45. "i32.load8_u": sign([u32, u32], [i32]),
  46. "i32.load16_s": sign([u32, u32], [i32]),
  47. "i32.load16_u": sign([u32, u32], [i32]),
  48. "i64.load8_s": sign([u32, u32], [i64]),
  49. "i64.load8_u": sign([u32, u32], [i64]),
  50. "i64.load16_s": sign([u32, u32], [i64]),
  51. "i64.load16_u": sign([u32, u32], [i64]),
  52. "i64.load32_s": sign([u32, u32], [i64]),
  53. "i64.load32_u": sign([u32, u32], [i64]),
  54. "i32.store": sign([u32, u32], []),
  55. "i64.store": sign([u32, u32], []),
  56. "f32.store": sign([u32, u32], []),
  57. "f64.store": sign([u32, u32], []),
  58. "i32.store8": sign([u32, u32], []),
  59. "i32.store16": sign([u32, u32], []),
  60. "i64.store8": sign([u32, u32], []),
  61. "i64.store16": sign([u32, u32], []),
  62. "i64.store32": sign([u32, u32], []),
  63. current_memory: sign([], []),
  64. grow_memory: sign([], [])
  65. };
  66. var numericInstructions = {
  67. "i32.const": sign([i32], [i32]),
  68. "i64.const": sign([i64], [i64]),
  69. "f32.const": sign([f32], [f32]),
  70. "f64.const": sign([f64], [f64]),
  71. "i32.eqz": sign([i32], [i32]),
  72. "i32.eq": sign([i32, i32], [i32]),
  73. "i32.ne": sign([i32, i32], [i32]),
  74. "i32.lt_s": sign([i32, i32], [i32]),
  75. "i32.lt_u": sign([i32, i32], [i32]),
  76. "i32.gt_s": sign([i32, i32], [i32]),
  77. "i32.gt_u": sign([i32, i32], [i32]),
  78. "i32.le_s": sign([i32, i32], [i32]),
  79. "i32.le_u": sign([i32, i32], [i32]),
  80. "i32.ge_s": sign([i32, i32], [i32]),
  81. "i32.ge_u": sign([i32, i32], [i32]),
  82. "i64.eqz": sign([i64], [i64]),
  83. "i64.eq": sign([i64, i64], [i32]),
  84. "i64.ne": sign([i64, i64], [i32]),
  85. "i64.lt_s": sign([i64, i64], [i32]),
  86. "i64.lt_u": sign([i64, i64], [i32]),
  87. "i64.gt_s": sign([i64, i64], [i32]),
  88. "i64.gt_u": sign([i64, i64], [i32]),
  89. "i64.le_s": sign([i64, i64], [i32]),
  90. "i64.le_u": sign([i64, i64], [i32]),
  91. "i64.ge_s": sign([i64, i64], [i32]),
  92. "i64.ge_u": sign([i64, i64], [i32]),
  93. "f32.eq": sign([f32, f32], [i32]),
  94. "f32.ne": sign([f32, f32], [i32]),
  95. "f32.lt": sign([f32, f32], [i32]),
  96. "f32.gt": sign([f32, f32], [i32]),
  97. "f32.le": sign([f32, f32], [i32]),
  98. "f32.ge": sign([f32, f32], [i32]),
  99. "f64.eq": sign([f64, f64], [i32]),
  100. "f64.ne": sign([f64, f64], [i32]),
  101. "f64.lt": sign([f64, f64], [i32]),
  102. "f64.gt": sign([f64, f64], [i32]),
  103. "f64.le": sign([f64, f64], [i32]),
  104. "f64.ge": sign([f64, f64], [i32]),
  105. "i32.clz": sign([i32], [i32]),
  106. "i32.ctz": sign([i32], [i32]),
  107. "i32.popcnt": sign([i32], [i32]),
  108. "i32.add": sign([i32, i32], [i32]),
  109. "i32.sub": sign([i32, i32], [i32]),
  110. "i32.mul": sign([i32, i32], [i32]),
  111. "i32.div_s": sign([i32, i32], [i32]),
  112. "i32.div_u": sign([i32, i32], [i32]),
  113. "i32.rem_s": sign([i32, i32], [i32]),
  114. "i32.rem_u": sign([i32, i32], [i32]),
  115. "i32.and": sign([i32, i32], [i32]),
  116. "i32.or": sign([i32, i32], [i32]),
  117. "i32.xor": sign([i32, i32], [i32]),
  118. "i32.shl": sign([i32, i32], [i32]),
  119. "i32.shr_s": sign([i32, i32], [i32]),
  120. "i32.shr_u": sign([i32, i32], [i32]),
  121. "i32.rotl": sign([i32, i32], [i32]),
  122. "i32.rotr": sign([i32, i32], [i32]),
  123. "i64.clz": sign([i64], [i64]),
  124. "i64.ctz": sign([i64], [i64]),
  125. "i64.popcnt": sign([i64], [i64]),
  126. "i64.add": sign([i64, i64], [i64]),
  127. "i64.sub": sign([i64, i64], [i64]),
  128. "i64.mul": sign([i64, i64], [i64]),
  129. "i64.div_s": sign([i64, i64], [i64]),
  130. "i64.div_u": sign([i64, i64], [i64]),
  131. "i64.rem_s": sign([i64, i64], [i64]),
  132. "i64.rem_u": sign([i64, i64], [i64]),
  133. "i64.and": sign([i64, i64], [i64]),
  134. "i64.or": sign([i64, i64], [i64]),
  135. "i64.xor": sign([i64, i64], [i64]),
  136. "i64.shl": sign([i64, i64], [i64]),
  137. "i64.shr_s": sign([i64, i64], [i64]),
  138. "i64.shr_u": sign([i64, i64], [i64]),
  139. "i64.rotl": sign([i64, i64], [i64]),
  140. "i64.rotr": sign([i64, i64], [i64]),
  141. "f32.abs": sign([f32], [f32]),
  142. "f32.neg": sign([f32], [f32]),
  143. "f32.ceil": sign([f32], [f32]),
  144. "f32.floor": sign([f32], [f32]),
  145. "f32.trunc": sign([f32], [f32]),
  146. "f32.nearest": sign([f32], [f32]),
  147. "f32.sqrt": sign([f32], [f32]),
  148. "f32.add": sign([f32, f32], [f32]),
  149. "f32.sub": sign([f32, f32], [f32]),
  150. "f32.mul": sign([f32, f32], [f32]),
  151. "f32.div": sign([f32, f32], [f32]),
  152. "f32.min": sign([f32, f32], [f32]),
  153. "f32.max": sign([f32, f32], [f32]),
  154. "f32.copysign": sign([f32, f32], [f32]),
  155. "f64.abs": sign([f64], [f64]),
  156. "f64.neg": sign([f64], [f64]),
  157. "f64.ceil": sign([f64], [f64]),
  158. "f64.floor": sign([f64], [f64]),
  159. "f64.trunc": sign([f64], [f64]),
  160. "f64.nearest": sign([f64], [f64]),
  161. "f64.sqrt": sign([f64], [f64]),
  162. "f64.add": sign([f64, f64], [f64]),
  163. "f64.sub": sign([f64, f64], [f64]),
  164. "f64.mul": sign([f64, f64], [f64]),
  165. "f64.div": sign([f64, f64], [f64]),
  166. "f64.min": sign([f64, f64], [f64]),
  167. "f64.max": sign([f64, f64], [f64]),
  168. "f64.copysign": sign([f64, f64], [f64]),
  169. "i32.wrap/i64": sign([i64], [i32]),
  170. "i32.trunc_s/f32": sign([f32], [i32]),
  171. "i32.trunc_u/f32": sign([f32], [i32]),
  172. "i32.trunc_s/f64": sign([f32], [i32]),
  173. "i32.trunc_u/f64": sign([f64], [i32]),
  174. "i64.extend_s/i32": sign([i32], [i64]),
  175. "i64.extend_u/i32": sign([i32], [i64]),
  176. "i64.trunc_s/f32": sign([f32], [i64]),
  177. "i64.trunc_u/f32": sign([f32], [i64]),
  178. "i64.trunc_s/f64": sign([f64], [i64]),
  179. "i64.trunc_u/f64": sign([f64], [i64]),
  180. "f32.convert_s/i32": sign([i32], [f32]),
  181. "f32.convert_u/i32": sign([i32], [f32]),
  182. "f32.convert_s/i64": sign([i64], [f32]),
  183. "f32.convert_u/i64": sign([i64], [f32]),
  184. "f32.demote/f64": sign([f64], [f32]),
  185. "f64.convert_s/i32": sign([i32], [f64]),
  186. "f64.convert_u/i32": sign([i32], [f64]),
  187. "f64.convert_s/i64": sign([i64], [f64]),
  188. "f64.convert_u/i64": sign([i64], [f64]),
  189. "f64.promote/f32": sign([f32], [f64]),
  190. "i32.reinterpret/f32": sign([f32], [i32]),
  191. "i64.reinterpret/f64": sign([f64], [i64]),
  192. "f32.reinterpret/i32": sign([i32], [f32]),
  193. "f64.reinterpret/i64": sign([i64], [f64])
  194. };
  195. export var signatures = Object.assign({}, controlInstructions, parametricInstructions, variableInstructions, memoryInstructions, numericInstructions);