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