2002-02-10 Daniel Jacobowitz <drow@mvista.com>
[deliverable/binutils-gdb.git] / gdb / parse.c
index 2edc6d76669eb5b7a2e037b9e47f09afeb626ee1..b3fbe19950bfee39708952680269a3f52e64a514 100644 (file)
@@ -46,6 +46,7 @@
 #include "symfile.h"           /* for overlay functions */
 #include "inferior.h"          /* for NUM_PSEUDO_REGS.  NOTE: replace 
                                   with "gdbarch.h" when appropriate.  */
+#include "doublest.h"
 
 \f
 /* Symbols which architectures can redefine.  */
@@ -116,25 +117,8 @@ target_map_name_to_register (char *str, int len)
 {
   int i;
 
-  /* First try target specific aliases. We try these first because on some 
-     systems standard names can be context dependent (eg. $pc on a 
-     multiprocessor can be could be any of several PCs).  */
-#ifdef REGISTER_NAME_ALIAS_HOOK
-  i = REGISTER_NAME_ALIAS_HOOK (str, len);
-  if (i >= 0)
-    return i;
-#endif
-
-  /* Search architectural register name space. */
-  for (i = 0; i < NUM_REGS; i++)
-    if (REGISTER_NAME (i) && len == strlen (REGISTER_NAME (i))
-       && STREQN (str, REGISTER_NAME (i), len))
-      {
-       return i;
-      }
-
-  /* Try pseudo-registers, if any. */
-  for (i = NUM_REGS; i < NUM_REGS + NUM_PSEUDO_REGS; i++)
+  /* Search register name space. */
+  for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++)
     if (REGISTER_NAME (i) && len == strlen (REGISTER_NAME (i))
        && STREQN (str, REGISTER_NAME (i), len))
       {
@@ -1207,8 +1191,8 @@ parse_expression (char *string)
 /* Stuff for maintaining a stack of types.  Currently just used by C, but
    probably useful for any language which declares its types "backwards".  */
 
-void
-push_type (enum type_pieces tp)
+static void
+check_type_stack_depth (void)
 {
   if (type_stack_depth == type_stack_size)
     {
@@ -1216,21 +1200,28 @@ push_type (enum type_pieces tp)
       type_stack = (union type_stack_elt *)
        xrealloc ((char *) type_stack, type_stack_size * sizeof (*type_stack));
     }
+}
+
+void
+push_type (enum type_pieces tp)
+{
+  check_type_stack_depth ();
   type_stack[type_stack_depth++].piece = tp;
 }
 
 void
 push_type_int (int n)
 {
-  if (type_stack_depth == type_stack_size)
-    {
-      type_stack_size *= 2;
-      type_stack = (union type_stack_elt *)
-       xrealloc ((char *) type_stack, type_stack_size * sizeof (*type_stack));
-    }
+  check_type_stack_depth ();
   type_stack[type_stack_depth++].int_val = n;
 }
 
+void
+push_type_address_space (char *string)
+{
+  push_type_int (address_space_name_to_int (string));
+}
+
 enum type_pieces
 pop_type (void)
 {
@@ -1254,6 +1245,9 @@ struct type *
 follow_types (struct type *follow_type)
 {
   int done = 0;
+  int make_const = 0;
+  int make_volatile = 0;
+  int make_addr_space = 0;
   int array_size;
   struct type *range_type;
 
@@ -1262,12 +1256,60 @@ follow_types (struct type *follow_type)
       {
       case tp_end:
        done = 1;
+       if (make_const)
+         follow_type = make_cv_type (make_const, 
+                                     TYPE_VOLATILE (follow_type), 
+                                     follow_type, 0);
+       if (make_volatile)
+         follow_type = make_cv_type (TYPE_CONST (follow_type), 
+                                     make_volatile, 
+                                     follow_type, 0);
+       if (make_addr_space)
+         follow_type = make_type_with_address_space (follow_type, 
+                                                     make_addr_space);
+       make_const = make_volatile = 0;
+       make_addr_space = 0;
+       break;
+      case tp_const:
+       make_const = 1;
+       break;
+      case tp_volatile:
+       make_volatile = 1;
+       break;
+      case tp_space_identifier:
+       make_addr_space = pop_type_int ();
        break;
       case tp_pointer:
        follow_type = lookup_pointer_type (follow_type);
+       if (make_const)
+         follow_type = make_cv_type (make_const, 
+                                     TYPE_VOLATILE (follow_type), 
+                                     follow_type, 0);
+       if (make_volatile)
+         follow_type = make_cv_type (TYPE_CONST (follow_type), 
+                                     make_volatile, 
+                                     follow_type, 0);
+       if (make_addr_space)
+         follow_type = make_type_with_address_space (follow_type, 
+                                                     make_addr_space);
+       make_const = make_volatile = 0;
+       make_addr_space = 0;
        break;
       case tp_reference:
        follow_type = lookup_reference_type (follow_type);
+       if (make_const)
+         follow_type = make_cv_type (make_const, 
+                                     TYPE_VOLATILE (follow_type), 
+                                     follow_type, 0);
+       if (make_volatile)
+         follow_type = make_cv_type (TYPE_CONST (follow_type), 
+                                     make_volatile, 
+                                     follow_type, 0);
+       if (make_addr_space)
+         follow_type = make_type_with_address_space (follow_type, 
+                                                     make_addr_space);
+       make_const = make_volatile = 0;
+       make_addr_space = 0;
        break;
       case tp_array:
        array_size = pop_type_int ();
This page took 0.025821 seconds and 4 git commands to generate.