- struct type *preferred_type;
- int i, preferred_index;
-
- if (left_block_context == NULL)
- nsyms = ada_lookup_symbol_list (name, expression_context_block,
- VAR_DOMAIN, &syms);
- else
- nsyms = ada_lookup_symbol_list (name, left_block_context,
- VAR_DOMAIN, &syms);
-
-
- /* Check for a type renaming. */
-
- if (nsyms == 1 && !ada_is_object_renaming (syms[0].sym))
- {
- struct symbol *renaming_sym =
- ada_find_renaming_symbol (SYMBOL_LINKAGE_NAME (syms[0].sym),
- syms[0].block);
-
- if (renaming_sym != NULL)
- syms[0].sym = renaming_sym;
- }
-
- /* Check for a type definition. */
-
- /* Look for a symbol that doesn't denote void. This is (I think) a */
- /* temporary kludge to get around problems in GNAT output. */
- preferred_index = -1; preferred_type = NULL;
- for (i = 0; i < nsyms; i += 1)
- switch (SYMBOL_CLASS (syms[i].sym))
- {
- case LOC_TYPEDEF:
- if (ada_prefer_type (SYMBOL_TYPE (syms[i].sym), preferred_type))
- {
- preferred_index = i;
- preferred_type = SYMBOL_TYPE (syms[i].sym);
- }
- break;
- 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:
- goto NotType;
- default:
- break;
- }
- if (preferred_type != NULL)
- {
- if (TYPE_CODE (preferred_type) == TYPE_CODE_VOID)
- error ("`%s' matches only void type name(s)",
- ada_decode (name));
- else if (ada_is_object_renaming (syms[preferred_index].sym))
- {
- yylval.ssym.sym = syms[preferred_index].sym;
- *token_type = OBJECT_RENAMING;
- return segments;
- }
- else if (ada_renaming_type (SYMBOL_TYPE (syms[preferred_index].sym))
- != NULL)
- {
- int result;
- char *renaming
- = ada_simple_renamed_entity (syms[preferred_index].sym);
- char *new_name
- = (char *) obstack_alloc (&temp_parse_space,
- strlen (renaming) + len0
- - yylval.ssym.stoken.length + 1);
- strcpy (new_name, renaming);
- free (renaming);
- strcat (new_name, name0 + yylval.ssym.stoken.length);
- result = name_lookup (new_name, err_name, token_type, depth - 1);
- if (result > segments)
- error ("Confused by renamed symbol.");
- return result;
- }
- else if (segments == 0)
- {
- yylval.tval = preferred_type;
- *token_type = TYPENAME;
- return 0;
- }
- }
-
- if (segments == 0)
- {
- type = lookup_primitive_typename (name);
- if (type == NULL && strcmp ("system__address", name) == 0)
- type = builtin_type_ada_system_address;
- if (type != NULL)
- {
- /* First 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);
- if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- type = SYMBOL_TYPE (sym);
-
- yylval.tval = type;
- *token_type = TYPENAME;
- return 0;
- }
- }
-
- NotType:
- if (nsyms == 1)
- {
- *token_type = NAME;
- yylval.ssym.sym = syms[0].sym;
- yylval.ssym.msym = NULL;
- yylval.ssym.block = syms[0].block;
- return segments;
- }
- else if (nsyms == 0) {
- int i;
- yylval.ssym.msym = ada_lookup_simple_minsym (name);
- if (yylval.ssym.msym != NULL)
- {
- yylval.ssym.sym = NULL;
- yylval.ssym.block = NULL;
- *token_type = NAME;
- return segments;
- }
-
- if (segments == 0
- && strncmp (name, "standard__", sizeof ("standard__") - 1) == 0)
- error ("No definition of \"%s\" found.", err_name);
-
- for (i = yylval.ssym.stoken.length - 1; i > 0; i -= 1)
- {
- if (name[i] == '.')
- {
- name[i] = '\0';
- yylval.ssym.stoken.length = i;
- break;
- }
- else if (name[i] == '_' && name[i-1] == '_')
- {
- i -= 1;
- name[i] = '\0';
- yylval.ssym.stoken.length = i;
- break;
- }
- }
- if (i <= 0)
- {
- if (!have_full_symbols () && !have_partial_symbols ()
- && left_block_context == NULL)
- error ("No symbol table is loaded. Use the \"file\" command.");
- if (left_block_context == NULL)
- error ("No definition of \"%s\" in current context.",
- err_name);
- else
- error ("No definition of \"%s\" in specified context.",
- err_name);
- }
- }
- else
- {
- *token_type = NAME;
- yylval.ssym.sym = NULL;
- yylval.ssym.msym = NULL;
- if (left_block_context == NULL)
- yylval.ssym.block = expression_context_block;
- else
- yylval.ssym.block = left_block_context;
- return segments;
- }
- }