OSDN Git Service

Add - before rms to be more portable.
[pf3gnuchains/gcc-fork.git] / gcc / cp / dump.c
1 /* Tree-dumping functionality for intermediate representation.
2    Copyright (C) 1999, 2000 Free Software Foundation, Inc.
3    Written by Mark Mitchell <mark@codesourcery.com>
4
5 This file is part of GNU CC.
6
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 2, or (at your option)
10 any later version.
11
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.
16
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, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.  */
21
22 #include "config.h"
23 #include "system.h"
24 #include "tree.h"
25 #include "cp-tree.h"
26 #include "c-dump.h"
27
28 int
29 cp_dump_tree (di, t)
30      dump_info_p di;
31      tree t;
32 {
33   enum tree_code code;
34
35   /* Figure out what kind of node this is.  */
36   code = TREE_CODE (t);
37
38   if (DECL_P (t))
39     {
40       if (DECL_LANG_SPECIFIC (t) && DECL_LANGUAGE (t) != lang_cplusplus)
41         dump_string (di, language_to_string (DECL_LANGUAGE (t), 0));
42     }
43
44   switch (code)
45     {
46     case IDENTIFIER_NODE:
47       if (IDENTIFIER_OPNAME_P (t))
48         {
49           dump_string (di, "operator");
50           return 1;
51         }
52       else if (IDENTIFIER_TYPENAME_P (t))
53         {
54           dump_child ("tynm", TREE_TYPE (t));
55           return 1;
56         }
57       else if (t == anonymous_namespace_name)
58         {
59           dump_string (di, "unnamed");
60           return 1;
61         }
62       break;
63
64     case POINTER_TYPE:
65       if (TYPE_PTRMEM_P (t))
66         {
67           dump_string (di, "ptrmem");
68           dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
69           dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
70           return 1;
71         }
72       break;
73
74     case RECORD_TYPE:
75     case UNION_TYPE:
76       if (TYPE_PTRMEMFUNC_P (t))
77         {
78           dump_string (di, "ptrmem");
79           dump_child ("ptd", TYPE_PTRMEM_POINTED_TO_TYPE (t));
80           dump_child ("cls", TYPE_PTRMEM_CLASS_TYPE (t));
81           return 1;
82         }
83
84       dump_child ("vfld", TYPE_VFIELD (t));
85       break;
86
87     case FUNCTION_DECL:
88       if (!DECL_THUNK_P (t))
89         {
90           if (DECL_FUNCTION_MEMBER_P (t))
91             dump_string (di, "member");
92           if (DECL_CONSTRUCTOR_P (t))
93             dump_string (di, "constructor");
94           if (DECL_DESTRUCTOR_P (t))
95             dump_string (di, "destructor");
96           if (DECL_OVERLOADED_OPERATOR_P (t))
97             dump_string (di, "operator");
98           if (DECL_CONV_FN_P (t))
99             dump_string (di, "conversion");
100           if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
101             {
102               if (DECL_GLOBAL_CTOR_P (t))
103                 dump_string (di, "global init");
104               if (DECL_GLOBAL_DTOR_P (t))
105                 dump_string (di, "global fini");
106               dump_int (di, "prio", GLOBAL_INIT_PRIORITY (t));
107             }
108           if (DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t))
109             dump_string (di, "pseudo tmpl");
110         }
111       else
112         {
113           dump_string (di, "thunk");
114           dump_int (di, "dlta", THUNK_DELTA (t));
115           dump_child ("vcll", THUNK_VCALL_OFFSET (t));
116           dump_child ("fn", DECL_INITIAL (t));
117         }
118       break;
119
120     case NAMESPACE_DECL:
121       /* The fake `::std' namespace does not have DECL_LANG_SPECIFIC,
122          and therefore many other macros do not work on it.  */
123       if (t == fake_std_node)
124         break;
125       if (DECL_NAMESPACE_ALIAS (t))
126         dump_child ("alis", DECL_NAMESPACE_ALIAS (t));
127       else
128         dump_child ("dcls", cp_namespace_decls (t));
129       break;
130
131     case TEMPLATE_DECL:
132       dump_child ("rslt", DECL_TEMPLATE_RESULT (t));
133       dump_child ("inst", DECL_TEMPLATE_INSTANTIATIONS (t));
134       dump_child ("spcs", DECL_TEMPLATE_SPECIALIZATIONS (t));
135       break;
136
137     case OVERLOAD:
138       dump_child ("crnt", OVL_CURRENT (t));
139       dump_child ("chan", OVL_CHAIN (t));
140       break;
141
142     case TRY_BLOCK:
143       dump_stmt (di, t);
144       if (CLEANUP_P (t))
145         dump_string (di, "cleanup");
146       dump_child ("body", TRY_STMTS (t));
147       dump_child ("hdlr", TRY_HANDLERS (t));
148       dump_next_stmt (di, t);
149       break;
150
151     case PTRMEM_CST:
152       dump_child ("clas", PTRMEM_CST_CLASS (t));
153       dump_child ("mbr", PTRMEM_CST_MEMBER (t));
154       break;
155
156     case THROW_EXPR:
157       /* These nodes are unary, but do not have code class `1'.  */
158       dump_child ("op 0", TREE_OPERAND (t, 0));
159       break;
160
161     case AGGR_INIT_EXPR:
162       dump_int (di, "ctor", AGGR_INIT_VIA_CTOR_P (t));
163       dump_child ("fn", TREE_OPERAND (t, 0));
164       dump_child ("args", TREE_OPERAND (t, 1));
165       dump_child ("decl", TREE_OPERAND (t, 2));
166       break;
167       
168     case CLEANUP_STMT:
169       dump_stmt (di, t);
170       dump_child ("decl", CLEANUP_DECL (t));
171       dump_child ("expr", CLEANUP_EXPR (t));
172       dump_next_stmt (di, t);
173       break;
174
175     case CTOR_STMT:
176       dump_stmt (di, t);
177       if (CTOR_BEGIN_P (t))
178         dump_string (di, "begn");
179       else
180         dump_string (di, "end");
181       dump_next_stmt (di, t);
182       break;
183
184     case HANDLER:
185       dump_stmt (di, t);
186       dump_child ("body", HANDLER_BODY (t));
187       dump_next_stmt (di, t);
188       break;
189
190     case SUBOBJECT:
191       dump_stmt (di, t);
192       dump_child ("clnp", TREE_OPERAND (t, 0));
193       dump_next_stmt (di, t);
194       break;
195
196     case START_CATCH_STMT:
197       dump_stmt (di, t);
198       queue_and_dump_type (di, t);
199       dump_next_stmt (di, t);
200       break;
201
202     default:
203       break;
204     }
205
206   return 0;
207 }
208