return 0;
}
+/* Return true if TYPE is a (Gnat-encoded) constrained packed array
+ type, or if it is an ordinary (non-Gnat-encoded) packed array. */
+
+static bool
+ada_is_any_packed_array_type (struct type *type)
+{
+ return (ada_is_constrained_packed_array_type (type)
+ || (type->code () == TYPE_CODE_ARRAY
+ && TYPE_FIELD_BITSIZE (type, 0) % 8 != 0));
+}
+
/* Given that TYPE encodes a packed array type (constrained or unconstrained),
return the size of its elements in bits. */
base_low_pos = base_low;
}
- base = value_as_address (array_ptr)
- + ((low_pos - base_low_pos)
- * TYPE_LENGTH (TYPE_TARGET_TYPE (type0)));
+ ULONGEST stride = TYPE_FIELD_BITSIZE (slice_type, 0) / 8;
+ if (stride == 0)
+ stride = TYPE_LENGTH (TYPE_TARGET_TYPE (type0));
+
+ base = value_as_address (array_ptr) + (low_pos - base_low_pos) * stride;
return value_at_lazy (slice_type, base);
}
t1 = ada_to_fixed_type (ada_get_base_type (t1), NULL,
address, NULL, check_tag);
+ /* Resolve the dynamic type as well. */
+ arg = value_from_contents_and_address (t1, nullptr, address);
+ t1 = value_type (arg);
+
if (find_struct_field (name, t1, 0,
&field_type, &byte_offset, &bit_offset,
&bit_size, NULL))
TYPE_TARGET_TYPE (value_type (array)) =
ada_aligned_type (TYPE_TARGET_TYPE (value_type (array)));
- if (ada_is_constrained_packed_array_type (value_type (array)))
+ if (ada_is_any_packed_array_type (value_type (array)))
error (_("cannot slice a packed array"));
/* If this is a reference to an array or an array lvalue,
{"'size", OP_ATR_SIZE, PREC_SUFFIX, 1},
{NULL, OP_NULL, PREC_SUFFIX, 0}
};
-\f
-enum ada_primitive_types {
- ada_primitive_type_int,
- ada_primitive_type_long,
- ada_primitive_type_short,
- ada_primitive_type_char,
- ada_primitive_type_float,
- ada_primitive_type_double,
- ada_primitive_type_void,
- ada_primitive_type_long_long,
- ada_primitive_type_long_double,
- ada_primitive_type_natural,
- ada_primitive_type_positive,
- ada_primitive_type_system_address,
- ada_primitive_type_storage_offset,
- nr_ada_primitive_types
-};
-
\f
/* Language vector */
{
const struct builtin_type *builtin = builtin_type (gdbarch);
- lai->primitive_type_vector
- = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_ada_primitive_types + 1,
- struct type *);
-
- lai->primitive_type_vector [ada_primitive_type_int]
- = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
- 0, "integer");
- lai->primitive_type_vector [ada_primitive_type_long]
- = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
- 0, "long_integer");
- lai->primitive_type_vector [ada_primitive_type_short]
- = arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch),
- 0, "short_integer");
- lai->string_char_type
- = lai->primitive_type_vector [ada_primitive_type_char]
- = arch_character_type (gdbarch, TARGET_CHAR_BIT, 0, "character");
- lai->primitive_type_vector [ada_primitive_type_float]
- = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
- "float", gdbarch_float_format (gdbarch));
- lai->primitive_type_vector [ada_primitive_type_double]
- = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
- "long_float", gdbarch_double_format (gdbarch));
- lai->primitive_type_vector [ada_primitive_type_long_long]
- = arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch),
- 0, "long_long_integer");
- lai->primitive_type_vector [ada_primitive_type_long_double]
- = arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
- "long_long_float", gdbarch_long_double_format (gdbarch));
- lai->primitive_type_vector [ada_primitive_type_natural]
- = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
- 0, "natural");
- lai->primitive_type_vector [ada_primitive_type_positive]
- = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
- 0, "positive");
- lai->primitive_type_vector [ada_primitive_type_void]
- = builtin->builtin_void;
-
- lai->primitive_type_vector [ada_primitive_type_system_address]
+ /* Helper function to allow shorter lines below. */
+ auto add = [&] (struct type *t)
+ {
+ lai->add_primitive_type (t);
+ };
+
+ add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+ 0, "integer"));
+ add (arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
+ 0, "long_integer"));
+ add (arch_integer_type (gdbarch, gdbarch_short_bit (gdbarch),
+ 0, "short_integer"));
+ struct type *char_type = arch_character_type (gdbarch, TARGET_CHAR_BIT,
+ 0, "character");
+ lai->set_string_char_type (char_type);
+ add (char_type);
+ add (arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
+ "float", gdbarch_float_format (gdbarch)));
+ add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
+ "long_float", gdbarch_double_format (gdbarch)));
+ add (arch_integer_type (gdbarch, gdbarch_long_long_bit (gdbarch),
+ 0, "long_long_integer"));
+ add (arch_float_type (gdbarch, gdbarch_long_double_bit (gdbarch),
+ "long_long_float",
+ gdbarch_long_double_format (gdbarch)));
+ add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+ 0, "natural"));
+ add (arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+ 0, "positive"));
+ add (builtin->builtin_void);
+
+ struct type *system_addr_ptr
= lookup_pointer_type (arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT,
"void"));
- lai->primitive_type_vector [ada_primitive_type_system_address]
- ->set_name ("system__address");
+ system_addr_ptr->set_name ("system__address");
+ add (system_addr_ptr);
/* Create the equivalent of the System.Storage_Elements.Storage_Offset
type. This is a signed integral type whose size is the same as
the size of addresses. */
- {
- unsigned int addr_length = TYPE_LENGTH
- (lai->primitive_type_vector [ada_primitive_type_system_address]);
-
- lai->primitive_type_vector [ada_primitive_type_storage_offset]
- = arch_integer_type (gdbarch, addr_length * HOST_CHAR_BIT, 0,
- "storage_offset");
- }
+ unsigned int addr_length = TYPE_LENGTH (system_addr_ptr);
+ add (arch_integer_type (gdbarch, addr_length * HOST_CHAR_BIT, 0,
+ "storage_offset"));
- lai->bool_type_symbol = NULL;
- lai->bool_type_default = builtin->builtin_bool;
+ lai->set_bool_type (builtin->builtin_bool);
}
/* See language.h. */