2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: expr.str,v 1.7 1994/06/27 07:59:44 ceriel Exp $ */
6 /* EXPRESSION DESCRIPTOR */
8 /* What we want to define is the struct expr, but since it contains
9 a union of various goodies, we define them first; so be patient.
12 /* classes of value */
18 int vl_class; /* Const, Name or Label */
19 arith vl_value; /* constant value or offset */
21 struct idf *vl_idf; /* external name */
22 label vl_lbl; /* compiler-generated label */
27 char *sg_value; /* row of bytes repr. the constant */
28 int sg_len; /* length of the row */
32 struct type *op_type; /* resulting type of the operation */
34 int op_oper; /* the symbol of the operator */
35 struct expr *op_right;
38 /* The following constants indicate the class of the expression: */
39 #define Value 0 /* it is a value known at load time */
40 #define String 1 /* it is a string constant */
41 #define Float 2 /* it is a floating point constant */
42 #define Oper 3 /* it is a run-time expression */
43 #define Type 4 /* only its type is relevant */
46 char *ex_file; /* the file it (probably) comes from */
47 unsigned int ex_line; /* the line it (probably) comes from */
54 struct value ex_value;
55 struct string ex_string;
56 flt_arith ex_fl_arith;
61 /* some abbreviated selections */
62 #define EX_VALUE ex_object.ex_value
63 #define VL_CLASS EX_VALUE.vl_class
64 #define VL_VALUE EX_VALUE.vl_value
65 #define VL_IDF EX_VALUE.vl_data.vl_idf
66 #define VL_LBL EX_VALUE.vl_data.vl_lbl
67 #define SG_VALUE ex_object.ex_string.sg_value
68 #define SG_LEN ex_object.ex_string.sg_len
69 #define FL_ARITH ex_object.ex_fl_arith
70 #define OP_TYPE ex_object.ex_oper.op_type
71 #define OP_LEFT ex_object.ex_oper.op_left
72 #define OP_OPER ex_object.ex_oper.op_oper
73 #define OP_RIGHT ex_object.ex_oper.op_right
75 /* some bits for the ex_flag field, to keep track of various
76 interesting properties of an expression.
78 #define EX_SIZEOF 0x001 /* contains sizeof operator */
79 #define EX_CAST 0x002 /* contains cast */
80 #define EX_LOGICAL 0x004 /* contains logical operator */
81 #define EX_COMMA 0x008 /* contains expression comma */
82 #define EX_PARENS 0x010 /* the top level is parenthesized */
83 #define EX_SIDEEFFECTS 0x020 /* expression has side effects */
84 #define EX_READONLY 0x040 /* read only variabele */
85 #define EX_VOLATILE 0x080 /* volatile variabele */
86 #define EX_ILVALUE 0x100 /* an illegal lvalue e.g. f().x */
87 #define EX_ERROR 0x200 /* the expression is wrong */
88 #define EX_PTRDIFF 0x400 /* subtracting 2 pointers in expr. */
90 #define NILEXPR ((struct expr *)0)
92 /* some useful tests */
93 #define ISNAME(e) ((e)->ex_class == Value && (e)->VL_CLASS == Name)
94 #define ISCOMMA(e) ((e)->ex_class == Oper && (e)->OP_OPER == INITCOMMA)
96 extern struct expr *intexpr(), *new_oper();
98 /* ALLOCDEF "expr" 20 */