Evaluation of the child nodes and return result as a variant<double, int, bool> apply arithmetic operation to the evaluations.
738 {
739 typename AVariableManager::VarVariant l_val, r_val, ret;
743 case ArithmeticOperation::PLUS:
744 if (std::holds_alternative<int>(l_val) && std::holds_alternative<int>(r_val)) {
745 ret = std::get<int>(l_val) + std::get<int>(r_val);
746 return ret;
747 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<double>(r_val)) {
748 ret = std::get<double>(l_val) + std::get<double>(r_val);
749 return ret;
750 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<int>(r_val)) {
751 ret = std::get<double>(l_val) + std::get<int>(r_val);
752 return ret;
753 } else if (std::holds_alternative<int>(l_val) && std::holds_alternative<double>(r_val)) {
754 ret = std::get<int>(l_val) + std::get<double>(r_val);
755 return ret;
756 } else {
757 throw std::runtime_error("Invalid datatypes in plus operation.");
758 }
759 break;
760 case ArithmeticOperation::MINUS:
761 if (std::holds_alternative<int>(l_val) && std::holds_alternative<int>(r_val)) {
762 ret = std::get<int>(l_val) - std::get<int>(r_val);
763 return ret;
764 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<double>(r_val)) {
765 ret = std::get<double>(l_val) - std::get<double>(r_val);
766 return ret;
767 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<int>(r_val)) {
768 ret = std::get<double>(l_val) - std::get<int>(r_val);
769 return ret;
770 } else if (std::holds_alternative<int>(l_val) && std::holds_alternative<double>(r_val)) {
771 ret = std::get<int>(l_val) - std::get<double>(r_val);
772 return ret;
773 } else {
774 throw std::runtime_error("Invalid datatypes in minus operation.");
775 }
776 break;
777 case ArithmeticOperation::PRODUCT:
778 if (std::holds_alternative<int>(l_val) && std::holds_alternative<int>(r_val)) {
779 ret = std::get<int>(l_val) * std::get<int>(r_val);
780 return ret;
781 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<double>(r_val)) {
782 ret = std::get<double>(l_val) * std::get<double>(r_val);
783 return ret;
784 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<int>(r_val)) {
785 ret = std::get<double>(l_val) * std::get<int>(r_val);
786 return ret;
787 } else if (std::holds_alternative<int>(l_val) && std::holds_alternative<double>(r_val)) {
788 ret = std::get<int>(l_val) * std::get<double>(r_val);
789 return ret;
790 } else {
791 throw std::runtime_error("Invalid datatypes in product operation.");
792 }
793 break;
794 case ArithmeticOperation::DIVISION:
795 if (std::holds_alternative<int>(l_val) && std::holds_alternative<int>(r_val)) {
796
797 double d = std::get<int>(r_val);
798 ret = std::get<int>(l_val) / d;
799 return ret;
800 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<double>(r_val)) {
801 ret = std::get<double>(l_val) / std::get<double>(r_val);
802 return ret;
803 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<int>(r_val)) {
804 ret = std::get<double>(l_val) / std::get<int>(r_val);
805 return ret;
806 } else if (std::holds_alternative<int>(l_val) && std::holds_alternative<double>(r_val)) {
807 ret = std::get<int>(l_val) / std::get<double>(r_val);
808 return ret;
809 } else {
810 throw std::runtime_error("Invalid datatypes in division operation.");
811 }
812 break;
813 case ArithmeticOperation::POWER:
814 if (std::holds_alternative<int>(l_val) && std::holds_alternative<int>(r_val)) {
815 ret = std::pow(std::get<int>(l_val), std::get<int>(r_val));
816 return ret;
817 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<double>(r_val)) {
818 ret = std::pow(std::get<double>(l_val), std::get<double>(r_val));
819 return ret;
820 } else if (std::holds_alternative<double>(l_val) && std::holds_alternative<int>(r_val)) {
821 ret = std::pow(std::get<double>(l_val), std::get<int>(r_val));
822 return ret;
823 } else if (std::holds_alternative<int>(l_val) && std::holds_alternative<double>(r_val)) {
824 ret = std::pow(std::get<int>(l_val), std::get<double>(r_val));
825 return ret;
826 } else {
827 throw std::runtime_error("Invalid datatypes in power operation.");
828 }
829 break;
830 default:
831 throw std::runtime_error("Operation not valid");
832 }
833 ret = false;
834 return ret;
835 }