123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899(****************************************************************************)(* *)(* This file is part of MOPSA, a Modular Open Platform for Static Analysis. *)(* *)(* Copyright (C) 2017-2019 The MOPSA Project. *)(* *)(* This program is free software: you can redistribute it and/or modify *)(* it under the terms of the GNU Lesser General Public License as published *)(* by the Free Software Foundation, either version 3 of the License, or *)(* (at your option) any later version. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* You should have received a copy of the GNU Lesser General Public License *)(* along with this program. If not, see <http://www.gnu.org/licenses/>. *)(* *)(****************************************************************************)(** Extensible type of operators. *)openMopsa_utilsopenFormattypeoperator=..(** Basic operators *)typeoperator+=|O_eq(** == *)|O_ne(** != *)|O_lt(** < *)|O_le(** <= *)|O_gt(** > *)|O_ge(** >= *)|O_log_not(** Logical negation *)|O_log_or(** || *)|O_log_and(** && *)|O_log_xor(** xor *)|O_cast(** cast operator *)letoperator_compare_chain=TypeExt.mk_compare_chain(funo1o2->compareo1o2)letoperator_pp_chain=TypeExt.mk_print_chain(funfmtop->matchopwith|O_lt->pp_print_stringfmt"<"|O_le->pp_print_stringfmt"<="|O_gt->pp_print_stringfmt">"|O_ge->pp_print_stringfmt">="|O_eq->pp_print_stringfmt"=="|O_ne->pp_print_stringfmt"!="|O_log_or->pp_print_stringfmt"or"|O_log_and->pp_print_stringfmt"and"|O_log_not->pp_print_stringfmt"not"|O_log_xor->pp_print_stringfmt"xor"|O_cast->pp_print_stringfmt"cast"|_->Exceptions.panic"operator_pp_chain: unknown operator")letregister_operator(info:operatorTypeExt.info):unit=TypeExt.registerinfooperator_compare_chainoperator_pp_chainletregister_operator_comparecmp=TypeExt.register_comparecmpoperator_compare_chainletregister_operator_pppp=TypeExt.register_printppoperator_pp_chainletcompare_operatoro1o2=TypeExt.compareoperator_compare_chaino1o2letpp_operatorfmtoperator=TypeExt.printoperator_pp_chainfmtoperatorletis_comparison_op=function|O_eq|O_ne|O_gt|O_ge|O_lt|O_le->true|_->falseletis_logic_op=function|O_log_and|O_log_or|O_log_not|O_log_xor->true|_->falseletnegate_logic_op=function|O_log_and->O_log_or|O_log_or->O_log_and|op->Exceptions.panic"don't know how to negate operator %a"pp_operatoropletnegate_comparison_op=function|O_eq->O_ne|O_ne->O_eq|O_lt->O_ge|O_le->O_gt|O_gt->O_le|O_ge->O_lt|op->Exceptions.panic"don't know how to negate operator %a"pp_operatorop