Remove config.if.
[deliverable/binutils-gdb.git] / gdb / parse.c
index da39866f759ea3f85379f948699906f77a7affdd..c65d8bc4407c3d7c22bcf649b7dabaeed4e19b39 100644 (file)
@@ -1,6 +1,8 @@
 /* Parse expressions for GDB.
-   Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
-   1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+
+   Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+   1997, 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+
    Modified from expread.y by the Department of Computer Science at the
    State University of New York at Buffalo, 1991.
 
@@ -61,21 +63,6 @@ const struct exp_descriptor exp_descriptor_standard =
     dump_subexp_body_standard,
     evaluate_subexp_standard
   };
-\f
-/* Symbols which architectures can redefine.  */
-
-/* Some systems have routines whose names start with `$'.  Giving this
-   macro a non-zero value tells GDB's expression parser to check for
-   such routines when parsing tokens that begin with `$'.
-
-   On HP-UX, certain system routines (millicode) have names beginning
-   with `$' or `$$'.  For example, `$$dyncall' is a millicode routine
-   that handles inter-space procedure calls on PA-RISC.  */
-#ifndef SYMBOLS_CAN_START_WITH_DOLLAR
-#define SYMBOLS_CAN_START_WITH_DOLLAR (0)
-#endif
-
-
 \f
 /* Global variables declared in parser-defs.h (and commented there).  */
 struct expression *expout;
@@ -95,8 +82,6 @@ int comma_terminates;
 \f
 static int expressiondebug = 0;
 
-extern int hp_som_som_object_present;
-
 static void free_funcalls (void *ignore);
 
 static void prefixify_expression (struct expression *);
@@ -104,6 +89,9 @@ static void prefixify_expression (struct expression *);
 static void prefixify_subexp (struct expression *, struct expression *, int,
                              int);
 
+static struct expression *parse_exp_in_context (char **, struct block *, int, 
+                                               int);
+
 void _initialize_parse (void);
 
 /* Data structure for saving values of arglist_len for function calls whose
@@ -434,6 +422,9 @@ write_exp_msymbol (struct minimal_symbol *msymbol,
 void
 write_dollar_variable (struct stoken str)
 {
+  struct symbol *sym = NULL;
+  struct minimal_symbol *msym = NULL;
+
   /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
      and $$digits (equivalent to $<-digits> if you could type that). */
 
@@ -471,36 +462,26 @@ write_dollar_variable (struct stoken str)
   if (i >= 0)
     goto handle_register;
 
