1 /* Definitions for expressions stored in reversed prefix form, for GDB.
2 Copyright (C) 1986, 1989 Free Software Foundation, Inc.
4 This file is part of GDB.
6 GDB 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 1, or (at your option)
11 GDB 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 GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Definitions for saved C expressions. */
22 /* An expression is represented as a vector of union exp_element's.
23 Each exp_element is an opcode, except that some opcodes cause
24 the following exp_element to be treated as a long or double constant
25 or as a variable. The opcodes are obeyed, using a stack for temporaries.
26 The value is left on the temporary stack at the end. */
28 /* When it is necessary to include a string,
29 it can occupy as many exp_elements as it needs.
30 We find the length of the string using strlen,
31 divide to find out how many exp_elements are used up,
32 and skip that many. Strings, like numbers, are indicated
33 by the preceding opcode. */
37 /* BINOP_... operate on two values computed by following subexpressions,
38 replacing them by one result value. They take no immediate arguments. */
52 BINOP_NOTEQUAL
, /* != */
60 BINOP_SUBSCRIPT
, /* x[y] */
61 BINOP_EXP
, /* Exponentiation */
68 /* STRUCTOP_MEMBER is used for pointer-to-member constructs.
69 X . * Y translates into X STRUCTOP_MEMBER Y. */
71 /* STRUCTOP_MPTR is used for pointer-to-member constructs
72 when X is a pointer instead of an aggregate. */
78 BINOP_ASSIGN_MODIFY
, /* +=, -=, *=, and so on.
79 The following exp_element is another opcode,
80 a BINOP_, saying how to modify.
81 Then comes another BINOP_ASSIGN_MODIFY,
82 making three exp_elements in total. */
84 /* Operates on three values computed by following subexpressions. */
87 /* The OP_... series take immediate following arguments.
88 After the arguments come another OP_... (the same one)
89 so that the grouping can be recognized from the end. */
91 /* OP_LONG is followed by a type pointer in the next exp_element
92 and the long constant value in the following exp_element.
93 Then comes another OP_LONG.
94 Thus, the operation occupies four exp_elements. */
97 /* OP_DOUBLE is similar but takes a double constant instead of a long one. */
99 /* OP_VAR_VALUE takes one struct symbol * in the following exp_element,
100 followed by another OP_VAR_VALUE, making three exp_elements. */
102 /* OP_LAST is followed by an integer in the next exp_element.
103 The integer is zero for the last value printed,
104 or it is the absolute number of a history element.
105 With another OP_LAST at the end, this makes three exp_elements. */
107 /* OP_REGISTER is followed by an integer in the next exp_element.
108 This is the number of a register to fetch (as an int).
109 With another OP_REGISTER at the end, this makes three exp_elements. */
111 /* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element.
112 With another OP_INTERNALVAR at the end, this makes three exp_elements. */
114 /* OP_FUNCALL is followed by an integer in the next exp_element.
115 The integer is the number of args to the function call.
116 That many plus one values from following subexpressions
117 are used, the first one being the function.
118 The integer is followed by a repeat of OP_FUNCALL,
119 making three exp_elements. */
121 /* OP_STRING represents a string constant.
122 Its format is the same as that of a STRUCTOP, but the string
123 data is just made into a string constant when the operation
127 /* UNOP_CAST is followed by a type pointer in the next exp_element.
128 With another UNOP_CAST at the end, this makes three exp_elements.
129 It casts the value of the following subexpression. */
131 /* UNOP_MEMVAL is followed by a type pointer in the next exp_element
132 With another UNOP_MEMVAL at the end, this makes three exp_elements.
133 It casts the contents of the word addressed by the value of the
134 following subexpression. */
136 /* UNOP_... operate on one value from a following subexpression
137 and replace it with a result. They take no immediate arguments. */
138 UNOP_NEG
, /* Unary - */
139 UNOP_ZEROP
, /* Unary ! */
140 UNOP_LOGNOT
, /* Unary ~ */
141 UNOP_IND
, /* Unary * */
142 UNOP_ADDR
, /* Unary & */
143 UNOP_PREINCREMENT
, /* ++ before an expression */
144 UNOP_POSTINCREMENT
, /* ++ after an expression */
145 UNOP_PREDECREMENT
, /* -- before an expression */
146 UNOP_POSTDECREMENT
, /* -- after an expression */
147 UNOP_SIZEOF
, /* Unary sizeof (followed by expression) */
149 /* STRUCTOP_... operate on a value from a following subexpression
150 by extracting a structure component specified by a string
151 that appears in the following exp_elements (as many as needed).
152 STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->".
153 They differ only in the error message given in case the value is
154 not suitable or the structure component specified is not found.
156 The length of the string follows in the next exp_element,
157 (after the string), followed by another STRUCTOP_... code. */
162 /* OP_THIS is just a placeholder for the class instance variable.
163 It just comes in a tight (OP_THIS, OP_THIS) pair. */
166 /* OP_SCOPE surrounds a type name and a field name. The type
167 name is encoded as one element, but the field name stays as
168 a string, which, of course, is variable length. */
175 enum exp_opcode opcode
;
176 struct symbol
*symbol
;
181 struct internalvar
*internalvar
;
187 union exp_element elts
[1];
190 /* From expread.y. */
191 struct expression
*parse_c_expression ();
192 struct expression
*parse_c_1 ();
194 /* The innermost context required by the stack and register variables
195 we've encountered so far. To use this, set it to NULL, then call
196 parse_c_<whatever>, then look at it. */
197 extern struct block
*innermost_block
;
199 /* From expprint.c. */
200 void print_expression ();
This page took 0.032552 seconds and 4 git commands to generate.