1 /* Definitions for expressions stored in reversed prefix form, for GDB.
2 Copyright 1986, 1989, 1992 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 #if !defined (EXPRESSION_H)
21 #define EXPRESSION_H 1
23 /* Definitions for saved C expressions. */
25 /* An expression is represented as a vector of union exp_element's.
26 Each exp_element is an opcode, except that some opcodes cause
27 the following exp_element to be treated as a long or double constant
28 or as a variable. The opcodes are obeyed, using a stack for temporaries.
29 The value is left on the temporary stack at the end. */
31 /* When it is necessary to include a string,
32 it can occupy as many exp_elements as it needs.
33 We find the length of the string using strlen,
34 divide to find out how many exp_elements are used up,
35 and skip that many. Strings, like numbers, are indicated
36 by the preceding opcode. */
40 /* Used when it's necessary to pass an opcode which will be ignored,
41 or to catch uninitialized values. */
44 /* BINOP_... operate on two values computed by following subexpressions,
45 replacing them by one result value. They take no immediate arguments. */
59 BINOP_NOTEQUAL, /* != */
67 BINOP_SUBSCRIPT, /* x[y] */
68 BINOP_MULTI_SUBSCRIPT, /* Modula-2 x[a,b,...] */
69 BINOP_EXP, /* Exponentiation */
76 /* STRUCTOP_MEMBER is used for pointer-to-member constructs.
77 X . * Y translates into X STRUCTOP_MEMBER Y. */
79 /* STRUCTOP_MPTR is used for pointer-to-member constructs
80 when X is a pointer instead of an aggregate. */
84 /* For Modula-2 integer division DIV */
87 BINOP_ASSIGN_MODIFY, /* +=, -=, *=, and so on.
88 The following exp_element is another opcode,
89 a BINOP_, saying how to modify.
90 Then comes another BINOP_ASSIGN_MODIFY,
91 making three exp_elements in total. */
93 /* Modula-2 standard (binary) procedures*/
98 /* This must be the highest BINOP_ value, for expprint.c. */
101 /* Operates on three values computed by following subexpressions. */
102 TERNOP_COND, /* ?: */
104 /* The OP_... series take immediate following arguments.
105 After the arguments come another OP_... (the same one)
106 so that the grouping can be recognized from the end. */
108 /* OP_LONG is followed by a type pointer in the next exp_element
109 and the long constant value in the following exp_element.
110 Then comes another OP_LONG.
111 Thus, the operation occupies four exp_elements. */
114 /* OP_DOUBLE is similar but takes a double constant instead of a long one. */
116 /* OP_VAR_VALUE takes one struct symbol * in the following exp_element,
117 followed by another OP_VAR_VALUE, making three exp_elements. */
119 /* OP_LAST is followed by an integer in the next exp_element.
120 The integer is zero for the last value printed,
121 or it is the absolute number of a history element.
122 With another OP_LAST at the end, this makes three exp_elements. */
124 /* OP_REGISTER is followed by an integer in the next exp_element.
125 This is the number of a register to fetch (as an int).
126 With another OP_REGISTER at the end, this makes three exp_elements. */
128 /* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element.
129 With another OP_INTERNALVAR at the end, this makes three exp_elements. */
131 /* OP_FUNCALL is followed by an integer in the next exp_element.
132 The integer is the number of args to the function call.
133 That many plus one values from following subexpressions
134 are used, the first one being the function.
135 The integer is followed by a repeat of OP_FUNCALL,
136 making three exp_elements. */
138 /* OP_STRING represents a string constant.
139 Its format is the same as that of a STRUCTOP, but the string
140 data is just made into a string constant when the operation
144 /* UNOP_CAST is followed by a type pointer in the next exp_element.
145 With another UNOP_CAST at the end, this makes three exp_elements.
146 It casts the value of the following subexpression. */
148 /* UNOP_MEMVAL is followed by a type pointer in the next exp_element
149 With another UNOP_MEMVAL at the end, this makes three exp_elements.
150 It casts the contents of the word addressed by the value of the
151 following subexpression. */
153 /* UNOP_... operate on one value from a following subexpression
154 and replace it with a result. They take no immediate arguments. */
155 UNOP_NEG, /* Unary - */
156 UNOP_ZEROP, /* Unary ! */
157 UNOP_LOGNOT, /* Unary ~ */
158 UNOP_IND, /* Unary * */
159 UNOP_ADDR, /* Unary & */
160 UNOP_PREINCREMENT, /* ++ before an expression */
161 UNOP_POSTINCREMENT, /* ++ after an expression */
162 UNOP_PREDECREMENT, /* -- before an expression */
163 UNOP_POSTDECREMENT, /* -- after an expression */
164 UNOP_SIZEOF, /* Unary sizeof (followed by expression) */
166 UNOP_PLUS, /* Unary plus */
168 UNOP_CAP, /* Modula-2 standard (unary) procedures */
179 OP_BOOL, /* Modula-2 builtin BOOLEAN type */
180 OP_M2_STRING, /* Modula-2 string constants */
182 /* STRUCTOP_... operate on a value from a following subexpression
183 by extracting a structure component specified by a string
184 that appears in the following exp_elements (as many as needed).
185 STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->".
186 They differ only in the error message given in case the value is
187 not suitable or the structure component specified is not found.
189 After the sub-expression and before the string is a (struct type*).
190 This is normally NULL, but is used for the TYPE in a C++ qualified
191 reference like EXP.TYPE::NAME. (EXP.TYPE1::TYPE2::NAME does
192 not work, unfortunately.)
194 The length of the string follows in the next exp_element,
195 (after the string), followed by another STRUCTOP_... code. */
200 /* OP_THIS is just a placeholder for the class instance variable.
201 It just comes in a tight (OP_THIS, OP_THIS) pair. */
204 /* OP_SCOPE surrounds a type name and a field name. The type
205 name is encoded as one element, but the field name stays as
206 a string, which, of course, is variable length. */
209 /* OP_TYPE is for parsing types, and used with the "ptype" command
210 so we can look up types that are qualified by scope, either with
211 the GDB "::" operator, or the Modula-2 '.' operator. */
217 enum exp_opcode opcode;
218 struct symbol *symbol;
223 struct internalvar *internalvar;
228 const struct language_defn *language_defn; /* language it was entered in */
230 union exp_element elts[1];
235 extern struct expression *
236 parse_expression PARAMS ((char *));
238 extern struct expression *
239 parse_exp_1 PARAMS ((char **, struct block *, int));
241 /* The innermost context required by the stack and register variables
242 we've encountered so far. To use this, set it to NULL, then call
243 parse_<whatever>, then look at it. */
244 extern struct block *innermost_block;
246 /* From expprint.c */
249 print_expression PARAMS ((struct expression *, FILE *));
252 op_string PARAMS ((enum exp_opcode));
254 #endif /* !defined (EXPRESSION_H) */