* [rfc] Ada simplification: ada_coerce_to_simple_array_type
@ 2009-05-14 11:36 Ulrich Weigand
2009-05-15 14:07 ` Joel Brobecker
0 siblings, 1 reply; 3+ messages in thread
From: Ulrich Weigand @ 2009-05-14 11:36 UTC (permalink / raw)
To: gdb-patches, brobecker
Hello,
in my ongoing attempts to eliminate current_gdbarch from GDB, I've run into
a couple of places in Ada-specific code that makes things difficult. This
(and the following three) patches rework a couple of Ada details in order
to make life simpler for my subsequent changes ...
This patch addresses ada_coerce_to_simple_array_type, which creates a
dummy value only to pass it to ada_type_of_array which in the end only
inspects its type. Not only is that a bit wasteful; it makes a future
change to create values relative to a gdbarch difficult (because there
is no good choice of architecture to use for that dummy value).
This patch inlines the part of ada_type_of_array that is used in the
case of a "bounds == 0" parameter -- in this piece of code, only
the type of the passed-in value is inspected.
There should be no change in behaviour with this patch.
Joel, would this be OK?
Thanks,
Ulrich
ChangeLog:
* ada-lang.c (ada_coerce_to_simple_array_type): Reimplement to
avoid creating a dummy value.
Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -1689,13 +1689,13 @@ ada_coerce_to_simple_array (struct value
struct type *
ada_coerce_to_simple_array_type (struct type *type)
{
- struct value *mark = value_mark ();
- struct value *dummy = value_from_longest (builtin_type_int32, 0);
- struct type *result;
- deprecated_set_value_type (dummy, type);
- result = ada_type_of_array (dummy, 0);
- value_free_to_mark (mark);
- return result;
+ if (ada_is_packed_array_type (type))
+ return decode_packed_array_type (type);
+
+ if (ada_is_array_descriptor_type (type))
+ return ada_check_typedef (TYPE_TARGET_TYPE (desc_data_type (type)));
+
+ return type;
}
/* Non-zero iff TYPE represents a standard GNAT packed-array type. */
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfc] Ada simplification: ada_coerce_to_simple_array_type
2009-05-14 11:36 [rfc] Ada simplification: ada_coerce_to_simple_array_type Ulrich Weigand
@ 2009-05-15 14:07 ` Joel Brobecker
2009-05-18 13:51 ` Ulrich Weigand
0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2009-05-15 14:07 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gdb-patches
> * ada-lang.c (ada_coerce_to_simple_array_type): Reimplement to
> avoid creating a dummy value.
I like this change. On the one hand, it's a slight duplication, but this
is a relatively standard idiom, so it's OK. When I'm done reconciling
the sources with AdaCore's, it'll be easier for me to overhaul the ada-*
sources. Thanks for this patch.
--
Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rfc] Ada simplification: ada_coerce_to_simple_array_type
2009-05-15 14:07 ` Joel Brobecker
@ 2009-05-18 13:51 ` Ulrich Weigand
0 siblings, 0 replies; 3+ messages in thread
From: Ulrich Weigand @ 2009-05-18 13:51 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
Joel Brobecker wrote:
> > * ada-lang.c (ada_coerce_to_simple_array_type): Reimplement to
> > avoid creating a dummy value.
>
> I like this change. On the one hand, it's a slight duplication, but this
> is a relatively standard idiom, so it's OK. When I'm done reconciling
> the sources with AdaCore's, it'll be easier for me to overhaul the ada-*
> sources. Thanks for this patch.
Thanks for the review! I've checked the patch in now.
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-18 13:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-14 11:36 [rfc] Ada simplification: ada_coerce_to_simple_array_type Ulrich Weigand
2009-05-15 14:07 ` Joel Brobecker
2009-05-18 13:51 ` Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox