* jv-lang.c (jv_type_objfile_data_key, dynamics_objfile)
[deliverable/binutils-gdb.git] / gdb / ada-exp.y
index 9e8abaf26774210ebb7b110b73bf24838b39997a..e64d1eb4566ff66c5e8a37a2636323df6a15ed1e 100644 (file)
@@ -1,23 +1,21 @@
 /* YACC parser for Ada expressions, for GDB.
-   Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1997, 2000, 2003, 
-   2004 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1997, 2000, 2003, 2004,
+   2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 
-This file is part of GDB.
+   This file is part of GDB.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Parse an Ada expression from text in a string,
    and return the result as a  struct expression  pointer.
@@ -52,6 +50,8 @@ Boston, MA 02110-1301, USA.  */
 #include "frame.h"
 #include "block.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
    yacc generated parsers in gdb.  These are only the variables
@@ -124,7 +124,8 @@ static struct stoken string_to_operator (struct stoken);
 
 static void write_int (LONGEST, struct type *);
 
-static void write_object_renaming (struct block *, struct symbol *, int);
+static void write_object_renaming (struct block *, const char *, int,
+                                  const char *, int);
 
 static struct type* write_var_or_type (struct block *, struct stoken);
 
@@ -152,6 +153,8 @@ static struct type *type_long_double (void);
 
 static struct type *type_char (void);
 
+static struct type *type_boolean (void);
+
 static struct type *type_system_address (void);
 
 %}
@@ -179,6 +182,7 @@ static struct type *type_system_address (void);
 
 %token <typed_val> INT NULL_PTR CHARLIT
 %token <typed_val_float> FLOAT
+%token TRUEKEYWORD FALSEKEYWORD
 %token COLONCOLON
 %token <sval> STRING NAME DOT_ID 
 %type <bval> block
