#include "f-lang.h"
#include <algorithm>
#include "gmp-utils.h"
+#include "rust-lang.h"
+#include "ada-lang.h"
/* The value of an invalid conversion badness. */
#define INVALID_CONVERSION 100
size_t size = nfields * sizeof (*this->fields ());
memcpy (this->fields (), src.data (), size);
}
+
+bool
+type::is_array_like ()
+{
+ if (code () == TYPE_CODE_ARRAY)
+ return true;
+ if (HAVE_GNAT_AUX_INFO (this))
+ return (ada_is_constrained_packed_array_type (this)
+ || ada_is_array_descriptor_type (this));
+ if (HAVE_RUST_SPECIFIC (this))
+ return rust_slice_type_p (this);
+ return false;
+}
+
\f
static const registry<gdbarch>::key<struct builtin_type> gdbtypes_data;
return this->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (this);
}
+ /* Return true if this type is "array-like". This includes arrays,
+ but also some forms of structure type that are recognized as
+ representations of arrays by the type's language. */
+ bool is_array_like ();
+
/* * Type that is a pointer to this type.
NULL if no such pointer-to type is known yet.
The debugger may add the address of such a type
#include "infcall.h"
#include "gdbsupport/byte-vector.h"
#include "gdbarch.h"
+#include "rust-lang.h"
+#include "ada-lang.h"
/* Forward declarations. */
static struct value *value_subscripted_rvalue (struct value *array,
return value_from_component (array, elt_type, elt_offs);
}
+/* See value.h. */
+
+struct value *
+value_to_array (struct value *val)
+{
+ struct type *type = check_typedef (val->type ());
+ if (type->code () == TYPE_CODE_ARRAY)
+ return val;
+
+ if (type->is_array_like ())
+ {
+ if (HAVE_GNAT_AUX_INFO (type))
+ return ada_coerce_to_simple_array (val);
+ if (HAVE_RUST_SPECIFIC (type))
+ return rust_slice_to_array (val);
+ }
+ return nullptr;
+}
+
\f
/* Check to see if either argument is a structure, or a reference to
one. This is called so we know whether to go ahead with the normal
extern struct value *value_subscript (struct value *array, LONGEST index);
+/* Assuming VAL is array-like (see type::is_array_like), return an
+ array form of VAL. */
+extern struct value *value_to_array (struct value *val);
+
extern struct value *value_bitstring_subscript (struct type *type,
struct value *bitstring,
LONGEST index);