Add completion for operations
[deliverable/binutils-gdb.git] / gdb / parser-defs.h
index d6c3b068978efed010263ad85cdea2460344fd50..9f70ff9dca7aa3a005dd9125df65e0f36b723ed8 100644 (file)
@@ -1,6 +1,6 @@
 /* Parser definitions for GDB.
 
-   Copyright (C) 1986-2020 Free Software Foundation, Inc.
+   Copyright (C) 1986-2021 Free Software Foundation, Inc.
 
    Modified from expread.y by the Department of Computer Science at the
    State University of New York at Buffalo.
@@ -25,6 +25,7 @@
 
 #include "expression.h"
 #include "symtab.h"
+#include "expop.h"
 
 struct block;
 struct language_defn;
@@ -63,6 +64,13 @@ struct expr_builder
     return expout->language_defn;
   }
 
+  /* Set the root operation of the expression that is currently being
+     built.  */
+  void set_operation (expr::operation_up &&op)
+  {
+    expout->op = std::move (op);
+  }
+
   /* The size of the expression above.  */
 
   size_t expout_size;
@@ -86,6 +94,11 @@ struct expr_completion_state
      field name.  It is -1 if no dereference operation was found.  */
   int expout_last_struct = -1;
 
+  /* The last struct expression directly before a '.' or '->'.  This
+     is set when parsing and is only used when completing a field
+     name.  It is nullptr if no dereference operation was found.  */
+  expr::structop_base_operation *expout_last_op = nullptr;
+
   /* If we are completing a tagged type name, this will be nonzero.  */
   enum type_code expout_tag_completion_type = TYPE_CODE_UNDEF;
 
@@ -109,14 +122,16 @@ struct parser_state : public expr_builder
                int comma,
                const char *input,
                int completion,
-               innermost_block_tracker *tracker)
+               innermost_block_tracker *tracker,
+               bool void_p)
     : expr_builder (lang, gdbarch),
       expression_context_block (context_block),
       expression_context_pc (context_pc),
       comma_terminates (comma),
       lexptr (input),
       parse_completion (completion),
-      block_tracker (tracker)
+      block_tracker (tracker),
+      void_context_p (void_p)
   {
   }
 
@@ -147,6 +162,11 @@ struct parser_state : public expr_builder
 
   void mark_struct_expression ();
 
+  /* Mark the given operation as the starting location of a structure
+     expression.  This is used when completing on field names.  */
+
+  void mark_struct_expression (expr::structop_base_operation *op);
+
   /* Indicate that the current parser invocation is completing a tag.
      TAG is the type code of the tag, and PTR and LENGTH represent the
      start of the tag name.  */
@@ -192,6 +212,9 @@ struct parser_state : public expr_builder
   /* The innermost block tracker.  */
   innermost_block_tracker *block_tracker;
 
+  /* True if no value is expected from the expression.  */
+  bool void_context_p;
+
 private:
 
   /* Data structure for saving values of arglist_len for function calls whose
@@ -329,6 +352,16 @@ extern void write_exp_msymbol (struct expr_builder *,
 
 extern void write_dollar_variable (struct parser_state *, struct stoken str);
 
+/* Write a reference to a symbol to the expression being built in PS.
+   NAME is the name of the symbol to write; SYM is the symbol.  If SYM
+   is nullptr (meaning the 'symbol' member), a minimal symbol will be
+   searched for and used if available.  Throws an exception if SYM is
+   nullptr and no minimal symbol can be found.  */
+
+extern void write_exp_symbol_reference (struct parser_state *ps,
+                                       const char *name,
+                                       struct block_symbol sym);
+
 extern const char *find_template_name_end (const char *);
 
 extern std::string copy_name (struct stoken);
@@ -338,6 +371,13 @@ extern int dump_subexp (struct expression *, struct ui_file *, int);
 extern int dump_subexp_body_standard (struct expression *, 
                                      struct ui_file *, int);
 
+/* Dump (to STREAM) a function call like expression at position ELT in the
+   expression array EXP.  Return a new value for ELT just after the
+   function call expression.  */
+
+extern int dump_subexp_body_funcall (struct expression *exp,
+                                    struct ui_file *stream, int elt);
+
 extern void operator_length (const struct expression *, int, int *, int *);
 
 extern void operator_length_standard (const struct expression *, int, int *,
@@ -348,11 +388,6 @@ extern int operator_check_standard (struct expression *exp, int pos,
                                      (struct objfile *objfile, void *data),
                                    void *data);
 
-extern const char *op_name_standard (enum exp_opcode);
-
-extern void null_post_parser (expression_up *, int, int,
-                             innermost_block_tracker *);
-
 extern bool parse_float (const char *p, int len,
                         const struct type *type, gdb_byte *data);
 \f
@@ -413,12 +448,6 @@ struct exp_descriptor
                                                void *data),
                           void *data);
 
-    /* Name of this operator for dumping purposes.
-       The returned value should never be NULL, even if EXP_OPCODE is
-       an unknown opcode (a string containing an image of the numeric
-       value of the opcode can be returned, for instance).  */
-    const char *(*op_name) (enum exp_opcode);
-
     /* Dump the rest of this (prefix) expression after the operator
        itself has been printed.  See dump_subexp_body_standard in
        (expprint.c).  */
@@ -443,6 +472,15 @@ extern void print_subexp (struct expression *, int *, struct ui_file *,
 extern void print_subexp_standard (struct expression *, int *, 
                                   struct ui_file *, enum precedence);
 
+/* Print a function call like expression to STREAM.  This is called as a
+   helper function by which point the expression node identifying this as a
+   function call has already been stripped off and POS should point to the
+   number of function call arguments.  EXP is the object containing the
+   list of expression elements.  */
+
+extern void print_subexp_funcall (struct expression *exp, int *pos,
+                                 struct ui_file *stream);
+
 /* Function used to avoid direct calls to fprintf
    in the code generated by the bison parser.  */
 
This page took 0.027386 seconds and 4 git commands to generate.