/* Parse expressions for GDB.
- Copyright (C) 1986-2014 Free Software Foundation, Inc.
+ Copyright (C) 1986-2015 Free Software Foundation, Inc.
Modified from expread.y by the Department of Computer Science at the
State University of New York at Buffalo, 1991.
#include "defs.h"
#include <ctype.h>
#include "arch-utils.h"
-#include <string.h>
#include "symtab.h"
#include "gdbtypes.h"
#include "frame.h"
#include "symfile.h" /* for overlay functions */
#include "inferior.h"
#include "doublest.h"
-#include "gdb_assert.h"
#include "block.h"
#include "source.h"
#include "objfiles.h"
-#include "exceptions.h"
#include "user-regs.h"
/* Standard set of definitions for printing, dumping, prefixifying,
void
start_arglist (void)
{
- struct funcall *new;
+ struct funcall *newobj;
- new = (struct funcall *) xmalloc (sizeof (struct funcall));
- new->next = funcall_chain;
- new->arglist_len = arglist_len;
+ newobj = (struct funcall *) xmalloc (sizeof (struct funcall));
+ newobj->next = funcall_chain;
+ newobj->arglist_len = arglist_len;
arglist_len = 0;
- funcall_chain = new;
+ funcall_chain = newobj;
}
/* Return the number of arguments in a function call just terminated,
&& expout_last_struct == -1);
gdb_assert (tag == TYPE_CODE_UNION
|| tag == TYPE_CODE_STRUCT
- || tag == TYPE_CODE_CLASS
|| tag == TYPE_CODE_ENUM);
expout_tag_completion_type = tag;
expout_completion_name = xmalloc (length + 1);
const struct block *block,
int comma, int void_context_p, int *out_subexp)
{
- volatile struct gdb_exception except;
struct cleanup *old_chain, *inner_chain;
const struct language_defn *lang = NULL;
struct parser_state ps;
struct symtab_and_line cursal = get_current_source_symtab_and_line ();
if (cursal.symtab)
expression_context_block
- = BLOCKVECTOR_BLOCK (BLOCKVECTOR (cursal.symtab), STATIC_BLOCK);
+ = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (cursal.symtab),
+ STATIC_BLOCK);
if (expression_context_block)
expression_context_pc = BLOCK_START (expression_context_block);
}
inner_chain = make_cleanup_restore_current_language ();
set_language (lang->la_language);
- TRY_CATCH (except, RETURN_MASK_ALL)
+ TRY
{
if (lang->la_parser (&ps))
lang->la_error (NULL);
}
- if (except.reason < 0)
+ CATCH (except, RETURN_MASK_ALL)
{
if (! parse_completion)
{
throw_exception (except);
}
}
+ END_CATCH
reallocate_expout (&ps);
return exp;
}
+/* Same as parse_expression, but using the given language (LANG)
+ to parse the expression. */
+
+struct expression *
+parse_expression_with_language (const char *string, enum language lang)
+{
+ struct cleanup *old_chain = NULL;
+ struct expression *expr;
+
+ if (current_language->la_language != lang)
+ {
+ old_chain = make_cleanup_restore_current_language ();
+ set_language (lang);
+ }
+
+ expr = parse_expression (string);
+
+ if (old_chain != NULL)
+ do_cleanups (old_chain);
+ return expr;
+}
+
/* Parse STRING as an expression. If parsing ends in the middle of a
field reference, return the type of the left-hand-side of the
reference; furthermore, if the parsing ends in the field name,
struct expression *exp = NULL;
struct value *val;
int subexp;
- volatile struct gdb_exception except;
- TRY_CATCH (except, RETURN_MASK_ERROR)
+ TRY
{
parse_completion = 1;
exp = parse_exp_in_context (&string, 0, 0, 0, 0, &subexp);
}
+ CATCH (except, RETURN_MASK_ERROR)
+ {
+ /* Nothing, EXP remains NULL. */
+ }
+ END_CATCH
+
parse_completion = 0;
- if (except.reason < 0 || ! exp)
+ if (exp == NULL)
return NULL;
if (expout_tag_completion_type != TYPE_CODE_UNDEF)
lookup_array_range_type (follow_type,
0, array_size >= 0 ? array_size - 1 : 0);
if (array_size < 0)
- TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (follow_type) = 1;
+ TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (follow_type))
+ = PROP_UNDEFINED;
break;
case tp_function:
/* FIXME-type-allocation: need a way to free this type when we are
/* Check objfile where the variable itself is placed.
SYMBOL_OBJ_SECTION (symbol) may be NULL. */
- if ((*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
+ if ((*objfile_func) (symbol_objfile (symbol), data))
return 1;
/* Check objfile where is placed the code touching the variable. */
return 0;
}
-/* Call OBJFILE_FUNC for any TYPE and OBJFILE found being referenced by EXP.
- The functions are never called with NULL OBJFILE. Functions get passed an
- arbitrary caller supplied DATA pointer. If any of the functions returns
- non-zero value then (any other) non-zero value is immediately returned to
- the caller. Otherwise zero is returned after iterating through whole EXP.
- */
+/* Call OBJFILE_FUNC for any objfile found being referenced by EXP.
+ OBJFILE_FUNC is never called with NULL OBJFILE. OBJFILE_FUNC get
+ passed an arbitrary caller supplied DATA pointer. If OBJFILE_FUNC
+ returns non-zero value then (any other) non-zero value is immediately
+ returned to the caller. Otherwise zero is returned after iterating
+ through whole EXP. */
static int
exp_iterate (struct expression *exp,