Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
disassembly_visitor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <sysio/wasm_backend/opcodes.hpp>
4#include <iostream>
5#include <variant>
6
7namespace sysio { namespace wasm_backend {
9 void print(const std::string& s) {
10 //std::string tb(tab_width, '\t');
11 std::cout << s << '\n';
12 }
13 void operator()(unreachable_t) {
14 print("unreachable");
15 }
16 void operator()(nop_t) {
17 print("nop");
18 }
19 void operator()(end_t) {
20 print("end");
21 tab_width--;
22 }
23 void operator()(return__t) {
24 print("return");
25 }
26 void operator()(block_t) {
27 print("block");
28 tab_width++;
29 }
30 void operator()(loop_t) {
31 print("loop");
32 tab_width++;
33 }
34 void operator()(if__t) {
35 print("if");
36 tab_width++;
37 }
38 void operator()(else__t) {
39 print("else");
40 }
41 void operator()(br_t b) {
42 print("br : "+std::to_string(b.data));
43 }
44 void operator()(br_if_t b) {
45 print("br.if : "+std::to_string(b.data));
46 }
47 void operator()(br_table_t b) {
48 print("br.table : "); //+std::to_string(b.data);
49 }
50 void operator()(call_t b) {
51 print("call : "+std::to_string(b.index));
52 }
53 void operator()(call_indirect_t b) {
54 print("call_indirect : "+std::to_string(b.index));
55 }
56 void operator()(drop_t b) {
57 print("drop");
58 }
59 void operator()(select_t b) {
60 print("select");
61 }
62 void operator()(get_local_t b) {
63 print("get_local : "+std::to_string(b.index));
64 }
65 void operator()(set_local_t b) {
66 print("set_local : "+std::to_string(b.index));
67 }
68 void operator()(tee_local_t b) {
69 print("tee_local : "+std::to_string(b.index));
70 }
71 void operator()(get_global_t b) {
72 print("get_global : "+std::to_string(b.index));
73 }
74 void operator()(set_global_t b) {
75 print("set_global : "+std::to_string(b.index));
76 }
77 void operator()(i32_load_t b) {
78 print("i32.load : "); //+std::to_string(b.index);
79 }
80 void operator()(i32_load8_s_t b) {
81 print("i32.load8_s : "); //+std::to_string(b.index);
82 }
83 void operator()(i32_load16_s_t b) {
84 print("i32.load16_s : "); //+std::to_string(b.index);
85 }
86 void operator()(i32_load8_u_t b) {
87 print("i32.load8_u : "); //+std::to_string(b.index);
88 }
89 void operator()(i32_load16_u_t b) {
90 print("i32.load16_u : "); //+std::to_string(b.index);
91 }
92 void operator()(i64_load_t b) {
93 print("i64.load : "); //+std::to_string(b.index);
94 }
95 void operator()(i64_load8_s_t b) {
96 print("i64.load8_s : "); //+std::to_string(b.index);
97 }
98 void operator()(i64_load16_s_t b) {
99 print("i64.load16_s : "); //+std::to_string(b.index);
100 }
101 void operator()(i64_load32_s_t b) {
102 print("i64.load32_s : "); //+std::to_string(b.index);
103 }
104 void operator()(i64_load8_u_t b) {
105 print("i64.load8_u : "); //+std::to_string(b.index);
106 }
107 void operator()(i64_load16_u_t b) {
108 print("i64.load16_u : "); //+std::to_string(b.index);
109 }
110 void operator()(i64_load32_u_t b) {
111 print("i64.load32_u : "); //+std::to_string(b.index);
112 }
113 void operator()(f32_load_t b) {
114 print("f32.load : "); //+std::to_string(b.index);
115 }
116 void operator()(f64_load_t b) {
117 print("f64.load : "); //+std::to_string(b.index);
118 }
119 void operator()(i32_store_t b) {
120 print("i32.store : "); //+std::to_string(b.index);
121 }
122 void operator()(i32_store8_t b) {
123 print("i32.store8 : "); //+std::to_string(b.index);
124 }
125 void operator()(i32_store16_t b) {
126 print("i32.store16 : "); //+std::to_string(b.index);
127 }
128 void operator()(i64_store_t b) {
129 print("i64.store : "); //+std::to_string(b.index);
130 }
131 void operator()(i64_store8_t b) {
132 print("i64.store8 : "); //+std::to_string(b.index);
133 }
134 void operator()(i64_store16_t b) {
135 print("i64.store16 : "); //+std::to_string(b.index);
136 }
137 void operator()(i64_store32_t b) {
138 print("i64.store32 : "); //+std::to_string(b.index);
139 }
140 void operator()(f32_store_t b) {
141 print("f32.store : "); //+std::to_string(b.index);
142 }
143 void operator()(f64_store_t b) {
144 print("f64.store : "); //+std::to_string(b.index);
145 }
146 void operator()(current_memory_t b) {
147 print("current_memory ");
148 }
149 void operator()(grow_memory_t b) {
150 print("grow_memory ");
151 }
152 void operator()(i32_const_t b) {
153 print("i32.const : "+std::to_string(b.data));
154 }
155 void operator()(i64_const_t b) {
156 print("i64.const : "+std::to_string(b.data));
157 }
158 void operator()(f32_const_t b) {
159 print("f32.const : "+std::to_string(*((float*)&b.data)));
160 }
161 void operator()(f64_const_t b) {
162 print("f64.const : "+std::to_string(*((double*)&b.data)));
163 }
164 void operator()(i32_eqz_t b) {
165 print("i32.eqz");
166 }
167 void operator()(i32_eq_t b) {
168 print("i32.eq");
169 }
170 void operator()(i32_ne_t b) {
171 print("i32.ne");
172 }
173 void operator()(i32_lt_s_t b) {
174 print("i32.lt_s");
175 }
176 void operator()(i32_lt_u_t b) {
177 print("i32.lt_u");
178 }
179 void operator()(i32_le_s_t b) {
180 print("i32.le_s");
181 }
182 void operator()(i32_le_u_t b) {
183 print("i32.le_u");
184 }
185 void operator()(i32_gt_s_t b) {
186 print("i32.gt_s");
187 }
188 void operator()(i32_gt_u_t b) {
189 print("i32.gt_u");
190 }
191 void operator()(i32_ge_s_t b) {
192 print("i32.ge_s");
193 }
194 void operator()(i32_ge_u_t b) {
195 print("i32.ge_u");
196 }
197 void operator()(i64_eqz_t b) {
198 print("i64.eqz");
199 }
200 void operator()(i64_eq_t b) {
201 print("i64.eq");
202 }
203 void operator()(i64_ne_t b) {
204 print("i64.ne");
205 }
206 void operator()(i64_lt_s_t b) {
207 print("i64.lt_s");
208 }
209 void operator()(i64_lt_u_t b) {
210 print("i64.lt_u");
211 }
212 void operator()(i64_le_s_t b) {
213 print("i64.le_s");
214 }
215 void operator()(i64_le_u_t b) {
216 print("i64.le_u");
217 }
218 void operator()(i64_gt_s_t b) {
219 print("i64.gt_s");
220 }
221 void operator()(i64_gt_u_t b) {
222 print("i64.gt_u");
223 }
224 void operator()(i64_ge_s_t b) {
225 print("i64.ge_s");
226 }
227 void operator()(i64_ge_u_t b) {
228 print("i64.ge_u");
229 }
230 void operator()(f32_eq_t b) {
231 print("f32.eq");
232 }
233 void operator()(f32_ne_t b) {
234 print("f32.ne");
235 }
236 void operator()(f32_lt_t b) {
237 print("f32.lt");
238 }
239 void operator()(f32_gt_t b) {
240 print("f32.gt");
241 }
242 void operator()(f32_le_t b) {
243 print("f32.le");
244 }
245 void operator()(f32_ge_t b) {
246 print("f32.ge");
247 }
248 void operator()(f64_eq_t b) {
249 print("f64.eq");
250 }
251 void operator()(f64_ne_t b) {
252 print("f64.ne");
253 }
254 void operator()(f64_lt_t b) {
255 print("f64.lt");
256 }
257 void operator()(f64_gt_t b) {
258 print("f64.gt");
259 }
260 void operator()(f64_le_t b) {
261 print("f64.le");
262 }
263 void operator()(f64_ge_t b) {
264 print("f64.ge");
265 }
266 void operator()(i32_clz_t) {
267 print("i32.clz");
268 }
269 void operator()(i32_ctz_t) {
270 print("i32.ctz");
271 }
272 void operator()(i32_popcnt_t) {
273 print("i32.popcnt");
274 }
275 void operator()(i32_add_t) {
276 print("i32.add");
277 }
278 void operator()(i32_sub_t) {
279 print("i32.sub");
280 }
281 void operator()(i32_mul_t) {
282 print("i32.mul");
283 }
284 void operator()(i32_div_s_t) {
285 print("i32.div_s");
286 }
287 void operator()(i32_div_u_t) {
288 print("i32.div_u");
289 }
290 void operator()(i32_rem_s_t) {
291 print("i32.rem_s");
292 }
293 void operator()(i32_rem_u_t) {
294 print("i32.rem_u");
295 }
296 void operator()(i32_and_t) {
297 print("i32.and");
298 }
299 void operator()(i32_or_t) {
300 print("i32.or");
301 }
302 void operator()(i32_xor_t) {
303 print("i32.xor");
304 }
305 void operator()(i32_shl_t) {
306 print("i32.shl");
307 }
308 void operator()(i32_shr_s_t) {
309 print("i32.shr_s");
310 }
311 void operator()(i32_shr_u_t) {
312 print("i32.shr_u");
313 }
314 void operator()(i32_rotl_t) {
315 print("i32.rotl");
316 }
317 void operator()(i32_rotr_t) {
318 print("i32.rotr");
319 }
320 void operator()(i64_clz_t) {
321 print("i64.clz");
322 }
323 void operator()(i64_ctz_t) {
324 print("i64.ctz");
325 }
326 void operator()(i64_popcnt_t) {
327 print("i64.popcnt");
328 }
329 void operator()(i64_add_t) {
330 print("i64.add");
331 }
332 void operator()(i64_sub_t) {
333 print("i64.sub");
334 }
335 void operator()(i64_mul_t) {
336 print("i64.mul");
337 }
338 void operator()(i64_div_s_t) {
339 print("i64.div_s");
340 }
341 void operator()(i64_div_u_t) {
342 print("i64.div_u");
343 }
344 void operator()(i64_rem_s_t) {
345 print("i64.rem_s");
346 }
347 void operator()(i64_rem_u_t) {
348 print("i64.rem_u");
349 }
350 void operator()(i64_and_t) {
351 print("i64.and");
352 }
353 void operator()(i64_or_t) {
354 print("i64.or");
355 }
356 void operator()(i64_xor_t) {
357 print("i64.xor");
358 }
359 void operator()(i64_shl_t) {
360 print("i64.shl");
361 }
362 void operator()(i64_shr_s_t) {
363 print("i64.shr_s");
364 }
365 void operator()(i64_shr_u_t) {
366 print("i64.shr_u");
367 }
368 void operator()(i64_rotl_t) {
369 print("i64.rotl");
370 }
371 void operator()(i64_rotr_t) {
372 print("i64.rotr");
373 }
374 void operator()(f32_abs_t) {
375 print("f32.abs");
376 }
377 void operator()(f32_neg_t) {
378 print("f32.neg");
379 }
380 void operator()(f32_ceil_t) {
381 print("f32.ceil");
382 }
383 void operator()(f32_floor_t) {
384 print("f32.floor");
385 }
386 void operator()(f32_trunc_t) {
387 print("f32.trunc");
388 }
389 void operator()(f32_nearest_t) {
390 print("f32.nearest");
391 }
392 void operator()(f32_sqrt_t) {
393 print("f32.sqrt");
394 }
395 void operator()(f32_add_t) {
396 print("f32.add");
397 }
398 void operator()(f32_sub_t) {
399 print("f32.sub");
400 }
401 void operator()(f32_mul_t) {
402 print("f32.mul");
403 }
404 void operator()(f32_div_t) {
405 print("f32.div");
406 }
407 void operator()(f32_min_t) {
408 print("f32.min");
409 }
410 void operator()(f32_max_t) {
411 print("f32.max");
412 }
413 void operator()(f32_copysign_t) {
414 print("f32.copysign");
415 }
416 void operator()(f64_abs_t) {
417 print("f64.abs");
418 }
419 void operator()(f64_neg_t) {
420 print("f64.neg");
421 }
422 void operator()(f64_ceil_t) {
423 print("f64.ceil");
424 }
425 void operator()(f64_floor_t) {
426 print("f64.floor");
427 }
428 void operator()(f64_trunc_t) {
429 print("f64.trunc");
430 }
431 void operator()(f64_nearest_t) {
432 print("f64.nearest");
433 }
434 void operator()(f64_sqrt_t) {
435 print("f64.sqrt");
436 }
437 void operator()(f64_add_t) {
438 print("f64.add");
439 }
440 void operator()(f64_sub_t) {
441 print("f64.sub");
442 }
443 void operator()(f64_mul_t) {
444 print("f64.mul");
445 }
446 void operator()(f64_div_t) {
447 print("f64.div");
448 }
449 void operator()(f64_min_t) {
450 print("f64.min");
451 }
452 void operator()(f64_max_t) {
453 print("f64.max");
454 }
455 void operator()(f64_copysign_t) {
456 print("f64.copysign");
457 }
458 void operator()(i32_wrap_i64_t) {
459 print("i32.wrap_i64");
460 }
461 void operator()(i32_trunc_s_f32_t) {
462 print("i32.trunc_s_f32");
463 }
464 void operator()(i32_trunc_u_f32_t) {
465 print("i32.trunc_u_f32");
466 }
467 void operator()(i32_trunc_s_f64_t) {
468 print("i32.trunc_s_f64");
469 }
470 void operator()(i32_trunc_u_f64_t) {
471 print("i32.trunc_u_f64");
472 }
473 void operator()(i64_extend_s_i32_t) {
474 print("i64.extend_s_i32");
475 }
476 void operator()(i64_extend_u_i32_t) {
477 print("i64.extend_u_i32");
478 }
479 void operator()(i64_trunc_s_f32_t) {
480 print("i64.trunc_s_f32");
481 }
482 void operator()(i64_trunc_u_f32_t) {
483 print("i64.trunc_u_f32");
484 }
485 void operator()(i64_trunc_s_f64_t) {
486 print("i64.trunc_s_f64");
487 }
488 void operator()(i64_trunc_u_f64_t) {
489 print("i64.trunc_u_f64");
490 }
491 void operator()(f32_convert_s_i32_t) {
492 print("f32.convert_s_i32");
493 }
494 void operator()(f32_convert_u_i32_t) {
495 print("f32.convert_u_i32");
496 }
497 void operator()(f32_convert_s_i64_t) {
498 print("f32.convert_s_i64");
499 }
500 void operator()(f32_convert_u_i64_t) {
501 print("f32.convert_u_i64");
502 }
503 void operator()(f32_demote_f64_t) {
504 print("f32.demote_f64");
505 }
506 void operator()(f64_convert_s_i32_t) {
507 print("f64.convert_s_i32");
508 }
509 void operator()(f64_convert_u_i32_t) {
510 print("f64.convert_u_i32");
511 }
512 void operator()(f64_convert_s_i64_t) {
513 print("f64.convert_s_i64");
514 }
515 void operator()(f64_convert_u_i64_t) {
516 print("f64.convert_u_i64");
517 }
518 void operator()(f64_promote_f32_t) {
519 print("f64.promote_f32");
520 }
521 void operator()(i32_reinterpret_f32_t) {
522 print("i32.reinterpret_f32");
523 }
524 void operator()(i64_reinterpret_f64_t) {
525 print("i64.reinterpret_f64");
526 }
527 void operator()(f32_reinterpret_i32_t) {
528 print("f32.reinterpret_i32");
529 }
530 void operator()(f64_reinterpret_i64_t) {
531 print("f64.reinterpret_i64");
532 }
533 void operator()(error_t) {
534 print("error");
535 }
536
538};
539
540}} // ns sysio::wasm_backend
unsigned int uint32_t
Definition stdint.h:126
char * s