Re: [rfa/Ada] Restructure array bounds routines to remove builtin types

Joel Brobecker
2009-06-29T15:37:01Z

Hi Ulrich,

First of all, thank you for doing this. I know it's painful to change
someone else's code, sometime, especially when it's tough to test some
of them.

> - The ada_array_bound, ada_array_bound_from_type, and ada_array_length
> now solely return numerical values (as LONGEST); they do not attempt
> to do anything with types.

I'm slightly concerned at this part, but I don't think your patch makes
things any worse. In particular, I'm worried about arrays whose index
type is an unsigned 64bit type. If I understand things correctly, I
don't think it works well just yet, and PaulH was working on that.

> * ada-lang.c (ada_index_type): Make static. Add NAME argument.
> Throw error on invalid input arguments. Return NULL if unable
> to determine index type.
>
> (ada_array_bound_from_type): Remove TYPEP argument.
> (ada_array_bound): Make static. Return LONGEST instead of value.
> Update for ada_array_bound_from_type change.
> (ada_array_length): Return LONGEST instead of value.
> Update for ada_array_bound_from_type change.
> (make_array_descriptor): Update for ada_array_bound change.
>
> (ada_evaluate_subexp) [OP_ATR_RANGE, OP_ATR_FIRST, OP_ATR_LAST,
> OP_ATR_LENGTH]: Update for ada_array_bound_from_type,
> ada_array_bound, ada_array_length, ada_index_type changes.
> Always use ada_index_type to compute result type; fall back
> to architecture-specific integer type if ada_index_type fails.
>
> * ada-lang.h (ada_index_type): Remove prototype.
> (ada_array_bound): Likewise.

Looks OK to me, and verified also against AdaCore's testsuite
on x86-linux (DWARF and stabs).

Just one tiny request:

> -struct type *
> -ada_index_type (struct type *type, int n)
> +static struct type *
> +ada_index_type (struct type *type, int n, const char *name)

Would you mind documenting what this new NAME parameter is supposed
to be?

Thanks,
--
Joel