xref: /dflybsd-src/contrib/gdb-7/gdb/expression.h (revision 5796c8dc12c637f18a1740c26afd8d40ffa9b719)
1*5796c8dcSSimon Schubert /* Definitions for expressions stored in reversed prefix form, for GDB.
2*5796c8dcSSimon Schubert 
3*5796c8dcSSimon Schubert    Copyright (C) 1986, 1989, 1992, 1994, 2000, 2003, 2005, 2007, 2008, 2009
4*5796c8dcSSimon Schubert    Free Software Foundation, Inc.
5*5796c8dcSSimon Schubert 
6*5796c8dcSSimon Schubert    This file is part of GDB.
7*5796c8dcSSimon Schubert 
8*5796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
9*5796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
10*5796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
11*5796c8dcSSimon Schubert    (at your option) any later version.
12*5796c8dcSSimon Schubert 
13*5796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
14*5796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
15*5796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*5796c8dcSSimon Schubert    GNU General Public License for more details.
17*5796c8dcSSimon Schubert 
18*5796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
19*5796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20*5796c8dcSSimon Schubert 
21*5796c8dcSSimon Schubert #if !defined (EXPRESSION_H)
22*5796c8dcSSimon Schubert #define EXPRESSION_H 1
23*5796c8dcSSimon Schubert 
24*5796c8dcSSimon Schubert 
25*5796c8dcSSimon Schubert #include "symtab.h"		/* Needed for "struct block" type. */
26*5796c8dcSSimon Schubert #include "doublest.h"		/* Needed for DOUBLEST.  */
27*5796c8dcSSimon Schubert 
28*5796c8dcSSimon Schubert 
29*5796c8dcSSimon Schubert /* Definitions for saved C expressions.  */
30*5796c8dcSSimon Schubert 
31*5796c8dcSSimon Schubert /* An expression is represented as a vector of union exp_element's.
32*5796c8dcSSimon Schubert    Each exp_element is an opcode, except that some opcodes cause
33*5796c8dcSSimon Schubert    the following exp_element to be treated as a long or double constant
34*5796c8dcSSimon Schubert    or as a variable.  The opcodes are obeyed, using a stack for temporaries.
35*5796c8dcSSimon Schubert    The value is left on the temporary stack at the end.  */
36*5796c8dcSSimon Schubert 
37*5796c8dcSSimon Schubert /* When it is necessary to include a string,
38*5796c8dcSSimon Schubert    it can occupy as many exp_elements as it needs.
39*5796c8dcSSimon Schubert    We find the length of the string using strlen,
40*5796c8dcSSimon Schubert    divide to find out how many exp_elements are used up,
41*5796c8dcSSimon Schubert    and skip that many.  Strings, like numbers, are indicated
42*5796c8dcSSimon Schubert    by the preceding opcode.  */
43*5796c8dcSSimon Schubert 
44*5796c8dcSSimon Schubert enum exp_opcode
45*5796c8dcSSimon Schubert   {
46*5796c8dcSSimon Schubert     /* Used when it's necessary to pass an opcode which will be ignored,
47*5796c8dcSSimon Schubert        or to catch uninitialized values.  */
48*5796c8dcSSimon Schubert     OP_NULL,
49*5796c8dcSSimon Schubert 
50*5796c8dcSSimon Schubert /* BINOP_... operate on two values computed by following subexpressions,
51*5796c8dcSSimon Schubert    replacing them by one result value.  They take no immediate arguments.  */
52*5796c8dcSSimon Schubert 
53*5796c8dcSSimon Schubert     BINOP_ADD,			/* + */
54*5796c8dcSSimon Schubert     BINOP_SUB,			/* - */
55*5796c8dcSSimon Schubert     BINOP_MUL,			/* * */
56*5796c8dcSSimon Schubert     BINOP_DIV,			/* / */
57*5796c8dcSSimon Schubert     BINOP_REM,			/* % */
58*5796c8dcSSimon Schubert     BINOP_MOD,			/* mod (Knuth 1.2.4) */
59*5796c8dcSSimon Schubert     BINOP_LSH,			/* << */
60*5796c8dcSSimon Schubert     BINOP_RSH,			/* >> */
61*5796c8dcSSimon Schubert     BINOP_LOGICAL_AND,		/* && */
62*5796c8dcSSimon Schubert     BINOP_LOGICAL_OR,		/* || */
63*5796c8dcSSimon Schubert     BINOP_BITWISE_AND,		/* & */
64*5796c8dcSSimon Schubert     BINOP_BITWISE_IOR,		/* | */
65*5796c8dcSSimon Schubert     BINOP_BITWISE_XOR,		/* ^ */
66*5796c8dcSSimon Schubert     BINOP_EQUAL,		/* == */
67*5796c8dcSSimon Schubert     BINOP_NOTEQUAL,		/* != */
68*5796c8dcSSimon Schubert     BINOP_LESS,			/* < */
69*5796c8dcSSimon Schubert     BINOP_GTR,			/* > */
70*5796c8dcSSimon Schubert     BINOP_LEQ,			/* <= */
71*5796c8dcSSimon Schubert     BINOP_GEQ,			/* >= */
72*5796c8dcSSimon Schubert     BINOP_REPEAT,		/* @ */
73*5796c8dcSSimon Schubert     BINOP_ASSIGN,		/* = */
74*5796c8dcSSimon Schubert     BINOP_COMMA,		/* , */
75*5796c8dcSSimon Schubert     BINOP_SUBSCRIPT,		/* x[y] */
76*5796c8dcSSimon Schubert     BINOP_EXP,			/* Exponentiation */
77*5796c8dcSSimon Schubert 
78*5796c8dcSSimon Schubert     /* C++.  */
79*5796c8dcSSimon Schubert 
80*5796c8dcSSimon Schubert     BINOP_MIN,			/* <? */
81*5796c8dcSSimon Schubert     BINOP_MAX,			/* >? */
82*5796c8dcSSimon Schubert 
83*5796c8dcSSimon Schubert     /* STRUCTOP_MEMBER is used for pointer-to-member constructs.
84*5796c8dcSSimon Schubert        X . * Y translates into X STRUCTOP_MEMBER Y.  */
85*5796c8dcSSimon Schubert     STRUCTOP_MEMBER,
86*5796c8dcSSimon Schubert 
87*5796c8dcSSimon Schubert     /* STRUCTOP_MPTR is used for pointer-to-member constructs
88*5796c8dcSSimon Schubert        when X is a pointer instead of an aggregate.  */
89*5796c8dcSSimon Schubert     STRUCTOP_MPTR,
90*5796c8dcSSimon Schubert 
91*5796c8dcSSimon Schubert     /* end of C++.  */
92*5796c8dcSSimon Schubert 
93*5796c8dcSSimon Schubert     /* For Modula-2 integer division DIV */
94*5796c8dcSSimon Schubert     BINOP_INTDIV,
95*5796c8dcSSimon Schubert 
96*5796c8dcSSimon Schubert     BINOP_ASSIGN_MODIFY,	/* +=, -=, *=, and so on.
97*5796c8dcSSimon Schubert 				   The following exp_element is another opcode,
98*5796c8dcSSimon Schubert 				   a BINOP_, saying how to modify.
99*5796c8dcSSimon Schubert 				   Then comes another BINOP_ASSIGN_MODIFY,
100*5796c8dcSSimon Schubert 				   making three exp_elements in total.  */
101*5796c8dcSSimon Schubert 
102*5796c8dcSSimon Schubert     /* Modula-2 standard (binary) procedures */
103*5796c8dcSSimon Schubert     BINOP_VAL,
104*5796c8dcSSimon Schubert     BINOP_INCL,
105*5796c8dcSSimon Schubert     BINOP_EXCL,
106*5796c8dcSSimon Schubert 
107*5796c8dcSSimon Schubert     /* Concatenate two operands, such as character strings or bitstrings.
108*5796c8dcSSimon Schubert        If the first operand is a integer expression, then it means concatenate
109*5796c8dcSSimon Schubert        the second operand with itself that many times. */
110*5796c8dcSSimon Schubert     BINOP_CONCAT,
111*5796c8dcSSimon Schubert 
112*5796c8dcSSimon Schubert     /* For (the deleted) Chill and Pascal. */
113*5796c8dcSSimon Schubert     BINOP_IN,			/* Returns 1 iff ARG1 IN ARG2. */
114*5796c8dcSSimon Schubert 
115*5796c8dcSSimon Schubert     /* This is the "colon operator" used various places in (the
116*5796c8dcSSimon Schubert        deleted) Chill. */
117*5796c8dcSSimon Schubert     BINOP_RANGE,
118*5796c8dcSSimon Schubert 
119*5796c8dcSSimon Schubert     /* This must be the highest BINOP_ value, for expprint.c.  */
120*5796c8dcSSimon Schubert     BINOP_END,
121*5796c8dcSSimon Schubert 
122*5796c8dcSSimon Schubert     /* Operates on three values computed by following subexpressions.  */
123*5796c8dcSSimon Schubert     TERNOP_COND,		/* ?: */
124*5796c8dcSSimon Schubert 
125*5796c8dcSSimon Schubert     /* A sub-string/sub-array.  (the deleted) Chill syntax:
126*5796c8dcSSimon Schubert        OP1(OP2:OP3).  Return elements OP2 through OP3 of OP1.  */
127*5796c8dcSSimon Schubert     TERNOP_SLICE,
128*5796c8dcSSimon Schubert 
129*5796c8dcSSimon Schubert     /* A sub-string/sub-array.  (The deleted) Chill syntax: OP1(OP2 UP
130*5796c8dcSSimon Schubert        OP3).  Return OP3 elements of OP1, starting with element
131*5796c8dcSSimon Schubert        OP2. */
132*5796c8dcSSimon Schubert     TERNOP_SLICE_COUNT,
133*5796c8dcSSimon Schubert 
134*5796c8dcSSimon Schubert     /* Multidimensional subscript operator, such as Modula-2 x[a,b,...].
135*5796c8dcSSimon Schubert        The dimensionality is encoded in the operator, like the number of
136*5796c8dcSSimon Schubert        function arguments in OP_FUNCALL, I.E. <OP><dimension><OP>.
137*5796c8dcSSimon Schubert        The value of the first following subexpression is subscripted
138*5796c8dcSSimon Schubert        by each of the next following subexpressions, one per dimension. */
139*5796c8dcSSimon Schubert     MULTI_SUBSCRIPT,
140*5796c8dcSSimon Schubert 
141*5796c8dcSSimon Schubert     /* The OP_... series take immediate following arguments.
142*5796c8dcSSimon Schubert        After the arguments come another OP_... (the same one)
143*5796c8dcSSimon Schubert        so that the grouping can be recognized from the end.  */
144*5796c8dcSSimon Schubert 
145*5796c8dcSSimon Schubert     /* OP_LONG is followed by a type pointer in the next exp_element
146*5796c8dcSSimon Schubert        and the long constant value in the following exp_element.
147*5796c8dcSSimon Schubert        Then comes another OP_LONG.
148*5796c8dcSSimon Schubert        Thus, the operation occupies four exp_elements.  */
149*5796c8dcSSimon Schubert     OP_LONG,
150*5796c8dcSSimon Schubert 
151*5796c8dcSSimon Schubert     /* OP_DOUBLE is similar but takes a DOUBLEST constant instead of a long.  */
152*5796c8dcSSimon Schubert     OP_DOUBLE,
153*5796c8dcSSimon Schubert 
154*5796c8dcSSimon Schubert     /* OP_VAR_VALUE takes one struct block * in the following element,
155*5796c8dcSSimon Schubert        and one struct symbol * in the following exp_element, followed by
156*5796c8dcSSimon Schubert        another OP_VAR_VALUE, making four exp_elements.  If the block is
157*5796c8dcSSimon Schubert        non-NULL, evaluate the symbol relative to the innermost frame
158*5796c8dcSSimon Schubert        executing in that block; if the block is NULL use the selected frame.  */
159*5796c8dcSSimon Schubert     OP_VAR_VALUE,
160*5796c8dcSSimon Schubert 
161*5796c8dcSSimon Schubert     /* OP_LAST is followed by an integer in the next exp_element.
162*5796c8dcSSimon Schubert        The integer is zero for the last value printed,
163*5796c8dcSSimon Schubert        or it is the absolute number of a history element.
164*5796c8dcSSimon Schubert        With another OP_LAST at the end, this makes three exp_elements.  */
165*5796c8dcSSimon Schubert     OP_LAST,
166*5796c8dcSSimon Schubert 
167*5796c8dcSSimon Schubert     /* OP_REGISTER is followed by a string in the next exp_element.
168*5796c8dcSSimon Schubert        This is the name of a register to fetch.  */
169*5796c8dcSSimon Schubert     OP_REGISTER,
170*5796c8dcSSimon Schubert 
171*5796c8dcSSimon Schubert     /* OP_INTERNALVAR is followed by an internalvar ptr in the next exp_element.
172*5796c8dcSSimon Schubert        With another OP_INTERNALVAR at the end, this makes three exp_elements.  */
173*5796c8dcSSimon Schubert     OP_INTERNALVAR,
174*5796c8dcSSimon Schubert 
175*5796c8dcSSimon Schubert     /* OP_FUNCALL is followed by an integer in the next exp_element.
176*5796c8dcSSimon Schubert        The integer is the number of args to the function call.
177*5796c8dcSSimon Schubert        That many plus one values from following subexpressions
178*5796c8dcSSimon Schubert        are used, the first one being the function.
179*5796c8dcSSimon Schubert        The integer is followed by a repeat of OP_FUNCALL,
180*5796c8dcSSimon Schubert        making three exp_elements.  */
181*5796c8dcSSimon Schubert     OP_FUNCALL,
182*5796c8dcSSimon Schubert 
183*5796c8dcSSimon Schubert     /* OP_OBJC_MSGCALL is followed by a string in the next exp_element and then an
184*5796c8dcSSimon Schubert        integer.  The string is the selector string.  The integer is the number
185*5796c8dcSSimon Schubert        of arguments to the message call.  That many plus one values are used,
186*5796c8dcSSimon Schubert        the first one being the object pointer.  This is an Objective C message */
187*5796c8dcSSimon Schubert     OP_OBJC_MSGCALL,
188*5796c8dcSSimon Schubert 
189*5796c8dcSSimon Schubert     /* This is EXACTLY like OP_FUNCALL but is semantically different.
190*5796c8dcSSimon Schubert        In F77, array subscript expressions, substring expressions
191*5796c8dcSSimon Schubert        and function calls are  all exactly the same syntactically. They may
192*5796c8dcSSimon Schubert        only be disambiguated at runtime.  Thus this operator, which
193*5796c8dcSSimon Schubert        indicates that we have found something of the form <name> ( <stuff> ) */
194*5796c8dcSSimon Schubert     OP_F77_UNDETERMINED_ARGLIST,
195*5796c8dcSSimon Schubert 
196*5796c8dcSSimon Schubert     /* OP_COMPLEX takes a type in the following element, followed by another
197*5796c8dcSSimon Schubert        OP_COMPLEX, making three exp_elements.  It is followed by two double
198*5796c8dcSSimon Schubert        args, and converts them into a complex number of the given type. */
199*5796c8dcSSimon Schubert     OP_COMPLEX,
200*5796c8dcSSimon Schubert 
201*5796c8dcSSimon Schubert     /* OP_STRING represents a string constant.
202*5796c8dcSSimon Schubert        Its format is the same as that of a STRUCTOP, but the string
203*5796c8dcSSimon Schubert        data is just made into a string constant when the operation
204*5796c8dcSSimon Schubert        is executed.  */
205*5796c8dcSSimon Schubert     OP_STRING,
206*5796c8dcSSimon Schubert 
207*5796c8dcSSimon Schubert     /* OP_BITSTRING represents a packed bitstring constant.
208*5796c8dcSSimon Schubert        Its format is the same as that of a STRUCTOP, but the bitstring
209*5796c8dcSSimon Schubert        data is just made into a bitstring constant when the operation
210*5796c8dcSSimon Schubert        is executed.  */
211*5796c8dcSSimon Schubert     OP_BITSTRING,
212*5796c8dcSSimon Schubert 
213*5796c8dcSSimon Schubert     /* OP_ARRAY creates an array constant out of the following subexpressions.
214*5796c8dcSSimon Schubert        It is followed by two exp_elements, the first containing an integer
215*5796c8dcSSimon Schubert        that is the lower bound of the array and the second containing another
216*5796c8dcSSimon Schubert        integer that is the upper bound of the array.  The second integer is
217*5796c8dcSSimon Schubert        followed by a repeat of OP_ARRAY, making four exp_elements total.
218*5796c8dcSSimon Schubert        The bounds are used to compute the number of following subexpressions
219*5796c8dcSSimon Schubert        to consume, as well as setting the bounds in the created array constant.
220*5796c8dcSSimon Schubert        The type of the elements is taken from the type of the first subexp,
221*5796c8dcSSimon Schubert        and they must all match. */
222*5796c8dcSSimon Schubert     OP_ARRAY,
223*5796c8dcSSimon Schubert 
224*5796c8dcSSimon Schubert     /* UNOP_CAST is followed by a type pointer in the next exp_element.
225*5796c8dcSSimon Schubert        With another UNOP_CAST at the end, this makes three exp_elements.
226*5796c8dcSSimon Schubert        It casts the value of the following subexpression.  */
227*5796c8dcSSimon Schubert     UNOP_CAST,
228*5796c8dcSSimon Schubert 
229*5796c8dcSSimon Schubert     /* UNOP_MEMVAL is followed by a type pointer in the next exp_element
230*5796c8dcSSimon Schubert        With another UNOP_MEMVAL at the end, this makes three exp_elements.
231*5796c8dcSSimon Schubert        It casts the contents of the word addressed by the value of the
232*5796c8dcSSimon Schubert        following subexpression.  */
233*5796c8dcSSimon Schubert     UNOP_MEMVAL,
234*5796c8dcSSimon Schubert 
235*5796c8dcSSimon Schubert     /* UNOP_MEMVAL_TLS is followed by a `struct objfile' pointer in the next
236*5796c8dcSSimon Schubert        exp_element and a type pointer in the following exp_element.
237*5796c8dcSSimon Schubert        With another UNOP_MEMVAL_TLS at the end, this makes four exp_elements.
238*5796c8dcSSimon Schubert        It casts the contents of the word offsetted by the value of the
239*5796c8dcSSimon Schubert        following subexpression from the TLS specified by `struct objfile'.  */
240*5796c8dcSSimon Schubert     UNOP_MEMVAL_TLS,
241*5796c8dcSSimon Schubert 
242*5796c8dcSSimon Schubert     /* UNOP_... operate on one value from a following subexpression
243*5796c8dcSSimon Schubert        and replace it with a result.  They take no immediate arguments.  */
244*5796c8dcSSimon Schubert 
245*5796c8dcSSimon Schubert     UNOP_NEG,			/* Unary - */
246*5796c8dcSSimon Schubert     UNOP_LOGICAL_NOT,		/* Unary ! */
247*5796c8dcSSimon Schubert     UNOP_COMPLEMENT,		/* Unary ~ */
248*5796c8dcSSimon Schubert     UNOP_IND,			/* Unary * */
249*5796c8dcSSimon Schubert     UNOP_ADDR,			/* Unary & */
250*5796c8dcSSimon Schubert     UNOP_PREINCREMENT,		/* ++ before an expression */
251*5796c8dcSSimon Schubert     UNOP_POSTINCREMENT,		/* ++ after an expression */
252*5796c8dcSSimon Schubert     UNOP_PREDECREMENT,		/* -- before an expression */
253*5796c8dcSSimon Schubert     UNOP_POSTDECREMENT,		/* -- after an expression */
254*5796c8dcSSimon Schubert     UNOP_SIZEOF,		/* Unary sizeof (followed by expression) */
255*5796c8dcSSimon Schubert 
256*5796c8dcSSimon Schubert     UNOP_PLUS,			/* Unary plus */
257*5796c8dcSSimon Schubert 
258*5796c8dcSSimon Schubert     UNOP_CAP,			/* Modula-2 standard (unary) procedures */
259*5796c8dcSSimon Schubert     UNOP_CHR,
260*5796c8dcSSimon Schubert     UNOP_ORD,
261*5796c8dcSSimon Schubert     UNOP_ABS,
262*5796c8dcSSimon Schubert     UNOP_FLOAT,
263*5796c8dcSSimon Schubert     UNOP_HIGH,
264*5796c8dcSSimon Schubert     UNOP_MAX,
265*5796c8dcSSimon Schubert     UNOP_MIN,
266*5796c8dcSSimon Schubert     UNOP_ODD,
267*5796c8dcSSimon Schubert     UNOP_TRUNC,
268*5796c8dcSSimon Schubert 
269*5796c8dcSSimon Schubert     /* (The deleted) Chill builtin functions.  */
270*5796c8dcSSimon Schubert     UNOP_LOWER, UNOP_UPPER, UNOP_LENGTH, UNOP_CARD, UNOP_CHMAX, UNOP_CHMIN,
271*5796c8dcSSimon Schubert 
272*5796c8dcSSimon Schubert     OP_BOOL,			/* Modula-2 builtin BOOLEAN type */
273*5796c8dcSSimon Schubert     OP_M2_STRING,		/* Modula-2 string constants */
274*5796c8dcSSimon Schubert 
275*5796c8dcSSimon Schubert     /* STRUCTOP_... operate on a value from a following subexpression
276*5796c8dcSSimon Schubert        by extracting a structure component specified by a string
277*5796c8dcSSimon Schubert        that appears in the following exp_elements (as many as needed).
278*5796c8dcSSimon Schubert        STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->".
279*5796c8dcSSimon Schubert        They differ only in the error message given in case the value is
280*5796c8dcSSimon Schubert        not suitable or the structure component specified is not found.
281*5796c8dcSSimon Schubert 
282*5796c8dcSSimon Schubert        The length of the string follows the opcode, followed by
283*5796c8dcSSimon Schubert        BYTES_TO_EXP_ELEM(length) elements containing the data of the
284*5796c8dcSSimon Schubert        string, followed by the length again and the opcode again.  */
285*5796c8dcSSimon Schubert 
286*5796c8dcSSimon Schubert     STRUCTOP_STRUCT,
287*5796c8dcSSimon Schubert     STRUCTOP_PTR,
288*5796c8dcSSimon Schubert 
289*5796c8dcSSimon Schubert     /* C++: OP_THIS is just a placeholder for the class instance variable.
290*5796c8dcSSimon Schubert        It just comes in a tight (OP_THIS, OP_THIS) pair.  */
291*5796c8dcSSimon Schubert     OP_THIS,
292*5796c8dcSSimon Schubert 
293*5796c8dcSSimon Schubert     /* Objective-C: OP_OBJC_SELF is just a placeholder for the class instance
294*5796c8dcSSimon Schubert        variable.  It just comes in a tight (OP_OBJC_SELF, OP_OBJC_SELF) pair.  */
295*5796c8dcSSimon Schubert     OP_OBJC_SELF,
296*5796c8dcSSimon Schubert 
297*5796c8dcSSimon Schubert     /* Objective C: "@selector" pseudo-operator */
298*5796c8dcSSimon Schubert     OP_OBJC_SELECTOR,
299*5796c8dcSSimon Schubert 
300*5796c8dcSSimon Schubert     /* OP_SCOPE surrounds a type name and a field name.  The type
301*5796c8dcSSimon Schubert        name is encoded as one element, but the field name stays as
302*5796c8dcSSimon Schubert        a string, which, of course, is variable length.  */
303*5796c8dcSSimon Schubert     OP_SCOPE,
304*5796c8dcSSimon Schubert 
305*5796c8dcSSimon Schubert     /* Used to represent named structure field values in brace
306*5796c8dcSSimon Schubert        initializers (or tuples as they are called in (the deleted)
307*5796c8dcSSimon Schubert        Chill).
308*5796c8dcSSimon Schubert 
309*5796c8dcSSimon Schubert        The gcc C syntax is NAME:VALUE or .NAME=VALUE, the (the
310*5796c8dcSSimon Schubert        deleted) Chill syntax is .NAME:VALUE.  Multiple labels (as in
311*5796c8dcSSimon Schubert        the (the deleted) Chill syntax .NAME1,.NAME2:VALUE) is
312*5796c8dcSSimon Schubert        represented as if it were .NAME1:(.NAME2:VALUE) (though that is
313*5796c8dcSSimon Schubert        not valid (the deleted) Chill syntax).
314*5796c8dcSSimon Schubert 
315*5796c8dcSSimon Schubert        The NAME is represented as for STRUCTOP_STRUCT;  VALUE follows. */
316*5796c8dcSSimon Schubert     OP_LABELED,
317*5796c8dcSSimon Schubert 
318*5796c8dcSSimon Schubert     /* OP_TYPE is for parsing types, and used with the "ptype" command
319*5796c8dcSSimon Schubert        so we can look up types that are qualified by scope, either with
320*5796c8dcSSimon Schubert        the GDB "::" operator, or the Modula-2 '.' operator. */
321*5796c8dcSSimon Schubert     OP_TYPE,
322*5796c8dcSSimon Schubert 
323*5796c8dcSSimon Schubert     /* An un-looked-up identifier. */
324*5796c8dcSSimon Schubert     OP_NAME,
325*5796c8dcSSimon Schubert 
326*5796c8dcSSimon Schubert     /* An Objective C Foundation Class NSString constant */
327*5796c8dcSSimon Schubert     OP_OBJC_NSSTRING,
328*5796c8dcSSimon Schubert 
329*5796c8dcSSimon Schubert     /* A F90 array range operator (for "exp:exp", "exp:", ":exp" and ":").  */
330*5796c8dcSSimon Schubert     OP_F90_RANGE,
331*5796c8dcSSimon Schubert 
332*5796c8dcSSimon Schubert     /* OP_DECFLOAT is followed by a type pointer in the next exp_element
333*5796c8dcSSimon Schubert        and a dec long constant value in the following exp_element.
334*5796c8dcSSimon Schubert        Then comes another OP_DECFLOAT.  */
335*5796c8dcSSimon Schubert     OP_DECFLOAT,
336*5796c8dcSSimon Schubert 
337*5796c8dcSSimon Schubert      /* First extension operator.  Individual language modules define
338*5796c8dcSSimon Schubert 	extra operators in *.inc include files below always starting with
339*5796c8dcSSimon Schubert 	numbering at OP_EXTENDED0:
340*5796c8dcSSimon Schubert              BINOP_MOGRIFY = OP_EXTENDED0,
341*5796c8dcSSimon Schubert  	     BINOP_FROB,
342*5796c8dcSSimon Schubert  	     ...  */
343*5796c8dcSSimon Schubert     OP_EXTENDED0,
344*5796c8dcSSimon Schubert 
345*5796c8dcSSimon Schubert     /* Last possible extension operator.  Defined to provide an
346*5796c8dcSSimon Schubert        explicit and finite number of extended operators. */
347*5796c8dcSSimon Schubert     OP_EXTENDED_LAST = 0xff,
348*5796c8dcSSimon Schubert     /* NOTE: Eventually, we expect to convert to an object-oriented
349*5796c8dcSSimon Schubert        formulation for expression operators that does away with the
350*5796c8dcSSimon Schubert        need for these extension operators, and indeed for this
351*5796c8dcSSimon Schubert        entire enumeration type.  Therefore, consider the OP_EXTENDED
352*5796c8dcSSimon Schubert        definitions to be a temporary measure. */
353*5796c8dcSSimon Schubert 
354*5796c8dcSSimon Schubert     /* Each language specific set of operators starts at OP_EXTENDED0.  */
355*5796c8dcSSimon Schubert #include "ada-operator.inc"
356*5796c8dcSSimon Schubert 
357*5796c8dcSSimon Schubert     /* Existing only to swallow the last comma (',') from last .inc file.  */
358*5796c8dcSSimon Schubert     OP_UNUSED_LAST
359*5796c8dcSSimon Schubert   };
360*5796c8dcSSimon Schubert 
361*5796c8dcSSimon Schubert union exp_element
362*5796c8dcSSimon Schubert   {
363*5796c8dcSSimon Schubert     enum exp_opcode opcode;
364*5796c8dcSSimon Schubert     struct symbol *symbol;
365*5796c8dcSSimon Schubert     LONGEST longconst;
366*5796c8dcSSimon Schubert     DOUBLEST doubleconst;
367*5796c8dcSSimon Schubert     gdb_byte decfloatconst[16];
368*5796c8dcSSimon Schubert     /* Really sizeof (union exp_element) characters (or less for the last
369*5796c8dcSSimon Schubert        element of a string).  */
370*5796c8dcSSimon Schubert     char string;
371*5796c8dcSSimon Schubert     struct type *type;
372*5796c8dcSSimon Schubert     struct internalvar *internalvar;
373*5796c8dcSSimon Schubert     struct block *block;
374*5796c8dcSSimon Schubert     struct objfile *objfile;
375*5796c8dcSSimon Schubert   };
376*5796c8dcSSimon Schubert 
377*5796c8dcSSimon Schubert struct expression
378*5796c8dcSSimon Schubert   {
379*5796c8dcSSimon Schubert     const struct language_defn *language_defn;	/* language it was entered in */
380*5796c8dcSSimon Schubert     struct gdbarch *gdbarch;  /* architecture it was parsed in */
381*5796c8dcSSimon Schubert     int nelts;
382*5796c8dcSSimon Schubert     union exp_element elts[1];
383*5796c8dcSSimon Schubert   };
384*5796c8dcSSimon Schubert 
385*5796c8dcSSimon Schubert /* Macros for converting between number of expression elements and bytes
386*5796c8dcSSimon Schubert    to store that many expression elements. */
387*5796c8dcSSimon Schubert 
388*5796c8dcSSimon Schubert #define EXP_ELEM_TO_BYTES(elements) \
389*5796c8dcSSimon Schubert     ((elements) * sizeof (union exp_element))
390*5796c8dcSSimon Schubert #define BYTES_TO_EXP_ELEM(bytes) \
391*5796c8dcSSimon Schubert     (((bytes) + sizeof (union exp_element) - 1) / sizeof (union exp_element))
392*5796c8dcSSimon Schubert 
393*5796c8dcSSimon Schubert /* From parse.c */
394*5796c8dcSSimon Schubert 
395*5796c8dcSSimon Schubert extern struct expression *parse_expression (char *);
396*5796c8dcSSimon Schubert 
397*5796c8dcSSimon Schubert extern struct type *parse_field_expression (char *, char **);
398*5796c8dcSSimon Schubert 
399*5796c8dcSSimon Schubert extern struct expression *parse_exp_1 (char **, struct block *, int);
400*5796c8dcSSimon Schubert 
401*5796c8dcSSimon Schubert /* For use by parsers; set if we want to parse an expression and
402*5796c8dcSSimon Schubert    attempt to complete a field name.  */
403*5796c8dcSSimon Schubert extern int in_parse_field;
404*5796c8dcSSimon Schubert 
405*5796c8dcSSimon Schubert /* The innermost context required by the stack and register variables
406*5796c8dcSSimon Schubert    we've encountered so far.  To use this, set it to NULL, then call
407*5796c8dcSSimon Schubert    parse_<whatever>, then look at it.  */
408*5796c8dcSSimon Schubert extern struct block *innermost_block;
409*5796c8dcSSimon Schubert 
410*5796c8dcSSimon Schubert /* From eval.c */
411*5796c8dcSSimon Schubert 
412*5796c8dcSSimon Schubert /* Values of NOSIDE argument to eval_subexp.  */
413*5796c8dcSSimon Schubert 
414*5796c8dcSSimon Schubert enum noside
415*5796c8dcSSimon Schubert   {
416*5796c8dcSSimon Schubert     EVAL_NORMAL,
417*5796c8dcSSimon Schubert     EVAL_SKIP,			/* Only effect is to increment pos.  */
418*5796c8dcSSimon Schubert     EVAL_AVOID_SIDE_EFFECTS	/* Don't modify any variables or
419*5796c8dcSSimon Schubert 				   call any functions.  The value
420*5796c8dcSSimon Schubert 				   returned will have the correct
421*5796c8dcSSimon Schubert 				   type, and will have an
422*5796c8dcSSimon Schubert 				   approximately correct lvalue
423*5796c8dcSSimon Schubert 				   type (inaccuracy: anything that is
424*5796c8dcSSimon Schubert 				   listed as being in a register in
425*5796c8dcSSimon Schubert 				   the function in which it was
426*5796c8dcSSimon Schubert 				   declared will be lval_register).  */
427*5796c8dcSSimon Schubert   };
428*5796c8dcSSimon Schubert 
429*5796c8dcSSimon Schubert extern struct value *evaluate_subexp_standard
430*5796c8dcSSimon Schubert   (struct type *, struct expression *, int *, enum noside);
431*5796c8dcSSimon Schubert 
432*5796c8dcSSimon Schubert /* From expprint.c */
433*5796c8dcSSimon Schubert 
434*5796c8dcSSimon Schubert extern void print_expression (struct expression *, struct ui_file *);
435*5796c8dcSSimon Schubert 
436*5796c8dcSSimon Schubert extern char *op_string (enum exp_opcode);
437*5796c8dcSSimon Schubert 
438*5796c8dcSSimon Schubert extern void dump_raw_expression (struct expression *, struct ui_file *, char *);
439*5796c8dcSSimon Schubert extern void dump_prefix_expression (struct expression *, struct ui_file *);
440*5796c8dcSSimon Schubert 
441*5796c8dcSSimon Schubert #endif /* !defined (EXPRESSION_H) */
442