+ /* Get the type code of this type.
+
+ Note that the code can be TYPE_CODE_TYPEDEF, so if you want the real
+ type, you need to do `check_typedef (type)->code ()`. */
+ type_code code () const
+ {
+ return this->main_type->code;
+ }
+
+ /* Set the type code of this type. */
+ void set_code (type_code code)
+ {
+ this->main_type->code = code;
+ }
+
+ /* Get the name of this type. */
+ const char *name () const
+ {
+ return this->main_type->name;
+ }
+
+ /* Set the name of this type. */
+ void set_name (const char *name)
+ {
+ this->main_type->name = name;
+ }
+
+ /* Get the number of fields of this type. */
+ int num_fields () const
+ {
+ return this->main_type->nfields;
+ }
+
+ /* Set the number of fields of this type. */
+ void set_num_fields (int num_fields)
+ {
+ this->main_type->nfields = num_fields;
+ }
+
+ /* Get the fields array of this type. */
+ struct field *fields () const
+ {
+ return this->main_type->flds_bnds.fields;
+ }
+
+ /* Get the field at index IDX. */
+ struct field &field (int idx) const
+ {
+ return this->fields ()[idx];
+ }
+
+ /* Set the fields array of this type. */
+ void set_fields (struct field *fields)
+ {
+ this->main_type->flds_bnds.fields = fields;
+ }
+
+ type *index_type () const
+ {
+ return this->field (0).type ();
+ }
+
+ void set_index_type (type *index_type)
+ {
+ this->field (0).set_type (index_type);
+ }
+
+ /* Return the instance flags converted to the correct type. */
+ const type_instance_flags instance_flags () const
+ {
+ return (enum type_instance_flag_value) this->m_instance_flags;
+ }
+
+ /* Set the instance flags. */
+ void set_instance_flags (type_instance_flags flags)
+ {
+ this->m_instance_flags = flags;
+ }
+
+ /* Get the bounds bounds of this type. The type must be a range type. */
+ range_bounds *bounds () const
+ {
+ switch (this->code ())
+ {
+ case TYPE_CODE_RANGE:
+ return this->main_type->flds_bnds.bounds;
+
+ case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRING:
+ return this->index_type ()->bounds ();
+
+ default:
+ gdb_assert_not_reached
+ ("type::bounds called on type with invalid code");
+ }
+ }
+
+ /* Set the bounds of this type. The type must be a range type. */
+ void set_bounds (range_bounds *bounds)
+ {
+ gdb_assert (this->code () == TYPE_CODE_RANGE);
+
+ this->main_type->flds_bnds.bounds = bounds;
+ }
+
+ ULONGEST bit_stride () const
+ {
+ return this->bounds ()->bit_stride ();
+ }
+
+ /* Unsigned integer type. If this is not set for a TYPE_CODE_INT,
+ the type is signed (unless TYPE_NOSIGN is set). */
+
+ bool is_unsigned () const
+ {
+ return this->main_type->m_flag_unsigned;
+ }
+
+ void set_is_unsigned (bool is_unsigned)
+ {
+ this->main_type->m_flag_unsigned = is_unsigned;
+ }
+
+ /* No sign for this type. In C++, "char", "signed char", and
+ "unsigned char" are distinct types; so we need an extra flag to
+ indicate the absence of a sign! */
+
+ bool has_no_signedness () const
+ {
+ return this->main_type->m_flag_nosign;
+ }
+
+ void set_has_no_signedness (bool has_no_signedness)
+ {
+ this->main_type->m_flag_nosign = has_no_signedness;
+ }
+
+ /* This appears in a type's flags word if it is a stub type (e.g.,
+ if someone referenced a type that wasn't defined in a source file
+ via (struct sir_not_appearing_in_this_film *)). */
+
+ bool is_stub () const
+ {
+ return this->main_type->m_flag_stub;
+ }
+
+ void set_is_stub (bool is_stub)
+ {
+ this->main_type->m_flag_stub = is_stub;
+ }
+
+ /* The target type of this type is a stub type, and this type needs
+ to be updated if it gets un-stubbed in check_typedef. Used for
+ arrays and ranges, in which TYPE_LENGTH of the array/range gets set
+ based on the TYPE_LENGTH of the target type. Also, set for
+ TYPE_CODE_TYPEDEF. */
+
+ bool target_is_stub () const
+ {
+ return this->main_type->m_flag_target_stub;
+ }
+
+ void set_target_is_stub (bool target_is_stub)
+ {
+ this->main_type->m_flag_target_stub = target_is_stub;
+ }
+
+ /* This is a function type which appears to have a prototype. We
+ need this for function calls in order to tell us if it's necessary
+ to coerce the args, or to just do the standard conversions. This
+ is used with a short field. */
+
+ bool is_prototyped () const
+ {
+ return this->main_type->m_flag_prototyped;
+ }
+
+ void set_is_prototyped (bool is_prototyped)
+ {
+ this->main_type->m_flag_prototyped = is_prototyped;
+ }
+
+ /* FIXME drow/2002-06-03: Only used for methods, but applies as well
+ to functions. */
+
+ bool has_varargs () const
+ {
+ return this->main_type->m_flag_varargs;
+ }
+
+ void set_has_varargs (bool has_varargs)
+ {
+ this->main_type->m_flag_varargs = has_varargs;
+ }
+
+ /* Identify a vector type. Gcc is handling this by adding an extra
+ attribute to the array type. We slurp that in as a new flag of a
+ type. This is used only in dwarf2read.c. */
+
+ bool is_vector () const
+ {
+ return this->main_type->m_flag_vector;
+ }
+
+ void set_is_vector (bool is_vector)
+ {
+ this->main_type->m_flag_vector = is_vector;
+ }
+
+ /* This debug target supports TYPE_STUB(t). In the unsupported case
+ we have to rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE().
+ TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only
+ guessed the TYPE_STUB(t) value (see dwarfread.c). */
+
+ bool stub_is_supported () const
+ {
+ return this->main_type->m_flag_stub_supported;
+ }
+
+ void set_stub_is_supported (bool stub_is_supported)
+ {
+ this->main_type->m_flag_stub_supported = stub_is_supported;
+ }
+
+ /* Used only for TYPE_CODE_FUNC where it specifies the real function
+ address is returned by this function call. TYPE_TARGET_TYPE
+ determines the final returned function type to be presented to
+ user. */
+
+ bool is_gnu_ifunc () const
+ {
+ return this->main_type->m_flag_gnu_ifunc;
+ }
+
+ void set_is_gnu_ifunc (bool is_gnu_ifunc)
+ {
+ this->main_type->m_flag_gnu_ifunc = is_gnu_ifunc;
+ }
+
+ /* The debugging formats (especially STABS) do not contain enough
+ information to represent all Ada types---especially those whose
+ size depends on dynamic quantities. Therefore, the GNAT Ada
+ compiler includes extra information in the form of additional type
+ definitions connected by naming conventions. This flag indicates
+ that the type is an ordinary (unencoded) GDB type that has been
+ created from the necessary run-time information, and does not need
+ further interpretation. Optionally marks ordinary, fixed-size GDB
+ type. */
+
+ bool is_fixed_instance () const
+ {
+ return this->main_type->m_flag_fixed_instance;
+ }
+
+ void set_is_fixed_instance (bool is_fixed_instance)
+ {
+ this->main_type->m_flag_fixed_instance = is_fixed_instance;
+ }
+
+ /* A compiler may supply dwarf instrumentation that indicates the desired
+ endian interpretation of the variable differs from the native endian
+ representation. */
+
+ bool endianity_is_not_default () const
+ {
+ return this->main_type->m_flag_endianity_not_default;
+ }
+
+ void set_endianity_is_not_default (bool endianity_is_not_default)
+ {
+ this->main_type->m_flag_endianity_not_default = endianity_is_not_default;
+ }
+
+ /* * Return the dynamic property of the requested KIND from this type's
+ list of dynamic properties. */
+ dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
+
+ /* * Given a dynamic property PROP of a given KIND, add this dynamic
+ property to this type.
+
+ This function assumes that this type is objfile-owned. */
+ void add_dyn_prop (dynamic_prop_node_kind kind, dynamic_prop prop);
+
+ /* * Remove dynamic property of kind KIND from this type, if it exists. */
+ void remove_dyn_prop (dynamic_prop_node_kind kind);
+
+ /* * Return true if this is an integer type whose logical (bit) size
+ differs from its storage size; false otherwise. Always return
+ false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */
+ bool bit_size_differs_p () const
+ {
+ return (main_type->type_specific_field == TYPE_SPECIFIC_INT
+ && main_type->type_specific.int_stuff.bit_size != 8 * length);
+ }
+
+ /* * Return the logical (bit) size for this integer type. Only
+ valid for integer (TYPE_SPECIFIC_INT) types. */
+ unsigned short bit_size () const
+ {
+ gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
+ return main_type->type_specific.int_stuff.bit_size;
+ }
+
+ /* * Return the bit offset for this integer type. Only valid for
+ integer (TYPE_SPECIFIC_INT) types. */
+ unsigned short bit_offset () const
+ {
+ gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
+ return main_type->type_specific.int_stuff.bit_offset;
+ }
+