xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/std-operator.def (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1/* Standard language operator definitions for GDB, the GNU debugger.
2
3   Copyright (C) 1986-2023 Free Software Foundation, Inc.
4
5   This file is part of GDB.
6
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 3 of the License, or
10   (at your option) any later version.
11
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20/* Used when it's necessary to pass an opcode which will be ignored,
21   or to catch uninitialized values.  */
22OP (OP_NULL)
23
24/* BINOP_... operate on two values computed by following subexpressions,
25replacing them by one result value.  They take no immediate arguments.  */
26
27OP (BINOP_ADD)			/* + */
28OP (BINOP_SUB)			/* - */
29OP (BINOP_MUL)			/* * */
30OP (BINOP_DIV)			/* / */
31OP (BINOP_REM)			/* % */
32OP (BINOP_MOD)			/* mod (Knuth 1.2.4) */
33OP (BINOP_LSH)			/* << */
34OP (BINOP_RSH)			/* >> */
35OP (BINOP_LOGICAL_AND)		/* && */
36OP (BINOP_LOGICAL_OR)		/* || */
37OP (BINOP_BITWISE_AND)		/* & */
38OP (BINOP_BITWISE_IOR)		/* | */
39OP (BINOP_BITWISE_XOR)		/* ^ */
40OP (BINOP_EQUAL)		/* == */
41OP (BINOP_NOTEQUAL)		/* != */
42OP (BINOP_LESS)			/* < */
43OP (BINOP_GTR)			/* > */
44OP (BINOP_LEQ)			/* <= */
45OP (BINOP_GEQ)			/* >= */
46OP (BINOP_REPEAT)		/* @ */
47OP (BINOP_ASSIGN)		/* = */
48OP (BINOP_COMMA)		/* , */
49OP (BINOP_SUBSCRIPT)		/* x[y] */
50OP (BINOP_EXP)			/* Exponentiation */
51
52/* C++.  */
53
54OP (BINOP_MIN)			/* <? */
55OP (BINOP_MAX)			/* >? */
56
57/* STRUCTOP_MEMBER is used for pointer-to-member constructs.
58   X .  * Y translates into X STRUCTOP_MEMBER Y.  */
59OP (STRUCTOP_MEMBER)
60
61/* STRUCTOP_MPTR is used for pointer-to-member constructs
62   when X is a pointer instead of an aggregate.  */
63OP (STRUCTOP_MPTR)
64
65/* TYPE_INSTANCE is used when the user specifies a specific
66   type instantiation for overloaded methods/functions.
67
68   The format is:
69   TYPE_INSTANCE num_types type0 ... typeN num_types TYPE_INSTANCE.  */
70OP (TYPE_INSTANCE)
71
72/* end of C++.  */
73
74/* For Modula-2 integer division DIV.  */
75OP (BINOP_INTDIV)
76
77/* +=, -=, *=, and so on.  The following exp_element is another opcode,
78   a BINOP_, saying how to modify.  Then comes another BINOP_ASSIGN_MODIFY,
79   making three exp_elements in total.  */
80OP (BINOP_ASSIGN_MODIFY)
81
82/* Modula-2 standard (binary) procedures.  */
83OP (BINOP_VAL)
84
85/* Concatenate two operands, such as character strings or bitstrings.
86   If the first operand is a integer expression, then it means concatenate
87   the second operand with itself that many times.  */
88OP (BINOP_CONCAT)
89
90/* Operates on three values computed by following subexpressions.  */
91OP (TERNOP_COND)		/* ?: */
92
93/* A sub-string/sub-array.  Ada syntax: OP1(OP2..OP3).  Return
94   elements OP2 through OP3 of OP1.  */
95OP (TERNOP_SLICE)
96
97/* Multidimensional subscript operator, such as Modula-2 x[a,b,...].
98   The dimensionality is encoded in the operator, like the number of
99   function arguments in OP_FUNCALL, I.E. <OP><dimension><OP>.
100   The value of the first following subexpression is subscripted
101   by each of the next following subexpressions, one per dimension.  */
102OP (MULTI_SUBSCRIPT)
103
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.  */
107
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.  */
112OP (OP_LONG)
113
114/* OP_FLOAT is similar but takes a floating-point constant encoded in
115   the target format for the given type instead of a long.  */
116OP (OP_FLOAT)
117
118/* OP_VAR_VALUE takes one struct block * in the following element,
119   and one struct symbol * in the following exp_element, followed
120   by another OP_VAR_VALUE, making four exp_elements.  If the
121   block is non-NULL, evaluate the symbol relative to the
122   innermost frame executing in that block; if the block is NULL
123   use the selected frame.  */
124OP (OP_VAR_VALUE)
125
126/* OP_VAR_ENTRY_VALUE takes one struct symbol * in the following element,
127   followed by another OP_VAR_ENTRY_VALUE, making three exp_elements.
128   somename@entry may mean parameter value as present at the entry of the
129   current function.  Implemented via DW_OP_entry_value.  */
130OP (OP_VAR_ENTRY_VALUE)
131
132/* OP_VAR_MSYM_VALUE takes one struct objfile * in the following
133   element, and one struct minimal_symbol * in the following
134   exp_element, followed by another OP_VAR_MSYM_VALUE, making four
135   exp_elements.  */
136OP (OP_VAR_MSYM_VALUE)
137
138/* OP_LAST is followed by an integer in the next exp_element.
139   The integer is zero for the last value printed,
140   or it is the absolute number of a history element.
141   With another OP_LAST at the end, this makes three exp_elements.  */
142OP (OP_LAST)
143
144/* OP_REGISTER is followed by a string in the next exp_element.
145   This is the name of a register to fetch.  */
146OP (OP_REGISTER)
147
148/* OP_INTERNALVAR is followed by an internalvar ptr in the next
149   exp_element.  With another OP_INTERNALVAR at the end, this
150   makes three exp_elements.  */
151OP (OP_INTERNALVAR)
152
153/* OP_FUNCALL is followed by an integer in the next exp_element.
154   The integer is the number of args to the function call.
155   That many plus one values from following subexpressions
156   are used, the first one being the function.
157   The integer is followed by a repeat of OP_FUNCALL,
158   making three exp_elements.  */
159OP (OP_FUNCALL)
160
161/* OP_OBJC_MSGCALL is followed by a string in the next exp_element
162   and then an integer.  The string is the selector string.  The
163   integer is the number of arguments to the message call.  That
164   many plus one values are used, the first one being the object
165   pointer.  This is an Objective C message.  */
166OP (OP_OBJC_MSGCALL)
167
168/* OP_COMPLEX takes a type in the following element, followed by another
169   OP_COMPLEX, making three exp_elements.  It is followed by two double
170   args, and converts them into a complex number of the given type.  */
171OP (OP_COMPLEX)
172
173/* OP_STRING represents a string constant.
174   Its format is the same as that of a STRUCTOP, but the string
175   data is just made into a string constant when the operation
176   is executed.  */
177OP (OP_STRING)
178
179/* OP_ARRAY creates an array constant out of the following subexpressions.
180   It is followed by two exp_elements, the first containing an integer
181   that is the lower bound of the array and the second containing another
182   integer that is the upper bound of the array.  The second integer is
183   followed by a repeat of OP_ARRAY, making four exp_elements total.
184   The bounds are used to compute the number of following subexpressions
185   to consume, as well as setting the bounds in the created array constant.
186   The type of the elements is taken from the type of the first subexp,
187   and they must all match.  */
188OP (OP_ARRAY)
189
190/* UNOP_EXTRACT takes a value and a type, like a cast, but, instead of
191   casting the value to the given type, a new value (of the given
192   type) is extracted from the contents of the old value, starting
193   from the least significant byte.
194
195   It is invalid for the given type to be larger than the type of the
196   given value.  */
197OP (UNOP_EXTRACT)
198
199/* UNOP_CAST is followed by a type pointer in the next exp_element.
200   With another UNOP_CAST at the end, this makes three exp_elements.
201   It casts the value of the following subexpression.  */
202OP (UNOP_CAST)
203
204/* Like UNOP_CAST, but the type is a subexpression.  */
205OP (UNOP_CAST_TYPE)
206
207/* The C++ dynamic_cast operator.  */
208OP (UNOP_DYNAMIC_CAST)
209
210/* The C++ reinterpret_cast operator.  */
211OP (UNOP_REINTERPRET_CAST)
212
213/* UNOP_MEMVAL is followed by a type pointer in the next exp_element
214   With another UNOP_MEMVAL at the end, this makes three exp_elements.
215   It casts the contents of the word addressed by the value of the
216   following subexpression.  */
217OP (UNOP_MEMVAL)
218
219/* Like UNOP_MEMVAL, but the type is supplied as a subexpression.  */
220OP (UNOP_MEMVAL_TYPE)
221
222/* UNOP_... operate on one value from a following subexpression
223   and replace it with a result.  They take no immediate arguments.  */
224
225OP (UNOP_NEG)			/* Unary - */
226OP (UNOP_LOGICAL_NOT)		/* Unary ! */
227OP (UNOP_COMPLEMENT)		/* Unary ~ */
228OP (UNOP_IND)			/* Unary * */
229OP (UNOP_ADDR)			/* Unary & */
230OP (UNOP_PREINCREMENT)		/* ++ before an expression */
231OP (UNOP_POSTINCREMENT)		/* ++ after an expression */
232OP (UNOP_PREDECREMENT)		/* -- before an expression */
233OP (UNOP_POSTDECREMENT)		/* -- after an expression */
234OP (UNOP_SIZEOF)		/* Unary sizeof (followed by expression) */
235OP (UNOP_ALIGNOF)		/* Unary alignof (followed by expression) */
236
237OP (UNOP_PLUS)			/* Unary plus */
238
239OP (UNOP_ABS)
240OP (UNOP_HIGH)
241
242OP (OP_BOOL)			/* Modula-2 builtin BOOLEAN type */
243
244/* STRUCTOP_... operate on a value from a following subexpression
245   by extracting a structure component specified by a string
246   that appears in the following exp_elements (as many as needed).
247   STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->".
248   They differ only in the error message given in case the value is
249   not suitable or the structure component specified is not found.
250
251   The length of the string follows the opcode, followed by
252   BYTES_TO_EXP_ELEM(length) elements containing the data of the
253   string, followed by the length again and the opcode again.  */
254
255OP (STRUCTOP_STRUCT)
256OP (STRUCTOP_PTR)
257
258/* Anonymous field access, e.g. "foo.3".  Used in Rust.  */
259OP (STRUCTOP_ANONYMOUS)
260
261/* C++: OP_THIS is just a placeholder for the class instance variable.
262   It just comes in a tight (OP_THIS, OP_THIS) pair.  */
263OP (OP_THIS)
264
265/* Objective C: "@selector" pseudo-operator.  */
266OP (OP_OBJC_SELECTOR)
267
268/* OP_SCOPE surrounds a type name and a field name.  The type
269   name is encoded as one element, but the field name stays as
270   a string, which, of course, is variable length.  */
271OP (OP_SCOPE)
272
273/* OP_FUNC_STATIC_VAR refers to a function local static variable.  The
274   function is taken from the following subexpression.  The length of
275   the variable name as a string follows the opcode, followed by
276   BYTES_TO_EXP_ELEM(length) elements containing the data of the
277   string, followed by the length again and the opcode again.
278
279   Note this is used by C++, but not C.  The C parser handles local
280   static variables in the parser directly.  Also, this is only used
281   in C++ if the function/method name is not quoted, like e.g.:
282
283     p S:method()::var
284     p S:method() const::var
285
286   If the function/method is quoted like instead:
287
288     p 'S:method() const'::var
289
290   then the C-specific handling directly in the parser takes over (see
291   block/variable productions).
292
293   Also, if the whole function+var is quoted like this:
294
295     p 'S:method() const::var'
296
297   then the whole quoted expression is interpreted as a single symbol
298   name and we don't use OP_FUNC_STATIC_VAR either.  In that case, the
299   C++-specific symbol lookup routines take care of the
300   function-local-static search.  */
301OP (OP_FUNC_STATIC_VAR)
302
303/* OP_TYPE is for parsing types, and used with the "ptype" command
304   so we can look up types that are qualified by scope, either with
305   the GDB "::" operator, or the Modula-2 '.' operator.  */
306OP (OP_TYPE)
307
308/* An Objective C Foundation Class NSString constant.  */
309OP (OP_OBJC_NSSTRING)
310
311/* An array range operator (in Fortran 90, for "exp:exp", "exp:",
312   ":exp" and ":").  */
313OP (OP_RANGE)
314
315/* OP_ADL_FUNC specifies that the function is to be looked up in an
316   Argument Dependent manner (Koenig lookup).  */
317OP (OP_ADL_FUNC)
318
319/* The typeof operator.  This has one expression argument, which is
320   evaluated solely for its type.  */
321OP (OP_TYPEOF)
322
323/* The decltype operator.  This has one expression argument, which is
324   evaluated solely for its type.  This is similar to typeof, but has
325   slight different semantics.  */
326OP (OP_DECLTYPE)
327
328/* The typeid operator.  This has one expression argument.  */
329OP (OP_TYPEID)
330
331/* This is used for the Rust [expr; N] form of array construction.  It
332   takes two expression arguments.  */
333OP (OP_RUST_ARRAY)
334
335/* ================ Ada operators ================ */
336
337/* X IN A'RANGE(N).  N is an immediate operand, surrounded by
338   BINOP_IN_BOUNDS before and after.  A is an array, X an index
339   value.  Evaluates to true iff X is within range of the Nth
340   dimension (1-based) of A.  (A multi-dimensional array
341   type is represented as array of array of ...) */
342OP (BINOP_IN_BOUNDS)
343
344/* X IN L .. U.  True iff L <= X <= U.  */
345OP (TERNOP_IN_RANGE)
346
347/* Ada attributes ('Foo). */
348OP (OP_ATR_FIRST)
349OP (OP_ATR_LAST)
350OP (OP_ATR_LENGTH)
351OP (OP_ATR_POS)
352OP (OP_ATR_SIZE)
353OP (OP_ATR_TAG)
354OP (OP_ATR_VAL)
355
356/* Ada type qualification.  It is encoded as for UNOP_CAST, above,
357   and denotes the TYPE'(EXPR) construct. */
358OP (UNOP_QUAL)
359
360/* X IN TYPE.  The `TYPE' argument is immediate, with
361   UNOP_IN_RANGE before and after it. True iff X is a member of
362   type TYPE (typically a subrange). */
363OP (UNOP_IN_RANGE)
364
365/* An aggregate.   A single immediate operand, N>0, gives
366   the number of component specifications that follow.  The
367   immediate operand is followed by a second OP_AGGREGATE.
368   Next come N component specifications.  A component
369   specification is either an OP_OTHERS (others=>...), an
370   OP_CHOICES (for named associations), or other expression (for
371   positional aggregates only).  Aggregates currently
372   occur only as the right sides of assignments. */
373OP (OP_AGGREGATE)
374
375/* ================ Fortran operators ================ */
376
377/* This is EXACTLY like OP_FUNCALL but is semantically different.
378   In F77, array subscript expressions, substring expressions and
379   function calls are all exactly the same syntactically.  They
380   may only be disambiguated at runtime.  Thus this operator,
381   which indicates that we have found something of the form
382   <name> ( <stuff> ).  */
383OP (OP_F77_UNDETERMINED_ARGLIST)
384
385/* Single operand builtins.  */
386OP (UNOP_FORTRAN_KIND)
387OP (UNOP_FORTRAN_ALLOCATED)
388OP (UNOP_FORTRAN_RANK)
389OP (UNOP_FORTRAN_SHAPE)
390OP (UNOP_FORTRAN_LOC)
391
392/* Two operand builtins.  */
393OP (BINOP_FORTRAN_MODULO)
394
395/* Builtins that take one or two operands.  */
396OP (FORTRAN_CEILING)
397OP (FORTRAN_FLOOR)
398OP (FORTRAN_ASSOCIATED)
399
400/* Builtins that take one, two or three operands.  */
401OP (FORTRAN_LBOUND)
402OP (FORTRAN_UBOUND)
403OP (FORTRAN_CMPLX)
404OP (FORTRAN_ARRAY_SIZE)
405