@@ -252,7 +256,7 @@ primary :   primary '(' arglist ')'
                          if ($1 != NULL)
                            {
                              if ($3 != 1)
-                               error ("Invalid conversion");
+                               error (_("Invalid conversion"));
                              write_exp_elt_opcode (UNOP_CAST);
                              write_exp_elt_type ($1);
                              write_exp_elt_opcode (UNOP_CAST);
@@ -270,7 +274,7 @@ primary :   var_or_type '\'' save_qualifier { type_qualifier = $1; }
                   '(' exp ')'
                        {
                          if ($1 == NULL)
-                           error ("Type required for qualification");
+                           error (_("Type required for qualification"));
                          write_exp_elt_opcode (UNOP_QUAL);
                          write_exp_elt_type ($1);
                          write_exp_elt_opcode (UNOP_QUAL);
@@ -288,7 +292,7 @@ primary :
                        { if ($1 == NULL) 
                             write_exp_elt_opcode (TERNOP_SLICE);
                          else
-                           error ("Cannot slice a type");
+                           error (_("Cannot slice a type"));
                        }
        ;
 
@@ -352,11 +356,11 @@ arglist   :       exp
                        { $$ = $1 + 1; }
        ;
 
-simple_exp :   '{' var_or_type '}' simple_exp  %prec '.'
+primary :      '{' var_or_type '}' primary  %prec '.'
                /* GDB extension */
                        { 
                          if ($2 == NULL)
-                           error ("Type required within braces in coercion");
+                           error (_("Type required within braces in coercion"));
                          write_exp_elt_opcode (UNOP_MEMVAL);
                          write_exp_elt_type ($2);
                          write_exp_elt_opcode (UNOP_MEMVAL);
@@ -426,7 +430,7 @@ relation :  simple_exp IN simple_exp DOTDOT simple_exp
        |       simple_exp IN var_or_type       %prec TICK_ACCESS
                        { 
                          if ($3 == NULL)
-                           error ("Right operand of 'in' must be type");
+                           error (_("Right operand of 'in' must be type"));
                          write_exp_elt_opcode (UNOP_IN_RANGE);
                          write_exp_elt_type ($3);
                          write_exp_elt_opcode (UNOP_IN_RANGE);
@@ -444,7 +448,7 @@ relation :  simple_exp IN simple_exp DOTDOT simple_exp
        |       simple_exp NOT IN var_or_type   %prec TICK_ACCESS
                        { 
                          if ($4 == NULL)
-                           error ("Right operand of 'in' must be type");
+                           error (_("Right operand of 'in' must be type"));
                          write_exp_elt_opcode (UNOP_IN_RANGE);
                          write_exp_elt_type ($4);
                          write_exp_elt_opcode (UNOP_IN_RANGE);
@@ -557,7 +561,7 @@ type_prefix :
                 var_or_type
                        { 
                          if ($1 == NULL)
-                           error ("Prefix must be type");
+                           error (_("Prefix must be type"));
                          write_exp_elt_opcode (OP_TYPE);
                          write_exp_elt_type ($1);
                          write_exp_elt_opcode (OP_TYPE); }
@@ -567,7 +571,7 @@ opt_type_prefix :
                type_prefix
        |       /* EMPTY */
                        { write_exp_elt_opcode (OP_TYPE);
-                         write_exp_elt_type (builtin_type_void);
+                         write_exp_elt_type (parse_type->builtin_void);
                          write_exp_elt_opcode (OP_TYPE); }
        ;
 
@@ -601,8 +605,14 @@ primary    :       STRING
                        }
        ;
 
+primary :      TRUEKEYWORD
+                       { write_int (1, type_boolean ()); }
+        |      FALSEKEYWORD
+                       { write_int (0, type_boolean ()); }
+       ;
+
 primary        :       NEW NAME
-                       { error ("NEW not implemented."); }
+                       { error (_("NEW not implemented.")); }
        ;
 
 var_or_type:   NAME        %prec VAR
@@ -768,7 +778,7 @@ ada_parse (void)
 void
 yyerror (char *msg)
 {
-  error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
+  error (_("Error in expression, near `%s'."), lexptr);
 }
 
 /* The operator name corresponding to operator symbol STRING (adds
@@ -796,7 +806,7 @@ string_to_operator (struct stoken string)
          return string;
        }
     }
-  error ("Invalid operator symbol `%s'", string.ptr);
+  error (_("Invalid operator symbol `%s'"), string.ptr);
 }
 
 /* Emit expression to access an instance of SYM, in block BLOCK (if
@@ -819,7 +829,7 @@ write_var_from_sym (struct block *orig_left_context,
   write_exp_elt_opcode (OP_VAR_VALUE);
 }
 
-/* Write integer constant ARG of type TYPE.  */
+/* Write integer or boolean constant ARG of type TYPE.  */
 
 static void
 write_int (LONGEST arg, struct type *type)
@@ -839,82 +849,87 @@ write_exp_op_with_string (enum exp_opcode opcode, struct stoken token)
   write_exp_elt_opcode (opcode);
 }
   
-/* Emit expression corresponding to the renamed object designated by
- * the type RENAMING, which must be the referent of an object renaming
- * type, in the context of ORIG_LEFT_CONTEXT.  MAX_DEPTH is the maximum
- * number of cascaded renamings to allow.  */
+/* Emit expression corresponding to the renamed object named 
+ * designated by RENAMED_ENTITY[0 .. RENAMED_ENTITY_LEN-1] in the
+ * context of ORIG_LEFT_CONTEXT, to which is applied the operations
+ * encoded by RENAMING_EXPR.  MAX_DEPTH is the maximum number of
+ * cascaded renamings to allow.  If ORIG_LEFT_CONTEXT is null, it
+ * defaults to the currently selected block. ORIG_SYMBOL is the 
+ * symbol that originally encoded the renaming.  It is needed only
+ * because its prefix also qualifies any index variables used to index
+ * or slice an array.  It should not be necessary once we go to the
+ * new encoding entirely (FIXME pnh 7/20/2007).  */
+
 static void
-write_object_renaming (struct block *orig_left_context, 
-                      struct symbol *renaming, int max_depth)
+write_object_renaming (struct block *orig_left_context,
+                      const char *renamed_entity, int renamed_entity_len,
+                      const char *renaming_expr, int max_depth)
 {
-  const char *qualification = SYMBOL_LINKAGE_NAME (renaming);
-  const char *simple_tail;
-  const char *expr = TYPE_FIELD_NAME (SYMBOL_TYPE (renaming), 0);
-  const char *suffix;
   char *name;
-  struct symbol *sym;
   enum { SIMPLE_INDEX, LOWER_BOUND, UPPER_BOUND } slice_state;
+  struct symbol *sym;
+  struct block *block;
 
   if (max_depth <= 0)
-    error ("Could not find renamed symbol");
+    error (_("Could not find renamed symbol"));
 
-  /* if orig_left_context is null, then use the currently selected
-     block; otherwise we might fail our symbol lookup below.  */
   if (orig_left_context == NULL)
     orig_left_context = get_selected_block (NULL);
 
-  for (simple_tail = qualification + strlen (qualification);
-       simple_tail != qualification; simple_tail -= 1)
-    {
-      if (*simple_tail == '.')
-       {
-         simple_tail += 1;
-         break;
-       }
-      else if (strncmp (simple_tail, "__", 2) == 0)
-       {
-         simple_tail += 2;
-         break;
-       }
-    }
+  name = obsavestring (renamed_entity, renamed_entity_len, &temp_parse_space);
+  sym = ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, 
+                                  &block);
+  if (sym == NULL)
+    error (_("Could not find renamed variable: %s"), ada_decode (name));
+  else if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+    /* We have a renaming of an old-style renaming symbol.  Don't
+       trust the block information.  */
+    block = orig_left_context;
 
-  suffix = strstr (expr, "___XE");
-  if (suffix == NULL)
-    goto BadEncoding;
+  {
+    const char *inner_renamed_entity;
+    int inner_renamed_entity_len;
+    const char *inner_renaming_expr;
 
-  name = (char *) obstack_alloc (&temp_parse_space, suffix - expr + 1);
-  strncpy (name, expr, suffix-expr);
-  name[suffix-expr] = '\000';
-  sym = lookup_symbol (name, orig_left_context, VAR_DOMAIN, 0, NULL);
-  if (sym == NULL)
-    error ("Could not find renamed variable: %s", ada_decode (name));
-  if (ada_is_object_renaming (sym))
-    write_object_renaming (orig_left_context, sym, max_depth-1);
-  else
-    write_var_from_sym (orig_left_context, block_found, sym);
+    switch (ada_parse_renaming (sym, &inner_renamed_entity, 
+                               &inner_renamed_entity_len,
+                               &inner_renaming_expr))
+      {
+      case ADA_NOT_RENAMING:
+       write_var_from_sym (orig_left_context, block, sym);
+       break;
+      case ADA_OBJECT_RENAMING:
+       write_object_renaming (block,
+                              inner_renamed_entity, inner_renamed_entity_len,
+                              inner_renaming_expr, max_depth - 1);
+       break;
+      default:
+       goto BadEncoding;
+      }
+  }
 
-  suffix += 5;
   slice_state = SIMPLE_INDEX;
-  while (*suffix == 'X')
+  while (*renaming_expr == 'X')
     {
-      suffix += 1;
+      renaming_expr += 1;
 
-      switch (*suffix) {
+      switch (*renaming_expr) {
       case 'A':
-        suffix += 1;
+        renaming_expr += 1;
         write_exp_elt_opcode (UNOP_IND);
         break;
       case 'L':
        slice_state = LOWER_BOUND;
+       /* FALLTHROUGH */
       case 'S':
-       suffix += 1;
-       if (isdigit (*suffix))
+       renaming_expr += 1;
+       if (isdigit (*renaming_expr))
          {
            char *next;
-           long val = strtol (suffix, &next, 10);
-           if (next == suffix)
+           long val = strtol (renaming_expr, &next, 10);
+           if (next == renaming_expr)
              goto BadEncoding;
-           suffix = next;
+           renaming_expr = next;
            write_exp_elt_opcode (OP_LONG);
            write_exp_elt_type (type_int ());
            write_exp_elt_longcst ((LONGEST) val);
@@ -924,27 +939,25 @@ write_object_renaming (struct block *orig_left_context,
          {
            const char *end;
            char *index_name;
-           int index_len;
            struct symbol *index_sym;
 
-           end = strchr (suffix, 'X');
+           end = strchr (renaming_expr, 'X');
            if (end == NULL)
-             end = suffix + strlen (suffix);
-
-           index_len = simple_tail - qualification + 2 + (suffix - end) + 1;
-           index_name
-             = (char *) obstack_alloc (&temp_parse_space, index_len);
-           memset (index_name, '\000', index_len);
-           strncpy (index_name, qualification, simple_tail - qualification);
-           index_name[simple_tail - qualification] = '\000';
-           strncat (index_name, suffix, suffix-end);
-           suffix = end;
-
-           index_sym =
-             lookup_symbol (index_name, NULL, VAR_DOMAIN, 0, NULL);
+             end = renaming_expr + strlen (renaming_expr);
+
+           index_name =
+             obsavestring (renaming_expr, end - renaming_expr,
+                           &temp_parse_space);
+           renaming_expr = end;
+
+           index_sym = ada_lookup_encoded_symbol (index_name, NULL,
+                                                  VAR_DOMAIN, &block);
            if (index_sym == NULL)
-             error ("Could not find %s", index_name);
-           write_var_from_sym (NULL, block_found, sym);
+             error (_("Could not find %s"), index_name);
+           else if (SYMBOL_CLASS (index_sym) == LOC_TYPEDEF)
+             /* Index is an old-style renaming symbol.  */
+             block = orig_left_context;
+           write_var_from_sym (NULL, block, index_sym);
          }
        if (slice_state == SIMPLE_INDEX)
          {
@@ -965,18 +978,18 @@ write_object_renaming (struct block *orig_left_context,
        {
          struct stoken field_name;
          const char *end;
-         suffix += 1;
+         renaming_expr += 1;
 
          if (slice_state != SIMPLE_INDEX)
            goto BadEncoding;
-         end = strchr (suffix, 'X');
+         end = strchr (renaming_expr, 'X');
          if (end == NULL)
-           end = suffix + strlen (suffix);
-         field_name.length = end - suffix;
-         field_name.ptr = xmalloc (end - suffix + 1);
-         strncpy (field_name.ptr, suffix, end - suffix);
-         field_name.ptr[end - suffix] = '\000';
-         suffix = end;
+           end = renaming_expr + strlen (renaming_expr);
+         field_name.length = end - renaming_expr;
+         field_name.ptr = malloc (end - renaming_expr + 1);
+         strncpy (field_name.ptr, renaming_expr, end - renaming_expr);
+         field_name.ptr[end - renaming_expr] = '\000';
+         renaming_expr = end;
          write_exp_op_with_string (STRUCTOP_STRUCT, field_name);
          break;
        }
@@ -989,8 +1002,7 @@ write_object_renaming (struct block *orig_left_context,
     return;
 
  BadEncoding:
-  error ("Internal error in encoding of renaming declaration: %s",
-        SYMBOL_LINKAGE_NAME (renaming));
+  error (_("Internal error in encoding of renaming declaration"));
 }
 
 static struct block*
@@ -1010,8 +1022,8 @@ block_lookup (struct block *context, char *raw_name)
     name = ada_encode (raw_name);
 
   nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
-  if (context == NULL &&
-      (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK))
+  if (context == NULL
+      && (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK))
     symtab = lookup_symtab (name);
   else
     symtab = NULL;
@@ -1021,14 +1033,14 @@ block_lookup (struct block *context, char *raw_name)
   else if (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK)
     {
       if (context == NULL)
-       error ("No file or function \"%s\".", raw_name);
+       error (_("No file or function \"%s\"."), raw_name);
       else
-       error ("No function \"%s\" in specified context.", raw_name);
+       error (_("No function \"%s\" in specified context."), raw_name);
     }
   else
     {
       if (nsyms > 1)
-       warning ("Function name \"%s\" ambiguous here", raw_name);
+       warning (_("Function name \"%s\" ambiguous here"), raw_name);
       return SYMBOL_BLOCK_VALUE (syms[0].sym);
     }
 }
@@ -1054,14 +1066,9 @@ select_possible_type_sym (struct ada_symbol_info *syms, int nsyms)
       case LOC_REGISTER:
       case LOC_ARG:
       case LOC_REF_ARG:
-      case LOC_REGPARM:
       case LOC_REGPARM_ADDR:
       case LOC_LOCAL:
-      case LOC_LOCAL_ARG:
-      case LOC_BASEREG:
-      case LOC_BASEREG_ARG:
       case LOC_COMPUTED:
-      case LOC_COMPUTED_ARG:
        return NULL;
       default:
        break;
@@ -1075,8 +1082,8 @@ static struct type*
 find_primitive_type (char *name)
 {
   struct type *type;
-  type = language_lookup_primitive_type_by_name (current_language,
-                                                current_gdbarch,
+  type = language_lookup_primitive_type_by_name (parse_language,
+                                                parse_gdbarch,
                                                 name);
   if (type == NULL && strcmp ("system__address", name) == 0)
     type = type_system_address ();
@@ -1085,13 +1092,12 @@ find_primitive_type (char *name)
     {
       /* Check to see if we have a regular definition of this
         type that just didn't happen to have been read yet.  */
-      int ntypes;
       struct symbol *sym;
       char *expanded_name = 
        (char *) alloca (strlen (name) + sizeof ("standard__"));
       strcpy (expanded_name, "standard__");
       strcat (expanded_name, name);
-      sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL, NULL);
+      sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL);
       if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
        type = SYMBOL_TYPE (sym);
     }
@@ -1109,6 +1115,22 @@ chop_selector (char *name, int end)
   return -1;
 }
 
+/* If NAME is a string beginning with a separator (either '__', or
+   '.'), chop this separator and return the result; else, return
+   NAME.  */
+
+static char *
+chop_separator (char *name)
+{
+  if (*name == '.')
+   return name + 1;
+
+  if (name[0] == '_' && name[1] == '_')
+    return name + 2;
+
+  return name;
+}
+
 /* Given that SELS is a string of the form (<sep><identifier>)*, where
    <sep> is '__' or '.', write the indicated sequence of
    STRUCTOP_STRUCT expression operators. */
@@ -1118,10 +1140,8 @@ write_selectors (char *sels)
   while (*sels != '\0')
     {
       struct stoken field_name;
-      char *p;
-      while (*sels == '_' || *sels == '.')
-       sels += 1;
-      p = sels;
+      char *p = chop_separator (sels);
+      sels = p;
       while (*sels != '\0' && *sels != '.' 
             && (sels[0] != '_' || sels[1] != '_'))
        sels += 1;
@@ -1151,6 +1171,71 @@ write_ambiguous_var (struct block *block, char *name, int len)
   write_exp_elt_opcode (OP_VAR_VALUE);
 }
 
+/* A convenient wrapper around ada_get_field_index that takes
+   a non NUL-terminated FIELD_NAME0 and a FIELD_NAME_LEN instead
+   of a NUL-terminated field name.  */
+
+static int
+ada_nget_field_index (const struct type *type, const char *field_name0,
+                      int field_name_len, int maybe_missing)
+{
+  char *field_name = alloca ((field_name_len + 1) * sizeof (char));
+
+  strncpy (field_name, field_name0, field_name_len);
+  field_name[field_name_len] = '\0';
+  return ada_get_field_index (type, field_name, maybe_missing);
+}
+
+/* If encoded_field_name is the name of a field inside symbol SYM,
+   then return the type of that field.  Otherwise, return NULL.
+
+   This function is actually recursive, so if ENCODED_FIELD_NAME
+   doesn't match one of the fields of our symbol, then try to see
+   if ENCODED_FIELD_NAME could not be a succession of field names
+   (in other words, the user entered an expression of the form
+   TYPE_NAME.FIELD1.FIELD2.FIELD3), in which case we evaluate
+   each field name sequentially to obtain the desired field type.
+   In case of failure, we return NULL.  */
+
+static struct type *
+get_symbol_field_type (struct symbol *sym, char *encoded_field_name)
+{
+  char *field_name = encoded_field_name;
+  char *subfield_name;
+  struct type *type = SYMBOL_TYPE (sym);
+  int fieldno;
+
+  if (type == NULL || field_name == NULL)
+    return NULL;
+  type = check_typedef (type);
+
+  while (field_name[0] != '\0')
+    {
+      field_name = chop_separator (field_name);
+
+      fieldno = ada_get_field_index (type, field_name, 1);
+      if (fieldno >= 0)
+        return TYPE_FIELD_TYPE (type, fieldno);
+
+      subfield_name = field_name;
+      while (*subfield_name != '\0' && *subfield_name != '.' 
+            && (subfield_name[0] != '_' || subfield_name[1] != '_'))
+       subfield_name += 1;
+
+      if (subfield_name[0] == '\0')
+        return NULL;
+
+      fieldno = ada_nget_field_index (type, field_name,
+                                      subfield_name - field_name, 1);
+      if (fieldno < 0)
+        return NULL;
+
+      type = TYPE_FIELD_TYPE (type, fieldno);
+      field_name = subfield_name;
+    }
+
+  return NULL;
+}
 
 /* Look up NAME0 (an unencoded identifier or dotted name) in BLOCK (or 
    expression_block_context if NULL).  If it denotes a type, return
@@ -1185,6 +1270,10 @@ write_var_or_type (struct block *block, struct stoken name0)
          int nsyms;
          struct ada_symbol_info *syms;
          struct symbol *type_sym;
+         struct symbol *renaming_sym;
+         const char* renaming;
+         int renaming_len;
+         const char* renaming_expr;
          int terminator = encoded_name[tail_index];
 
          encoded_name[tail_index] = '\0';
@@ -1194,51 +1283,72 @@ write_var_or_type (struct block *block, struct stoken name0)
 
          /* A single symbol may rename a package or object. */
 
-         if (nsyms == 1 && !ada_is_object_renaming (syms[0].sym))
+         /* This should go away when we move entirely to new version.
+            FIXME pnh 7/20/2007. */
+         if (nsyms == 1)
            {
-             struct symbol *renaming_sym =
+             struct symbol *renaming =
                ada_find_renaming_symbol (SYMBOL_LINKAGE_NAME (syms[0].sym), 
                                          syms[0].block);
 
-             if (renaming_sym != NULL)
-               syms[0].sym = renaming_sym;
+             if (renaming != NULL)
+               syms[0].sym = renaming;
            }
 
          type_sym = select_possible_type_sym (syms, nsyms);
+
          if (type_sym != NULL)
+           renaming_sym = type_sym;
+         else if (nsyms == 1)
+           renaming_sym = syms[0].sym;
+         else 
+           renaming_sym = NULL;
+
+         switch (ada_parse_renaming (renaming_sym, &renaming,
+                                     &renaming_len, &renaming_expr))
            {
-             struct type *type = SYMBOL_TYPE (type_sym);
+           case ADA_NOT_RENAMING:
+             break;
+           case ADA_PACKAGE_RENAMING:
+           case ADA_EXCEPTION_RENAMING:
+           case ADA_SUBPROGRAM_RENAMING:
+             {
+               char *new_name
+                 = obstack_alloc (&temp_parse_space,
+                                  renaming_len + name_len - tail_index + 1);
+               strncpy (new_name, renaming, renaming_len);
+               strcpy (new_name + renaming_len, encoded_name + tail_index);
+               encoded_name = new_name;
+               name_len = renaming_len + name_len - tail_index;
+               goto TryAfterRenaming;
+             } 
+           case ADA_OBJECT_RENAMING:
+             write_object_renaming (block, renaming, renaming_len, 
+                                    renaming_expr, MAX_RENAMING_CHAIN_LENGTH);
+             write_selectors (encoded_name + tail_index);
+             return NULL;
+           default:
+             internal_error (__FILE__, __LINE__,
+                             _("impossible value from ada_parse_renaming"));
+           }
 
-             if (TYPE_CODE (type) == TYPE_CODE_VOID)
-               error ("`%s' matches only void type name(s)", name0.ptr);
-             else if (ada_is_object_renaming (type_sym))
-               {
-                 write_object_renaming (block, type_sym, 
-                                        MAX_RENAMING_CHAIN_LENGTH);
-                 write_selectors (encoded_name + tail_index);
-                 return NULL;
-               }
-             else if (ada_renaming_type (SYMBOL_TYPE (type_sym)) != NULL)
-               {
-                 int result;
-                 char *renaming = ada_simple_renamed_entity (type_sym);
-                 int renaming_len = strlen (renaming);
-
-                 char *new_name
-                   = obstack_alloc (&temp_parse_space,
-                                    renaming_len + name_len - tail_index 
-                                    + 1);
-                 strcpy (new_name, renaming);
-                 xfree (renaming);
-                 strcpy (new_name + renaming_len, encoded_name + tail_index);
-                 encoded_name = new_name;
-                 name_len = renaming_len + name_len - tail_index;
-                 goto TryAfterRenaming;
-               }
-             else if (tail_index == name_len)
-               return type;
+         if (type_sym != NULL)
+           {
+              struct type *field_type;
+              
+              if (tail_index == name_len)
+                return SYMBOL_TYPE (type_sym);
+
+              /* We have some extraneous characters after the type name.
+                 If this is an expression "TYPE_NAME.FIELD0.[...].FIELDN",
+                 then try to get the type of FIELDN.  */
+              field_type
+                = get_symbol_field_type (type_sym, encoded_name + tail_index);
+              if (field_type != NULL)
+                return field_type;
              else 
-               error ("Invalid attempt to select from type: \"%s\".", name0.ptr);
+               error (_("Invalid attempt to select from type: \"%s\"."),
+                       name0.ptr);
            }
          else if (tail_index == name_len && nsyms == 0)
            {
@@ -1256,13 +1366,11 @@ write_var_or_type (struct block *block, struct stoken name0)
            }
          else if (nsyms == 0) 
            {
-             int i;
              struct minimal_symbol *msym 
                = ada_lookup_simple_minsym (encoded_name);
              if (msym != NULL)
                {
-                 write_exp_msymbol (msym, lookup_function_type (type_int ()),
-                                    type_int ());
+                 write_exp_msymbol (msym);
                  /* Maybe cause error here rather than later? FIXME? */
                  write_selectors (encoded_name + tail_index);
                  return NULL;
@@ -1271,7 +1379,7 @@ write_var_or_type (struct block *block, struct stoken name0)
              if (tail_index == name_len
                  && strncmp (encoded_name, "standard__", 
                              sizeof ("standard__") - 1) == 0)
-               error ("No definition of \"%s\" found.", name0.ptr);
+               error (_("No definition of \"%s\" found."), name0.ptr);
 
              tail_index = chop_selector (encoded_name, tail_index);
            } 
@@ -1284,16 +1392,16 @@ write_var_or_type (struct block *block, struct stoken name0)
        }
 
       if (!have_full_symbols () && !have_partial_symbols () && block == NULL)
-       error ("No symbol table is loaded.  Use the \"file\" command.");
+       error (_("No symbol table is loaded.  Use the \"file\" command."));
       if (block == expression_context_block)
-       error ("No definition of \"%s\" in current context.", name0.ptr);
+       error (_("No definition of \"%s\" in current context."), name0.ptr);
       else
-       error ("No definition of \"%s\" in specified context.", name0.ptr);
+       error (_("No definition of \"%s\" in specified context."), name0.ptr);
       
     TryAfterRenaming: ;
     }
 
-  error ("Could not find renamed symbol \"%s\"", name0.ptr);
+  error (_("Could not find renamed symbol \"%s\""), name0.ptr);
 
 }
 
@@ -1327,7 +1435,7 @@ write_name_assoc (struct stoken name)
     }
   else
     if (write_var_or_type (NULL, name) != NULL)
-      error ("Invalid use of type.");
+      error (_("Invalid use of type."));
 }
 
 /* Convert the character literal whose ASCII value would be VAL to the
@@ -1343,7 +1451,7 @@ convert_char_literal (struct type *type, LONGEST val)
 
   if (type == NULL || TYPE_CODE (type) != TYPE_CODE_ENUM)
     return val;
-  sprintf (name, "QU%02x", (int) val);
+  xsnprintf (name, sizeof (name), "QU%02x", (int) val);
   for (f = 0; f < TYPE_NFIELDS (type); f += 1)
     {
       if (strcmp (name, TYPE_FIELD_NAME (type, f)) == 0)
@@ -1355,55 +1463,64 @@ convert_char_literal (struct type *type, LONGEST val)
 static struct type *
 type_int (void)
 {
-  return builtin_type (current_gdbarch)->builtin_int;
+  return parse_type->builtin_int;
 }
 
 static struct type *
 type_long (void)
 {
-  return builtin_type (current_gdbarch)->builtin_long;
+  return parse_type->builtin_long;
 }
 
 static struct type *
 type_long_long (void)
 {
-  return builtin_type (current_gdbarch)->builtin_long_long;
+  return parse_type->builtin_long_long;
 }
 
 static struct type *
 type_float (void)
 {
-  return builtin_type (current_gdbarch)->builtin_float;
+  return parse_type->builtin_float;
 }
 
 static struct type *
 type_double (void)
 {
-  return builtin_type (current_gdbarch)->builtin_double;
+  return parse_type->builtin_double;
 }
 
 static struct type *
 type_long_double (void)
 {
-  return builtin_type (current_gdbarch)->builtin_long_double;
+  return parse_type->builtin_long_double;
 }
 
 static struct type *
 type_char (void)
 {
-  return language_string_char_type (current_language, current_gdbarch);
+  return language_string_char_type (parse_language, parse_gdbarch);
+}
+
+static struct type *
+type_boolean (void)
+{
+  return parse_type->builtin_bool;
 }
 
 static struct type *
 type_system_address (void)
 {
   struct type *type 
-    = language_lookup_primitive_type_by_name (current_language,
-                                             current_gdbarch, 
+    = language_lookup_primitive_type_by_name (parse_language,
+                                             parse_gdbarch,
                                              "system__address");
-  return  type != NULL ? type : lookup_pointer_type (builtin_type_void);
+  return  type != NULL ? type : parse_type->builtin_data_ptr;
 }
 
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_ada_exp;
+
 void
 _initialize_ada_exp (void)
 {
This page took 0.036175 seconds and 4 git commands to generate.