wag 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.gitlab-ci.yml +15 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +32 -0
  6. data/.travis.yml +6 -0
  7. data/Gemfile +13 -0
  8. data/Gemfile.lock +66 -0
  9. data/LICENSE.txt +40 -0
  10. data/README.md +170 -0
  11. data/Rakefile +8 -0
  12. data/bin/console +15 -0
  13. data/bin/setup +8 -0
  14. data/lib/wag.rb +42 -0
  15. data/lib/wag/data.rb +18 -0
  16. data/lib/wag/element.rb +18 -0
  17. data/lib/wag/encodable.rb +23 -0
  18. data/lib/wag/export.rb +39 -0
  19. data/lib/wag/f32_instructions.rb +21 -0
  20. data/lib/wag/f64_instructions.rb +21 -0
  21. data/lib/wag/function.rb +33 -0
  22. data/lib/wag/function_type.rb +16 -0
  23. data/lib/wag/global.rb +18 -0
  24. data/lib/wag/global_instructions.rb +19 -0
  25. data/lib/wag/i32_instructions.rb +22 -0
  26. data/lib/wag/i64_instructions.rb +23 -0
  27. data/lib/wag/import.rb +42 -0
  28. data/lib/wag/indices.rb +14 -0
  29. data/lib/wag/indices/base.rb +16 -0
  30. data/lib/wag/indices/func.rb +8 -0
  31. data/lib/wag/indices/global.rb +8 -0
  32. data/lib/wag/indices/label.rb +8 -0
  33. data/lib/wag/indices/local.rb +8 -0
  34. data/lib/wag/indices/mem.rb +8 -0
  35. data/lib/wag/indices/table.rb +8 -0
  36. data/lib/wag/indices/type.rb +8 -0
  37. data/lib/wag/inflector.rb +13 -0
  38. data/lib/wag/instructable.rb +65 -0
  39. data/lib/wag/instruction.rb +193 -0
  40. data/lib/wag/instructions/base.rb +24 -0
  41. data/lib/wag/instructions/block.rb +21 -0
  42. data/lib/wag/instructions/br.rb +18 -0
  43. data/lib/wag/instructions/br_if.rb +18 -0
  44. data/lib/wag/instructions/br_table.rb +18 -0
  45. data/lib/wag/instructions/call.rb +18 -0
  46. data/lib/wag/instructions/call_indirect.rb +18 -0
  47. data/lib/wag/instructions/drop.rb +8 -0
  48. data/lib/wag/instructions/else.rb +9 -0
  49. data/lib/wag/instructions/end.rb +8 -0
  50. data/lib/wag/instructions/f32/abs.rb +11 -0
  51. data/lib/wag/instructions/f32/add.rb +11 -0
  52. data/lib/wag/instructions/f32/base.rb +13 -0
  53. data/lib/wag/instructions/f32/ceil.rb +11 -0
  54. data/lib/wag/instructions/f32/const.rb +20 -0
  55. data/lib/wag/instructions/f32/convert_i32_s.rb +11 -0
  56. data/lib/wag/instructions/f32/convert_i32_u.rb +11 -0
  57. data/lib/wag/instructions/f32/convert_i64_s.rb +11 -0
  58. data/lib/wag/instructions/f32/convert_i64_u.rb +11 -0
  59. data/lib/wag/instructions/f32/copysign.rb +11 -0
  60. data/lib/wag/instructions/f32/demote_f64.rb +11 -0
  61. data/lib/wag/instructions/f32/div.rb +11 -0
  62. data/lib/wag/instructions/f32/eq.rb +11 -0
  63. data/lib/wag/instructions/f32/floor.rb +11 -0
  64. data/lib/wag/instructions/f32/ge.rb +11 -0
  65. data/lib/wag/instructions/f32/gt.rb +11 -0
  66. data/lib/wag/instructions/f32/le.rb +11 -0
  67. data/lib/wag/instructions/f32/load.rb +11 -0
  68. data/lib/wag/instructions/f32/lt.rb +11 -0
  69. data/lib/wag/instructions/f32/max.rb +11 -0
  70. data/lib/wag/instructions/f32/min.rb +11 -0
  71. data/lib/wag/instructions/f32/mul.rb +11 -0
  72. data/lib/wag/instructions/f32/ne.rb +11 -0
  73. data/lib/wag/instructions/f32/nearest.rb +11 -0
  74. data/lib/wag/instructions/f32/neg.rb +11 -0
  75. data/lib/wag/instructions/f32/reinterpret_i32.rb +11 -0
  76. data/lib/wag/instructions/f32/sqrt.rb +11 -0
  77. data/lib/wag/instructions/f32/store.rb +11 -0
  78. data/lib/wag/instructions/f32/sub.rb +11 -0
  79. data/lib/wag/instructions/f32/trunc.rb +11 -0
  80. data/lib/wag/instructions/f64/abs.rb +11 -0
  81. data/lib/wag/instructions/f64/add.rb +11 -0
  82. data/lib/wag/instructions/f64/base.rb +13 -0
  83. data/lib/wag/instructions/f64/ceil.rb +11 -0
  84. data/lib/wag/instructions/f64/const.rb +20 -0
  85. data/lib/wag/instructions/f64/convert_i32_s.rb +11 -0
  86. data/lib/wag/instructions/f64/convert_i32_u.rb +11 -0
  87. data/lib/wag/instructions/f64/convert_i64_s.rb +11 -0
  88. data/lib/wag/instructions/f64/convert_i64_u.rb +11 -0
  89. data/lib/wag/instructions/f64/copysign.rb +11 -0
  90. data/lib/wag/instructions/f64/div.rb +11 -0
  91. data/lib/wag/instructions/f64/eq.rb +11 -0
  92. data/lib/wag/instructions/f64/floor.rb +11 -0
  93. data/lib/wag/instructions/f64/ge.rb +11 -0
  94. data/lib/wag/instructions/f64/gt.rb +11 -0
  95. data/lib/wag/instructions/f64/le.rb +11 -0
  96. data/lib/wag/instructions/f64/load.rb +11 -0
  97. data/lib/wag/instructions/f64/lt.rb +11 -0
  98. data/lib/wag/instructions/f64/max.rb +11 -0
  99. data/lib/wag/instructions/f64/min.rb +11 -0
  100. data/lib/wag/instructions/f64/mul.rb +11 -0
  101. data/lib/wag/instructions/f64/ne.rb +11 -0
  102. data/lib/wag/instructions/f64/nearest.rb +11 -0
  103. data/lib/wag/instructions/f64/neg.rb +11 -0
  104. data/lib/wag/instructions/f64/promote_f32.rb +11 -0
  105. data/lib/wag/instructions/f64/reinterpret_i64.rb +11 -0
  106. data/lib/wag/instructions/f64/sqrt.rb +11 -0
  107. data/lib/wag/instructions/f64/store.rb +11 -0
  108. data/lib/wag/instructions/f64/sub.rb +11 -0
  109. data/lib/wag/instructions/f64/trunc.rb +11 -0
  110. data/lib/wag/instructions/global/base.rb +13 -0
  111. data/lib/wag/instructions/global/get.rb +20 -0
  112. data/lib/wag/instructions/global/set.rb +20 -0
  113. data/lib/wag/instructions/i32/add.rb +11 -0
  114. data/lib/wag/instructions/i32/and.rb +11 -0
  115. data/lib/wag/instructions/i32/base.rb +13 -0
  116. data/lib/wag/instructions/i32/clz.rb +11 -0
  117. data/lib/wag/instructions/i32/const.rb +20 -0
  118. data/lib/wag/instructions/i32/ctz.rb +11 -0
  119. data/lib/wag/instructions/i32/div_s.rb +11 -0
  120. data/lib/wag/instructions/i32/div_u.rb +11 -0
  121. data/lib/wag/instructions/i32/eq.rb +11 -0
  122. data/lib/wag/instructions/i32/eqz.rb +11 -0
  123. data/lib/wag/instructions/i32/ge_s.rb +11 -0
  124. data/lib/wag/instructions/i32/ge_u.rb +11 -0
  125. data/lib/wag/instructions/i32/gt_s.rb +11 -0
  126. data/lib/wag/instructions/i32/gt_u.rb +11 -0
  127. data/lib/wag/instructions/i32/le_s.rb +11 -0
  128. data/lib/wag/instructions/i32/le_u.rb +11 -0
  129. data/lib/wag/instructions/i32/load.rb +11 -0
  130. data/lib/wag/instructions/i32/load16_s.rb +11 -0
  131. data/lib/wag/instructions/i32/load16_u.rb +11 -0
  132. data/lib/wag/instructions/i32/load8_s.rb +11 -0
  133. data/lib/wag/instructions/i32/load8_u.rb +11 -0
  134. data/lib/wag/instructions/i32/lt_s.rb +11 -0
  135. data/lib/wag/instructions/i32/lt_u.rb +11 -0
  136. data/lib/wag/instructions/i32/mul.rb +11 -0
  137. data/lib/wag/instructions/i32/ne.rb +11 -0
  138. data/lib/wag/instructions/i32/or.rb +11 -0
  139. data/lib/wag/instructions/i32/popcnt.rb +11 -0
  140. data/lib/wag/instructions/i32/reinterpret_f32.rb +11 -0
  141. data/lib/wag/instructions/i32/rem_s.rb +11 -0
  142. data/lib/wag/instructions/i32/rem_u.rb +11 -0
  143. data/lib/wag/instructions/i32/rotl.rb +11 -0
  144. data/lib/wag/instructions/i32/rotr.rb +11 -0
  145. data/lib/wag/instructions/i32/shl.rb +11 -0
  146. data/lib/wag/instructions/i32/shr_s.rb +11 -0
  147. data/lib/wag/instructions/i32/shr_u.rb +11 -0
  148. data/lib/wag/instructions/i32/store.rb +11 -0
  149. data/lib/wag/instructions/i32/store16.rb +11 -0
  150. data/lib/wag/instructions/i32/store8.rb +11 -0
  151. data/lib/wag/instructions/i32/sub.rb +11 -0
  152. data/lib/wag/instructions/i32/trunc_f32_s.rb +11 -0
  153. data/lib/wag/instructions/i32/trunc_f32_u.rb +11 -0
  154. data/lib/wag/instructions/i32/trunc_f64_s.rb +11 -0
  155. data/lib/wag/instructions/i32/trunc_f64_u.rb +11 -0
  156. data/lib/wag/instructions/i32/wrap_i64.rb +11 -0
  157. data/lib/wag/instructions/i32/xor.rb +11 -0
  158. data/lib/wag/instructions/i64/add.rb +11 -0
  159. data/lib/wag/instructions/i64/and.rb +11 -0
  160. data/lib/wag/instructions/i64/base.rb +13 -0
  161. data/lib/wag/instructions/i64/clz.rb +11 -0
  162. data/lib/wag/instructions/i64/const.rb +20 -0
  163. data/lib/wag/instructions/i64/ctz.rb +11 -0
  164. data/lib/wag/instructions/i64/div_s.rb +11 -0
  165. data/lib/wag/instructions/i64/div_u.rb +11 -0
  166. data/lib/wag/instructions/i64/eq.rb +11 -0
  167. data/lib/wag/instructions/i64/eqz.rb +11 -0
  168. data/lib/wag/instructions/i64/extend_i32_s.rb +11 -0
  169. data/lib/wag/instructions/i64/extend_i32_u.rb +11 -0
  170. data/lib/wag/instructions/i64/ge_s.rb +11 -0
  171. data/lib/wag/instructions/i64/ge_u.rb +11 -0
  172. data/lib/wag/instructions/i64/gt_s.rb +11 -0
  173. data/lib/wag/instructions/i64/gt_u.rb +11 -0
  174. data/lib/wag/instructions/i64/le_s.rb +11 -0
  175. data/lib/wag/instructions/i64/le_u.rb +11 -0
  176. data/lib/wag/instructions/i64/load.rb +11 -0
  177. data/lib/wag/instructions/i64/load16_s.rb +11 -0
  178. data/lib/wag/instructions/i64/load16_u.rb +11 -0
  179. data/lib/wag/instructions/i64/load32_s.rb +11 -0
  180. data/lib/wag/instructions/i64/load32_u.rb +11 -0
  181. data/lib/wag/instructions/i64/load8_s.rb +11 -0
  182. data/lib/wag/instructions/i64/load8_u.rb +11 -0
  183. data/lib/wag/instructions/i64/lt_s.rb +11 -0
  184. data/lib/wag/instructions/i64/lt_u.rb +11 -0
  185. data/lib/wag/instructions/i64/mul.rb +11 -0
  186. data/lib/wag/instructions/i64/ne.rb +11 -0
  187. data/lib/wag/instructions/i64/or.rb +11 -0
  188. data/lib/wag/instructions/i64/popcnt.rb +11 -0
  189. data/lib/wag/instructions/i64/reinterpret_f64.rb +11 -0
  190. data/lib/wag/instructions/i64/rem_s.rb +11 -0
  191. data/lib/wag/instructions/i64/rem_u.rb +11 -0
  192. data/lib/wag/instructions/i64/rotl.rb +11 -0
  193. data/lib/wag/instructions/i64/rotr.rb +11 -0
  194. data/lib/wag/instructions/i64/shl.rb +11 -0
  195. data/lib/wag/instructions/i64/shr_s.rb +11 -0
  196. data/lib/wag/instructions/i64/shr_u.rb +11 -0
  197. data/lib/wag/instructions/i64/store.rb +11 -0
  198. data/lib/wag/instructions/i64/store16.rb +11 -0
  199. data/lib/wag/instructions/i64/store32.rb +11 -0
  200. data/lib/wag/instructions/i64/store8.rb +11 -0
  201. data/lib/wag/instructions/i64/sub.rb +11 -0
  202. data/lib/wag/instructions/i64/trunc_f32_s.rb +11 -0
  203. data/lib/wag/instructions/i64/trunc_f32_u.rb +11 -0
  204. data/lib/wag/instructions/i64/trunc_f64_s.rb +11 -0
  205. data/lib/wag/instructions/i64/trunc_f64_u.rb +11 -0
  206. data/lib/wag/instructions/i64/xor.rb +11 -0
  207. data/lib/wag/instructions/if.rb +26 -0
  208. data/lib/wag/instructions/local/base.rb +13 -0
  209. data/lib/wag/instructions/local/get.rb +20 -0
  210. data/lib/wag/instructions/local/set.rb +20 -0
  211. data/lib/wag/instructions/local/tee.rb +20 -0
  212. data/lib/wag/instructions/loop.rb +9 -0
  213. data/lib/wag/instructions/memory/base.rb +13 -0
  214. data/lib/wag/instructions/memory/grow.rb +11 -0
  215. data/lib/wag/instructions/memory/size.rb +11 -0
  216. data/lib/wag/instructions/nop.rb +8 -0
  217. data/lib/wag/instructions/return.rb +9 -0
  218. data/lib/wag/instructions/select.rb +9 -0
  219. data/lib/wag/instructions/unreachable.rb +8 -0
  220. data/lib/wag/label.rb +32 -0
  221. data/lib/wag/local.rb +19 -0
  222. data/lib/wag/local_instructions.rb +19 -0
  223. data/lib/wag/memory.rb +26 -0
  224. data/lib/wag/memory_instructions.rb +19 -0
  225. data/lib/wag/module.rb +100 -0
  226. data/lib/wag/param.rb +20 -0
  227. data/lib/wag/result.rb +17 -0
  228. data/lib/wag/table.rb +17 -0
  229. data/lib/wag/then.rb +13 -0
  230. data/lib/wag/type.rb +19 -0
  231. data/lib/wag/types/base.rb +16 -0
  232. data/lib/wag/types/f32.rb +8 -0
  233. data/lib/wag/types/f64.rb +8 -0
  234. data/lib/wag/types/i32.rb +8 -0
  235. data/lib/wag/types/i64.rb +8 -0
  236. data/lib/wag/version.rb +5 -0
  237. data/lib/wag/wabt.rb +45 -0
  238. data/lib/wag/wasm.rb +22 -0
  239. data/lib/wag/wat.rb +18 -0
  240. data/wag.gemspec +35 -0
  241. metadata +299 -0
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Const < Base.instruction(0x44)
7
+ prepend WAG::Instructable
8
+ attr_reader :literal
9
+
10
+ def initialize(literal)
11
+ @literal = literal.to_f
12
+ end
13
+
14
+ def to_sexpr
15
+ [name, @literal]
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class ConvertI32S < Base.instruction(0xb7)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class ConvertI32U < Base.instruction(0xb8)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class ConvertI64S < Base.instruction(0xb9)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class ConvertI64U < Base.instruction(0xba)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Copysign < Base.instruction(0xa6)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Div < Base.instruction(0xa3)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Eq < Base.instruction(0x61)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Floor < Base.instruction(0x9c)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Ge < Base.instruction(0x66)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Gt < Base.instruction(0x64)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Le < Base.instruction(0x65)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Load < Base.instruction(0x2b)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Lt < Base.instruction(0x63)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Max < Base.instruction(0xa5)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Min < Base.instruction(0xa4)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Mul < Base.instruction(0xa2)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Ne < Base.instruction(0x62)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Nearest < Base.instruction(0x9e)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Neg < Base.instruction(0x9a)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class PromoteF32 < Base.instruction(0xbb)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class ReinterpretI64 < Base.instruction(0xbf)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Sqrt < Base.instruction(0x9f)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Store < Base.instruction(0x39)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Sub < Base.instruction(0xa1)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module F64
6
+ class Trunc < Base.instruction(0x9d)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module Global
6
+ class Base < WAG::Instruction::Base
7
+ def name
8
+ "global.#{super()}".to_sym
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module Global
6
+ class Get < Base.instruction(0x23)
7
+ prepend WAG::Instructable
8
+ attr_reader :label
9
+
10
+ def initialize(label)
11
+ @label = WAG::Label.from(label)
12
+ end
13
+
14
+ def to_sexpr
15
+ [name, label.to_sexpr]
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module Global
6
+ class Set < Base.instruction(0x24)
7
+ prepend WAG::Instructable
8
+ attr_reader :label
9
+
10
+ def initialize(label)
11
+ @label = WAG::Label.from(label)
12
+ end
13
+
14
+ def to_sexpr
15
+ [name, label.to_sexpr]
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module I32
6
+ class Add < Base.instruction(0x6a)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module I32
6
+ class And < Base.instruction(0x71)
7
+ prepend WAG::Instructable
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WAG
4
+ module Instruction
5
+ module I32
6
+ class Base < WAG::Instruction::Base
7
+ def name
8
+ "i32.#{super()}".to_sym
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end