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 3.16 1994/06/24 12:03:42 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.
14 /* classes of value */
20 int vl_class; /* Const, Name or Label */
21 arith vl_value; /* constant value or offset */
23 struct idf *vl_idf; /* external name */
24 label vl_lbl; /* compiler-generated label */
29 char *sg_value; /* row of bytes repr. the constant */
30 int sg_len; /* length of the row */
31 label sg_datlab; /* global data-label */
36 char *fl_value; /* pointer to string repr. the fp const. */
37 label fl_datlab; /* global data_label */
42 struct type *op_type; /* resulting type of the operation */
44 int op_oper; /* the symbol of the operator */
45 struct expr *op_right;
48 /* The following constants indicate the class of the expression: */
49 #define Value 0 /* it is a value known at load time */
50 #define String 1 /* it is a string constant */
52 #define Float 2 /* it is a floating point constant */
54 #define Oper 3 /* it is a run-time expression */
55 #define Type 4 /* only its type is relevant */
59 char *ex_file; /* the file it (probably) comes from */
60 unsigned int ex_line; /* the line it (probably) comes from */
67 struct value ex_value;
68 struct string ex_string;
70 struct floating ex_float;
76 /* some abbreviated selections */
77 #define EX_VALUE ex_object.ex_value
78 #define VL_CLASS EX_VALUE.vl_class
79 #define VL_VALUE EX_VALUE.vl_value
80 #define VL_IDF EX_VALUE.vl_data.vl_idf
81 #define VL_LBL EX_VALUE.vl_data.vl_lbl
82 #define SG_VALUE ex_object.ex_string.sg_value
83 #define SG_LEN ex_object.ex_string.sg_len
84 #define SG_DATLAB ex_object.ex_string.sg_datlab
86 #define FL_VALUE ex_object.ex_float.fl_value
87 #define FL_DATLAB ex_object.ex_float.fl_datlab
89 #define OP_TYPE ex_object.ex_oper.op_type
90 #define OP_LEFT ex_object.ex_oper.op_left
91 #define OP_OPER ex_object.ex_oper.op_oper
92 #define OP_RIGHT ex_object.ex_oper.op_right
94 /* some bits for the ex_flag field, to keep track of various
95 interesting properties of an expression.
97 #define EX_SIZEOF 0001 /* contains sizeof operator */
98 #define EX_CAST 0002 /* contains cast */
99 #define EX_LOGICAL 0004 /* contains logical operator */
100 #define EX_COMMA 0010 /* contains expression comma */
101 #define EX_PARENS 0020 /* the top level is parenthesized */
102 #define EX_SIDEEFFECTS 0040 /* expression has side effects */
103 #define EX_ERROR 0200 /* the expression is wrong */
105 #define NILEXPR ((struct expr *)0)
107 /* some useful tests */
108 #define ISNAME(e) ((e)->ex_class == Value && (e)->VL_CLASS == Name)
109 #define ISCOMMA(e) ((e)->ex_class == Oper && (e)->OP_OPER == INITCOMMA)
111 extern struct expr *intexpr(), *new_oper();
113 /* ALLOCDEF "expr" 20 */