-  if (SYMBOLS_CAN_START_WITH_DOLLAR)
-    {
-      struct symbol *sym = NULL;
-      struct minimal_symbol *msym = NULL;
+  /* On some systems, such as HP-UX and hppa-linux, certain system routines 
+     have names beginning with $ or $$.  Check for those, first. */
 
-      /* On HP-UX, certain system routines (millicode) have names beginning
-        with $ or $$, e.g. $$dyncall, which handles inter-space procedure
-        calls on PA-RISC. Check for those, first. */
-
-      /* This code is not enabled on non HP-UX systems, since worst case 
-        symbol table lookup performance is awful, to put it mildly. */
-
-      sym = lookup_symbol (copy_name (str), (struct block *) NULL,
-                          VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL);
-      if (sym)
-       {
-         write_exp_elt_opcode (OP_VAR_VALUE);
-         write_exp_elt_block (block_found);    /* set by lookup_symbol */
-         write_exp_elt_sym (sym);
-         write_exp_elt_opcode (OP_VAR_VALUE);
-         return;
-       }
-      msym = lookup_minimal_symbol (copy_name (str), NULL, NULL);
-      if (msym)
-       {
-         write_exp_msymbol (msym,
-                            lookup_function_type (builtin_type_int),
-                            builtin_type_int);
-         return;
-       }
+  sym = lookup_symbol (copy_name (str), (struct block *) NULL,
+                      VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL);
+  if (sym)
+    {
+      write_exp_elt_opcode (OP_VAR_VALUE);
+      write_exp_elt_block (block_found);       /* set by lookup_symbol */
+      write_exp_elt_sym (sym);
+      write_exp_elt_opcode (OP_VAR_VALUE);
+      return;
+    }
+  msym = lookup_minimal_symbol (copy_name (str), NULL, NULL);
+  if (msym)
+    {
+      write_exp_msymbol (msym,
+                        lookup_function_type (builtin_type_int),
+                        builtin_type_int);
+      return;
     }
 
   /* Any other names starting in $ are debugger internal variables.  */
@@ -590,7 +571,7 @@ parse_nested_classes_for_hpacc (char *name, int len, char **token,
      return NULL, and caller must default to standard GDB
      behaviour. */
 
-  if (!hp_som_som_object_present)
+  if (!deprecated_hp_som_som_object_present)
     return (struct symbol *) NULL;
 
   p = name;
@@ -1022,6 +1003,16 @@ prefixify_subexp (struct expression *inexpr,
 
 struct expression *
 parse_exp_1 (char **stringptr, struct block *block, int comma)
+{
+  return parse_exp_in_context (stringptr, block, comma, 0);
+}
+
+/* As for parse_exp_1, except that if VOID_CONTEXT_P, then
+   no value is expected from the expression.  */
+
+static struct expression *
+parse_exp_in_context (char **stringptr, struct block *block, int comma, 
+                     int void_context_p)
 {
   struct cleanup *old_chain;
 
@@ -1078,6 +1069,8 @@ parse_exp_1 (char **stringptr, struct block *block, int comma)
 
   prefixify_expression (expout);
 
+  current_language->la_post_parser (&expout, void_context_p);
+
   if (expressiondebug)
     dump_prefix_expression (expout, gdb_stdlog);
 
@@ -1097,6 +1090,27 @@ parse_expression (char *string)
     error ("Junk after end of expression.");
   return exp;
 }
+
+
+/* As for parse_expression, except that if VOID_CONTEXT_P, then
+   no value is expected from the expression.  */
+
+struct expression *
+parse_expression_in_context (char *string, int void_context_p)
+{
+  struct expression *exp;
+  exp = parse_exp_in_context (&string, 0, 0, void_context_p);
+  if (*string != '\000')
+    error ("Junk after end of expression.");
+  return exp;
+}
+
+/* A post-parser that does nothing */
+
+void
+null_post_parser (struct expression **exp, int void_context_p)
+{
+}
 \f
 /* Stuff for maintaining a stack of types.  Currently just used by C, but
    probably useful for any language which declares its types "backwards".  */
@@ -1293,17 +1307,16 @@ _initialize_parse (void)
   /* FIXME - For the moment, handle types by swapping them in and out.
      Should be using the per-architecture data-pointer and a large
      struct. */
-  register_gdbarch_swap (&msym_text_symbol_type, sizeof (msym_text_symbol_type), NULL);
-  register_gdbarch_swap (&msym_data_symbol_type, sizeof (msym_data_symbol_type), NULL);
-  register_gdbarch_swap (&msym_unknown_symbol_type, sizeof (msym_unknown_symbol_type), NULL);
-
-  register_gdbarch_swap (NULL, 0, build_parse);
-
-  add_show_from_set (
-           add_set_cmd ("expression", class_maintenance, var_zinteger,
-                        (char *) &expressiondebug,
-                        "Set expression debugging.\n\
+  DEPRECATED_REGISTER_GDBARCH_SWAP (msym_text_symbol_type);
+  DEPRECATED_REGISTER_GDBARCH_SWAP (msym_data_symbol_type);
+  DEPRECATED_REGISTER_GDBARCH_SWAP (msym_unknown_symbol_type);
+  deprecated_register_gdbarch_swap (NULL, 0, build_parse);
+
+  deprecated_add_show_from_set
+    (add_set_cmd ("expression", class_maintenance, var_zinteger,
+                 (char *) &expressiondebug,
+                 "Set expression debugging.\n\
 When non-zero, the internal representation of expressions will be printed.",
-                        &setdebuglist),
-                     &showdebuglist);
+                 &setdebuglist),
+     &showdebuglist);
 }
This page took 0.026315 seconds and 4 git commands to generate.