ptree.c revision 117409
1/* Prints out trees in human readable form. 2 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 3 1999 Free Software Foundation, Inc. 4 Hacked by Michael Tiemann (tiemann@cygnus.com) 5 6This file is part of GNU CC. 7 8GNU CC is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 2, or (at your option) 11any later version. 12 13GNU CC is distributed in the hope that it will be useful, 14but WITHOUT ANY WARRANTY; without even the implied warranty of 15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16GNU General Public License for more details. 17 18You should have received a copy of the GNU General Public License 19along with GNU CC; see the file COPYING. If not, write to 20the Free Software Foundation, 59 Temple Place - Suite 330, 21Boston, MA 02111-1307, USA. */ 22 23/* $FreeBSD: head/contrib/gcc/cp/ptree.c 117409 2003-07-11 04:32:20Z kan $ */ 24 25 26#include "config.h" 27#include "system.h" 28#include "tree.h" 29#include "cp-tree.h" 30 31#ifndef HOST_PTR_PRINTF_FORMAT 32#define HOST_PTR_PRINTF_FORMAT HOST_PTR_PRINTF 33#endif 34#ifndef HOST_PTR_PRINTF_TYPE 35#define HOST_PTR_PRINTF_TYPE (void *) 36#endif 37 38void 39cxx_print_decl (file, node, indent) 40 FILE *file; 41 tree node; 42 int indent; 43{ 44 if (TREE_CODE (node) == FIELD_DECL) 45 { 46 if (DECL_MUTABLE_P (node)) 47 { 48 indent_to (file, indent + 3); 49 fprintf (file, " mutable "); 50 } 51 return; 52 } 53 54 if (!DECL_LANG_SPECIFIC (node)) 55 return; 56 indent_to (file, indent + 3); 57 if (TREE_CODE (node) == FUNCTION_DECL 58 && DECL_PENDING_INLINE_INFO (node)) 59 { 60 fprintf (file, " pending-inline-info "); 61 fprintf (file, HOST_PTR_PRINTF_FORMAT, HOST_PTR_PRINTF_TYPE DECL_PENDING_INLINE_INFO (node)); 62 } 63 if (TREE_CODE (node) == TYPE_DECL 64 && DECL_SORTED_FIELDS (node)) 65 { 66 fprintf (file, " sorted-fields "); 67 fprintf (file, HOST_PTR_PRINTF_FORMAT, HOST_PTR_PRINTF_TYPE DECL_SORTED_FIELDS (node)); 68 } 69 if ((TREE_CODE (node) == FUNCTION_DECL || TREE_CODE (node) == VAR_DECL) 70 && DECL_TEMPLATE_INFO (node)) 71 { 72 fprintf (file, " template-info "); 73 fprintf (file, HOST_PTR_PRINTF_FORMAT, HOST_PTR_PRINTF_TYPE DECL_TEMPLATE_INFO (node)); 74 } 75} 76 77void 78cxx_print_type (file, node, indent) 79 FILE *file; 80 register tree node; 81 int indent; 82{ 83 switch (TREE_CODE (node)) 84 { 85 case TEMPLATE_TYPE_PARM: 86 case TEMPLATE_TEMPLATE_PARM: 87 case BOUND_TEMPLATE_TEMPLATE_PARM: 88 indent_to (file, indent + 3); 89 fputs ("index ", file); 90 fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_IDX (node)); 91 fputs (" level ", file); 92 fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_LEVEL (node)); 93 fputs (" orig_level ", file); 94 fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_ORIG_LEVEL (node)); 95 return; 96 97 case FUNCTION_TYPE: 98 case METHOD_TYPE: 99 if (TYPE_RAISES_EXCEPTIONS (node)) 100 print_node (file, "throws", TYPE_RAISES_EXCEPTIONS (node), indent + 4); 101 return; 102 103 case RECORD_TYPE: 104 case UNION_TYPE: 105 break; 106 107 default: 108 return; 109 } 110 111 if (TYPE_PTRMEMFUNC_P (node)) 112 print_node (file, "ptrmemfunc fn type", TYPE_PTRMEMFUNC_FN_TYPE (node), 113 indent + 4); 114 115 if (! CLASS_TYPE_P (node)) 116 return; 117 118 indent_to (file, indent + 3); 119 120 if (TYPE_NEEDS_CONSTRUCTING (node)) 121 fputs ( "needs-constructor", file); 122 if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (node)) 123 fputs (" needs-destructor", file); 124 if (TYPE_HAS_DESTRUCTOR (node)) 125 fputs (" ~X()", file); 126 if (TYPE_HAS_DEFAULT_CONSTRUCTOR (node)) 127 fputs (" X()", file); 128 if (TYPE_HAS_CONVERSION (node)) 129 fputs (" has-type-conversion", file); 130 if (TYPE_HAS_INIT_REF (node)) 131 { 132 if (TYPE_HAS_CONST_INIT_REF (node)) 133 fputs (" X(constX&)", file); 134 else 135 fputs (" X(X&)", file); 136 } 137 if (TYPE_HAS_NEW_OPERATOR (node)) 138 fputs (" new", file); 139 if (TYPE_HAS_ARRAY_NEW_OPERATOR (node)) 140 fputs (" new[]", file); 141 if (TYPE_GETS_DELETE (node) & 1) 142 fputs (" delete", file); 143 if (TYPE_GETS_DELETE (node) & 2) 144 fputs (" delete[]", file); 145 if (TYPE_HAS_ASSIGN_REF (node)) 146 fputs (" this=(X&)", file); 147 if (TYPE_OVERLOADS_CALL_EXPR (node)) 148 fputs (" op()", file); 149 if (TYPE_OVERLOADS_ARRAY_REF (node)) 150 fputs (" op[]", file); 151 if (TYPE_OVERLOADS_ARROW (node)) 152 fputs (" op->", file); 153 if (TYPE_USES_MULTIPLE_INHERITANCE (node)) 154 fputs (" uses-multiple-inheritance", file); 155 156 if (TREE_CODE (node) == RECORD_TYPE) 157 { 158 fprintf (file, " n_parents %d", CLASSTYPE_N_BASECLASSES (node)); 159 fprintf (file, " use_template=%d", CLASSTYPE_USE_TEMPLATE (node)); 160 if (CLASSTYPE_INTERFACE_ONLY (node)) 161 fprintf (file, " interface-only"); 162 if (CLASSTYPE_INTERFACE_UNKNOWN (node)) 163 fprintf (file, " interface-unknown"); 164 print_node (file, "member-functions", CLASSTYPE_METHOD_VEC (node), 165 indent + 4); 166 } 167} 168 169static void 170cxx_print_binding (FILE *stream, cxx_binding *binding, const char *prefix) 171{ 172 fprintf (stream, "%s <", prefix); 173 fprintf (stream, HOST_PTR_PRINTF_FORMAT, HOST_PTR_PRINTF_TYPE binding); 174 fprintf (stream, ">"); 175} 176 177void 178cxx_print_identifier (file, node, indent) 179 FILE *file; 180 tree node; 181 int indent; 182{ 183 cxx_print_binding (file, IDENTIFIER_NAMESPACE_BINDINGS (node), "bindings"); 184 print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4); 185 cxx_print_binding (file, IDENTIFIER_BINDING (node), "local bindings"); 186 print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4); 187 print_node (file, "template", IDENTIFIER_TEMPLATE (node), indent + 4); 188 print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4); 189 print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4); 190} 191 192void 193cxx_print_xnode (file, node, indent) 194 FILE *file; 195 tree node; 196 int indent; 197{ 198 switch (TREE_CODE (node)) 199 { 200 case OVERLOAD: 201 print_node (file, "function", OVL_FUNCTION (node), indent+4); 202 print_node (file, "chain", TREE_CHAIN (node), indent+4); 203 break; 204 case TEMPLATE_PARM_INDEX: 205 indent_to (file, indent + 3); 206 fputs ("index ", file); 207 fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_IDX (node)); 208 fputs (" level ", file); 209 fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_LEVEL (node)); 210 fputs (" orig_level ", file); 211 fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_ORIG_LEVEL (node)); 212 break; 213 default: 214 break; 215 } 216} 217