1 /* Definitions for expressions stored in reversed prefix form, for GDB.
2 Copyright (C) 1986 Free Software Foundation, Inc.
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
21 /* Definitions for saved C expressions. */
23 /* An expression is represented as a vector of union exp_element's.
24 Each exp_element is an opcode, except that some opcodes cause
25 the following exp_element to be treated as a long or double constant
26 or as a variable. The opcodes are obeyed, using a stack for temporaries.
27 The value is left on the temporary stack at the end. */
29 /* When it is necessary to include a string,
30 it can occupy as many exp_elements as it needs.
31 We find the length of the string using strlen,
32 divide to find out how many exp_elements are used up,
33 and skip that many. Strings, like numbers, are indicated
34 by the preceding opcode. */
38 /* BINOP_... operate on two values computed by following subexpressions,
39 replacing them by one result value. They take no immediate arguments. */
53 BINOP_NOTEQUAL, /* != */
61 BINOP_SUBSCRIPT, /* x[y] */
62 BINOP_EXP, /* Exponentiation */
65 BINOP_ASSIGN_MODIFY, /* +=, -=, *=, and so on.
66 The following exp_element is another opcode,
67 a BINOP_, saying how to modify.
68 Then comes another BINOP_ASSIGN_MODIFY,
69 making three exp_elements in total. */
71 /* Operates on three values computed by following subexpressions. */
74 /* The OP_... series take immediate following arguments.
75 After the arguments come another OP_... (the same one)
76 so that the grouping can be recognized from the end. */
78 /* OP_LONG is followed by a type pointer in the next exp_element
79 and the long constant value in the following exp_element.
80 Then comes another OP_LONG.
81 Thus, the operation occupies four exp_elements. */
84 /* OP_DOUBLE is similar but takes a double constant instead of a long one. */
86 /* OP_VAR_VALUE takes one struct symbol * in the following exp_element,
87 followed by another OP_VAR_VALUE, making three exp_elements. */
89 /* OP_LAST is followed by an integer in the next exp_element.
90 The integer is zero for the last value printed,
91 or it is the absolute number of a history element.
92 With another OP_LAST at the end, this makes three exp_elements. */
94 /* OP_REGISTER is followed by an integer in the next exp_element.
95 This is the number of a register to fetch (as an int).
96 With another OP_REGISTER at the end, this makes three exp_elements. */
98 /* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element.
99 With another OP_INTERNALVAR at the end, this makes three exp_elements. */
101 /* OP_FUNCALL is followed by an integer in the next exp_element.
102 The integer is the number of args to the function call.
103 That many plus one values from following subexpressions
104 are used, the first one being the function.
105 The integer is followed by a repeat of OP_FUNCALL,
106 making three exp_elements. */
108 /* OP_STRING represents a string constant.
109 Its format is the same as that of a STRUCTOP, but the string
110 data is just made into a string constant when the operation
114 /* UNOP_CAST is followed by a type pointer in the next exp_element.
115 With another UNOP_CAST at the end, this makes three exp_elements.
116 It casts the value of the following subexpression. */
118 /* UNOP_MEMVAL is followed by a type pointer in the next exp_element
119 With another UNOP_MEMVAL at the end, this makes three exp_elements.
120 It casts the contents of the word addressed by the value of the
121 following subexpression. */
123 /* UNOP_... operate on one value from a following subexpression
124 and replace it with a result. They take no immediate arguments. */
125 UNOP_NEG, /* Unary - */
126 UNOP_ZEROP, /* Unary ! */
127 UNOP_LOGNOT, /* Unary ~ */
128 UNOP_IND, /* Unary * */
129 UNOP_ADDR, /* Unary & */
130 UNOP_PREINCREMENT, /* ++ before an expression */
131 UNOP_POSTINCREMENT, /* ++ after an expression */
132 UNOP_PREDECREMENT, /* -- before an expression */
133 UNOP_POSTDECREMENT, /* -- after an expression */
134 UNOP_SIZEOF, /* Unary sizeof (followed by expression) */
136 /* STRUCTOP_... operate on a value from a following subexpression
137 by extracting a structure component specified by a string
138 that appears in the following exp_elements (as many as needed).
139 STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->".
140 They differ only in the error message given in case the value is
141 not suitable or the structure component specified is not found.
143 The length of the string follows in the next exp_element,
144 (after the string), followed by another STRUCTOP_... code. */
151 enum exp_opcode opcode;
152 struct symbol *symbol;
157 struct internalvar *internalvar;
163 union exp_element elts[1];
166 struct expression *parse_c_expression ();
167 struct expression *parse_c_1 ();