static void free_funcalls (void *ignore);
-static int prefixify_expression (struct expression *);
-
static int prefixify_subexp (struct expression *, struct expression *, int,
int);
/* This page contains the functions for adding data to the struct expression
being constructed. */
+/* See definition in parser-defs.h. */
+
+void
+initialize_expout (int initial_size, const struct language_defn *lang,
+ struct gdbarch *gdbarch)
+{
+ expout_size = initial_size;
+ expout_ptr = 0;
+ expout = xmalloc (sizeof (struct expression)
+ + EXP_ELEM_TO_BYTES (expout_size));
+ expout->language_defn = lang;
+ expout->gdbarch = gdbarch;
+}
+
+/* See definition in parser-defs.h. */
+
+void
+reallocate_expout (void)
+{
+ /* Record the actual number of expression elements, and then
+ reallocate the expression memory so that we free up any
+ excess elements. */
+
+ expout->nelts = expout_ptr;
+ expout = xrealloc ((char *) expout,
+ sizeof (struct expression)
+ + EXP_ELEM_TO_BYTES (expout_ptr));
+}
+
/* Add one element to the end of the expression. */
/* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
return namecopy;
}
\f
-/* Reverse an expression from suffix form (in which it is constructed)
- to prefix form (in which we can conveniently print or execute it).
- Ordinarily this always returns -1. However, if EXPOUT_LAST_STRUCT
- is not -1 (i.e., we are trying to complete a field name), it will
- return the index of the subexpression which is the left-hand-side
- of the struct operation at EXPOUT_LAST_STRUCT. */
-static int
+/* See comments on parser-defs.h. */
+
+int
prefixify_expression (struct expression *expr)
{
int len = sizeof (struct expression) + EXP_ELEM_TO_BYTES (expr->nelts);
else
lang = current_language;
- expout_size = 10;
- expout_ptr = 0;
- expout = (struct expression *)
- xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
- expout->language_defn = lang;
- expout->gdbarch = get_current_arch ();
+ initialize_expout (10, lang, get_current_arch ());
TRY_CATCH (except, RETURN_MASK_ALL)
{
discard_cleanups (old_chain);
- /* Record the actual number of expression elements, and then
- reallocate the expression memory so that we free up any
- excess elements. */
-
- expout->nelts = expout_ptr;
- expout = (struct expression *)
- xrealloc ((char *) expout,
- sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_ptr));
+ reallocate_expout ();
/* Convert expression from postfix form as generated by yacc
parser, to a prefix form. */