#include "config.h"
#ifdef ENABLE_DMP_TREE
#include "system.h"
#include "tree.h"
#include "c-common.h"
#include <string.h>
#include <ctype.h>
#define DMP_TREE
#include "dmp-tree.h"
int c_dump_tree_p (FILE *, const char *, tree, int);
lang_dump_tree_p_t c_prev_lang_dump_tree_p = NULL;
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) \
static void print_ ## SYM (FILE *file, const char *annotation, tree node, int indent);
#include "c-common.def"
#undef DEFTREECODE
#ifndef CP_DMP_TREE
#include "c-tree.h"
void
c_dump_identifier (file, node, indent, after_id)
FILE *file;
tree node;
int indent;
int after_id;
{
if (!after_id)
{
if (C_IS_RESERVED_WORD (node))
{
tree rid = ridpointers[C_RID_CODE (node)];
fprintf (file, " rid=");
fprintf (file, HOST_PTR_PRINTF, HOST_PTR_PRINTF_VALUE((void *)rid));
fprintf (file, "(%s)", IDENTIFIER_POINTER (rid));
}
if (IDENTIFIER_GLOBAL_VALUE (node))
{
fprintf (file, " gbl=");
fprintf (file, HOST_PTR_PRINTF, IDENTIFIER_GLOBAL_VALUE (node));
}
if (IDENTIFIER_LOCAL_VALUE (node))
{
fprintf (file, " lcl=");
fprintf (file, HOST_PTR_PRINTF, IDENTIFIER_LOCAL_VALUE (node));
}
if (IDENTIFIER_LABEL_VALUE (node))
{
fprintf (file, " lbl=");
fprintf (file, HOST_PTR_PRINTF, IDENTIFIER_LABEL_VALUE (node));
}
if (IDENTIFIER_IMPLICIT_DECL (node))
{
fprintf (file, " impl=");
fprintf (file, HOST_PTR_PRINTF, IDENTIFIER_IMPLICIT_DECL (node));
}
if (IDENTIFIER_ERROR_LOCUS (node))
{
fprintf (file, " err-locus=");
fprintf (file, HOST_PTR_PRINTF, IDENTIFIER_ERROR_LOCUS (node));
}
if (IDENTIFIER_LIMBO_VALUE (node))
{
fprintf (file, " limbo-value=");
fprintf (file, HOST_PTR_PRINTF, IDENTIFIER_LIMBO_VALUE (node));
}
}
else
{
dump_tree (file, "(gbl)", IDENTIFIER_GLOBAL_VALUE (node), indent + INDENT);
dump_tree (file, "(lcl)", IDENTIFIER_LOCAL_VALUE (node), indent + INDENT);
dump_tree (file, "(lbl)", IDENTIFIER_LABEL_VALUE (node), indent + INDENT);
dump_tree (file, "(impl)", IDENTIFIER_IMPLICIT_DECL (node), indent + INDENT);
dump_tree (file, "(err-locus)", IDENTIFIER_ERROR_LOCUS (node), indent + INDENT);
dump_tree (file, "(limbo-value)", IDENTIFIER_LIMBO_VALUE (node), indent + INDENT);
}
}
void
c_dump_decl (file, node, indent, after_id)
FILE *file ATTRIBUTE_UNUSED;
tree node ATTRIBUTE_UNUSED;
int indent ATTRIBUTE_UNUSED;
int after_id ATTRIBUTE_UNUSED;
{
}
void
c_dump_type (file, node, indent, after_id)
FILE *file ATTRIBUTE_UNUSED;
tree node ATTRIBUTE_UNUSED;
int indent ATTRIBUTE_UNUSED;
int after_id ATTRIBUTE_UNUSED;
{
}
int
c_dump_blank_line_p (previous_node, current_node)
tree previous_node;
tree current_node;
{
return (TREE_CODE (current_node) != SCOPE_STMT
&& !(TREE_CODE (previous_node) == SCOPE_STMT
&& SCOPE_BEGIN_P (previous_node)));
}
int
c_dump_lineno_p (file, node)
FILE *file;
tree node;
{
if (statement_code_p (TREE_CODE (node)) && STMT_LINENO (node))
{
if (STMT_LINENO_FOR_FN_P (node))
fprintf (file, " end-line=%d", STMT_LINENO (node));
else
fprintf (file, " line=%d", STMT_LINENO (node));
return 1;
}
return 0;
}
int
c_dmp_tree3 (file, node, flags)
FILE *file;
tree node;
int flags;
{
dmp_tree3 (file, node, flags);
return 1;
}
#endif
#ifndef CP_DMP_TREE
static void
print_SRCLOC (file, annotation, node, indent)
FILE *file ATTRIBUTE_UNUSED;
const char *annotation ATTRIBUTE_UNUSED;
tree node ATTRIBUTE_UNUSED;
int indent ATTRIBUTE_UNUSED;
{
}
#endif
static void
print_SIZEOF_EXPR (file, annotation, node, indent)
FILE *file ATTRIBUTE_UNUSED;
const char *annotation ATTRIBUTE_UNUSED;
tree node ATTRIBUTE_UNUSED;
int indent ATTRIBUTE_UNUSED;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_ARROW_EXPR (file, annotation, node, indent)
FILE *file ATTRIBUTE_UNUSED;
const char *annotation ATTRIBUTE_UNUSED;
tree node ATTRIBUTE_UNUSED;
int indent ATTRIBUTE_UNUSED;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_ALIGNOF_EXPR (file, annotation, node, indent)
FILE *file ATTRIBUTE_UNUSED;
const char *annotation ATTRIBUTE_UNUSED;
tree node ATTRIBUTE_UNUSED;
int indent ATTRIBUTE_UNUSED;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_EXPR_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_COMPOUND_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, FALSE, NULL);
for (node = COMPOUND_BODY (node); node; node = TREE_CHAIN (node))
{
if (TREE_CODE (node) == SCOPE_STMT && SCOPE_END_P (node) && indent >= INDENT)
indent -= INDENT;
dump_tree (file, NULL, node, indent + INDENT);
if (TREE_CODE (node) == SCOPE_STMT && SCOPE_BEGIN_P (node))
indent += INDENT;
}
}
static void
print_DECL_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
tree type;
fprintf (file, " %s=", tree_code_name[(int) TREE_CODE (DECL_STMT_DECL (node))]);
fprintf (file, HOST_PTR_PRINTF, HOST_PTR_PRINTF_VALUE (DECL_STMT_DECL (node)));
type = TREE_TYPE (DECL_STMT_DECL (node));
if (type && TREE_CODE_CLASS (TREE_CODE (type)) == 't')
{
if (TYPE_NAME (type))
{
if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
fprintf (file, " {%s}", IDENTIFIER_POINTER (TYPE_NAME (type)));
else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& DECL_NAME (TYPE_NAME (type)))
fprintf (file, " {%s}",
IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
}
else
fprintf (file, " {%s}", tree_code_name[(int) TREE_CODE (type)]);
}
if (DECL_NAME ( DECL_STMT_DECL (node)))
fprintf (file, " %s", IDENTIFIER_POINTER (DECL_NAME ( DECL_STMT_DECL (node))));
if (!node_seen (DECL_STMT_DECL (node), FALSE)
|| TREE_CODE (DECL_STMT_DECL (node)) != VAR_DECL)
dump_tree (file, NULL, DECL_STMT_DECL (node), indent + INDENT);
}
static void
print_IF_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, "(if)", "(then)", "(else)", NULL);
}
static void
print_FOR_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
if (NEW_FOR_SCOPE_P (node))
fputs (" new-scope", file);
print_operands (file, node, indent, TRUE, "(init)", "(cond)",
"(expr)", "(body)", NULL);
}
static void
print_WHILE_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, "(cond)", "(body)", NULL);
}
static void
print_DO_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, "(cond)", "(body)", NULL);
}
static void
print_RETURN_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_BREAK_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_CONTINUE_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_SWITCH_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, "(cond)", "(body)", NULL);
}
static void
print_GOTO_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_LABEL_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_ASM_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
if (ASM_VOLATILE_P (node))
fputs (" volatile", file);
print_operands (file, node, indent, TRUE, "(cv-qual)", "(string)",
"(outputs)", "(inputs)", "(clobbers)", NULL);
}
static void
print_SCOPE_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
if (SCOPE_BEGIN_P (node))
fputs (" BEGIN", file);
if (SCOPE_END_P (node))
fputs (" END", file);
if (SCOPE_NULLIFIED_P (node))
fputs (" no-vars", file);
if (SCOPE_NO_CLEANUPS_P (node))
fputs (" no-cleanups", file);
if (SCOPE_PARTIAL_P (node))
fputs (" partial", file);
fprintf (file, " block=");
fprintf (file, HOST_PTR_PRINTF,
HOST_PTR_PRINTF_VALUE (SCOPE_STMT_BLOCK (node)));
if (SCOPE_BEGIN_P (node) || !node_seen (SCOPE_STMT_BLOCK (node), FALSE))
dump_tree (file, NULL, SCOPE_STMT_BLOCK (node), indent + INDENT);
(void)node_seen (node, TRUE);
for (node = TREE_CHAIN (node); node; node = TREE_CHAIN (node))
dump_tree (file, annotation, node, indent + INDENT);
}
static void
print_FILE_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_CASE_LABEL (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, "(lo)", "(hi)", "(lbl)", NULL);
}
static void
print_STMT_EXPR (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_COMPOUND_LITERAL_EXPR (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, NULL);
}
static void
print_CLEANUP_STMT (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
print_operands (file, node, indent, TRUE, "(decl)", "(expr)", NULL);
}
int
c_dump_tree_p (file, annotation, node, indent)
FILE *file;
const char *annotation ATTRIBUTE_UNUSED;
tree node;
int indent;
{
switch (TREE_CODE (node))
{
# define DEFTREECODE(SYM, NAME, TYPE, LENGTH) \
case SYM: print_ ## SYM (file, annotation, node, indent); break;
# include "c-common.def"
# undef DEFTREECODE
default:
return c_prev_lang_dump_tree_p (file, annotation, node, indent);
}
return 1;
}
#endif