Remove unused Modula-2 opcodes
[binutils-gdb.git] / gdb / std-operator.def
1 /* Standard language operator definitions for GDB, the GNU debugger.
2
3 Copyright (C) 1986-2021 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. */
22 OP (OP_NULL)
23
24 /* BINOP_... operate on two values computed by following subexpressions,
25 replacing them by one result value. They take no immediate arguments. */
26
27 OP (BINOP_ADD) /* + */
28 OP (BINOP_SUB) /* - */
29 OP (BINOP_MUL) /* * */
30 OP (BINOP_DIV) /* / */
31 OP (BINOP_REM) /* % */
32 OP (BINOP_MOD) /* mod (Knuth 1.2.4) */
33 OP (BINOP_LSH) /* << */
34 OP (BINOP_RSH) /* >> */
35 OP (BINOP_LOGICAL_AND) /* && */
36 OP (BINOP_LOGICAL_OR) /* || */
37 OP (BINOP_BITWISE_AND) /* & */
38 OP (BINOP_BITWISE_IOR) /* | */
39 OP (BINOP_BITWISE_XOR) /* ^ */
40 OP (BINOP_EQUAL) /* == */
41 OP (BINOP_NOTEQUAL) /* != */
42 OP (BINOP_LESS) /* < */
43 OP (BINOP_GTR) /* > */
44 OP (BINOP_LEQ) /* <= */
45 OP (BINOP_GEQ) /* >= */
46 OP (BINOP_REPEAT) /* @ */
47 OP (BINOP_ASSIGN) /* = */
48 OP (BINOP_COMMA) /* , */
49 OP (BINOP_SUBSCRIPT) /* x[y] */
50 OP (BINOP_EXP) /* Exponentiation */
51
52 /* C++. */
53
54 OP (BINOP_MIN) /* <? */
55 OP (BINOP_MAX) /* >? */
56
57 /* STRUCTOP_MEMBER is used for pointer-to-member constructs.
58 X . * Y translates into X STRUCTOP_MEMBER Y. */
59 OP (STRUCTOP_MEMBER)
60
61 /* STRUCTOP_MPTR is used for pointer-to-member constructs
62 when X is a pointer instead of an aggregate. */
63 OP (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. */
70 OP (TYPE_INSTANCE)
71
72 /* end of C++. */
73
74 /* For Modula-2 integer division DIV. */
75 OP (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. */
80 OP (BINOP_ASSIGN_MODIFY)
81
82 /* Modula-2 standard (binary) procedures. */
83 OP (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. */
88 OP (BINOP_CONCAT)
89
90 /* This must be the highest BINOP_ value, for expprint.c. */
91 OP (BINOP_END)
92
93 /* Operates on three values computed by following subexpressions. */
94 OP (TERNOP_COND) /* ?: */
95
96 /* A sub-string/sub-array. Ada syntax: OP1(OP2..OP3). Return
97 elements OP2 through OP3 of OP1. */
98 OP (TERNOP_SLICE)
99
100 /* Multidimensional subscript operator, such as Modula-2 x[a,b,...].
101 The dimensionality is encoded in the operator, like the number of
102 function arguments in OP_FUNCALL, I.E. <OP><dimension><OP>.
103 The value of the first following subexpression is subscripted
104 by each of the next following subexpressions, one per dimension. */
105 OP (MULTI_SUBSCRIPT)
106
107 /* The OP_... series take immediate following arguments.
108 After the arguments come another OP_... (the same one)
109 so that the grouping can be recognized from the end. */
110
111 /* OP_LONG is followed by a type pointer in the next exp_element
112 and the long constant value in the following exp_element.
113 Then comes another OP_LONG.
114 Thus, the operation occupies four exp_elements. */
115 OP (OP_LONG)
116
117 /* OP_FLOAT is similar but takes a floating-point constant encoded in
118 the target format for the given type instead of a long. */
119 OP (OP_FLOAT)
120
121 /* OP_VAR_VALUE takes one struct block * in the following element,
122 and one struct symbol * in the following exp_element, followed
123 by another OP_VAR_VALUE, making four exp_elements. If the
124 block is non-NULL, evaluate the symbol relative to the
125 innermost frame executing in that block; if the block is NULL
126 use the selected frame. */
127 OP (OP_VAR_VALUE)
128
129 /* OP_VAR_ENTRY_VALUE takes one struct symbol * in the following element,
130 followed by another OP_VAR_ENTRY_VALUE, making three exp_elements.
131 somename@entry may mean parameter value as present at the entry of the
132 current function. Implemented via DW_OP_entry_value. */
133 OP (OP_VAR_ENTRY_VALUE)
134
135 /* OP_VAR_MSYM_VALUE takes one struct objfile * in the following
136 element, and one struct minimal_symbol * in the following
137 exp_element, followed by another OP_VAR_MSYM_VALUE, making four
138 exp_elements. */
139 OP (OP_VAR_MSYM_VALUE)
140
141 /* OP_LAST is followed by an integer in the next exp_element.
142 The integer is zero for the last value printed,
143 or it is the absolute number of a history element.
144 With another OP_LAST at the end, this makes three exp_elements. */
145 OP (OP_LAST)
146
147 /* OP_REGISTER is followed by a string in the next exp_element.
148 This is the name of a register to fetch. */
149 OP (OP_REGISTER)
150
151 /* OP_INTERNALVAR is followed by an internalvar ptr in the next
152 exp_element. With another OP_INTERNALVAR at the end, this
153 makes three exp_elements. */
154 OP (OP_INTERNALVAR)
155
156 /* OP_FUNCALL is followed by an integer in the next exp_element.
157 The integer is the number of args to the function call.
158 That many plus one values from following subexpressions
159 are used, the first one being the function.
160 The integer is followed by a repeat of OP_FUNCALL,
161 making three exp_elements. */
162 OP (OP_FUNCALL)
163
164 /* OP_OBJC_MSGCALL is followed by a string in the next exp_element
165 and then an integer. The string is the selector string. The
166 integer is the number of arguments to the message call. That
167 many plus one values are used, the first one being the object
168 pointer. This is an Objective C message. */
169 OP (OP_OBJC_MSGCALL)
170
171 /* OP_COMPLEX takes a type in the following element, followed by another
172 OP_COMPLEX, making three exp_elements. It is followed by two double
173 args, and converts them into a complex number of the given type. */
174 OP (OP_COMPLEX)
175
176 /* OP_STRING represents a string constant.
177 Its format is the same as that of a STRUCTOP, but the string
178 data is just made into a string constant when the operation
179 is executed. */
180 OP (OP_STRING)
181
182 /* OP_ARRAY creates an array constant out of the following subexpressions.
183 It is followed by two exp_elements, the first containing an integer
184 that is the lower bound of the array and the second containing another
185 integer that is the upper bound of the array. The second integer is
186 followed by a repeat of OP_ARRAY, making four exp_elements total.
187 The bounds are used to compute the number of following subexpressions
188 to consume, as well as setting the bounds in the created array constant.
189 The type of the elements is taken from the type of the first subexp,
190 and they must all match. */
191 OP (OP_ARRAY)
192
193 /* UNOP_CAST is followed by a type pointer in the next exp_element.
194 With another UNOP_CAST at the end, this makes three exp_elements.
195 It casts the value of the following subexpression. */
196 OP (UNOP_CAST)
197
198 /* Like UNOP_CAST, but the type is a subexpression. */
199 OP (UNOP_CAST_TYPE)
200
201 /* The C++ dynamic_cast operator. */
202 OP (UNOP_DYNAMIC_CAST)
203
204 /* The C++ reinterpret_cast operator. */
205 OP (UNOP_REINTERPRET_CAST)
206
207 /* UNOP_MEMVAL is followed by a type pointer in the next exp_element
208 With another UNOP_MEMVAL at the end, this makes three exp_elements.
209 It casts the contents of the word addressed by the value of the
210 following subexpression. */
211 OP (UNOP_MEMVAL)
212
213 /* Like UNOP_MEMVAL, but the type is supplied as a subexpression. */
214 OP (UNOP_MEMVAL_TYPE)
215
216 /* UNOP_... operate on one value from a following subexpression
217 and replace it with a result. They take no immediate arguments. */
218
219 OP (UNOP_NEG) /* Unary - */
220 OP (UNOP_LOGICAL_NOT) /* Unary ! */
221 OP (UNOP_COMPLEMENT) /* Unary ~ */
222 OP (UNOP_IND) /* Unary * */
223 OP (UNOP_ADDR) /* Unary & */
224 OP (UNOP_PREINCREMENT) /* ++ before an expression */
225 OP (UNOP_POSTINCREMENT) /* ++ after an expression */
226 OP (UNOP_PREDECREMENT) /* -- before an expression */
227 OP (UNOP_POSTDECREMENT) /* -- after an expression */
228 OP (UNOP_SIZEOF) /* Unary sizeof (followed by expression) */
229 OP (UNOP_ALIGNOF) /* Unary alignof (followed by expression) */
230
231 OP (UNOP_PLUS) /* Unary plus */
232
233 OP (UNOP_ABS)
234 OP (UNOP_HIGH)
235
236 OP (OP_BOOL) /* Modula-2 builtin BOOLEAN type */
237
238 /* STRUCTOP_... operate on a value from a following subexpression
239 by extracting a structure component specified by a string
240 that appears in the following exp_elements (as many as needed).
241 STRUCTOP_STRUCT is used for "." and STRUCTOP_PTR for "->".
242 They differ only in the error message given in case the value is
243 not suitable or the structure component specified is not found.
244
245 The length of the string follows the opcode, followed by
246 BYTES_TO_EXP_ELEM(length) elements containing the data of the
247 string, followed by the length again and the opcode again. */
248
249 OP (STRUCTOP_STRUCT)
250 OP (STRUCTOP_PTR)
251
252 /* Anonymous field access, e.g. "foo.3". Used in Rust. */
253 OP (STRUCTOP_ANONYMOUS)
254
255 /* C++: OP_THIS is just a placeholder for the class instance variable.
256 It just comes in a tight (OP_THIS, OP_THIS) pair. */
257 OP (OP_THIS)
258
259 /* Objective C: "@selector" pseudo-operator. */
260 OP (OP_OBJC_SELECTOR)
261
262 /* OP_SCOPE surrounds a type name and a field name. The type
263 name is encoded as one element, but the field name stays as
264 a string, which, of course, is variable length. */
265 OP (OP_SCOPE)
266
267 /* OP_FUNC_STATIC_VAR refers to a function local static variable. The
268 function is taken from the following subexpression. The length of
269 the variable name as a string follows the opcode, followed by
270 BYTES_TO_EXP_ELEM(length) elements containing the data of the
271 string, followed by the length again and the opcode again.
272
273 Note this is used by C++, but not C. The C parser handles local
274 static variables in the parser directly. Also, this is only used
275 in C++ if the function/method name is not quoted, like e.g.:
276
277 p S:method()::var
278 p S:method() const::var
279
280 If the function/method is quoted like instead:
281
282 p 'S:method() const'::var
283
284 then the C-specific handling directly in the parser takes over (see
285 block/variable productions).
286
287 Also, if the whole function+var is quoted like this:
288
289 p 'S:method() const::var'
290
291 then the whole quoted expression is interpreted as a single symbol
292 name and we don't use OP_FUNC_STATIC_VAR either. In that case, the
293 C++-specific symbol lookup routines take care of the
294 function-local-static search. */
295 OP (OP_FUNC_STATIC_VAR)
296
297 /* OP_TYPE is for parsing types, and used with the "ptype" command
298 so we can look up types that are qualified by scope, either with
299 the GDB "::" operator, or the Modula-2 '.' operator. */
300 OP (OP_TYPE)
301
302 /* An un-looked-up identifier. */
303 OP (OP_NAME)
304
305 /* An Objective C Foundation Class NSString constant. */
306 OP (OP_OBJC_NSSTRING)
307
308 /* An array range operator (in Fortran 90, for "exp:exp", "exp:",
309 ":exp" and ":"). */
310 OP (OP_RANGE)
311
312 /* OP_ADL_FUNC specifies that the function is to be looked up in an
313 Argument Dependent manner (Koenig lookup). */
314 OP (OP_ADL_FUNC)
315
316 /* The typeof operator. This has one expression argument, which is
317 evaluated solely for its type. */
318 OP (OP_TYPEOF)
319
320 /* The decltype operator. This has one expression argument, which is
321 evaluated solely for its type. This is similar to typeof, but has
322 slight different semantics. */
323 OP (OP_DECLTYPE)
324
325 /* The typeid operator. This has one expression argument. */
326 OP (OP_TYPEID)
327
328 /* This is used for the Rust [expr; N] form of array construction. It
329 takes two expression arguments. */
330 OP (OP_RUST_ARRAY)
331
332 /* First extension operator. Some language modules define extra
333 operators below with numbers higher than OP_EXTENDED0. */
334 OP (OP_EXTENDED0)
335
336 /* ================ Ada operators ================ */
337
338 /* X IN A'RANGE(N). N is an immediate operand, surrounded by
339 BINOP_IN_BOUNDS before and after. A is an array, X an index
340 value. Evaluates to true iff X is within range of the Nth
341 dimension (1-based) of A. (A multi-dimensional array
342 type is represented as array of array of ...) */
343 OP (BINOP_IN_BOUNDS)
344
345 /* X IN L .. U. True iff L <= X <= U. */
346 OP (TERNOP_IN_RANGE)
347
348 /* Ada attributes ('Foo). */
349 OP (OP_ATR_FIRST)
350 OP (OP_ATR_LAST)
351 OP (OP_ATR_LENGTH)
352 OP (OP_ATR_IMAGE)
353 OP (OP_ATR_MODULUS)
354 OP (OP_ATR_POS)
355 OP (OP_ATR_SIZE)
356 OP (OP_ATR_TAG)
357 OP (OP_ATR_VAL)
358
359 /* Ada type qualification. It is encoded as for UNOP_CAST, above,
360 and denotes the TYPE'(EXPR) construct. */
361 OP (UNOP_QUAL)
362
363 /* X IN TYPE. The `TYPE' argument is immediate, with
364 UNOP_IN_RANGE before and after it. True iff X is a member of
365 type TYPE (typically a subrange). */
366 OP (UNOP_IN_RANGE)
367
368 /* An aggregate. A single immediate operand, N>0, gives
369 the number of component specifications that follow. The
370 immediate operand is followed by a second OP_AGGREGATE.
371 Next come N component specifications. A component
372 specification is either an OP_OTHERS (others=>...), an
373 OP_CHOICES (for named associations), or other expression (for
374 positional aggregates only). Aggregates currently
375 occur only as the right sides of assignments. */
376 OP (OP_AGGREGATE)
377
378 /* An others clause. Followed by a single expression. */
379 OP (OP_OTHERS)
380
381 /* An aggregate component association. A single immediate operand, N,
382 gives the number of choices that follow. This is followed by a second
383 OP_CHOICES operator. Next come N operands, each of which is an
384 expression, an OP_DISCRETE_RANGE, or an OP_NAME---the latter
385 for a simple name that must be a record component name and does
386 not correspond to a single existing symbol. After the N choice
387 indicators comes an expression giving the value.
388
389 In an aggregate such as (X => E1, ...), where X is a simple
390 name, X could syntactically be either a component_selector_name
391 or an expression used as a discrete_choice, depending on the
392 aggregate's type context. Since this is not known at parsing
393 time, we don't attempt to disambiguate X if it has multiple
394 definitions, but instead supply an OP_NAME. If X has a single
395 definition, we represent it with an OP_VAR_VALUE, even though
396 it may turn out to be within a record aggregate. Aggregate
397 evaluation can use either OP_NAMEs or OP_VAR_VALUEs to get a
398 record field name, and can evaluate OP_VAR_VALUE normally to
399 get its value as an expression. Unfortunately, we lose out in
400 cases where X has multiple meanings and is part of an array
401 aggregate. I hope these are not common enough to annoy users,
402 who can work around the problem in any case by putting
403 parentheses around X. */
404 OP (OP_CHOICES)
405
406 /* A positional aggregate component association. The operator is
407 followed by a single integer indicating the position in the
408 aggregate (0-based), followed by a second OP_POSITIONAL. Next
409 follows a single expression giving the component value. */
410 OP (OP_POSITIONAL)
411
412 /* A range of values. Followed by two expressions giving the
413 upper and lower bounds of the range. */
414 OP (OP_DISCRETE_RANGE)
415
416 /* ================ Fortran operators ================ */
417
418 /* This is EXACTLY like OP_FUNCALL but is semantically different.
419 In F77, array subscript expressions, substring expressions and
420 function calls are all exactly the same syntactically. They
421 may only be disambiguated at runtime. Thus this operator,
422 which indicates that we have found something of the form
423 <name> ( <stuff> ). */
424 OP (OP_F77_UNDETERMINED_ARGLIST)
425
426 /* Single operand builtins. */
427 OP (UNOP_FORTRAN_KIND)
428 OP (UNOP_FORTRAN_FLOOR)
429 OP (UNOP_FORTRAN_CEILING)
430 OP (UNOP_FORTRAN_ALLOCATED)
431
432 /* Two operand builtins. */
433 OP (BINOP_FORTRAN_CMPLX)
434 OP (BINOP_FORTRAN_MODULO)
435
436 /* Builtins that take one or two operands. */
437 OP (FORTRAN_LBOUND)
438 OP (FORTRAN_UBOUND)
439 OP (FORTRAN_ASSOCIATED)