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
24 struct block
; /* Forward declaration for prototypes */
27 /* Definitions for saved C expressions. */
29 /* An expression is represented as a vector of union exp_element's.
30 Each exp_element is an opcode, except that some opcodes cause
31 the following exp_element to be treated as a long or double constant
32 or as a variable. The opcodes are obeyed, using a stack for temporaries.
33 The value is left on the temporary stack at the end. */
35 /* When it is necessary to include a string,
36 it can occupy as many exp_elements as it needs.
37 We find the length of the string using strlen,
38 divide to find out how many exp_elements are used up,
39 and skip that many. Strings, like numbers, are indicated
40 by the preceding opcode. */
44 /* Used when it's necessary to pass an opcode which will be ignored,
45 or to catch uninitialized values. */
48 /* BINOP_... operate on two values computed by following subexpressions,
49 replacing them by one result value. They take no immediate arguments. */
55 BINOP_MOD
, /* mod (Knuth 1.2.4) */
58 BINOP_LOGICAL_AND
, /* && */
59 BINOP_LOGICAL_OR
, /* || */
60 BINOP_BITWISE_AND
, /* & */
61 BINOP_BITWISE_IOR
, /* | */
62 BINOP_BITWISE_XOR
, /* ^ */
64 BINOP_NOTEQUAL
, /* != */
72 BINOP_SUBSCRIPT
, /* x[y] */
73 BINOP_EXP
, /* Exponentiation */
80 /* STRUCTOP_MEMBER is used for pointer-to-member constructs.
81 X . * Y translates into X STRUCTOP_MEMBER Y. */
83 /* STRUCTOP_MPTR is used for pointer-to-member constructs
84 when X is a pointer instead of an aggregate. */
88 /* For Modula-2 integer division DIV */
91 BINOP_ASSIGN_MODIFY
, /* +=, -=, *=, and so on.
92 The following exp_element is another opcode,
93 a BINOP_, saying how to modify.
94 Then comes another BINOP_ASSIGN_MODIFY,
95 making three exp_elements in total. */
97 /* Modula-2 standard (binary) procedures*/
102 /* This must be the highest BINOP_ value, for expprint.c. */
105 /* Operates on three values computed by following subexpressions. */
106 TERNOP_COND
, /* ?: */
108 /* Multidimensional subscript operator, such as Modula-2 x[a,b,...].
109 The dimensionality is encoded in the operator, like the number of
110 function arguments in OP_FUNCALL, I.E. <OP><dimension><OP>.
111 The value of the first following subexpression is subscripted
112 by each of the next following subexpressions, one per dimension. */
116 /* The OP_... series take immediate following arguments.
117 After the arguments come another OP_... (the same one)
118 so that the grouping can be recognized from the end. */
120 /* OP_LONG is followed by a type pointer in the next exp_element
121 and the long constant value in the following exp_element.
122 Then comes another OP_LONG.
123 Thus, the operation occupies four exp_elements. */
126 /* OP_DOUBLE is similar but takes a double constant instead of a long one. */
128 /* OP_VAR_VALUE takes one struct symbol * in the following exp_element,
129 followed by another OP_VAR_VALUE, making three exp_elements. */
131 /* OP_LAST is followed by an integer in the next exp_element.
132 The integer is zero for the last value printed,
133 or it is the absolute number of a history element.
134 With another OP_LAST at the end, this makes three exp_elements. */
136 /* OP_REGISTER is followed by an integer in the next exp_element.
137 This is the number of a register to fetch (as an int).
138 With another OP_REGISTER at the end, this makes three exp_elements. */
140 /* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element.
141 With another OP_INTERNALVAR at the end, this makes three exp_elements. */
143 /* OP_FUNCALL is followed by an integer in the next exp_element.
144 The integer is the number of args to the function call.
145 That many plus one values from following subexpressions
146 are used, the first one being the function.
147 The integer is followed by a repeat of OP_FUNCALL,
148 making three exp_elements. */
150 /* OP_STRING represents a string constant.
151 Its format is the same as that of a STRUCTOP, but the string
152 data is just made into a string constant when the operation
156 /* UNOP_CAST is followed by a type pointer in the next exp_element.
157 With another UNOP_CAST at the end, this makes three exp_elements.
158 It casts the value of the following subexpression. */
160 /* UNOP_MEMVAL is followed by a type pointer in the next exp_element
161 With another UNOP_MEMVAL at the end, this makes three exp_elements.
162 It casts the contents of the word addressed by the value of the
163 following subexpression. */
165 /* UNOP_... operate on one value from a following subexpression
166 and replace it with a result. They take no immediate arguments. */
167 UNOP_NEG
, /* Unary - */
168 UNOP_LOGICAL_NOT
, /* Unary ! */
169 UNOP_COMPLEMENT
, /* Unary ~ */
170 UNOP_IND
, /* Unary * */
171 UNOP_ADDR
, /* Unary & */
172 UNOP_PREINCREMENT
, /* ++ before an expression */
173 UNOP_POSTINCREMENT
, /* ++ after an expression */
174 UNOP_PREDECREMENT
, /* -- before an expression */
175 UNOP_POSTDECREMENT
, /* -- after an expression */
176 UNOP_SIZEOF
, /* Unary sizeof (followed by expression) */
178 UNOP_PLUS
, /* Unary plus */
180 UNOP_CAP
, /* Modula-2 standard (unary) procedures */
191 OP_BOOL
, /* Modula-2 builtin BOOLEAN type */
192 OP_M2_STRING
, /* Modula-2 string constants */
194 /* STRUCTOP_... operate on a value from a following subexpression
195 by extracting a structure component specified by a string
196 that appears in the following exp_elements (as many as needed).
197 STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->".
198 They differ only in the error message given in case the value is
199 not suitable or the structure component specified is not found.
201 The length of the string follows in the next exp_element,
202 (after the string), followed by another STRUCTOP_... code. */
207 /* OP_THIS is just a placeholder for the class instance variable.
208 It just comes in a tight (OP_THIS, OP_THIS) pair. */
211 /* OP_SCOPE surrounds a type name and a field name. The type
212 name is encoded as one element, but the field name stays as
213 a string, which, of course, is variable length. */
216 /* OP_TYPE is for parsing types, and used with the "ptype" command
217 so we can look up types that are qualified by scope, either with
218 the GDB "::" operator, or the Modula-2 '.' operator. */
224 enum exp_opcode opcode
;
225 struct symbol
*symbol
;
230 struct internalvar
*internalvar
;
235 const struct language_defn
*language_defn
; /* language it was entered in */
237 union exp_element elts
[1];
242 extern struct expression
*
243 parse_expression
PARAMS ((char *));
245 extern struct expression
*
246 parse_exp_1
PARAMS ((char **, struct block
*, int));
248 /* The innermost context required by the stack and register variables
249 we've encountered so far. To use this, set it to NULL, then call
250 parse_<whatever>, then look at it. */
251 extern struct block
*innermost_block
;
253 /* From expprint.c */
256 print_expression
PARAMS ((struct expression
*, FILE *));
259 op_string
PARAMS ((enum exp_opcode
));
261 /* To enable dumping of all parsed expressions in a human readable
262 form, define DEBUG_EXPRESSIONS. This is a compile time constant
263 at the moment, since it's not clear that this feature is important
264 enough to include by default. */
266 #ifdef DEBUG_EXPRESSIONS
268 dump_expression
PARAMS ((struct expression
*, FILE *, char *));
269 #define DUMP_EXPRESSION(exp,file,note) dump_expression ((exp), (file), (note))
271 #define DUMP_EXPRESSION(exp,file,note) /* Null expansion */
272 #endif /* DEBUG_EXPRESSIONS */
274 #endif /* !defined (EXPRESSION_H) */
This page took 0.034347 seconds and 4 git commands to generate.