Fast IFS using RPN notation
python
c
x86-64
nasm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rpn_mutation.h 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Copyright (C) 2020 Weber Yann
  3. *
  4. * This file is part of pyrpn.
  5. *
  6. * pyrpn is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * any later version.
  10. *
  11. * pyrpn is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with pyrpn. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __rpn_mutation__h__
  20. #define __rpn_mutation__h__
  21. #include <stddef.h>
  22. #include "rpn_jit.h"
  23. /**@defgroup mutation RPN expression mutation
  24. * @ingroup rpn
  25. */
  26. /**@file rpn_mutation.h
  27. * @brief Contains structures and function to mutate RPN epxressions
  28. */
  29. /**@brief Defines mutation actions types */
  30. enum rpn_mutation_op_e {
  31. /**@brief Mutation action : delete a token */
  32. RPN_del,
  33. /**@brief Mutation action : add a token */
  34. RPN_add,
  35. /**@brief Mutation action : change a token */
  36. RPN_chg,
  37. /**@brief Mutation action : update a token (same type, different value) */
  38. RPN_upd
  39. };
  40. /**@brief Shortcut for struct @ref rpn_mutation_profile_s */
  41. typedef struct rpn_mutation_profile_s rpn_mutation_profile_t;
  42. /**@brief Stores mutation informations
  43. * @ingroup mutation
  44. */
  45. struct rpn_mutation_profile_s
  46. {
  47. /**@brief Size of @ref rpn_mutation_profile_s::mods attribute */
  48. size_t mods_sz;
  49. /**@brief Modification possibilities
  50. *
  51. * One value is picked up randomly from this list to determine
  52. * the type of mutation : addition, deletion, modification, value change
  53. */
  54. unsigned char mods[];
  55. };
  56. /**@brief Default mutation profile */
  57. extern const rpn_mutation_profile_t rpn_default_mutprof;
  58. /**@brief Shortcut for @ref rpn_expr_mutation_p with a @ref rpn_default_mutprof
  59. * @ingroup mutation */
  60. rpn_expr_t* rpn_expr_mutation(rpn_expr_t *src, size_t mutations);
  61. /**@brief Generate a new expression by applying mutations to a source
  62. * expression
  63. * @param src Source expression
  64. * @param mutations number of mutations
  65. * @param prof Mutation profile
  66. * @return A new instance of rpn_expr_t ready to be evaluate
  67. * @ingroup mutation
  68. */
  69. rpn_expr_t* rpn_expr_mutation_p(rpn_expr_t *src, size_t mutations,
  70. const rpn_mutation_profile_t *prof);
  71. #endif