Add an expr::operation_up to struct expression
[deliverable/binutils-gdb.git] / gdb / parse.c
index 884a00862ece650d99cb28f8e0eb6bd81c51ec0d..68386f17bc5e026a3cc578593e4cc2113b0d8842 100644 (file)
@@ -50,6 +50,7 @@
 #include "user-regs.h"
 #include <algorithm>
 #include "gdbsupport/gdb_optional.h"
+#include "c-exp.h"
 
 /* Standard set of definitions for printing, dumping, prefixifying,
  * and evaluating expressions.  */
@@ -1073,7 +1074,6 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
                      expr_completion_state *cstate)
 {
   const struct language_defn *lang = NULL;
-  int subexp;
 
   if (*stringptr == 0 || **stringptr == 0)
     error_no_arg (_("expression to compute"));
@@ -1153,7 +1153,8 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
       /* If parsing for completion, allow this to succeed; but if no
         expression elements have been written, then there's nothing
         to do, so fail.  */
-      if (! ps.parse_completion || ps.expout_ptr == 0)
+      if (! ps.parse_completion
+         || (ps.expout->op == nullptr && ps.expout_ptr == 0))
        throw;
     }
 
@@ -1168,12 +1169,17 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
     dump_raw_expression (result.get (), gdb_stdlog,
                         "before conversion to prefix form");
 
-  subexp = prefixify_expression (result.get (),
-                                ps.m_completion_state.expout_last_struct);
-  if (out_subexp)
-    *out_subexp = subexp;
+  if (result->op == nullptr)
+    {
+      int subexp = prefixify_expression (result.get (),
+                                        ps.m_completion_state.expout_last_struct);
+      if (out_subexp)
+       *out_subexp = subexp;
 
-  lang->post_parser (&result, &ps);
+      lang->post_parser (&result, &ps);
+    }
+  else
+    result->op->set_outermost ();
 
   if (expressiondebug)
     dump_prefix_expression (result.get (), gdb_stdlog);
@@ -1441,6 +1447,9 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile)
 {
   gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
 
+  if (exp->op != nullptr)
+    return exp->op->uses_objfile (objfile);
+
   return exp_iterate (exp, exp_uses_objfile_iter, objfile);
 }
 
This page took 0.025985 seconds and 4 git commands to generate.