expr.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* $Id$ */
  2. /* expression operators. Do not change values, as they are used as
  3. indices into arrays.
  4. */
  5. #define E_NOT 1
  6. #define E_DEREF 2
  7. #define E_AND 3
  8. #define E_OR 4
  9. #define E_DIV 5 /* equal to truncated quotient */
  10. #define E_MOD 6 /* x = (x E_DIV y) * y + x E_MOD y,
  11. 0 <= (x E_MOD y) < y
  12. */
  13. #define E_ZDIV 7 /* quotient rounded to 0 */
  14. #define E_ZMOD 8 /* remainder of E_ZDIV */
  15. #define E_IN 9 /* set membership */
  16. #define E_ARRAY 10
  17. #define E_PLUS 11
  18. #define E_MIN 12
  19. #define E_MUL 13
  20. #define E_EQUAL 14
  21. #define E_NOTEQUAL 15
  22. #define E_LTEQUAL 16
  23. #define E_GTEQUAL 17
  24. #define E_LT 18
  25. #define E_GT 19
  26. #define E_SELECT 20
  27. #define E_BAND 21 /* bitwise and */
  28. #define E_BOR 22 /* bitwise or */
  29. #define E_BXOR 23
  30. #define E_BNOT 24
  31. #define E_DERSELECT 25 /* -> in C */
  32. #define E_LSFT 26
  33. #define E_RSFT 27
  34. #define E_ADDR 28
  35. /* long get_int(char *buf, long size, int class)
  36. Returns the value of size 'size', residing in 'buf', of 'class'
  37. T_INTEGER, T_UNSIGNED, or T_ENUM.
  38. */
  39. extern long get_int();
  40. /* int put_int(char *buf, long size, long value)
  41. Stores the value 'value' of size 'size' in 'buf'.
  42. */
  43. extern int put_int();
  44. /* double get_real(char *buf, long size)
  45. Returns the real value of size 'size', residing in 'buf'.
  46. T_INTEGER, T_UNSIGNED, or T_ENUM.
  47. */
  48. extern double get_real();
  49. /* int put_real(char *buf, long size, double value)
  50. Stores the value 'value' of size 'size' in 'buf'.
  51. */
  52. extern int put_real();
  53. /* int eval_cond(p_tree p)
  54. This routine evaluates the conditional expression indicated by p
  55. and returns 1 if it evaluates to TRUE, or 0 if it could not be
  56. evaluated for some reason or if it evalutes to FALSE.
  57. If the expression cannot be evaluated, an error message is given.
  58. */
  59. extern int eval_cond();
  60. /* int eval_desig(p_tree p, t_addr *pbuf, long **psize, p_type *ptp)
  61. This routine evaluates the expression indicated by p, which should
  62. result in a designator. The result of the expression is an address
  63. which is to be found in *pbuf. *psize will contain the size of the
  64. designated object, and *ptp its type.
  65. If the expression cannot be evaluated or does not result in a
  66. designator, 0 is returned and an error message is given.
  67. Otherwise, 1 is returned.
  68. */
  69. extern int eval_desig();
  70. /* int eval_expr(p_tree p, char **pbuf, long **psize, p_type *ptp)
  71. This routine evaluates the expression indicated by p.
  72. The result of the expression is left in *pbuf.
  73. *psize will contain the size of the value, and *ptp its type.
  74. If the expression cannot be evaluated, 0 is returned and an error
  75. message is given. Otherwise, 1 is returned.
  76. */
  77. extern int eval_expr();
  78. /* int convert(char **pbuf, long *psize, p_type *ptp, p_type tp, long size)
  79. This routine tries to convert the value in pbuf of size psize
  80. and type ptp to type tp with size size. It returns 0 if this fails,
  81. while producing an error message. Otherwise, it returns 1 and
  82. the resulting value, type and size are left in pbuf, ptp, and
  83. psize, respectively.
  84. */
  85. extern int convert();