OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [expression.h] - Blame information for rev 24

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.