void
type_stack::insert (enum type_pieces tp)
{
- union type_stack_elt element;
- int slot;
-
gdb_assert (tp == tp_pointer || tp == tp_reference
|| tp == tp_rvalue_reference || tp == tp_const
|| tp == tp_volatile || tp == tp_restrict
push this on the top of the stack. */
if (!m_elements.empty () && (tp == tp_const || tp == tp_volatile
|| tp == tp_restrict))
- slot = 1;
+ insert_into (1, tp);
else
- slot = 0;
-
- element.piece = tp;
- insert_into (slot, element);
+ insert_into (0, tp);
}
/* See type-stack.h. */
void
type_stack::insert (struct gdbarch *gdbarch, const char *string)
{
- union type_stack_elt element;
- int slot;
-
/* If there is anything on the stack (we know it will be a
tp_pointer), insert the address space qualifier above it.
Otherwise, simply push this on the top of the stack. */
- if (!m_elements.empty ())
- slot = 1;
- else
- slot = 0;
+ int slot = (!m_elements.empty ()) ? 1 : 0;
- element.piece = tp_space_identifier;
- insert_into (slot, element);
- element.int_val
- = address_space_name_to_type_instance_flags (gdbarch, string);
- insert_into (slot, element);
+ insert_into (slot, tp_space_identifier);
+ insert_into (slot,
+ address_space_name_to_type_instance_flags (gdbarch,
+ string));
}
/* See type-stack.h. */
private:
/* A helper function for the insert methods. This does work of
- expanding the type stack and inserting the new element, ELEMENT,
+ expanding the type stack and inserting the new element, TP,
into the stack at location SLOT. */
- void insert_into (int slot, union type_stack_elt element)
+ void insert_into (int slot, enum type_pieces tp)
{
gdb_assert (slot <= m_elements.size ());
+ union type_stack_elt element;
+ element.piece = tp;
+ m_elements.insert (m_elements.begin () + slot, element);
+ }
+
+ /* A helper function for the insert methods. This does work of
+ expanding the type stack and inserting the new element, VAL,
+ into the stack at location SLOT. */
+
+ void insert_into (int slot, int val)
+ {
+ gdb_assert (slot <= m_elements.size ());
+ union type_stack_elt element;
+ element.int_val = val;
m_elements.insert (m_elements.begin () + slot, element);
}