@@ -432,15 +432,25 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
432432 }
433433
434434 fn visit_i32_eqz ( & mut self ) -> Self :: Output {
435- todo ! ( )
435+ bail_unreachable ! ( self ) ;
436+ self . stack . push_immediate ( 0_i32 ) ?;
437+ self . visit_i32_eq ( )
436438 }
437439
438440 fn visit_i32_eq ( & mut self ) -> Self :: Output {
439- todo ! ( )
441+ self . translate_binary_commutative :: < i32 , bool > (
442+ Instruction :: i32_eq,
443+ Instruction :: i32_eq_imm16,
444+ wasm:: i32_eq,
445+ )
440446 }
441447
442448 fn visit_i32_ne ( & mut self ) -> Self :: Output {
443- todo ! ( )
449+ self . translate_binary_commutative :: < i32 , bool > (
450+ Instruction :: i32_ne,
451+ Instruction :: i32_ne_imm16,
452+ wasm:: i32_ne,
453+ )
444454 }
445455
446456 fn visit_i32_lt_s ( & mut self ) -> Self :: Output {
@@ -476,15 +486,25 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
476486 }
477487
478488 fn visit_i64_eqz ( & mut self ) -> Self :: Output {
479- todo ! ( )
489+ bail_unreachable ! ( self ) ;
490+ self . stack . push_immediate ( 0_i64 ) ?;
491+ self . visit_i64_eq ( )
480492 }
481493
482494 fn visit_i64_eq ( & mut self ) -> Self :: Output {
483- todo ! ( )
495+ self . translate_binary_commutative :: < i64 , bool > (
496+ Instruction :: i64_eq,
497+ Instruction :: i64_eq_imm16,
498+ wasm:: i64_eq,
499+ )
484500 }
485501
486502 fn visit_i64_ne ( & mut self ) -> Self :: Output {
487- todo ! ( )
503+ self . translate_binary_commutative :: < i64 , bool > (
504+ Instruction :: i64_ne,
505+ Instruction :: i64_ne_imm16,
506+ wasm:: i64_ne,
507+ )
488508 }
489509
490510 fn visit_i64_lt_s ( & mut self ) -> Self :: Output {
@@ -592,7 +612,11 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
592612 }
593613
594614 fn visit_i32_mul ( & mut self ) -> Self :: Output {
595- todo ! ( )
615+ self . translate_binary_commutative :: < i32 , i32 > (
616+ Instruction :: i32_mul,
617+ Instruction :: i32_mul_imm16,
618+ wasm:: i32_mul,
619+ )
596620 }
597621
598622 fn visit_i32_div_s ( & mut self ) -> Self :: Output {
@@ -612,15 +636,27 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
612636 }
613637
614638 fn visit_i32_and ( & mut self ) -> Self :: Output {
615- todo ! ( )
639+ self . translate_binary_commutative :: < i32 , i32 > (
640+ Instruction :: i32_and,
641+ Instruction :: i32_and_imm16,
642+ wasm:: i32_bitand,
643+ )
616644 }
617645
618646 fn visit_i32_or ( & mut self ) -> Self :: Output {
619- todo ! ( )
647+ self . translate_binary_commutative :: < i32 , i32 > (
648+ Instruction :: i32_or,
649+ Instruction :: i32_or_imm16,
650+ wasm:: i32_bitor,
651+ )
620652 }
621653
622654 fn visit_i32_xor ( & mut self ) -> Self :: Output {
623- todo ! ( )
655+ self . translate_binary_commutative :: < i32 , i32 > (
656+ Instruction :: i32_xor,
657+ Instruction :: i32_xor_imm16,
658+ wasm:: i32_bitxor,
659+ )
624660 }
625661
626662 fn visit_i32_shl ( & mut self ) -> Self :: Output {
@@ -656,15 +692,23 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
656692 }
657693
658694 fn visit_i64_add ( & mut self ) -> Self :: Output {
659- todo ! ( )
695+ self . translate_binary_commutative :: < i64 , i64 > (
696+ Instruction :: i64_add,
697+ Instruction :: i64_add_imm16,
698+ wasm:: i64_add,
699+ )
660700 }
661701
662702 fn visit_i64_sub ( & mut self ) -> Self :: Output {
663703 todo ! ( )
664704 }
665705
666706 fn visit_i64_mul ( & mut self ) -> Self :: Output {
667- todo ! ( )
707+ self . translate_binary_commutative :: < i64 , i64 > (
708+ Instruction :: i64_mul,
709+ Instruction :: i64_mul_imm16,
710+ wasm:: i64_mul,
711+ )
668712 }
669713
670714 fn visit_i64_div_s ( & mut self ) -> Self :: Output {
@@ -684,15 +728,27 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
684728 }
685729
686730 fn visit_i64_and ( & mut self ) -> Self :: Output {
687- todo ! ( )
731+ self . translate_binary_commutative :: < i64 , i64 > (
732+ Instruction :: i64_and,
733+ Instruction :: i64_and_imm16,
734+ wasm:: i64_bitand,
735+ )
688736 }
689737
690738 fn visit_i64_or ( & mut self ) -> Self :: Output {
691- todo ! ( )
739+ self . translate_binary_commutative :: < i64 , i64 > (
740+ Instruction :: i64_or,
741+ Instruction :: i64_or_imm16,
742+ wasm:: i64_bitor,
743+ )
692744 }
693745
694746 fn visit_i64_xor ( & mut self ) -> Self :: Output {
695- todo ! ( )
747+ self . translate_binary_commutative :: < i64 , i64 > (
748+ Instruction :: i64_xor,
749+ Instruction :: i64_xor_imm16,
750+ wasm:: i64_bitxor,
751+ )
696752 }
697753
698754 fn visit_i64_shl ( & mut self ) -> Self :: Output {
0 commit comments