No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / usr.bin / g++ / cc1plus / cplus-ptree.c
blob03445ad06406030febad9bb3bb2796f82bd16d98
1 /* Prints out tree in human readable form - GNU C++ compiler
2 Copyright (C) 1987 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@mcc.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 1, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
22 #include "config.h"
23 #include "tree.h"
24 #include "cplus-tree.h"
25 #include <stdio.h>
28 extern char *tree_code_err_name[];
29 extern char *tree_code_err_asg_name[];
30 extern char *mode_name[];
32 extern char spaces[];
34 #define MIN(x,y) ((x < y) ? x : y)
36 static FILE *outfile;
38 /* This code is copied from print-tree.c. */
39 static
40 void
41 wruid (node)
42 tree node;
45 if (node == NULL)
46 fputs ("<>", outfile);
47 else {
48 fprintf (outfile, "%1d", TREE_UID (node));
52 static
53 void
54 part (title, node)
55 char title[];
56 tree node;
58 fprintf (outfile, " %s = ", title);
59 wruid (node);
60 putc (';', outfile);
63 /* Similar to `part' but prefix with @ if value is not constant
64 and print the constant value if it is constant. */
65 static
66 void
67 cpart (title, ct, punct)
68 char *title;
69 tree ct;
70 char punct;
72 fprintf (outfile, " %s = ", title);
73 if (ct == NULL)
74 fputs ("<>", outfile);
75 else
77 if (!TREE_LITERAL (ct))
79 putc ('@', outfile);
80 wruid (ct);
82 else
83 fprintf (outfile, "%ld", TREE_INT_CST_LOW (ct));
85 putc (punct, outfile);
88 void
89 print_lang_decl (node)
90 tree node;
94 void walk_lang_decl (node)
95 tree node;
99 void
100 print_lang_type (node)
101 register tree node;
103 int first;
104 if (! (TREE_CODE (node) == RECORD_TYPE
105 || TREE_CODE (node) == UNION_TYPE))
106 return;
107 first = 1;
108 fputs (" [", outfile);
109 if (TYPE_NEEDS_CONSTRUCTOR (node))
111 if (!first) putc (' ', outfile);
112 fputs ("needs-constructor", outfile);
113 first = 0;
115 if (TYPE_NEEDS_DESTRUCTOR (node))
117 if (!first) putc (' ', outfile);
118 fputs ("needs-destructor", outfile);
119 first = 0;
121 if (TYPE_HAS_CONVERSION (node))
123 if (!first) putc (' ', outfile);
124 fputs ("has-type-conversion", outfile);
125 first = 0;
127 if (TYPE_HAS_INT_CONVERSION (node))
129 if (!first) putc (' ', outfile);
130 fputs ("has-int-conversion", outfile);
131 first = 0;
133 if (TYPE_HAS_REAL_CONVERSION (node))
135 if (!first) putc (' ', outfile);
136 fputs ("has-float-conversion", outfile);
137 first = 0;
139 if (TYPE_HAS_INIT_REF (node))
141 if (!first) putc (' ', outfile);
142 fputs ("X(X&)", outfile);
143 first = 0;
145 if (TREE_GETS_NEW (node))
147 if (!first) putc (' ', outfile);
148 fputs ("gets-new", outfile);
149 first = 0;
151 if (TREE_GETS_DELETE (node))
153 if (!first) putc (' ', outfile);
154 fputs ("gets-delete", outfile);
155 first = 0;
157 if (TYPE_HAS_ASSIGNMENT (node))
159 if (!first) putc (' ', outfile);
160 fputs ("has=", outfile);
161 first = 0;
163 if (TYPE_GETS_ASSIGNMENT (node))
165 if (!first) putc (' ', outfile);
166 fputs ("gets=", outfile);
167 first = 0;
169 if (TYPE_HAS_ASSIGN_REF (node))
171 if (!first) putc (' ', outfile);
172 fputs ("this=(X&)", outfile);
173 first = 0;
175 if (TYPE_GETS_ASSIGN_REF (node))
177 if (!first) putc (' ', outfile);
178 fputs ("gets=(X&)", outfile);
179 first = 0;
181 if (TYPE_HAS_WRAPPER (node))
183 if (!first) putc (' ', outfile);
184 fputs ("wrapper", outfile);
185 first = 0;
187 if (TYPE_OVERLOADS_METHOD_CALL_EXPR (node))
189 if (!first) putc (' ', outfile);
190 fputs ("op->()", outfile);
191 first = 0;
193 if (TYPE_GETS_INIT_AGGR (node))
195 if (!first) putc (' ', outfile);
196 fputs ("gets X(X, ...)", outfile);
197 first = 0;
199 if (TYPE_OVERLOADS_CALL_EXPR (node))
201 if (!first) putc (' ', outfile);
202 fputs ("op()", outfile);
203 first = 0;
205 if (TYPE_OVERLOADS_ARRAY_REF (node))
207 if (!first) putc (' ', outfile);
208 fputs ("op[]", outfile);
209 first = 0;
211 if (TYPE_USES_MULTIPLE_INHERITANCE (node))
213 if (!first) putc (' ', outfile);
214 fputs ("uses-multiple-inheritance", outfile);
215 first = 0;
218 fputs ("] ", outfile);
221 void
222 walk_lang_type (node)
223 tree node;
225 if (! (TREE_CODE (node) == RECORD_TYPE))
226 return;
228 part ("member functions", CLASSTYPE_METHOD_VEC (node));
229 part ("baselinks", CLASSTYPE_BASELINK_VEC (node));
230 cpart ("offset", CLASSTYPE_OFFSET (node), ';');
231 fprintf (outfile, "n_parents = %d; n_ancestors = %d;",
232 CLASSTYPE_N_BASECLASSES (node),
233 CLASSTYPE_N_SUPERCLASSES (node));