xref: /dflybsd-src/contrib/gdb-7/gdb/expression.h (revision c50c785cb49e9377ca78104c5540c7b33f768771)
15796c8dcSSimon Schubert /* Definitions for expressions stored in reversed prefix form, for GDB.
25796c8dcSSimon Schubert 
3cf7f2e2dSJohn Marino    Copyright (C) 1986, 1989, 1992, 1994, 2000, 2003, 2005, 2007, 2008, 2009,
4*c50c785cSJohn Marino    2010, 2011 Free Software Foundation, Inc.
55796c8dcSSimon Schubert 
65796c8dcSSimon Schubert    This file is part of GDB.
75796c8dcSSimon Schubert 
85796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
95796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
105796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
115796c8dcSSimon Schubert    (at your option) any later version.
125796c8dcSSimon Schubert 
135796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
145796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
155796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
165796c8dcSSimon Schubert    GNU General Public License for more details.
175796c8dcSSimon Schubert 
185796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
195796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
205796c8dcSSimon Schubert 
215796c8dcSSimon Schubert #if !defined (EXPRESSION_H)
225796c8dcSSimon Schubert #define EXPRESSION_H 1
235796c8dcSSimon Schubert 
245796c8dcSSimon Schubert 
255796c8dcSSimon Schubert #include "symtab.h"		/* Needed for "struct block" type.  */
265796c8dcSSimon Schubert #include "doublest.h"		/* Needed for DOUBLEST.  */
275796c8dcSSimon Schubert 
285796c8dcSSimon Schubert 
295796c8dcSSimon Schubert /* Definitions for saved C expressions.  */
305796c8dcSSimon Schubert 
315796c8dcSSimon Schubert /* An expression is represented as a vector of union exp_element's.
325796c8dcSSimon Schubert    Each exp_element is an opcode, except that some opcodes cause
335796c8dcSSimon Schubert    the following exp_element to be treated as a long or double constant
345796c8dcSSimon Schubert    or as a variable.  The opcodes are obeyed, using a stack for temporaries.
355796c8dcSSimon Schubert    The value is left on the temporary stack at the end.  */
365796c8dcSSimon Schubert 
375796c8dcSSimon Schubert /* When it is necessary to include a string,
385796c8dcSSimon Schubert    it can occupy as many exp_elements as it needs.
395796c8dcSSimon Schubert    We find the length of the string using strlen,
405796c8dcSSimon Schubert    divide to find out how many exp_elements are used up,
415796c8dcSSimon Schubert    and skip that many.  Strings, like numbers, are indicated
425796c8dcSSimon Schubert    by the preceding opcode.  */
435796c8dcSSimon Schubert 
445796c8dcSSimon Schubert enum exp_opcode
455796c8dcSSimon Schubert   {
46*c50c785cSJohn Marino #define OP(name) name ,
475796c8dcSSimon Schubert 
48*c50c785cSJohn Marino #include "std-operator.def"
495796c8dcSSimon Schubert 
50*c50c785cSJohn Marino     /* First extension operator.  Individual language modules define extra
51*c50c785cSJohn Marino        operators in *.def include files below with numbers higher than
52*c50c785cSJohn Marino        OP_EXTENDED0.  */
53*c50c785cSJohn Marino     OP (OP_EXTENDED0)
545796c8dcSSimon Schubert 
55*c50c785cSJohn Marino /* Language specific operators.  */
56*c50c785cSJohn Marino #include "ada-operator.def"
575796c8dcSSimon Schubert 
58*c50c785cSJohn Marino #undef OP
595796c8dcSSimon Schubert 
605796c8dcSSimon Schubert     /* Existing only to swallow the last comma (',') from last .inc file.  */
615796c8dcSSimon Schubert     OP_UNUSED_LAST
625796c8dcSSimon Schubert   };
635796c8dcSSimon Schubert 
645796c8dcSSimon Schubert union exp_element
655796c8dcSSimon Schubert   {
665796c8dcSSimon Schubert     enum exp_opcode opcode;
675796c8dcSSimon Schubert     struct symbol *symbol;
685796c8dcSSimon Schubert     LONGEST longconst;
695796c8dcSSimon Schubert     DOUBLEST doubleconst;
705796c8dcSSimon Schubert     gdb_byte decfloatconst[16];
715796c8dcSSimon Schubert     /* Really sizeof (union exp_element) characters (or less for the last
725796c8dcSSimon Schubert        element of a string).  */
735796c8dcSSimon Schubert     char string;
745796c8dcSSimon Schubert     struct type *type;
755796c8dcSSimon Schubert     struct internalvar *internalvar;
765796c8dcSSimon Schubert     struct block *block;
775796c8dcSSimon Schubert     struct objfile *objfile;
785796c8dcSSimon Schubert   };
795796c8dcSSimon Schubert 
805796c8dcSSimon Schubert struct expression
815796c8dcSSimon Schubert   {
82*c50c785cSJohn Marino     const struct language_defn *language_defn;	/* language it was
83*c50c785cSJohn Marino 						   entered in.  */
84*c50c785cSJohn Marino     struct gdbarch *gdbarch;  /* architecture it was parsed in.  */
855796c8dcSSimon Schubert     int nelts;
865796c8dcSSimon Schubert     union exp_element elts[1];
875796c8dcSSimon Schubert   };
885796c8dcSSimon Schubert 
895796c8dcSSimon Schubert /* Macros for converting between number of expression elements and bytes
905796c8dcSSimon Schubert    to store that many expression elements.  */
915796c8dcSSimon Schubert 
925796c8dcSSimon Schubert #define EXP_ELEM_TO_BYTES(elements) \
935796c8dcSSimon Schubert     ((elements) * sizeof (union exp_element))
945796c8dcSSimon Schubert #define BYTES_TO_EXP_ELEM(bytes) \
955796c8dcSSimon Schubert     (((bytes) + sizeof (union exp_element) - 1) / sizeof (union exp_element))
965796c8dcSSimon Schubert 
975796c8dcSSimon Schubert /* From parse.c */
985796c8dcSSimon Schubert 
995796c8dcSSimon Schubert extern struct expression *parse_expression (char *);
1005796c8dcSSimon Schubert 
1015796c8dcSSimon Schubert extern struct type *parse_field_expression (char *, char **);
1025796c8dcSSimon Schubert 
1035796c8dcSSimon Schubert extern struct expression *parse_exp_1 (char **, struct block *, int);
1045796c8dcSSimon Schubert 
1055796c8dcSSimon Schubert /* For use by parsers; set if we want to parse an expression and
1065796c8dcSSimon Schubert    attempt to complete a field name.  */
1075796c8dcSSimon Schubert extern int in_parse_field;
1085796c8dcSSimon Schubert 
1095796c8dcSSimon Schubert /* The innermost context required by the stack and register variables
1105796c8dcSSimon Schubert    we've encountered so far.  To use this, set it to NULL, then call
1115796c8dcSSimon Schubert    parse_<whatever>, then look at it.  */
1125796c8dcSSimon Schubert extern struct block *innermost_block;
1135796c8dcSSimon Schubert 
1145796c8dcSSimon Schubert /* From eval.c */
1155796c8dcSSimon Schubert 
1165796c8dcSSimon Schubert /* Values of NOSIDE argument to eval_subexp.  */
1175796c8dcSSimon Schubert 
1185796c8dcSSimon Schubert enum noside
1195796c8dcSSimon Schubert   {
1205796c8dcSSimon Schubert     EVAL_NORMAL,
1215796c8dcSSimon Schubert     EVAL_SKIP,			/* Only effect is to increment pos.  */
1225796c8dcSSimon Schubert     EVAL_AVOID_SIDE_EFFECTS	/* Don't modify any variables or
1235796c8dcSSimon Schubert 				   call any functions.  The value
1245796c8dcSSimon Schubert 				   returned will have the correct
1255796c8dcSSimon Schubert 				   type, and will have an
1265796c8dcSSimon Schubert 				   approximately correct lvalue
1275796c8dcSSimon Schubert 				   type (inaccuracy: anything that is
1285796c8dcSSimon Schubert 				   listed as being in a register in
1295796c8dcSSimon Schubert 				   the function in which it was
1305796c8dcSSimon Schubert 				   declared will be lval_register).  */
1315796c8dcSSimon Schubert   };
1325796c8dcSSimon Schubert 
1335796c8dcSSimon Schubert extern struct value *evaluate_subexp_standard
1345796c8dcSSimon Schubert   (struct type *, struct expression *, int *, enum noside);
1355796c8dcSSimon Schubert 
1365796c8dcSSimon Schubert /* From expprint.c */
1375796c8dcSSimon Schubert 
1385796c8dcSSimon Schubert extern void print_expression (struct expression *, struct ui_file *);
1395796c8dcSSimon Schubert 
1405796c8dcSSimon Schubert extern char *op_string (enum exp_opcode);
1415796c8dcSSimon Schubert 
142*c50c785cSJohn Marino extern void dump_raw_expression (struct expression *,
143*c50c785cSJohn Marino 				 struct ui_file *, char *);
1445796c8dcSSimon Schubert extern void dump_prefix_expression (struct expression *, struct ui_file *);
1455796c8dcSSimon Schubert 
1465796c8dcSSimon Schubert #endif /* !defined (EXPRESSION_H) */
147