#include "attribs.h"
/* Local functions, macros and variables. */
-static int dump_generic_ada_node (pretty_printer *, tree, tree, int, bool,
- bool);
+static int dump_ada_node (pretty_printer *, tree, tree, int, bool, bool);
static int dump_ada_declaration (pretty_printer *, tree, tree, int);
-static void dump_ada_struct_decl (pretty_printer *, tree, tree, int, bool);
+static void dump_ada_structure (pretty_printer *, tree, tree, int, bool);
static char *to_ada_name (const char *, unsigned int, bool *);
#define INDENT(SPACE) \
pp_string (buffer, buf);
}
- dump_generic_ada_node (buffer, TREE_TYPE (arg), node, spc, 0, true);
+ dump_ada_node (buffer, TREE_TYPE (arg), node, spc, false, true);
}
else
{
sprintf (buf, "arg%d : ", num);
pp_string (buffer, buf);
- dump_generic_ada_node (buffer, TREE_VALUE (arg), node, spc, 0, true);
+ dump_ada_node (buffer, TREE_VALUE (arg), node, spc, false, true);
}
/* If the type is a pointer to a tagged type, we need to differentiate
{
pp_string (buffer, " return ");
tree type = is_constructor ? DECL_CONTEXT (func) : TREE_TYPE (node);
- dump_generic_ada_node (buffer, type, type, spc, false, true);
+ dump_ada_node (buffer, type, type, spc, false, true);
}
}
first = 0;
if (min)
- dump_generic_ada_node (buffer, min, NULL_TREE, spc, 0, true);
+ dump_ada_node (buffer, min, NULL_TREE, spc, false, true);
pp_string (buffer, " .. ");
/* If the upper bound is zero, gcc may generate a NULL_TREE
for TYPE_MAX_VALUE rather than an integer_cst. */
if (max)
- dump_generic_ada_node (buffer, max, NULL_TREE, spc, 0, true);
+ dump_ada_node (buffer, max, NULL_TREE, spc, false, true);
else
pp_string (buffer, "0");
}
}
tmp = TREE_TYPE (tmp);
- return num_dim == 1 && TREE_CODE (tmp) == INTEGER_TYPE
- && id_equal (DECL_NAME (TYPE_NAME (tmp)), "char");
+ return num_dim == 1
+ && TREE_CODE (tmp) == INTEGER_TYPE
+ && id_equal (DECL_NAME (TYPE_NAME (tmp)), "char");
}
/* Dump in BUFFER an array type T in Ada syntax. Assume that the "type"
pp_string (buffer, "aliased ");
if (TYPE_NAME (tmp) || !RECORD_OR_UNION_TYPE_P (tmp))
- dump_generic_ada_node (buffer, tmp, TREE_TYPE (t), spc, false, true);
+ dump_ada_node (buffer, tmp, TREE_TYPE (t), spc, false, true);
else
dump_ada_double_name (buffer, parent, get_underlying_decl (tmp));
}
static void
dump_template_types (pretty_printer *buffer, tree types, int spc)
{
- size_t i;
- size_t len = TREE_VEC_LENGTH (types);
-
- for (i = 0; i < len; i++)
+ for (int i = 0; i < TREE_VEC_LENGTH (types); i++)
{
tree elem = TREE_VEC_ELT (types, i);
pp_underscore (buffer);
- if (!dump_generic_ada_node (buffer, elem, 0, spc, false, true))
+
+ if (!dump_ada_node (buffer, elem, NULL_TREE, spc, false, true))
{
pp_string (buffer, "unknown");
pp_scalar (buffer, "%lu", (unsigned long) TREE_HASH (elem));
INDENT (spc);
pp_string (buffer, "package ");
package_prefix = false;
- dump_generic_ada_node (buffer, instance, t, spc, false, true);
+ dump_ada_node (buffer, instance, t, spc, false, true);
dump_template_types (buffer, types, spc);
pp_string (buffer, " is");
spc += INDENT_INCR;
TREE_VISITED (get_underlying_decl (instance)) = 1;
pp_string (buffer, "type ");
- dump_generic_ada_node (buffer, instance, t, spc, false, true);
+ dump_ada_node (buffer, instance, t, spc, false, true);
package_prefix = true;
if (is_tagged_type (instance))
else
pp_string (buffer, " is limited ");
- dump_generic_ada_node (buffer, instance, t, spc, false, false);
+ dump_ada_node (buffer, instance, t, spc, false, false);
pp_newline (buffer);
spc -= INDENT_INCR;
newline_and_indent (buffer, spc);
newline_and_indent (buffer, spc);
pp_string (buffer, "use ");
package_prefix = false;
- dump_generic_ada_node (buffer, instance, t, spc, false, true);
+ dump_ada_node (buffer, instance, t, spc, false, true);
dump_template_types (buffer, types, spc);
package_prefix = true;
pp_semicolon (buffer);
we should only dump the name of NODE, instead of its full declaration. */
static int
-dump_generic_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
- bool limited_access, bool name_only)
+dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
+ bool limited_access, bool name_only)
{
if (node == NULL_TREE)
return 0;
return 0;
case TREE_BINFO:
- dump_generic_ada_node
- (buffer, BINFO_TYPE (node), type, spc, limited_access, name_only);
+ dump_ada_node (buffer, BINFO_TYPE (node), type, spc, limited_access,
+ name_only);
return 0;
case TREE_VEC:
case ENUMERAL_TYPE:
if (name_only)
- dump_generic_ada_node (buffer, TYPE_NAME (node), node, spc, 0, true);
+ dump_ada_node (buffer, TYPE_NAME (node), node, spc, false, true);
else
{
tree value = TYPE_VALUES (node);
spc -= INDENT_INCR;
newline_and_indent (buffer, spc);
pp_string (buffer, "pragma Convention (C, ");
- dump_generic_ada_node
- (buffer, DECL_NAME (type) ? type : TYPE_NAME (node), type,
- spc, 0, true);
+ dump_ada_node (buffer,
+ DECL_NAME (type) ? type : TYPE_NAME (node),
+ type, spc, false, true);
pp_right_paren (buffer);
}
else
0, false);
pp_string (buffer, " : constant ");
- dump_generic_ada_node
- (buffer, DECL_NAME (type) ? type : TYPE_NAME (node), type,
- spc, 0, true);
+ dump_ada_node (buffer,
+ DECL_NAME (type) ? type : TYPE_NAME (node),
+ type, spc, false, true);
pp_string (buffer, " := ");
- dump_generic_ada_node
- (buffer,
- TREE_CODE (TREE_VALUE (value)) == INTEGER_CST ?
- TREE_VALUE (value) : DECL_INITIAL (TREE_VALUE (value)),
- node, spc, false, true);
+ dump_ada_node (buffer,
+ TREE_CODE (TREE_VALUE (value)) == INTEGER_CST
+ ? TREE_VALUE (value)
+ : DECL_INITIAL (TREE_VALUE (value)),
+ node, spc, false, true);
}
}
}
case POINTER_TYPE:
case REFERENCE_TYPE:
if (name_only && TYPE_NAME (node))
- dump_generic_ada_node
- (buffer, TYPE_NAME (node), node, spc, limited_access, true);
+ dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access,
+ true);
else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
{
pp_semicolon (buffer);
newline_and_indent (buffer, spc);
pp_string (buffer, "pragma Convention (C, ");
- dump_generic_ada_node (buffer, type, 0, spc, false, true);
+ dump_ada_node (buffer, type, NULL_TREE, spc, false, true);
pp_right_paren (buffer);
}
}
}
if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (node)) && type_name)
- dump_generic_ada_node (buffer, type_name, TREE_TYPE (node),
- spc, is_access, true);
+ dump_ada_node (buffer, type_name, TREE_TYPE (node), spc,
+ is_access, true);
else
- dump_generic_ada_node (buffer, TREE_TYPE (node),
- TREE_TYPE (node), spc, 0, true);
+ dump_ada_node (buffer, TREE_TYPE (node), TREE_TYPE (node),
+ spc, false, true);
}
}
}
case ARRAY_TYPE:
if (name_only)
- dump_generic_ada_node
- (buffer, TYPE_NAME (node), node, spc, limited_access, true);
+ dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access,
+ true);
else
dump_ada_array_type (buffer, node, type, spc);
break;
if (name_only)
{
if (TYPE_NAME (node))
- dump_generic_ada_node
- (buffer, TYPE_NAME (node), node, spc, limited_access, true);
+ dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access,
+ true);
else
{
pp_string (buffer, "anon_");
}
}
else
- dump_ada_struct_decl (buffer, node, type, spc, true);
+ dump_ada_structure (buffer, node, type, spc, true);
break;
case INTEGER_CST:
else if (has_nontrivial_methods (TREE_TYPE (node)))
pp_string (buffer, "limited ");
- dump_generic_ada_node
- (buffer, TREE_TYPE (node), type, spc, false, false);
+ dump_ada_node (buffer, TREE_TYPE (node), type, spc, false, false);
}
break;
/* Generate an incomplete type declaration. */
pp_string (buffer, "type ");
- dump_generic_ada_node (buffer, decl, 0, spc, false, true);
+ dump_ada_node (buffer, decl, NULL_TREE, spc, false, true);
pp_semicolon (buffer);
newline_and_indent (buffer, spc);
if (TYPE_NAME (field_type))
{
- dump_generic_ada_node (buffer, field_type, 0, spc, false, true);
+ dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true);
if (TREE_CODE (field_type) == UNION_TYPE)
pp_string (buffer, " (discr : unsigned := 0)");
pp_string (buffer, " is ");
- dump_ada_struct_decl (buffer, field_type, t, spc, false);
+ dump_ada_structure (buffer, field_type, t, spc, false);
pp_string (buffer, "pragma Convention (C_Pass_By_Copy, ");
- dump_generic_ada_node (buffer, field_type, 0, spc, false, true);
+ dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true);
pp_string (buffer, ");");
newline_and_indent (buffer, spc);
if (TREE_CODE (field_type) == UNION_TYPE)
{
pp_string (buffer, "pragma Unchecked_Union (");
- dump_generic_ada_node (buffer, field_type, 0, spc, false, true);
+ dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true);
pp_string (buffer, ");");
}
}
if (TREE_CODE (field_type) == UNION_TYPE)
pp_string (buffer, " (discr : unsigned := 0)");
pp_string (buffer, " is ");
- dump_ada_struct_decl (buffer, field_type, t, spc, false);
+ dump_ada_structure (buffer, field_type, t, spc, false);
pp_string (buffer, "pragma Convention (C_Pass_By_Copy, ");
dump_ada_double_name (buffer, parent, field);
if (RECORD_OR_UNION_TYPE_P (typ) && !COMPLETE_TYPE_P (typ))
{
pp_string (buffer, "-- skipped incomplete struct ");
- dump_generic_ada_node (buffer, t, type, spc, false, true);
+ dump_ada_node (buffer, t, type, spc, false, true);
}
else
{
dump_forward_type (buffer, stub, t, spc);
pp_string (buffer, "subtype ");
- dump_generic_ada_node (buffer, t, type, spc, false, true);
+ dump_ada_node (buffer, t, type, spc, false, true);
pp_string (buffer, " is ");
- dump_generic_ada_node (buffer, typ, type, spc, false, true);
+ dump_ada_node (buffer, typ, type, spc, false, true);
pp_string (buffer, "; -- ");
dump_sloc (buffer, t);
}
if (!COMPLETE_TYPE_P (TREE_TYPE (t)))
{
pp_string (buffer, "-- skipped incomplete struct ");
- dump_generic_ada_node (buffer, t, type, spc, false, true);
+ dump_ada_node (buffer, t, type, spc, false, true);
return 1;
}
|| *IDENTIFIER_POINTER (decl_name) == '$'))
{
pp_string (buffer, "-- skipped anonymous struct ");
- dump_generic_ada_node (buffer, t, type, spc, false, true);
+ dump_ada_node (buffer, t, type, spc, false, true);
TREE_VISITED (t) = 1;
return 1;
}
{
is_class = true;
pp_string (buffer, "package Class_");
- dump_generic_ada_node (buffer, t, type, spc, false, true);
+ dump_ada_node (buffer, t, type, spc, false, true);
pp_string (buffer, " is");
spc += INDENT_INCR;
newline_and_indent (buffer, spc);
case FUNCTION_TYPE:
pp_string (buffer, "-- skipped function type ");
- dump_generic_ada_node (buffer, t, type, spc, false, true);
+ dump_ada_node (buffer, t, type, spc, false, true);
return 1;
case ENUMERAL_TYPE:
INDENT (spc);
/* Print variable's name. */
- dump_generic_ada_node (buffer, t, type, spc, false, true);
+ dump_ada_node (buffer, t, type, spc, false, true);
if (TREE_CODE (t) == TYPE_DECL)
{
pp_string (buffer, " is ");
if (orig && TYPE_NAME (orig))
- dump_generic_ada_node
- (buffer, TYPE_NAME (orig), type, spc, false, true);
+ dump_ada_node (buffer, TYPE_NAME (orig), type, spc, false, true);
else
dump_ada_array_type (buffer, t, type, spc);
}
pp_string (buffer, "aliased ");
if (tmp)
- dump_generic_ada_node (buffer, tmp, type, spc, false, true);
+ dump_ada_node (buffer, tmp, type, spc, false, true);
else if (type)
dump_ada_double_name (buffer, type, t);
else
INDENT (spc);
/* Anonymous structs/unions. */
- dump_generic_ada_node (buffer, TREE_TYPE (t), t, spc, false, true);
+ dump_ada_node (buffer, TREE_TYPE (t), t, spc, false, true);
if (TREE_CODE (TREE_TYPE (t)) == UNION_TYPE)
pp_string (buffer, " (discr : unsigned := 0)");
dump_sloc (buffer, t);
newline_and_indent (buffer, spc);
pp_string (buffer, "pragma Import (CPP, ");
- dump_generic_ada_node
- (buffer, TYPE_NAME (TREE_TYPE (t)), type, spc, false, true);
- pp_right_paren (buffer);
+ dump_ada_node (buffer, TYPE_NAME (TREE_TYPE (t)), type, spc, false,
+ true);
+ pp_right_paren (buffer);
dump_ada_methods (buffer, TREE_TYPE (t), spc);
}
{
if (is_abstract_record)
pp_string (buffer, "abstract ");
- dump_generic_ada_node (buffer, t, t, spc, false, false);
+ dump_ada_node (buffer, t, t, spc, false, false);
}
}
else
check_name (buffer, t);
/* Print variable/type's name. */
- dump_generic_ada_node (buffer, t, t, spc, false, true);
+ dump_ada_node (buffer, t, t, spc, false, true);
if (TREE_CODE (t) == TYPE_DECL)
{
pp_string (buffer, " is ");
- dump_generic_ada_node (buffer, orig, t, spc, false, is_subtype);
+ dump_ada_node (buffer, orig, t, spc, false, is_subtype);
}
else
{
pp_string (buffer, "constant ");
if (TYPE_NAME (TREE_TYPE (t)))
- dump_generic_ada_node
- (buffer, TREE_TYPE (t), t, spc, false, true);
+ dump_ada_node (buffer, TREE_TYPE (t), t, spc, false, true);
else if (type)
dump_ada_double_name (buffer, type, t);
}
if (TREE_READONLY (t) && TREE_CODE (t) != FIELD_DECL)
pp_string (buffer, "constant ");
- dump_generic_ada_node
- (buffer, TREE_TYPE (t), TREE_TYPE (t), spc, false, true);
+ dump_ada_node (buffer, TREE_TYPE (t), TREE_TYPE (t), spc, false,
+ true);
}
}
}
pp_string (buffer, "end;");
newline_and_indent (buffer, spc);
pp_string (buffer, "use Class_");
- dump_generic_ada_node (buffer, t, type, spc, false, true);
+ dump_ada_node (buffer, t, type, spc, false, true);
pp_semicolon (buffer);
pp_newline (buffer);
true, also print the pragma Convention for NODE. */
static void
-dump_ada_struct_decl (pretty_printer *buffer, tree node, tree type, int spc,
- bool display_convention)
+dump_ada_structure (pretty_printer *buffer, tree node, tree type, int spc,
+ bool display_convention)
{
tree tmp;
const bool is_union = (TREE_CODE (node) == UNION_TYPE);
pp_string (buffer, "pragma Convention (C, ");
package_prefix = false;
- dump_generic_ada_node (buffer, TREE_TYPE (type), type, spc, false, true);
+ dump_ada_node (buffer, TREE_TYPE (type), type, spc, false, true);
package_prefix = true;
pp_right_paren (buffer);
newline_and_indent (buffer, spc);
pp_string (buffer, "pragma Unchecked_Union (");
- dump_generic_ada_node (buffer, TREE_TYPE (type), type, spc, false, true);
+ dump_ada_node (buffer, TREE_TYPE (type), type, spc, false, true);
pp_right_paren (buffer);
}
pp_semicolon (buffer);
newline_and_indent (buffer, spc);
pp_string (buffer, "pragma Pack (");
- dump_generic_ada_node
- (buffer, TREE_TYPE (type), type, spc, false, true);
+ dump_ada_node (buffer, TREE_TYPE (type), type, spc, false, true);
pp_right_paren (buffer);
bitfield_used = false;
}