Beispiel #1
0
static int
type_is_full_subrange_of_target_type (struct type *type)
{
  struct type *subtype;

  if (TYPE_CODE (type) != TYPE_CODE_RANGE)
    return 0;

  subtype = TYPE_TARGET_TYPE (type);
  if (subtype == NULL)
    return 0;

  if (is_dynamic_type (type))
    return 0;

  if (ada_discrete_type_low_bound (type)
      != ada_discrete_type_low_bound (subtype))
    return 0;

  if (ada_discrete_type_high_bound (type)
      != ada_discrete_type_high_bound (subtype))
    return 0;

  return 1;
}
Beispiel #2
0
static void
print_range (struct type *type, struct ui_file *stream)
{
    switch (TYPE_CODE (type))
    {
    case TYPE_CODE_RANGE:
    case TYPE_CODE_ENUM:
    {
        struct type *target_type;
        target_type = TYPE_TARGET_TYPE (type);
        if (target_type == NULL)
            target_type = type;
        ada_print_scalar (target_type, ada_discrete_type_low_bound (type),
                          stream);
        fprintf_filtered (stream, " .. ");
        ada_print_scalar (target_type, ada_discrete_type_high_bound (type),
                          stream);
    }
    break;
    default:
        fprintf_filtered (stream, "%.*s",
                          ada_name_prefix_len (TYPE_NAME (type)),
                          TYPE_NAME (type));
        break;
    }
}
Beispiel #3
0
static void
print_range (struct type *type, struct ui_file *stream,
	     int bounds_prefered_p)
{
  if (!bounds_prefered_p)
    {
      /* Try stripping all TYPE_CODE_RANGE layers whose bounds
	 are identical to the bounds of their subtype.  When
	 the bounds of both types match, it can allow us to
	 print a range using the name of its base type, which
	 is easier to read.  For instance, we would print...

	     array (character) of ...

	 ... instead of...

	     array ('["00"]' .. '["ff"]') of ...  */
      while (type_is_full_subrange_of_target_type (type))
	type = TYPE_TARGET_TYPE (type);
    }

  switch (TYPE_CODE (type))
    {
    case TYPE_CODE_RANGE:
    case TYPE_CODE_ENUM:
      {
	struct type *target_type;
	volatile struct gdb_exception e;
	LONGEST lo = 0, hi = 0; /* init for gcc -Wall */

	target_type = TYPE_TARGET_TYPE (type);
	if (target_type == NULL)
	  target_type = type;

	TRY_CATCH (e, RETURN_MASK_ERROR)
	  {
	    lo = ada_discrete_type_low_bound (type);
	    hi = ada_discrete_type_high_bound (type);
	  }
	if (e.reason < 0)
	  {
	    /* This can happen when the range is dynamic.  Sometimes,
	       resolving dynamic property values requires us to have
	       access to an actual object, which is not available
	       when the user is using the "ptype" command on a type.
	       Print the range as an unbounded range.  */
	    fprintf_filtered (stream, "<>");
	  }
	else
	  {
	    ada_print_scalar (target_type, lo, stream);
	    fprintf_filtered (stream, " .. ");
	    ada_print_scalar (target_type, hi, stream);
	  }
      }
      break;
    default:
      fprintf_filtered (stream, "%.*s",
			ada_name_prefix_len (TYPE_NAME (type)),
			TYPE_NAME (type));
      break;
    }