annotate gcc/c-family/c-ada-spec.c @ 136:4627f235cf2a

fix c-next example
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:11:56 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Print GENERIC declaration (functions, variables, types) trees coming from
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 the C and C++ front-ends as well as macros in Ada syntax.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3 Copyright (C) 2010-2018 Free Software Foundation, Inc.
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 Adapted from tree-pretty-print.c by Arnaud Charlet <charlet@adacore.com>
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 This file is part of GCC.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 GCC is free software; you can redistribute it and/or modify it under
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 the terms of the GNU General Public License as published by the Free
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 Software Foundation; either version 3, or (at your option) any later
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 version.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 for more details.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 along with GCC; see the file COPYING3. If not see
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 <http://www.gnu.org/licenses/>. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "config.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "system.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "coretypes.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "tm.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #include "tree.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 #include "c-ada-spec.h"
111
kono
parents: 68
diff changeset
28 #include "fold-const.h"
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 #include "c-pragma.h"
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
30 #include "diagnostic.h"
111
kono
parents: 68
diff changeset
31 #include "stringpool.h"
kono
parents: 68
diff changeset
32 #include "attribs.h"
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 /* Local functions, macros and variables. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
35 static int dump_ada_node (pretty_printer *, tree, tree, int, bool, bool);
111
kono
parents: 68
diff changeset
36 static int dump_ada_declaration (pretty_printer *, tree, tree, int);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
37 static void dump_ada_structure (pretty_printer *, tree, tree, bool, int);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
38 static char *to_ada_name (const char *, bool *);
111
kono
parents: 68
diff changeset
39
kono
parents: 68
diff changeset
40 #define INDENT(SPACE) \
kono
parents: 68
diff changeset
41 do { int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 #define INDENT_INCR 3
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
111
kono
parents: 68
diff changeset
45 /* Global hook used to perform C++ queries on nodes. */
kono
parents: 68
diff changeset
46 static int (*cpp_check) (tree, cpp_operation) = NULL;
kono
parents: 68
diff changeset
47
kono
parents: 68
diff changeset
48 /* Global variables used in macro-related callbacks. */
kono
parents: 68
diff changeset
49 static int max_ada_macros;
kono
parents: 68
diff changeset
50 static int store_ada_macro_index;
kono
parents: 68
diff changeset
51 static const char *macro_source_file;
kono
parents: 68
diff changeset
52
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 /* Given a cpp MACRO, compute the max length BUFFER_LEN of the macro, as well
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 as max length PARAM_LEN of arguments for fun_like macros, and also set
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 SUPPORTED to 0 if the macro cannot be mapped to an Ada construct. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 macro_length (const cpp_macro *macro, int *supported, int *buffer_len,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 int *param_len)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 int i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 unsigned j;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 *supported = 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 *buffer_len = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 *param_len = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 if (macro->fun_like)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 {
111
kono
parents: 68
diff changeset
70 (*param_len)++;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 for (i = 0; i < macro->paramc; i++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
73 cpp_hashnode *param = macro->parm.params[i];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 *param_len += NODE_LEN (param);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 if (i + 1 < macro->paramc)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 *param_len += 2; /* ", " */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 else if (macro->variadic)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 *supported = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 *param_len += 2; /* ")\0" */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 for (j = 0; j < macro->count; j++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
92 const cpp_token *token = &macro->exp.tokens[j];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 if (token->flags & PREV_WHITE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 (*buffer_len)++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 if (token->flags & STRINGIFY_ARG || token->flags & PASTE_LEFT)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 *supported = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 if (token->type == CPP_MACRO_ARG)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 *buffer_len +=
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
105 NODE_LEN (macro->parm.params[token->val.macro_arg.arg_no - 1]);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 /* Include enough extra space to handle e.g. special characters. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 *buffer_len += (cpp_token_len (token) + 1) * 8;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
110
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 (*buffer_len)++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
111
kono
parents: 68
diff changeset
114 /* Dump all digits/hex chars from NUMBER to BUFFER and return a pointer
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
115 to the character after the last character written. If FLOAT_P is true,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
116 this is a floating-point number. */
111
kono
parents: 68
diff changeset
117
kono
parents: 68
diff changeset
118 static unsigned char *
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
119 dump_number (unsigned char *number, unsigned char *buffer, bool float_p)
111
kono
parents: 68
diff changeset
120 {
kono
parents: 68
diff changeset
121 while (*number != '\0'
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
122 && *number != (float_p ? 'F' : 'U')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
123 && *number != (float_p ? 'f' : 'u')
111
kono
parents: 68
diff changeset
124 && *number != 'l'
kono
parents: 68
diff changeset
125 && *number != 'L')
kono
parents: 68
diff changeset
126 *buffer++ = *number++;
kono
parents: 68
diff changeset
127
kono
parents: 68
diff changeset
128 return buffer;
kono
parents: 68
diff changeset
129 }
kono
parents: 68
diff changeset
130
kono
parents: 68
diff changeset
131 /* Handle escape character C and convert to an Ada character into BUFFER.
kono
parents: 68
diff changeset
132 Return a pointer to the character after the last character written, or
kono
parents: 68
diff changeset
133 NULL if the escape character is not supported. */
kono
parents: 68
diff changeset
134
kono
parents: 68
diff changeset
135 static unsigned char *
kono
parents: 68
diff changeset
136 handle_escape_character (unsigned char *buffer, char c)
kono
parents: 68
diff changeset
137 {
kono
parents: 68
diff changeset
138 switch (c)
kono
parents: 68
diff changeset
139 {
kono
parents: 68
diff changeset
140 case '"':
kono
parents: 68
diff changeset
141 *buffer++ = '"';
kono
parents: 68
diff changeset
142 *buffer++ = '"';
kono
parents: 68
diff changeset
143 break;
kono
parents: 68
diff changeset
144
kono
parents: 68
diff changeset
145 case 'n':
kono
parents: 68
diff changeset
146 strcpy ((char *) buffer, "\" & ASCII.LF & \"");
kono
parents: 68
diff changeset
147 buffer += 16;
kono
parents: 68
diff changeset
148 break;
kono
parents: 68
diff changeset
149
kono
parents: 68
diff changeset
150 case 'r':
kono
parents: 68
diff changeset
151 strcpy ((char *) buffer, "\" & ASCII.CR & \"");
kono
parents: 68
diff changeset
152 buffer += 16;
kono
parents: 68
diff changeset
153 break;
kono
parents: 68
diff changeset
154
kono
parents: 68
diff changeset
155 case 't':
kono
parents: 68
diff changeset
156 strcpy ((char *) buffer, "\" & ASCII.HT & \"");
kono
parents: 68
diff changeset
157 buffer += 16;
kono
parents: 68
diff changeset
158 break;
kono
parents: 68
diff changeset
159
kono
parents: 68
diff changeset
160 default:
kono
parents: 68
diff changeset
161 return NULL;
kono
parents: 68
diff changeset
162 }
kono
parents: 68
diff changeset
163
kono
parents: 68
diff changeset
164 return buffer;
kono
parents: 68
diff changeset
165 }
kono
parents: 68
diff changeset
166
kono
parents: 68
diff changeset
167 /* Callback used to count the number of macros from cpp_forall_identifiers.
kono
parents: 68
diff changeset
168 PFILE and V are not used. NODE is the current macro to consider. */
kono
parents: 68
diff changeset
169
kono
parents: 68
diff changeset
170 static int
kono
parents: 68
diff changeset
171 count_ada_macro (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *node,
kono
parents: 68
diff changeset
172 void *v ATTRIBUTE_UNUSED)
kono
parents: 68
diff changeset
173 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
174 if (cpp_user_macro_p (node) && *NODE_NAME (node) != '_')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
175 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176 const cpp_macro *macro = node->value.macro;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
177 if (macro->count && LOCATION_FILE (macro->line) == macro_source_file)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
178 max_ada_macros++;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
179 }
111
kono
parents: 68
diff changeset
180
kono
parents: 68
diff changeset
181 return 1;
kono
parents: 68
diff changeset
182 }
kono
parents: 68
diff changeset
183
kono
parents: 68
diff changeset
184 /* Callback used to store relevant macros from cpp_forall_identifiers.
kono
parents: 68
diff changeset
185 PFILE is not used. NODE is the current macro to store if relevant.
kono
parents: 68
diff changeset
186 MACROS is an array of cpp_hashnode* used to store NODE. */
kono
parents: 68
diff changeset
187
kono
parents: 68
diff changeset
188 static int
kono
parents: 68
diff changeset
189 store_ada_macro (cpp_reader *pfile ATTRIBUTE_UNUSED,
kono
parents: 68
diff changeset
190 cpp_hashnode *node, void *macros)
kono
parents: 68
diff changeset
191 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
192 if (cpp_user_macro_p (node) && *NODE_NAME (node) != '_')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
193 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
194 const cpp_macro *macro = node->value.macro;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
195 if (macro->count
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
196 && LOCATION_FILE (macro->line) == macro_source_file)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
197 ((cpp_hashnode **) macros)[store_ada_macro_index++] = node;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
198 }
111
kono
parents: 68
diff changeset
199 return 1;
kono
parents: 68
diff changeset
200 }
kono
parents: 68
diff changeset
201
kono
parents: 68
diff changeset
202 /* Callback used to compare (during qsort) macros. NODE1 and NODE2 are the
kono
parents: 68
diff changeset
203 two macro nodes to compare. */
kono
parents: 68
diff changeset
204
kono
parents: 68
diff changeset
205 static int
kono
parents: 68
diff changeset
206 compare_macro (const void *node1, const void *node2)
kono
parents: 68
diff changeset
207 {
kono
parents: 68
diff changeset
208 typedef const cpp_hashnode *const_hnode;
kono
parents: 68
diff changeset
209
kono
parents: 68
diff changeset
210 const_hnode n1 = *(const const_hnode *) node1;
kono
parents: 68
diff changeset
211 const_hnode n2 = *(const const_hnode *) node2;
kono
parents: 68
diff changeset
212
kono
parents: 68
diff changeset
213 return n1->value.macro->line - n2->value.macro->line;
kono
parents: 68
diff changeset
214 }
kono
parents: 68
diff changeset
215
kono
parents: 68
diff changeset
216 /* Dump in PP all relevant macros appearing in FILE. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 static void
111
kono
parents: 68
diff changeset
219 dump_ada_macros (pretty_printer *pp, const char* file)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 {
111
kono
parents: 68
diff changeset
221 int num_macros = 0, prev_line = -1;
kono
parents: 68
diff changeset
222 cpp_hashnode **macros;
kono
parents: 68
diff changeset
223
kono
parents: 68
diff changeset
224 /* Initialize file-scope variables. */
kono
parents: 68
diff changeset
225 max_ada_macros = 0;
kono
parents: 68
diff changeset
226 store_ada_macro_index = 0;
kono
parents: 68
diff changeset
227 macro_source_file = file;
kono
parents: 68
diff changeset
228
kono
parents: 68
diff changeset
229 /* Count all potentially relevant macros, and then sort them by sloc. */
kono
parents: 68
diff changeset
230 cpp_forall_identifiers (parse_in, count_ada_macro, NULL);
kono
parents: 68
diff changeset
231 macros = XALLOCAVEC (cpp_hashnode *, max_ada_macros);
kono
parents: 68
diff changeset
232 cpp_forall_identifiers (parse_in, store_ada_macro, macros);
kono
parents: 68
diff changeset
233 qsort (macros, max_ada_macros, sizeof (cpp_hashnode *), compare_macro);
kono
parents: 68
diff changeset
234
kono
parents: 68
diff changeset
235 for (int j = 0; j < max_ada_macros; j++)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 {
111
kono
parents: 68
diff changeset
237 cpp_hashnode *node = macros[j];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 const cpp_macro *macro = node->value.macro;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 unsigned i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 int supported = 1, prev_is_one = 0, buffer_len, param_len;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 int is_string = 0, is_char = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 char *ada_name;
111
kono
parents: 68
diff changeset
243 unsigned char *s, *params, *buffer, *buf_param, *char_one = NULL, *tmp;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 macro_length (macro, &supported, &buffer_len, &param_len);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 s = buffer = XALLOCAVEC (unsigned char, buffer_len);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 params = buf_param = XALLOCAVEC (unsigned char, param_len);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 if (supported)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 if (macro->fun_like)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 *buf_param++ = '(';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 for (i = 0; i < macro->paramc; i++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
256 cpp_hashnode *param = macro->parm.params[i];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
258 memcpy (buf_param, NODE_NAME (param), NODE_LEN (param));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 buf_param += NODE_LEN (param);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
260
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 if (i + 1 < macro->paramc)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 *buf_param++ = ',';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 *buf_param++ = ' ';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 else if (macro->variadic)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 supported = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 *buf_param++ = ')';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 *buf_param = '\0';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 for (i = 0; supported && i < macro->count; i++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
278 const cpp_token *token = &macro->exp.tokens[i];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 int is_one = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 if (token->flags & PREV_WHITE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 *buffer++ = ' ';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 if (token->flags & STRINGIFY_ARG || token->flags & PASTE_LEFT)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 supported = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 switch (token->type)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 case CPP_MACRO_ARG:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 cpp_hashnode *param =
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
295 macro->parm.params[token->val.macro_arg.arg_no - 1];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 memcpy (buffer, NODE_NAME (param), NODE_LEN (param));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 buffer += NODE_LEN (param);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 case CPP_EQ_EQ: *buffer++ = '='; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 case CPP_GREATER: *buffer++ = '>'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 case CPP_LESS: *buffer++ = '<'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 case CPP_PLUS: *buffer++ = '+'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 case CPP_MINUS: *buffer++ = '-'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 case CPP_MULT: *buffer++ = '*'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 case CPP_DIV: *buffer++ = '/'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 case CPP_COMMA: *buffer++ = ','; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 case CPP_OPEN_SQUARE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 case CPP_OPEN_PAREN: *buffer++ = '('; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 case CPP_CLOSE_SQUARE: /* fallthrough */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 case CPP_CLOSE_PAREN: *buffer++ = ')'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 case CPP_DEREF: /* fallthrough */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 case CPP_SCOPE: /* fallthrough */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 case CPP_DOT: *buffer++ = '.'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 case CPP_EQ: *buffer++ = ':'; *buffer++ = '='; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 case CPP_NOT_EQ: *buffer++ = '/'; *buffer++ = '='; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 case CPP_GREATER_EQ: *buffer++ = '>'; *buffer++ = '='; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 case CPP_LESS_EQ: *buffer++ = '<'; *buffer++ = '='; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 case CPP_NOT:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 *buffer++ = 'n'; *buffer++ = 'o'; *buffer++ = 't'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 case CPP_MOD:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 *buffer++ = 'm'; *buffer++ = 'o'; *buffer++ = 'd'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 case CPP_AND:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 *buffer++ = 'a'; *buffer++ = 'n'; *buffer++ = 'd'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 case CPP_OR:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 *buffer++ = 'o'; *buffer++ = 'r'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 case CPP_XOR:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 *buffer++ = 'x'; *buffer++ = 'o'; *buffer++ = 'r'; break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 case CPP_AND_AND:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 strcpy ((char *) buffer, " and then ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 buffer += 10;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 case CPP_OR_OR:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 strcpy ((char *) buffer, " or else ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 buffer += 9;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 case CPP_PADDING:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 *buffer++ = ' ';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 is_one = prev_is_one;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
346 case CPP_COMMENT:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
347 break;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 case CPP_WSTRING:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350 case CPP_STRING16:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 case CPP_STRING32:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 case CPP_UTF8STRING:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 case CPP_WCHAR:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 case CPP_CHAR16:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 case CPP_CHAR32:
111
kono
parents: 68
diff changeset
356 case CPP_UTF8CHAR:
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 case CPP_NAME:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 if (!macro->fun_like)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 supported = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
361 buffer
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
362 = cpp_spell_token (parse_in, token, buffer, false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364
111
kono
parents: 68
diff changeset
365 case CPP_STRING:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
366 if (is_string)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
367 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
368 *buffer++ = '&';
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
369 *buffer++ = ' ';
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
370 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
371 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
372 is_string = 1;
111
kono
parents: 68
diff changeset
373 {
kono
parents: 68
diff changeset
374 const unsigned char *s = token->val.str.text;
kono
parents: 68
diff changeset
375
kono
parents: 68
diff changeset
376 for (; *s; s++)
kono
parents: 68
diff changeset
377 if (*s == '\\')
kono
parents: 68
diff changeset
378 {
kono
parents: 68
diff changeset
379 s++;
kono
parents: 68
diff changeset
380 buffer = handle_escape_character (buffer, *s);
kono
parents: 68
diff changeset
381 if (buffer == NULL)
kono
parents: 68
diff changeset
382 {
kono
parents: 68
diff changeset
383 supported = 0;
kono
parents: 68
diff changeset
384 break;
kono
parents: 68
diff changeset
385 }
kono
parents: 68
diff changeset
386 }
kono
parents: 68
diff changeset
387 else
kono
parents: 68
diff changeset
388 *buffer++ = *s;
kono
parents: 68
diff changeset
389 }
kono
parents: 68
diff changeset
390 break;
kono
parents: 68
diff changeset
391
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 case CPP_CHAR:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 is_char = 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 unsigned chars_seen;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 int ignored;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 cppchar_t c;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
398
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 c = cpp_interpret_charconst (parse_in, token,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 &chars_seen, &ignored);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 if (c >= 32 && c <= 126)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 *buffer++ = '\'';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 *buffer++ = (char) c;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 *buffer++ = '\'';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 chars_seen = sprintf
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 ((char *) buffer, "Character'Val (%d)", (int) c);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411 buffer += chars_seen;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415
111
kono
parents: 68
diff changeset
416 case CPP_NUMBER:
kono
parents: 68
diff changeset
417 tmp = cpp_token_as_text (parse_in, token);
kono
parents: 68
diff changeset
418
kono
parents: 68
diff changeset
419 switch (*tmp)
kono
parents: 68
diff changeset
420 {
kono
parents: 68
diff changeset
421 case '0':
kono
parents: 68
diff changeset
422 switch (tmp[1])
kono
parents: 68
diff changeset
423 {
kono
parents: 68
diff changeset
424 case '\0':
kono
parents: 68
diff changeset
425 case 'l':
kono
parents: 68
diff changeset
426 case 'L':
kono
parents: 68
diff changeset
427 case 'u':
kono
parents: 68
diff changeset
428 case 'U':
kono
parents: 68
diff changeset
429 *buffer++ = '0';
kono
parents: 68
diff changeset
430 break;
kono
parents: 68
diff changeset
431
kono
parents: 68
diff changeset
432 case 'x':
kono
parents: 68
diff changeset
433 case 'X':
kono
parents: 68
diff changeset
434 *buffer++ = '1';
kono
parents: 68
diff changeset
435 *buffer++ = '6';
kono
parents: 68
diff changeset
436 *buffer++ = '#';
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
437 buffer = dump_number (tmp + 2, buffer, false);
111
kono
parents: 68
diff changeset
438 *buffer++ = '#';
kono
parents: 68
diff changeset
439 break;
kono
parents: 68
diff changeset
440
kono
parents: 68
diff changeset
441 case 'b':
kono
parents: 68
diff changeset
442 case 'B':
kono
parents: 68
diff changeset
443 *buffer++ = '2';
kono
parents: 68
diff changeset
444 *buffer++ = '#';
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
445 buffer = dump_number (tmp + 2, buffer, false);
111
kono
parents: 68
diff changeset
446 *buffer++ = '#';
kono
parents: 68
diff changeset
447 break;
kono
parents: 68
diff changeset
448
kono
parents: 68
diff changeset
449 default:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
450 /* Dump floating-point constant unmodified. */
111
kono
parents: 68
diff changeset
451 if (strchr ((const char *)tmp, '.'))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
452 buffer = dump_number (tmp, buffer, true);
111
kono
parents: 68
diff changeset
453 else
kono
parents: 68
diff changeset
454 {
kono
parents: 68
diff changeset
455 *buffer++ = '8';
kono
parents: 68
diff changeset
456 *buffer++ = '#';
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
457 buffer
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
458 = dump_number (tmp + 1, buffer, false);
111
kono
parents: 68
diff changeset
459 *buffer++ = '#';
kono
parents: 68
diff changeset
460 }
kono
parents: 68
diff changeset
461 break;
kono
parents: 68
diff changeset
462 }
kono
parents: 68
diff changeset
463 break;
kono
parents: 68
diff changeset
464
kono
parents: 68
diff changeset
465 case '1':
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
466 if (tmp[1] == '\0'
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
467 || tmp[1] == 'u'
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
468 || tmp[1] == 'U'
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
469 || tmp[1] == 'l'
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
470 || tmp[1] == 'L')
111
kono
parents: 68
diff changeset
471 {
kono
parents: 68
diff changeset
472 is_one = 1;
kono
parents: 68
diff changeset
473 char_one = buffer;
kono
parents: 68
diff changeset
474 *buffer++ = '1';
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
475 break;
111
kono
parents: 68
diff changeset
476 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
477 /* fallthrough */
111
kono
parents: 68
diff changeset
478
kono
parents: 68
diff changeset
479 default:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
480 buffer
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
481 = dump_number (tmp, buffer,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
482 strchr ((const char *)tmp, '.'));
111
kono
parents: 68
diff changeset
483 break;
kono
parents: 68
diff changeset
484 }
kono
parents: 68
diff changeset
485 break;
kono
parents: 68
diff changeset
486
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 case CPP_LSHIFT:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 if (prev_is_one)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 /* Replace "1 << N" by "2 ** N" */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 *char_one = '2';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 *buffer++ = '*';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 *buffer++ = '*';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 /* fallthrough */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 case CPP_RSHIFT:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 case CPP_COMPL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 case CPP_QUERY:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 case CPP_EOF:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 case CPP_PLUS_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 case CPP_MINUS_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
504 case CPP_MULT_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505 case CPP_DIV_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506 case CPP_MOD_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 case CPP_AND_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 case CPP_OR_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 case CPP_XOR_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 case CPP_RSHIFT_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 case CPP_LSHIFT_EQ:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 case CPP_PRAGMA:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 case CPP_PRAGMA_EOL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 case CPP_HASH:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 case CPP_PASTE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 case CPP_OPEN_BRACE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 case CPP_CLOSE_BRACE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 case CPP_SEMICOLON:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 case CPP_ELLIPSIS:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 case CPP_PLUS_PLUS:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 case CPP_MINUS_MINUS:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 case CPP_DEREF_STAR:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 case CPP_DOT_STAR:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 case CPP_ATSIGN:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 case CPP_HEADER_NAME:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 case CPP_AT_NAME:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 case CPP_OTHER:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 case CPP_OBJC_STRING:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 if (!macro->fun_like)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 supported = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 buffer = cpp_spell_token (parse_in, token, buffer, false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 prev_is_one = is_one;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 if (supported)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 *buffer = '\0';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 if (macro->fun_like && supported)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 char *start = (char *) s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 int is_function = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 pp_string (pp, " -- arg-macro: ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550
111
kono
parents: 68
diff changeset
551 if (*start == '(' && buffer[-1] == ')')
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 start++;
111
kono
parents: 68
diff changeset
554 buffer[-1] = '\0';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
555 is_function = 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 pp_string (pp, "function ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 pp_string (pp, "procedure ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
562
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 pp_string (pp, (const char *) NODE_NAME (node));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 pp_space (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 pp_string (pp, (char *) params);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 pp_newline (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 pp_string (pp, " -- ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 if (is_function)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 pp_string (pp, "return ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
572 pp_string (pp, start);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 pp_semicolon (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 pp_string (pp, start);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 pp_newline (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 else if (supported)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 expanded_location sloc = expand_location (macro->line);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583
111
kono
parents: 68
diff changeset
584 if (sloc.line != prev_line + 1 && prev_line > 0)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 pp_newline (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 num_macros++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 prev_line = sloc.line;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 pp_string (pp, " ");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
591 ada_name = to_ada_name ((const char *) NODE_NAME (node), NULL);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 pp_string (pp, ada_name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 free (ada_name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 pp_string (pp, " : ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 if (is_string)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 pp_string (pp, "aliased constant String");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598 else if (is_char)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 pp_string (pp, "aliased constant Character");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 pp_string (pp, "constant");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
602
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
603 pp_string (pp, " := ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
604 pp_string (pp, (char *) s);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
605
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
606 if (is_string)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
607 pp_string (pp, " & ASCII.NUL");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
608
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
609 pp_string (pp, "; -- ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
610 pp_string (pp, sloc.file);
111
kono
parents: 68
diff changeset
611 pp_colon (pp);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
612 pp_scalar (pp, "%d", sloc.line);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
613 pp_newline (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
614 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
615 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
616 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
617 pp_string (pp, " -- unsupported macro: ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
618 pp_string (pp, (const char *) cpp_macro_definition (parse_in, node));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
619 pp_newline (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
620 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
621 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
622
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
623 if (num_macros > 0)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
624 pp_newline (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
625 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
626
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
627 /* Current source file being handled. */
111
kono
parents: 68
diff changeset
628 static const char *current_source_file;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
629
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
630 /* Return sloc of DECL, using sloc of last field if LAST is true. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
631
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
632 location_t
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
633 decl_sloc (const_tree decl, bool last)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 {
111
kono
parents: 68
diff changeset
635 tree field;
kono
parents: 68
diff changeset
636
kono
parents: 68
diff changeset
637 /* Compare the declaration of struct-like types based on the sloc of their
kono
parents: 68
diff changeset
638 last field (if LAST is true), so that more nested types collate before
kono
parents: 68
diff changeset
639 less nested ones. */
kono
parents: 68
diff changeset
640 if (TREE_CODE (decl) == TYPE_DECL
kono
parents: 68
diff changeset
641 && !DECL_ORIGINAL_TYPE (decl)
kono
parents: 68
diff changeset
642 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl))
kono
parents: 68
diff changeset
643 && (field = TYPE_FIELDS (TREE_TYPE (decl))))
kono
parents: 68
diff changeset
644 {
kono
parents: 68
diff changeset
645 if (last)
kono
parents: 68
diff changeset
646 while (DECL_CHAIN (field))
kono
parents: 68
diff changeset
647 field = DECL_CHAIN (field);
kono
parents: 68
diff changeset
648 return DECL_SOURCE_LOCATION (field);
kono
parents: 68
diff changeset
649 }
kono
parents: 68
diff changeset
650
kono
parents: 68
diff changeset
651 return DECL_SOURCE_LOCATION (decl);
kono
parents: 68
diff changeset
652 }
kono
parents: 68
diff changeset
653
kono
parents: 68
diff changeset
654 /* Compare two locations LHS and RHS. */
kono
parents: 68
diff changeset
655
kono
parents: 68
diff changeset
656 static int
kono
parents: 68
diff changeset
657 compare_location (location_t lhs, location_t rhs)
kono
parents: 68
diff changeset
658 {
kono
parents: 68
diff changeset
659 expanded_location xlhs = expand_location (lhs);
kono
parents: 68
diff changeset
660 expanded_location xrhs = expand_location (rhs);
kono
parents: 68
diff changeset
661
kono
parents: 68
diff changeset
662 if (xlhs.file != xrhs.file)
kono
parents: 68
diff changeset
663 return filename_cmp (xlhs.file, xrhs.file);
kono
parents: 68
diff changeset
664
kono
parents: 68
diff changeset
665 if (xlhs.line != xrhs.line)
kono
parents: 68
diff changeset
666 return xlhs.line - xrhs.line;
kono
parents: 68
diff changeset
667
kono
parents: 68
diff changeset
668 if (xlhs.column != xrhs.column)
kono
parents: 68
diff changeset
669 return xlhs.column - xrhs.column;
kono
parents: 68
diff changeset
670
kono
parents: 68
diff changeset
671 return 0;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 /* Compare two declarations (LP and RP) by their source location. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
675
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
676 static int
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
677 compare_node (const void *lp, const void *rp)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
678 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
679 const_tree lhs = *((const tree *) lp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
680 const_tree rhs = *((const tree *) rp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681
111
kono
parents: 68
diff changeset
682 return compare_location (decl_sloc (lhs, true), decl_sloc (rhs, true));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
683 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
684
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 /* Compare two comments (LP and RP) by their source location. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
686
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 static int
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 compare_comment (const void *lp, const void *rp)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
689 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690 const cpp_comment *lhs = (const cpp_comment *) lp;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691 const cpp_comment *rhs = (const cpp_comment *) rp;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
692
111
kono
parents: 68
diff changeset
693 return compare_location (lhs->sloc, rhs->sloc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
694 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
695
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 static tree *to_dump = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 static int to_dump_count = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 /* Collect a list of declarations from T relevant to SOURCE_FILE to be dumped
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 by a subsequent call to dump_ada_nodes. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
701
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
702 void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 collect_ada_nodes (tree t, const char *source_file)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 tree n;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 int i = to_dump_count;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707
111
kono
parents: 68
diff changeset
708 /* Count the likely relevant nodes: do not dump builtins (they are irrelevant
kono
parents: 68
diff changeset
709 in the context of bindings) and namespaces (we do not handle them properly
kono
parents: 68
diff changeset
710 yet). */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
711 for (n = t; n; n = TREE_CHAIN (n))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
712 if (!DECL_IS_BUILTIN (n)
111
kono
parents: 68
diff changeset
713 && TREE_CODE (n) != NAMESPACE_DECL
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
714 && LOCATION_FILE (decl_sloc (n, false)) == source_file)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
715 to_dump_count++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
716
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
717 /* Allocate sufficient storage for all nodes. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
718 to_dump = XRESIZEVEC (tree, to_dump, to_dump_count);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
719
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 /* Store the relevant nodes. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721 for (n = t; n; n = TREE_CHAIN (n))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
722 if (!DECL_IS_BUILTIN (n)
111
kono
parents: 68
diff changeset
723 && TREE_CODE (n) != NAMESPACE_DECL
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 && LOCATION_FILE (decl_sloc (n, false)) == source_file)
111
kono
parents: 68
diff changeset
725 to_dump[i++] = n;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
726 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
727
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
728 /* Call back for walk_tree to clear the TREE_VISITED flag of TP. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
729
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
730 static tree
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
731 unmark_visited_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
732 void *data ATTRIBUTE_UNUSED)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
733 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
734 if (TREE_VISITED (*tp))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
735 TREE_VISITED (*tp) = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
736 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
737 *walk_subtrees = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
738
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 return NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
740 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
741
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 /* Print a COMMENT to the output stream PP. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
743
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 print_comment (pretty_printer *pp, const char *comment)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
746 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
747 int len = strlen (comment);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
748 char *str = XALLOCAVEC (char, len + 1);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 char *tok;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 bool extra_newline = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
751
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 memcpy (str, comment, len + 1);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 /* Trim C/C++ comment indicators. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 if (str[len - 2] == '*' && str[len - 1] == '/')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 str[len - 2] = ' ';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 str[len - 1] = '\0';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 str += 2;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
761
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 tok = strtok (str, "\n");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 while (tok) {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 pp_string (pp, " --");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 pp_string (pp, tok);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 pp_newline (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 tok = strtok (NULL, "\n");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
768
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 /* Leave a blank line after multi-line comments. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 if (tok)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 extra_newline = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 if (extra_newline)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 pp_newline (pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
777
111
kono
parents: 68
diff changeset
778 /* Dump nodes into PP relevant to SOURCE_FILE, as collected by previous calls
kono
parents: 68
diff changeset
779 to collect_ada_nodes. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
780
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
781 static void
111
kono
parents: 68
diff changeset
782 dump_ada_nodes (pretty_printer *pp, const char *source_file)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 {
111
kono
parents: 68
diff changeset
784 int i, j;
kono
parents: 68
diff changeset
785 cpp_comment_table *comments;
kono
parents: 68
diff changeset
786
kono
parents: 68
diff changeset
787 /* Sort the table of declarations to dump by sloc. */
kono
parents: 68
diff changeset
788 qsort (to_dump, to_dump_count, sizeof (tree), compare_node);
kono
parents: 68
diff changeset
789
kono
parents: 68
diff changeset
790 /* Fetch the table of comments. */
kono
parents: 68
diff changeset
791 comments = cpp_get_comments (parse_in);
kono
parents: 68
diff changeset
792
kono
parents: 68
diff changeset
793 /* Sort the comments table by sloc. */
kono
parents: 68
diff changeset
794 if (comments->count > 1)
kono
parents: 68
diff changeset
795 qsort (comments->entries, comments->count, sizeof (cpp_comment),
kono
parents: 68
diff changeset
796 compare_comment);
kono
parents: 68
diff changeset
797
kono
parents: 68
diff changeset
798 /* Interleave comments and declarations in line number order. */
kono
parents: 68
diff changeset
799 i = j = 0;
kono
parents: 68
diff changeset
800 do
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
801 {
111
kono
parents: 68
diff changeset
802 /* Advance j until comment j is in this file. */
kono
parents: 68
diff changeset
803 while (j != comments->count
kono
parents: 68
diff changeset
804 && LOCATION_FILE (comments->entries[j].sloc) != source_file)
kono
parents: 68
diff changeset
805 j++;
kono
parents: 68
diff changeset
806
kono
parents: 68
diff changeset
807 /* Advance j until comment j is not a duplicate. */
kono
parents: 68
diff changeset
808 while (j < comments->count - 1
kono
parents: 68
diff changeset
809 && !compare_comment (&comments->entries[j],
kono
parents: 68
diff changeset
810 &comments->entries[j + 1]))
kono
parents: 68
diff changeset
811 j++;
kono
parents: 68
diff changeset
812
kono
parents: 68
diff changeset
813 /* Write decls until decl i collates after comment j. */
kono
parents: 68
diff changeset
814 while (i != to_dump_count)
kono
parents: 68
diff changeset
815 {
kono
parents: 68
diff changeset
816 if (j == comments->count
kono
parents: 68
diff changeset
817 || LOCATION_LINE (decl_sloc (to_dump[i], false))
kono
parents: 68
diff changeset
818 < LOCATION_LINE (comments->entries[j].sloc))
kono
parents: 68
diff changeset
819 {
kono
parents: 68
diff changeset
820 current_source_file = source_file;
kono
parents: 68
diff changeset
821
kono
parents: 68
diff changeset
822 if (dump_ada_declaration (pp, to_dump[i++], NULL_TREE,
kono
parents: 68
diff changeset
823 INDENT_INCR))
kono
parents: 68
diff changeset
824 {
kono
parents: 68
diff changeset
825 pp_newline (pp);
kono
parents: 68
diff changeset
826 pp_newline (pp);
kono
parents: 68
diff changeset
827 }
kono
parents: 68
diff changeset
828 }
kono
parents: 68
diff changeset
829 else
kono
parents: 68
diff changeset
830 break;
kono
parents: 68
diff changeset
831 }
kono
parents: 68
diff changeset
832
kono
parents: 68
diff changeset
833 /* Write comment j, if there is one. */
kono
parents: 68
diff changeset
834 if (j != comments->count)
kono
parents: 68
diff changeset
835 print_comment (pp, comments->entries[j++].comment);
kono
parents: 68
diff changeset
836
kono
parents: 68
diff changeset
837 } while (i != to_dump_count || j != comments->count);
kono
parents: 68
diff changeset
838
kono
parents: 68
diff changeset
839 /* Clear the TREE_VISITED flag over each subtree we've dumped. */
kono
parents: 68
diff changeset
840 for (i = 0; i < to_dump_count; i++)
kono
parents: 68
diff changeset
841 walk_tree (&to_dump[i], unmark_visited_r, NULL, NULL);
kono
parents: 68
diff changeset
842
kono
parents: 68
diff changeset
843 /* Finalize the to_dump table. */
kono
parents: 68
diff changeset
844 if (to_dump)
kono
parents: 68
diff changeset
845 {
kono
parents: 68
diff changeset
846 free (to_dump);
kono
parents: 68
diff changeset
847 to_dump = NULL;
kono
parents: 68
diff changeset
848 to_dump_count = 0;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
849 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
851
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
852 /* Dump a newline and indent BUFFER by SPC chars. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 newline_and_indent (pretty_printer *buffer, int spc)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 pp_newline (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
860
111
kono
parents: 68
diff changeset
861 struct with { char *s; const char *in_file; bool limited; };
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 static struct with *withs = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 static int withs_max = 4096;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 static int with_len = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 /* Record a "with" clause on package S (a limited with if LIMITED_ACCESS is
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 true), if not already done. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 static void
111
kono
parents: 68
diff changeset
870 append_withs (const char *s, bool limited_access)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 int i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
873
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 if (withs == NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 withs = XNEWVEC (struct with, withs_max);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
876
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
877 if (with_len == withs_max)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 withs_max *= 2;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 withs = XRESIZEVEC (struct with, withs, withs_max);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 for (i = 0; i < with_len; i++)
111
kono
parents: 68
diff changeset
884 if (!strcmp (s, withs[i].s)
kono
parents: 68
diff changeset
885 && current_source_file == withs[i].in_file)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
886 {
111
kono
parents: 68
diff changeset
887 withs[i].limited &= limited_access;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890
111
kono
parents: 68
diff changeset
891 withs[with_len].s = xstrdup (s);
kono
parents: 68
diff changeset
892 withs[with_len].in_file = current_source_file;
kono
parents: 68
diff changeset
893 withs[with_len].limited = limited_access;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 with_len++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
896
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 /* Reset "with" clauses. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
898
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
900 reset_ada_withs (void)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
902 int i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
903
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
904 if (!withs)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
905 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
906
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 for (i = 0; i < with_len; i++)
111
kono
parents: 68
diff changeset
908 free (withs[i].s);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 free (withs);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
910 withs = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
911 withs_max = 4096;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
912 with_len = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
913 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
914
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 /* Dump "with" clauses in F. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
917 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
918 dump_ada_withs (FILE *f)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
919 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
920 int i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
921
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
922 fprintf (f, "with Interfaces.C; use Interfaces.C;\n");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
923
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 for (i = 0; i < with_len; i++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
925 fprintf
111
kono
parents: 68
diff changeset
926 (f, "%swith %s;\n", withs[i].limited ? "limited " : "", withs[i].s);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
927 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
928
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
929 /* Return suitable Ada package name from FILE. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
930
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
931 static char *
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
932 get_ada_package (const char *file)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
933 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
934 const char *base;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
935 char *res;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
936 const char *s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
937 int i;
111
kono
parents: 68
diff changeset
938 size_t plen;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
939
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
940 s = strstr (file, "/include/");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
941 if (s)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
942 base = s + 9;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
943 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
944 base = lbasename (file);
111
kono
parents: 68
diff changeset
945
kono
parents: 68
diff changeset
946 if (ada_specs_parent == NULL)
kono
parents: 68
diff changeset
947 plen = 0;
kono
parents: 68
diff changeset
948 else
kono
parents: 68
diff changeset
949 plen = strlen (ada_specs_parent) + 1;
kono
parents: 68
diff changeset
950
kono
parents: 68
diff changeset
951 res = XNEWVEC (char, plen + strlen (base) + 1);
kono
parents: 68
diff changeset
952 if (ada_specs_parent != NULL) {
kono
parents: 68
diff changeset
953 strcpy (res, ada_specs_parent);
kono
parents: 68
diff changeset
954 res[plen - 1] = '.';
kono
parents: 68
diff changeset
955 }
kono
parents: 68
diff changeset
956
kono
parents: 68
diff changeset
957 for (i = plen; *base; base++, i++)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
958 switch (*base)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
959 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
960 case '+':
111
kono
parents: 68
diff changeset
961 res[i] = 'p';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
963
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 case '.':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 case '-':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
966 case '_':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 case '/':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
968 case '\\':
111
kono
parents: 68
diff changeset
969 res[i] = (i == 0 || res[i - 1] == '.' || res[i - 1] == '_') ? 'u' : '_';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 default:
111
kono
parents: 68
diff changeset
973 res[i] = *base;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 }
111
kono
parents: 68
diff changeset
976 res[i] = '\0';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
977
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
978 return res;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
979 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
980
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
981 static const char *ada_reserved[] = {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 "abort", "abs", "abstract", "accept", "access", "aliased", "all", "and",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 "array", "at", "begin", "body", "case", "constant", "declare", "delay",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
984 "delta", "digits", "do", "else", "elsif", "end", "entry", "exception",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 "exit", "for", "function", "generic", "goto", "if", "in", "interface", "is",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
986 "limited", "loop", "mod", "new", "not", "null", "others", "out", "of", "or",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
987 "overriding", "package", "pragma", "private", "procedure", "protected",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 "raise", "range", "record", "rem", "renames", "requeue", "return", "reverse",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 "select", "separate", "subtype", "synchronized", "tagged", "task",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 "terminate", "then", "type", "until", "use", "when", "while", "with", "xor",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
991 NULL};
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
992
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 /* ??? would be nice to specify this list via a config file, so that users
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 can create their own dictionary of conflicts. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 static const char *c_duplicates[] = {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 /* system will cause troubles with System.Address. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 "system",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
998
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
999 /* The following values have other definitions with same name/other
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 casing. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 "funmap",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 "rl_vi_fWord",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 "rl_vi_bWord",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 "rl_vi_eWord",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005 "rl_readline_version",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 "_Vx_ushort",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007 "USHORT",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008 "XLookupKeysym",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009 NULL};
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1010
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1011 /* Return a declaration tree corresponding to TYPE. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1012
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1013 static tree
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1014 get_underlying_decl (tree type)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015 {
111
kono
parents: 68
diff changeset
1016 if (!type)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 return NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 /* type is a declaration. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020 if (DECL_P (type))
111
kono
parents: 68
diff changeset
1021 return type;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1023 if (TYPE_P (type))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1024 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1025 type = TYPE_MAIN_VARIANT (type);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1026
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1027 /* type is a typedef. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1028 if (TYPE_NAME (type) && DECL_P (TYPE_NAME (type)))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1029 return TYPE_NAME (type);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1030
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1031 /* TYPE_STUB_DECL has been set for type. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1032 if (TYPE_STUB_DECL (type))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1033 return TYPE_STUB_DECL (type);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1034 }
111
kono
parents: 68
diff changeset
1035
kono
parents: 68
diff changeset
1036 return NULL_TREE;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039 /* Return whether TYPE has static fields. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040
111
kono
parents: 68
diff changeset
1041 static bool
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042 has_static_fields (const_tree type)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043 {
111
kono
parents: 68
diff changeset
1044 if (!type || !RECORD_OR_UNION_TYPE_P (type))
kono
parents: 68
diff changeset
1045 return false;
kono
parents: 68
diff changeset
1046
kono
parents: 68
diff changeset
1047 for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
kono
parents: 68
diff changeset
1048 if (TREE_CODE (fld) == VAR_DECL && DECL_NAME (fld))
kono
parents: 68
diff changeset
1049 return true;
kono
parents: 68
diff changeset
1050
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054 /* Return whether TYPE corresponds to an Ada tagged type (has a dispatch
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1055 table). */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056
111
kono
parents: 68
diff changeset
1057 static bool
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058 is_tagged_type (const_tree type)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 if (!type || !RECORD_OR_UNION_TYPE_P (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062
111
kono
parents: 68
diff changeset
1063 for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
kono
parents: 68
diff changeset
1064 if (TREE_CODE (fld) == FUNCTION_DECL && DECL_VINDEX (fld))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 return true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069
111
kono
parents: 68
diff changeset
1070 /* Return whether TYPE has non-trivial methods, i.e. methods that do something
kono
parents: 68
diff changeset
1071 for the objects of TYPE. In C++, all classes have implicit special methods,
kono
parents: 68
diff changeset
1072 e.g. constructors and destructors, but they can be trivial if the type is
kono
parents: 68
diff changeset
1073 sufficiently simple. */
kono
parents: 68
diff changeset
1074
kono
parents: 68
diff changeset
1075 static bool
kono
parents: 68
diff changeset
1076 has_nontrivial_methods (tree type)
kono
parents: 68
diff changeset
1077 {
kono
parents: 68
diff changeset
1078 if (!type || !RECORD_OR_UNION_TYPE_P (type))
kono
parents: 68
diff changeset
1079 return false;
kono
parents: 68
diff changeset
1080
kono
parents: 68
diff changeset
1081 /* Only C++ types can have methods. */
kono
parents: 68
diff changeset
1082 if (!cpp_check)
kono
parents: 68
diff changeset
1083 return false;
kono
parents: 68
diff changeset
1084
kono
parents: 68
diff changeset
1085 /* A non-trivial type has non-trivial special methods. */
kono
parents: 68
diff changeset
1086 if (!cpp_check (type, IS_TRIVIAL))
kono
parents: 68
diff changeset
1087 return true;
kono
parents: 68
diff changeset
1088
kono
parents: 68
diff changeset
1089 /* If there are user-defined methods, they are deemed non-trivial. */
kono
parents: 68
diff changeset
1090 for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
kono
parents: 68
diff changeset
1091 if (TREE_CODE (fld) == FUNCTION_DECL && !DECL_ARTIFICIAL (fld))
kono
parents: 68
diff changeset
1092 return true;
kono
parents: 68
diff changeset
1093
kono
parents: 68
diff changeset
1094 return false;
kono
parents: 68
diff changeset
1095 }
kono
parents: 68
diff changeset
1096
kono
parents: 68
diff changeset
1097 #define INDEX_LENGTH 8
kono
parents: 68
diff changeset
1098
kono
parents: 68
diff changeset
1099 /* Generate a legal Ada name from a C/C++ NAME and return a malloc'ed string.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1100 SPACE_FOUND, if not NULL, is used to indicate whether a space was found in
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1101 NAME. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 static char *
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1104 to_ada_name (const char *name, bool *space_found)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106 const char **names;
111
kono
parents: 68
diff changeset
1107 const int len = strlen (name);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 int j, len2 = 0;
111
kono
parents: 68
diff changeset
1109 bool found = false;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1110 char *s = XNEWVEC (char, len * 2 + 5);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 char c;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 if (space_found)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 *space_found = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115
111
kono
parents: 68
diff changeset
1116 /* Add "c_" prefix if name is an Ada reserved word. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117 for (names = ada_reserved; *names; names++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118 if (!strcasecmp (name, *names))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 {
111
kono
parents: 68
diff changeset
1120 s[len2++] = 'c';
kono
parents: 68
diff changeset
1121 s[len2++] = '_';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 found = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126 if (!found)
111
kono
parents: 68
diff changeset
1127 /* Add "c_" prefix if name is a potential case sensitive duplicate. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1128 for (names = c_duplicates; *names; names++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 if (!strcmp (name, *names))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1130 {
111
kono
parents: 68
diff changeset
1131 s[len2++] = 'c';
kono
parents: 68
diff changeset
1132 s[len2++] = '_';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 found = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136
111
kono
parents: 68
diff changeset
1137 for (j = 0; name[j] == '_'; j++)
kono
parents: 68
diff changeset
1138 s[len2++] = 'u';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1139
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1140 if (j > 0)
111
kono
parents: 68
diff changeset
1141 s[len2++] = '_';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1142 else if (*name == '.' || *name == '$')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1143 {
111
kono
parents: 68
diff changeset
1144 s[0] = 'a';
kono
parents: 68
diff changeset
1145 s[1] = 'n';
kono
parents: 68
diff changeset
1146 s[2] = 'o';
kono
parents: 68
diff changeset
1147 s[3] = 'n';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1148 len2 = 4;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1149 j++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1150 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1151
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1152 /* Replace unsuitable characters for Ada identifiers. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1153 for (; j < len; j++)
111
kono
parents: 68
diff changeset
1154 switch (name[j])
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1155 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1156 case ' ':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1157 if (space_found)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158 *space_found = true;
111
kono
parents: 68
diff changeset
1159 s[len2++] = '_';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1162 /* ??? missing some C++ operators. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163 case '=':
111
kono
parents: 68
diff changeset
1164 s[len2++] = '_';
kono
parents: 68
diff changeset
1165
kono
parents: 68
diff changeset
1166 if (name[j + 1] == '=')
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1168 j++;
111
kono
parents: 68
diff changeset
1169 s[len2++] = 'e';
kono
parents: 68
diff changeset
1170 s[len2++] = 'q';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1171 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 {
111
kono
parents: 68
diff changeset
1174 s[len2++] = 'a';
kono
parents: 68
diff changeset
1175 s[len2++] = 's';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1178
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1179 case '!':
111
kono
parents: 68
diff changeset
1180 s[len2++] = '_';
kono
parents: 68
diff changeset
1181 if (name[j + 1] == '=')
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183 j++;
111
kono
parents: 68
diff changeset
1184 s[len2++] = 'n';
kono
parents: 68
diff changeset
1185 s[len2++] = 'e';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1186 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1187 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1188
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1189 case '~':
111
kono
parents: 68
diff changeset
1190 s[len2++] = '_';
kono
parents: 68
diff changeset
1191 s[len2++] = 't';
kono
parents: 68
diff changeset
1192 s[len2++] = 'i';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1193 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1194
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1195 case '&':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1196 case '|':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1197 case '^':
111
kono
parents: 68
diff changeset
1198 s[len2++] = '_';
kono
parents: 68
diff changeset
1199 s[len2++] = name[j] == '&' ? 'a' : name[j] == '|' ? 'o' : 'x';
kono
parents: 68
diff changeset
1200
kono
parents: 68
diff changeset
1201 if (name[j + 1] == '=')
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1202 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1203 j++;
111
kono
parents: 68
diff changeset
1204 s[len2++] = 'e';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1205 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1206 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1207
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208 case '+':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1209 case '-':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1210 case '*':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211 case '/':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1212 case '(':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1213 case '[':
111
kono
parents: 68
diff changeset
1214 if (s[len2 - 1] != '_')
kono
parents: 68
diff changeset
1215 s[len2++] = '_';
kono
parents: 68
diff changeset
1216
kono
parents: 68
diff changeset
1217 switch (name[j + 1]) {
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1218 case '\0':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1219 j++;
111
kono
parents: 68
diff changeset
1220 switch (name[j - 1]) {
kono
parents: 68
diff changeset
1221 case '+': s[len2++] = 'p'; break; /* + */
kono
parents: 68
diff changeset
1222 case '-': s[len2++] = 'm'; break; /* - */
kono
parents: 68
diff changeset
1223 case '*': s[len2++] = 't'; break; /* * */
kono
parents: 68
diff changeset
1224 case '/': s[len2++] = 'd'; break; /* / */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1225 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1226 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1227
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1228 case '=':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1229 j++;
111
kono
parents: 68
diff changeset
1230 switch (name[j - 1]) {
kono
parents: 68
diff changeset
1231 case '+': s[len2++] = 'p'; break; /* += */
kono
parents: 68
diff changeset
1232 case '-': s[len2++] = 'm'; break; /* -= */
kono
parents: 68
diff changeset
1233 case '*': s[len2++] = 't'; break; /* *= */
kono
parents: 68
diff changeset
1234 case '/': s[len2++] = 'd'; break; /* /= */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1235 }
111
kono
parents: 68
diff changeset
1236 s[len2++] = 'a';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1237 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1238
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1239 case '-': /* -- */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1240 j++;
111
kono
parents: 68
diff changeset
1241 s[len2++] = 'm';
kono
parents: 68
diff changeset
1242 s[len2++] = 'm';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1243 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1244
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1245 case '+': /* ++ */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1246 j++;
111
kono
parents: 68
diff changeset
1247 s[len2++] = 'p';
kono
parents: 68
diff changeset
1248 s[len2++] = 'p';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1249 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1250
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1251 case ')': /* () */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1252 j++;
111
kono
parents: 68
diff changeset
1253 s[len2++] = 'o';
kono
parents: 68
diff changeset
1254 s[len2++] = 'p';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1255 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1256
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1257 case ']': /* [] */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1258 j++;
111
kono
parents: 68
diff changeset
1259 s[len2++] = 'o';
kono
parents: 68
diff changeset
1260 s[len2++] = 'b';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1261 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1262 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1263
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1264 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1265
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1266 case '<':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1267 case '>':
111
kono
parents: 68
diff changeset
1268 c = name[j] == '<' ? 'l' : 'g';
kono
parents: 68
diff changeset
1269 s[len2++] = '_';
kono
parents: 68
diff changeset
1270
kono
parents: 68
diff changeset
1271 switch (name[j + 1]) {
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1272 case '\0':
111
kono
parents: 68
diff changeset
1273 s[len2++] = c;
kono
parents: 68
diff changeset
1274 s[len2++] = 't';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1275 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1276 case '=':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1277 j++;
111
kono
parents: 68
diff changeset
1278 s[len2++] = c;
kono
parents: 68
diff changeset
1279 s[len2++] = 'e';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1280 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1281 case '>':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1282 j++;
111
kono
parents: 68
diff changeset
1283 s[len2++] = 's';
kono
parents: 68
diff changeset
1284 s[len2++] = 'r';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1285 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1286 case '<':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1287 j++;
111
kono
parents: 68
diff changeset
1288 s[len2++] = 's';
kono
parents: 68
diff changeset
1289 s[len2++] = 'l';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1294 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296 case '_':
111
kono
parents: 68
diff changeset
1297 if (len2 && s[len2 - 1] == '_')
kono
parents: 68
diff changeset
1298 s[len2++] = 'u';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299 /* fall through */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1300
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301 default:
111
kono
parents: 68
diff changeset
1302 s[len2++] = name[j];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304
111
kono
parents: 68
diff changeset
1305 if (s[len2 - 1] == '_')
kono
parents: 68
diff changeset
1306 s[len2++] = 'u';
kono
parents: 68
diff changeset
1307
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1308 s[len2] = '\0';
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1309
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1310 return s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1311 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1312
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1313 /* Return true if DECL refers to a C++ class type for which a
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1314 separate enclosing package has been or should be generated. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1315
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1316 static bool
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1317 separate_class_package (tree decl)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1318 {
111
kono
parents: 68
diff changeset
1319 tree type = TREE_TYPE (decl);
kono
parents: 68
diff changeset
1320 return has_nontrivial_methods (type) || has_static_fields (type);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1321 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1322
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1323 static bool package_prefix = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1324
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1325 /* Dump in BUFFER the name of an identifier NODE of type TYPE, following Ada
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1326 syntax. LIMITED_ACCESS indicates whether NODE can be accessed through a
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1327 limited 'with' clause rather than a regular 'with' clause. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1328
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1329 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1330 pp_ada_tree_identifier (pretty_printer *buffer, tree node, tree type,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1331 bool limited_access)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1332 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1333 const char *name = IDENTIFIER_POINTER (node);
111
kono
parents: 68
diff changeset
1334 bool space_found = false;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1335 char *s = to_ada_name (name, &space_found);
111
kono
parents: 68
diff changeset
1336 tree decl = get_underlying_decl (type);
kono
parents: 68
diff changeset
1337
kono
parents: 68
diff changeset
1338 /* If the entity comes from another file, generate a package prefix. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1339 if (decl)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1340 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1341 expanded_location xloc = expand_location (decl_sloc (decl, false));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1342
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1343 if (xloc.file && xloc.line)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1344 {
111
kono
parents: 68
diff changeset
1345 if (xloc.file != current_source_file)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1346 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1347 switch (TREE_CODE (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1348 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1349 case ENUMERAL_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1350 case INTEGER_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1351 case REAL_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1352 case FIXED_POINT_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1353 case BOOLEAN_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1354 case REFERENCE_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1355 case POINTER_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1356 case ARRAY_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1357 case RECORD_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1358 case UNION_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1359 case TYPE_DECL:
111
kono
parents: 68
diff changeset
1360 if (package_prefix)
kono
parents: 68
diff changeset
1361 {
kono
parents: 68
diff changeset
1362 char *s1 = get_ada_package (xloc.file);
kono
parents: 68
diff changeset
1363 append_withs (s1, limited_access);
kono
parents: 68
diff changeset
1364 pp_string (buffer, s1);
kono
parents: 68
diff changeset
1365 pp_dot (buffer);
kono
parents: 68
diff changeset
1366 free (s1);
kono
parents: 68
diff changeset
1367 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1368 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1369 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1370 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1371 }
111
kono
parents: 68
diff changeset
1372
kono
parents: 68
diff changeset
1373 /* Generate the additional package prefix for C++ classes. */
kono
parents: 68
diff changeset
1374 if (separate_class_package (decl))
kono
parents: 68
diff changeset
1375 {
kono
parents: 68
diff changeset
1376 pp_string (buffer, "Class_");
kono
parents: 68
diff changeset
1377 pp_string (buffer, s);
kono
parents: 68
diff changeset
1378 pp_dot (buffer);
kono
parents: 68
diff changeset
1379 }
kono
parents: 68
diff changeset
1380 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1381 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1382 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1383
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1384 if (space_found)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1385 if (!strcmp (s, "short_int"))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1386 pp_string (buffer, "short");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1387 else if (!strcmp (s, "short_unsigned_int"))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1388 pp_string (buffer, "unsigned_short");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1389 else if (!strcmp (s, "unsigned_int"))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1390 pp_string (buffer, "unsigned");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1391 else if (!strcmp (s, "long_int"))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1392 pp_string (buffer, "long");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1393 else if (!strcmp (s, "long_unsigned_int"))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1394 pp_string (buffer, "unsigned_long");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1395 else if (!strcmp (s, "long_long_int"))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1396 pp_string (buffer, "Long_Long_Integer");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1397 else if (!strcmp (s, "long_long_unsigned_int"))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1398 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1399 if (package_prefix)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1400 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1401 append_withs ("Interfaces.C.Extensions", false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1402 pp_string (buffer, "Extensions.unsigned_long_long");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1403 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1404 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1405 pp_string (buffer, "unsigned_long_long");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1406 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1407 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1408 pp_string(buffer, s);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1409 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1410 if (!strcmp (s, "u_Bool") || !strcmp (s, "bool"))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1411 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1412 if (package_prefix)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1413 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1414 append_withs ("Interfaces.C.Extensions", false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1415 pp_string (buffer, "Extensions.bool");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1416 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1417 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1418 pp_string (buffer, "bool");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1419 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1420 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1421 pp_string(buffer, s);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1422
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1423 free (s);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1424 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1425
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1426 /* Dump in BUFFER the assembly name of T. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1427
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1428 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1429 pp_asm_name (pretty_printer *buffer, tree t)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1430 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1431 tree name = DECL_ASSEMBLER_NAME (t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1432 char *ada_name = XALLOCAVEC (char, IDENTIFIER_LENGTH (name) + 1), *s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1433 const char *ident = IDENTIFIER_POINTER (name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1434
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1435 for (s = ada_name; *ident; ident++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1436 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1437 if (*ident == ' ')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1438 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1439 else if (*ident != '*')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1440 *s++ = *ident;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1441 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1442
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1443 *s = '\0';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1444 pp_string (buffer, ada_name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1445 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1446
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1447 /* Dump in BUFFER the name of a DECL node if set, in Ada syntax.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1448 LIMITED_ACCESS indicates whether NODE can be accessed via a
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1449 limited 'with' clause rather than a regular 'with' clause. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1450
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1451 static void
111
kono
parents: 68
diff changeset
1452 dump_ada_decl_name (pretty_printer *buffer, tree decl, bool limited_access)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1453 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1454 if (DECL_NAME (decl))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1455 pp_ada_tree_identifier (buffer, DECL_NAME (decl), decl, limited_access);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1456 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1457 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1458 tree type_name = TYPE_NAME (TREE_TYPE (decl));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1459
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1460 if (!type_name)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1461 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1462 pp_string (buffer, "anon");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1463 if (TREE_CODE (decl) == FIELD_DECL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1464 pp_scalar (buffer, "%d", DECL_UID (decl));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1465 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1466 pp_scalar (buffer, "%d", TYPE_UID (TREE_TYPE (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1467 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1468 else if (TREE_CODE (type_name) == IDENTIFIER_NODE)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1469 pp_ada_tree_identifier (buffer, type_name, decl, limited_access);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1470 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1471 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1472
111
kono
parents: 68
diff changeset
1473 /* Dump in BUFFER a name based on both T1 and T2 followed by a suffix. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1474
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1475 static void
111
kono
parents: 68
diff changeset
1476 dump_ada_double_name (pretty_printer *buffer, tree t1, tree t2)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1477 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1478 if (DECL_NAME (t1))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1479 pp_ada_tree_identifier (buffer, DECL_NAME (t1), t1, false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1480 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1481 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1482 pp_string (buffer, "anon");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1483 pp_scalar (buffer, "%d", TYPE_UID (TREE_TYPE (t1)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1484 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1485
111
kono
parents: 68
diff changeset
1486 pp_underscore (buffer);
kono
parents: 68
diff changeset
1487
kono
parents: 68
diff changeset
1488 if (DECL_NAME (t2))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1489 pp_ada_tree_identifier (buffer, DECL_NAME (t2), t2, false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1490 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1491 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1492 pp_string (buffer, "anon");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1493 pp_scalar (buffer, "%d", TYPE_UID (TREE_TYPE (t2)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1494 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1495
111
kono
parents: 68
diff changeset
1496 switch (TREE_CODE (TREE_TYPE (t2)))
kono
parents: 68
diff changeset
1497 {
kono
parents: 68
diff changeset
1498 case ARRAY_TYPE:
kono
parents: 68
diff changeset
1499 pp_string (buffer, "_array");
kono
parents: 68
diff changeset
1500 break;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1501 case ENUMERAL_TYPE:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1502 pp_string (buffer, "_enum");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1503 break;
111
kono
parents: 68
diff changeset
1504 case RECORD_TYPE:
kono
parents: 68
diff changeset
1505 pp_string (buffer, "_struct");
kono
parents: 68
diff changeset
1506 break;
kono
parents: 68
diff changeset
1507 case UNION_TYPE:
kono
parents: 68
diff changeset
1508 pp_string (buffer, "_union");
kono
parents: 68
diff changeset
1509 break;
kono
parents: 68
diff changeset
1510 default:
kono
parents: 68
diff changeset
1511 pp_string (buffer, "_unknown");
kono
parents: 68
diff changeset
1512 break;
kono
parents: 68
diff changeset
1513 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1514 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1515
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1516 /* Dump in BUFFER aspect Import on a given node T. SPC is the current
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1517 indentation level. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1518
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1519 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1520 dump_ada_import (pretty_printer *buffer, tree t, int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1521 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1522 const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (t));
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1523 const bool is_stdcall
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1524 = TREE_CODE (t) == FUNCTION_DECL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1525 && lookup_attribute ("stdcall", TYPE_ATTRIBUTES (TREE_TYPE (t)));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1526
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1527 pp_string (buffer, "with Import => True, ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1528
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1529 newline_and_indent (buffer, spc + 5);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1530
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1531 if (is_stdcall)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1532 pp_string (buffer, "Convention => Stdcall, ");
111
kono
parents: 68
diff changeset
1533 else if (name[0] == '_' && name[1] == 'Z')
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1534 pp_string (buffer, "Convention => CPP, ");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1535 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1536 pp_string (buffer, "Convention => C, ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1537
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1538 newline_and_indent (buffer, spc + 5);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1539
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1540 pp_string (buffer, "External_Name => \"");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1541
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1542 if (is_stdcall)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1543 pp_string (buffer, IDENTIFIER_POINTER (DECL_NAME (t)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1544 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1545 pp_asm_name (buffer, t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1546
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1547 pp_string (buffer, "\";");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1548 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1549
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1550 /* Check whether T and its type have different names, and append "the_"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1551 otherwise in BUFFER. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1552
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1553 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1554 check_name (pretty_printer *buffer, tree t)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1555 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1556 const char *s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1557 tree tmp = TREE_TYPE (t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1558
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1559 while (TREE_CODE (tmp) == POINTER_TYPE && !TYPE_NAME (tmp))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1560 tmp = TREE_TYPE (tmp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1561
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1562 if (TREE_CODE (tmp) != FUNCTION_TYPE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1563 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1564 if (TREE_CODE (tmp) == IDENTIFIER_NODE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1565 s = IDENTIFIER_POINTER (tmp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1566 else if (!TYPE_NAME (tmp))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1567 s = "";
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1568 else if (TREE_CODE (TYPE_NAME (tmp)) == IDENTIFIER_NODE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1569 s = IDENTIFIER_POINTER (TYPE_NAME (tmp));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1570 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1571 s = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (tmp)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1572
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1573 if (!strcasecmp (IDENTIFIER_POINTER (DECL_NAME (t)), s))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1574 pp_string (buffer, "the_");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1575 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1576 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1577
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1578 /* Dump in BUFFER a function declaration FUNC in Ada syntax.
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1579 IS_METHOD indicates whether FUNC is a C++ method.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1580 IS_CONSTRUCTOR whether FUNC is a C++ constructor.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1581 IS_DESTRUCTOR whether FUNC is a C++ destructor.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1582 SPC is the current indentation level. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1583
111
kono
parents: 68
diff changeset
1584 static void
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1585 dump_ada_function_declaration (pretty_printer *buffer, tree func,
111
kono
parents: 68
diff changeset
1586 bool is_method, bool is_constructor,
kono
parents: 68
diff changeset
1587 bool is_destructor, int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1588 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1589 tree arg;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1590 const tree node = TREE_TYPE (func);
111
kono
parents: 68
diff changeset
1591 char buf[17];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1592 int num = 0, num_args = 0, have_args = true, have_ellipsis = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1593
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1594 /* Compute number of arguments. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1595 arg = TYPE_ARG_TYPES (node);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1596
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1597 if (arg)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1598 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1599 while (TREE_CHAIN (arg) && arg != error_mark_node)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1600 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1601 num_args++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1602 arg = TREE_CHAIN (arg);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1603 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1604
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1605 if (TREE_CODE (TREE_VALUE (arg)) != VOID_TYPE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1606 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1607 num_args++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1608 have_ellipsis = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1609 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1610 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1611
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1612 if (is_constructor)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1613 num_args--;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1614
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1615 if (is_destructor)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1616 num_args = 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1617
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1618 if (num_args > 2)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1619 newline_and_indent (buffer, spc + 1);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1620
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1621 if (num_args > 0)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1622 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1623 pp_space (buffer);
111
kono
parents: 68
diff changeset
1624 pp_left_paren (buffer);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1625 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1626
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1627 if (TREE_CODE (func) == FUNCTION_DECL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1628 arg = DECL_ARGUMENTS (func);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1629 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1630 arg = NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1631
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1632 if (arg == NULL_TREE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1633 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1634 have_args = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1635 arg = TYPE_ARG_TYPES (node);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1636
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1637 if (arg && TREE_CODE (TREE_VALUE (arg)) == VOID_TYPE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1638 arg = NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1639 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1640
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1641 if (is_constructor)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1642 arg = TREE_CHAIN (arg);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1643
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1644 /* Print the argument names (if available) & types. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1645
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1646 for (num = 1; num <= num_args; num++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1647 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1648 if (have_args)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1649 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1650 if (DECL_NAME (arg))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1651 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1652 check_name (buffer, arg);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1653 pp_ada_tree_identifier (buffer, DECL_NAME (arg), NULL_TREE,
111
kono
parents: 68
diff changeset
1654 false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1655 pp_string (buffer, " : ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1656 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1657 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1658 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1659 sprintf (buf, "arg%d : ", num);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1660 pp_string (buffer, buf);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1661 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1662
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1663 dump_ada_node (buffer, TREE_TYPE (arg), node, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1664 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1665 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1666 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1667 sprintf (buf, "arg%d : ", num);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1668 pp_string (buffer, buf);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1669 dump_ada_node (buffer, TREE_VALUE (arg), node, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1670 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1671
111
kono
parents: 68
diff changeset
1672 /* If the type is a pointer to a tagged type, we need to differentiate
kono
parents: 68
diff changeset
1673 virtual methods from the rest (non-virtual methods, static member
kono
parents: 68
diff changeset
1674 or regular functions) and import only them as primitive operations,
kono
parents: 68
diff changeset
1675 because they make up the virtual table which is mirrored on the Ada
kono
parents: 68
diff changeset
1676 side by the dispatch table. So we add 'Class to the type of every
kono
parents: 68
diff changeset
1677 parameter that is not the first one of a method which either has a
kono
parents: 68
diff changeset
1678 slot in the virtual table or is a constructor. */
kono
parents: 68
diff changeset
1679 if (TREE_TYPE (arg)
kono
parents: 68
diff changeset
1680 && POINTER_TYPE_P (TREE_TYPE (arg))
kono
parents: 68
diff changeset
1681 && is_tagged_type (TREE_TYPE (TREE_TYPE (arg)))
kono
parents: 68
diff changeset
1682 && !(num == 1 && is_method && (DECL_VINDEX (func) || is_constructor)))
kono
parents: 68
diff changeset
1683 pp_string (buffer, "'Class");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1684
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1685 arg = TREE_CHAIN (arg);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1686
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1687 if (num < num_args)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1688 {
111
kono
parents: 68
diff changeset
1689 pp_semicolon (buffer);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1690
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1691 if (num_args > 2)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1692 newline_and_indent (buffer, spc + INDENT_INCR);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1693 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1694 pp_space (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1695 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1696 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1697
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1698 if (have_ellipsis)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1699 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1700 pp_string (buffer, " -- , ...");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1701 newline_and_indent (buffer, spc + INDENT_INCR);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1702 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1703
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1704 if (num_args > 0)
111
kono
parents: 68
diff changeset
1705 pp_right_paren (buffer);
kono
parents: 68
diff changeset
1706
kono
parents: 68
diff changeset
1707 if (is_constructor || !VOID_TYPE_P (TREE_TYPE (node)))
kono
parents: 68
diff changeset
1708 {
kono
parents: 68
diff changeset
1709 pp_string (buffer, " return ");
kono
parents: 68
diff changeset
1710 tree type = is_constructor ? DECL_CONTEXT (func) : TREE_TYPE (node);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1711 dump_ada_node (buffer, type, type, spc, false, true);
111
kono
parents: 68
diff changeset
1712 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1713 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1714
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1715 /* Dump in BUFFER all the domains associated with an array NODE,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1716 in Ada syntax. SPC is the current indentation level. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1717
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1718 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1719 dump_ada_array_domains (pretty_printer *buffer, tree node, int spc)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1720 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1721 int first = 1;
111
kono
parents: 68
diff changeset
1722 pp_left_paren (buffer);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1723
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1724 for (; TREE_CODE (node) == ARRAY_TYPE; node = TREE_TYPE (node))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1725 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1726 tree domain = TYPE_DOMAIN (node);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1727
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1728 if (domain)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1729 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1730 tree min = TYPE_MIN_VALUE (domain);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1731 tree max = TYPE_MAX_VALUE (domain);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1732
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1733 if (!first)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1734 pp_string (buffer, ", ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1735 first = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1736
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1737 if (min)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1738 dump_ada_node (buffer, min, NULL_TREE, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1739 pp_string (buffer, " .. ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1740
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1741 /* If the upper bound is zero, gcc may generate a NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1742 for TYPE_MAX_VALUE rather than an integer_cst. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1743 if (max)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1744 dump_ada_node (buffer, max, NULL_TREE, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1745 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1746 pp_string (buffer, "0");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1747 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1748 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1749 pp_string (buffer, "size_t");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1750 }
111
kono
parents: 68
diff changeset
1751 pp_right_paren (buffer);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1752 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1753
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1754 /* Dump in BUFFER file:line information related to NODE. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1755
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1756 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1757 dump_sloc (pretty_printer *buffer, tree node)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1758 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1759 expanded_location xloc;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1760
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1761 xloc.file = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1762
111
kono
parents: 68
diff changeset
1763 if (DECL_P (node))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1764 xloc = expand_location (DECL_SOURCE_LOCATION (node));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1765 else if (EXPR_HAS_LOCATION (node))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1766 xloc = expand_location (EXPR_LOCATION (node));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1767
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1768 if (xloc.file)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1769 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1770 pp_string (buffer, xloc.file);
111
kono
parents: 68
diff changeset
1771 pp_colon (buffer);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1772 pp_decimal_int (buffer, xloc.line);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1773 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1774 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1775
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1776 /* Return true if type T designates a 1-dimension array of "char". */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1777
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1778 static bool
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1779 is_char_array (tree t)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1780 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1781 int num_dim = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1782
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1783 while (TREE_CODE (t) == ARRAY_TYPE)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1784 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1785 num_dim++;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1786 t = TREE_TYPE (t);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1787 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1788
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1789 return num_dim == 1
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1790 && TREE_CODE (t) == INTEGER_TYPE
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1791 && id_equal (DECL_NAME (TYPE_NAME (t)), "char");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1792 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1793
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1794 /* Dump in BUFFER an array type NODE of type TYPE in Ada syntax. SPC is the
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1795 indentation level. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1796
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1797 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1798 dump_ada_array_type (pretty_printer *buffer, tree node, tree type, int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1799 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1800 const bool char_array = is_char_array (node);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1801
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1802 /* Special case char arrays. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1803 if (char_array)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1804 pp_string (buffer, "Interfaces.C.char_array ");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1805 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1806 pp_string (buffer, "array ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1807
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1808 /* Print the dimensions. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1809 dump_ada_array_domains (buffer, node, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1810
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1811 /* Print array's type. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1812 if (!char_array)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1813 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1814 /* Retrieve the element type. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1815 tree tmp = node;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1816 while (TREE_CODE (tmp) == ARRAY_TYPE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1817 tmp = TREE_TYPE (tmp);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1818
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1819 pp_string (buffer, " of ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1820
111
kono
parents: 68
diff changeset
1821 if (TREE_CODE (tmp) != POINTER_TYPE)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1822 pp_string (buffer, "aliased ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1823
111
kono
parents: 68
diff changeset
1824 if (TYPE_NAME (tmp) || !RECORD_OR_UNION_TYPE_P (tmp))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1825 dump_ada_node (buffer, tmp, node, spc, false, true);
111
kono
parents: 68
diff changeset
1826 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1827 dump_ada_double_name (buffer, type, get_underlying_decl (tmp));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1828 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1829 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1830
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1831 /* Dump in BUFFER type names associated with a template, each prepended with
111
kono
parents: 68
diff changeset
1832 '_'. TYPES is the TREE_PURPOSE of a DECL_TEMPLATE_INSTANTIATIONS. SPC is
kono
parents: 68
diff changeset
1833 the indentation level. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1834
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1835 static void
111
kono
parents: 68
diff changeset
1836 dump_template_types (pretty_printer *buffer, tree types, int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1837 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1838 for (int i = 0; i < TREE_VEC_LENGTH (types); i++)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1839 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1840 tree elem = TREE_VEC_ELT (types, i);
111
kono
parents: 68
diff changeset
1841 pp_underscore (buffer);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1842
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1843 if (!dump_ada_node (buffer, elem, NULL_TREE, spc, false, true))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1844 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1845 pp_string (buffer, "unknown");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1846 pp_scalar (buffer, "%lu", (unsigned long) TREE_HASH (elem));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1847 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1848 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1849 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1850
111
kono
parents: 68
diff changeset
1851 /* Dump in BUFFER the contents of all class instantiations associated with
kono
parents: 68
diff changeset
1852 a given template T. SPC is the indentation level. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1853
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1854 static int
111
kono
parents: 68
diff changeset
1855 dump_ada_template (pretty_printer *buffer, tree t, int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1856 {
111
kono
parents: 68
diff changeset
1857 /* DECL_SIZE_UNIT is DECL_TEMPLATE_INSTANTIATIONS in this context. */
kono
parents: 68
diff changeset
1858 tree inst = DECL_SIZE_UNIT (t);
kono
parents: 68
diff changeset
1859 /* This emulates DECL_TEMPLATE_RESULT in this context. */
kono
parents: 68
diff changeset
1860 struct tree_template_decl {
kono
parents: 68
diff changeset
1861 struct tree_decl_common common;
kono
parents: 68
diff changeset
1862 tree arguments;
kono
parents: 68
diff changeset
1863 tree result;
kono
parents: 68
diff changeset
1864 };
kono
parents: 68
diff changeset
1865 tree result = ((struct tree_template_decl *) t)->result;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1866 int num_inst = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1867
111
kono
parents: 68
diff changeset
1868 /* Don't look at template declarations declaring something coming from
kono
parents: 68
diff changeset
1869 another file. This can occur for template friend declarations. */
kono
parents: 68
diff changeset
1870 if (LOCATION_FILE (decl_sloc (result, false))
kono
parents: 68
diff changeset
1871 != LOCATION_FILE (decl_sloc (t, false)))
kono
parents: 68
diff changeset
1872 return 0;
kono
parents: 68
diff changeset
1873
kono
parents: 68
diff changeset
1874 for (; inst && inst != error_mark_node; inst = TREE_CHAIN (inst))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1875 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1876 tree types = TREE_PURPOSE (inst);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1877 tree instance = TREE_VALUE (inst);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1878
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1879 if (TREE_VEC_LENGTH (types) == 0)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1880 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1881
111
kono
parents: 68
diff changeset
1882 if (!RECORD_OR_UNION_TYPE_P (instance))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1883 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1884
111
kono
parents: 68
diff changeset
1885 /* We are interested in concrete template instantiations only: skip
kono
parents: 68
diff changeset
1886 partially specialized nodes. */
kono
parents: 68
diff changeset
1887 if (RECORD_OR_UNION_TYPE_P (instance)
kono
parents: 68
diff changeset
1888 && cpp_check
kono
parents: 68
diff changeset
1889 && cpp_check (instance, HAS_DEPENDENT_TEMPLATE_ARGS))
kono
parents: 68
diff changeset
1890 continue;
kono
parents: 68
diff changeset
1891
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1892 num_inst++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1893 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1894 pp_string (buffer, "package ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1895 package_prefix = false;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1896 dump_ada_node (buffer, instance, t, spc, false, true);
111
kono
parents: 68
diff changeset
1897 dump_template_types (buffer, types, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1898 pp_string (buffer, " is");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1899 spc += INDENT_INCR;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1900 newline_and_indent (buffer, spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1901
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1902 TREE_VISITED (get_underlying_decl (instance)) = 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1903 pp_string (buffer, "type ");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1904 dump_ada_node (buffer, instance, t, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1905 package_prefix = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1906
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1907 if (is_tagged_type (instance))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1908 pp_string (buffer, " is tagged limited ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1909 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1910 pp_string (buffer, " is limited ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1911
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1912 dump_ada_node (buffer, instance, t, spc, false, false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1913 pp_newline (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1914 spc -= INDENT_INCR;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1915 newline_and_indent (buffer, spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1916
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1917 pp_string (buffer, "end;");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1918 newline_and_indent (buffer, spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1919 pp_string (buffer, "use ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1920 package_prefix = false;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1921 dump_ada_node (buffer, instance, t, spc, false, true);
111
kono
parents: 68
diff changeset
1922 dump_template_types (buffer, types, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1923 package_prefix = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1924 pp_semicolon (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1925 pp_newline (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1926 pp_newline (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1927 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1928
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1929 return num_inst > 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1930 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1931
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1932 /* Return true if NODE is a simple enum types, that can be mapped to an
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1933 Ada enum type directly. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1934
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1935 static bool
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1936 is_simple_enum (tree node)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1937 {
111
kono
parents: 68
diff changeset
1938 HOST_WIDE_INT count = 0;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1939
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1940 for (tree value = TYPE_VALUES (node); value; value = TREE_CHAIN (value))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1941 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1942 tree int_val = TREE_VALUE (value);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1943
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1944 if (TREE_CODE (int_val) != INTEGER_CST)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1945 int_val = DECL_INITIAL (int_val);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1946
111
kono
parents: 68
diff changeset
1947 if (!tree_fits_shwi_p (int_val))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1948 return false;
111
kono
parents: 68
diff changeset
1949 else if (tree_to_shwi (int_val) != count)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1950 return false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1951
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1952 count++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1953 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1954
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1955 return true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1956 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1957
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1958 /* Dump in BUFFER an enumeral type NODE in Ada syntax. SPC is the indentation
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1959 level. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1960
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1961 static void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1962 dump_ada_enum_type (pretty_printer *buffer, tree node, int spc)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1963 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1964 if (is_simple_enum (node))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1965 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1966 bool first = true;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1967 spc += INDENT_INCR;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1968 newline_and_indent (buffer, spc - 1);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1969 pp_left_paren (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1970 for (tree value = TYPE_VALUES (node); value; value = TREE_CHAIN (value))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1971 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1972 if (first)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1973 first = false;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1974 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1975 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1976 pp_comma (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1977 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1978 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1979
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1980 pp_ada_tree_identifier (buffer, TREE_PURPOSE (value), node, false);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1981 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1982 pp_string (buffer, ")");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1983 spc -= INDENT_INCR;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1984 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1985 pp_string (buffer, "with Convention => C");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1986 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1987 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1988 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1989 if (TYPE_UNSIGNED (node))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1990 pp_string (buffer, "unsigned");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1991 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1992 pp_string (buffer, "int");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1993 for (tree value = TYPE_VALUES (node); value; value = TREE_CHAIN (value))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1994 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1995 pp_semicolon (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1996 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1997
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1998 pp_ada_tree_identifier (buffer, TREE_PURPOSE (value), node, false);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1999 pp_string (buffer, " : constant ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2000
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2001 if (TYPE_UNSIGNED (node))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2002 pp_string (buffer, "unsigned");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2003 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2004 pp_string (buffer, "int");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2005
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2006 pp_string (buffer, " := ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2007 dump_ada_node (buffer,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2008 TREE_CODE (TREE_VALUE (value)) == INTEGER_CST
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2009 ? TREE_VALUE (value)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2010 : DECL_INITIAL (TREE_VALUE (value)),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2011 node, spc, false, true);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2012 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2013 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2014 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2015
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2016 static bool bitfield_used = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2017
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2018 /* Recursively dump in BUFFER Ada declarations corresponding to NODE of type
111
kono
parents: 68
diff changeset
2019 TYPE. SPC is the indentation level. LIMITED_ACCESS indicates whether NODE
kono
parents: 68
diff changeset
2020 can be referenced via a "limited with" clause. NAME_ONLY indicates whether
kono
parents: 68
diff changeset
2021 we should only dump the name of NODE, instead of its full declaration. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2022
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2023 static int
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2024 dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2025 bool limited_access, bool name_only)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2026 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2027 if (node == NULL_TREE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2028 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2029
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2030 switch (TREE_CODE (node))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2031 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2032 case ERROR_MARK:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2033 pp_string (buffer, "<<< error >>>");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2034 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2035
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2036 case IDENTIFIER_NODE:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2037 pp_ada_tree_identifier (buffer, node, type, limited_access);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2038 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2039
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2040 case TREE_LIST:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2041 pp_string (buffer, "--- unexpected node: TREE_LIST");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2042 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2043
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2044 case TREE_BINFO:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2045 dump_ada_node (buffer, BINFO_TYPE (node), type, spc, limited_access,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2046 name_only);
111
kono
parents: 68
diff changeset
2047 return 0;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2048
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2049 case TREE_VEC:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2050 pp_string (buffer, "--- unexpected node: TREE_VEC");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2051 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2052
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2053 case NULLPTR_TYPE:
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2054 case VOID_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2055 if (package_prefix)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2056 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2057 append_withs ("System", false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2058 pp_string (buffer, "System.Address");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2059 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2060 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2061 pp_string (buffer, "address");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2062 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2063
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2064 case VECTOR_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2065 pp_string (buffer, "<vector>");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2066 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2067
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2068 case COMPLEX_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2069 pp_string (buffer, "<complex>");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2070 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2071
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2072 case ENUMERAL_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2073 if (name_only)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2074 dump_ada_node (buffer, TYPE_NAME (node), node, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2075 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2076 dump_ada_enum_type (buffer, node, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2077 break;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2078
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2079 case REAL_TYPE:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2080 if (TYPE_NAME (node)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2081 && TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2082 && IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))) [0] == '_'
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2083 && (id_equal (DECL_NAME (TYPE_NAME (node)), "_Float128")
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2084 || id_equal (DECL_NAME (TYPE_NAME (node)), "__float128")))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2085 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2086 append_withs ("Interfaces.C.Extensions", false);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2087 pp_string (buffer, "Extensions.Float_128");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2088 break;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2089 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2090 /* fallthrough */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2091
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2092 case INTEGER_TYPE:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2093 case FIXED_POINT_TYPE:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2094 case BOOLEAN_TYPE:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2095 if (TYPE_NAME (node))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2096 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2097 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2098 pp_ada_tree_identifier (buffer, TYPE_NAME (node), node,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2099 limited_access);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2100 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2101 && DECL_NAME (TYPE_NAME (node)))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2102 dump_ada_decl_name (buffer, TYPE_NAME (node), limited_access);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2103 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2104 pp_string (buffer, "<unnamed type>");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2105 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2106 else if (TREE_CODE (node) == INTEGER_TYPE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2107 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2108 append_withs ("Interfaces.C.Extensions", false);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2109 bitfield_used = true;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2110
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2111 if (TYPE_PRECISION (node) == 1)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2112 pp_string (buffer, "Extensions.Unsigned_1");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2113 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2114 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2115 pp_string (buffer, TYPE_UNSIGNED (node)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2116 ? "Extensions.Unsigned_"
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2117 : "Extensions.Signed_");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2118 pp_decimal_int (buffer, TYPE_PRECISION (node));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2119 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2120 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2121 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2122 pp_string (buffer, "<unnamed type>");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2123 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2124
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2125 case POINTER_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2126 case REFERENCE_TYPE:
111
kono
parents: 68
diff changeset
2127 if (name_only && TYPE_NAME (node))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2128 dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2129 true);
111
kono
parents: 68
diff changeset
2130
kono
parents: 68
diff changeset
2131 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2132 {
111
kono
parents: 68
diff changeset
2133 if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (node))))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2134 pp_string (buffer, "access procedure");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2135 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2136 pp_string (buffer, "access function");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2137
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2138 dump_ada_function_declaration (buffer, node, false, false, false,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2139 spc + INDENT_INCR);
111
kono
parents: 68
diff changeset
2140
kono
parents: 68
diff changeset
2141 /* If we are dumping the full type, it means we are part of a
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2142 type definition and need also a Convention C aspect. */
111
kono
parents: 68
diff changeset
2143 if (!name_only)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2144 {
111
kono
parents: 68
diff changeset
2145 newline_and_indent (buffer, spc);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2146 pp_string (buffer, "with Convention => C");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2147 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2148 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2149 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2150 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2151 const unsigned int quals = TYPE_QUALS (TREE_TYPE (node));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2152 bool is_access = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2153
111
kono
parents: 68
diff changeset
2154 if (VOID_TYPE_P (TREE_TYPE (node)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2155 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2156 if (!name_only)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2157 pp_string (buffer, "new ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2158 if (package_prefix)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2159 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2160 append_withs ("System", false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2161 pp_string (buffer, "System.Address");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2162 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2163 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2164 pp_string (buffer, "address");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2165 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2166 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2167 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2168 if (TREE_CODE (node) == POINTER_TYPE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2169 && TREE_CODE (TREE_TYPE (node)) == INTEGER_TYPE
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2170 && id_equal (DECL_NAME (TYPE_NAME (TREE_TYPE (node))),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2171 "char"))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2172 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2173 if (!name_only)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2174 pp_string (buffer, "new ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2175
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2176 if (package_prefix)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2177 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2178 pp_string (buffer, "Interfaces.C.Strings.chars_ptr");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2179 append_withs ("Interfaces.C.Strings", false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2180 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2181 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2182 pp_string (buffer, "chars_ptr");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2183 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2184 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2185 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2186 tree type_name = TYPE_NAME (TREE_TYPE (node));
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2187
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2188 /* For now, handle access-to-access as System.Address. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2189 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2190 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2191 if (package_prefix)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2192 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2193 append_withs ("System", false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2194 if (!name_only)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2195 pp_string (buffer, "new ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2196 pp_string (buffer, "System.Address");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2197 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2198 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2199 pp_string (buffer, "address");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2200 return spc;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2201 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2202
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2203 if (!package_prefix)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2204 pp_string (buffer, "access");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2205 else if (AGGREGATE_TYPE_P (TREE_TYPE (node)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2206 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2207 if (!type || TREE_CODE (type) != FUNCTION_DECL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2208 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2209 pp_string (buffer, "access ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2210 is_access = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2211
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2212 if (quals & TYPE_QUAL_CONST)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2213 pp_string (buffer, "constant ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2214 else if (!name_only)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2215 pp_string (buffer, "all ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2216 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2217 else if (quals & TYPE_QUAL_CONST)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2218 pp_string (buffer, "in ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2219 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2220 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2221 is_access = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2222 pp_string (buffer, "access ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2223 /* ??? should be configurable: access or in out. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2224 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2225 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2226 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2227 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2228 is_access = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2229 pp_string (buffer, "access ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2230
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2231 if (!name_only)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2232 pp_string (buffer, "all ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2233 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2234
111
kono
parents: 68
diff changeset
2235 if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (node)) && type_name)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2236 dump_ada_node (buffer, type_name, TREE_TYPE (node), spc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2237 is_access, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2238 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2239 dump_ada_node (buffer, TREE_TYPE (node), TREE_TYPE (node),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2240 spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2241 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2242 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2243 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2244 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2245
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2246 case ARRAY_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2247 if (name_only)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2248 dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2249 true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2250 else
111
kono
parents: 68
diff changeset
2251 dump_ada_array_type (buffer, node, type, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2252 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2253
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2254 case RECORD_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2255 case UNION_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2256 if (name_only)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2257 dump_ada_node (buffer, TYPE_NAME (node), node, spc, limited_access,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2258 true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2259 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2260 dump_ada_structure (buffer, node, type, false, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2261 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2262
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2263 case INTEGER_CST:
111
kono
parents: 68
diff changeset
2264 /* We treat the upper half of the sizetype range as negative. This
kono
parents: 68
diff changeset
2265 is consistent with the internal treatment and makes it possible
kono
parents: 68
diff changeset
2266 to generate the (0 .. -1) range for flexible array members. */
kono
parents: 68
diff changeset
2267 if (TREE_TYPE (node) == sizetype)
kono
parents: 68
diff changeset
2268 node = fold_convert (ssizetype, node);
kono
parents: 68
diff changeset
2269 if (tree_fits_shwi_p (node))
kono
parents: 68
diff changeset
2270 pp_wide_integer (buffer, tree_to_shwi (node));
kono
parents: 68
diff changeset
2271 else if (tree_fits_uhwi_p (node))
kono
parents: 68
diff changeset
2272 pp_unsigned_wide_integer (buffer, tree_to_uhwi (node));
kono
parents: 68
diff changeset
2273 else
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2274 {
111
kono
parents: 68
diff changeset
2275 wide_int val = wi::to_wide (node);
kono
parents: 68
diff changeset
2276 int i;
kono
parents: 68
diff changeset
2277 if (wi::neg_p (val))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2278 {
111
kono
parents: 68
diff changeset
2279 pp_minus (buffer);
kono
parents: 68
diff changeset
2280 val = -val;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2281 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2282 sprintf (pp_buffer (buffer)->digit_buffer,
111
kono
parents: 68
diff changeset
2283 "16#%" HOST_WIDE_INT_PRINT "x",
kono
parents: 68
diff changeset
2284 val.elt (val.get_len () - 1));
kono
parents: 68
diff changeset
2285 for (i = val.get_len () - 2; i >= 0; i--)
kono
parents: 68
diff changeset
2286 sprintf (pp_buffer (buffer)->digit_buffer,
kono
parents: 68
diff changeset
2287 HOST_WIDE_INT_PRINT_PADDED_HEX, val.elt (i));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2288 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2289 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2290 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2291
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2292 case REAL_CST:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2293 case FIXED_CST:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2294 case COMPLEX_CST:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2295 case STRING_CST:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2296 case VECTOR_CST:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2297 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2298
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2299 case TYPE_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2300 if (DECL_IS_BUILTIN (node))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2301 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2302 /* Don't print the declaration of built-in types. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2303 if (name_only)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2304 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2305 /* If we're in the middle of a declaration, defaults to
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2306 System.Address. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2307 if (package_prefix)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2308 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2309 append_withs ("System", false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2310 pp_string (buffer, "System.Address");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2311 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2312 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2313 pp_string (buffer, "address");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2314 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2315 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2316 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2317
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2318 if (name_only)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2319 dump_ada_decl_name (buffer, node, limited_access);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2320 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2321 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2322 if (is_tagged_type (TREE_TYPE (node)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2323 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2324 int first = true;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2325
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2326 /* Look for ancestors. */
111
kono
parents: 68
diff changeset
2327 for (tree fld = TYPE_FIELDS (TREE_TYPE (node));
kono
parents: 68
diff changeset
2328 fld;
kono
parents: 68
diff changeset
2329 fld = TREE_CHAIN (fld))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2330 {
111
kono
parents: 68
diff changeset
2331 if (!DECL_NAME (fld) && is_tagged_type (TREE_TYPE (fld)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2332 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2333 if (first)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2334 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2335 pp_string (buffer, "limited new ");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2336 first = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2337 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2338 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2339 pp_string (buffer, " and ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2340
111
kono
parents: 68
diff changeset
2341 dump_ada_decl_name (buffer, TYPE_NAME (TREE_TYPE (fld)),
kono
parents: 68
diff changeset
2342 false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2343 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2344 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2345
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2346 pp_string (buffer, first ? "tagged limited " : " with ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2347 }
111
kono
parents: 68
diff changeset
2348 else if (has_nontrivial_methods (TREE_TYPE (node)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2349 pp_string (buffer, "limited ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2350
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2351 dump_ada_node (buffer, TREE_TYPE (node), type, spc, false, false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2352 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2353 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2354
111
kono
parents: 68
diff changeset
2355 case FUNCTION_DECL:
kono
parents: 68
diff changeset
2356 case CONST_DECL:
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2357 case VAR_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2358 case PARM_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2359 case FIELD_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2360 case NAMESPACE_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2361 dump_ada_decl_name (buffer, node, false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2362 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2363
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2364 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2365 /* Ignore other nodes (e.g. expressions). */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2366 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2367 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2368
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2369 return 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2370 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2371
111
kono
parents: 68
diff changeset
2372 /* Dump in BUFFER NODE's methods. SPC is the indentation level. Return 1 if
kono
parents: 68
diff changeset
2373 methods were printed, 0 otherwise. */
kono
parents: 68
diff changeset
2374
kono
parents: 68
diff changeset
2375 static int
kono
parents: 68
diff changeset
2376 dump_ada_methods (pretty_printer *buffer, tree node, int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2377 {
111
kono
parents: 68
diff changeset
2378 if (!has_nontrivial_methods (node))
kono
parents: 68
diff changeset
2379 return 0;
kono
parents: 68
diff changeset
2380
kono
parents: 68
diff changeset
2381 pp_semicolon (buffer);
kono
parents: 68
diff changeset
2382
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2383 int res = 1;
111
kono
parents: 68
diff changeset
2384 for (tree fld = TYPE_FIELDS (node); fld; fld = DECL_CHAIN (fld))
kono
parents: 68
diff changeset
2385 if (TREE_CODE (fld) == FUNCTION_DECL)
kono
parents: 68
diff changeset
2386 {
kono
parents: 68
diff changeset
2387 if (res)
kono
parents: 68
diff changeset
2388 {
kono
parents: 68
diff changeset
2389 pp_newline (buffer);
kono
parents: 68
diff changeset
2390 pp_newline (buffer);
kono
parents: 68
diff changeset
2391 }
kono
parents: 68
diff changeset
2392
kono
parents: 68
diff changeset
2393 res = dump_ada_declaration (buffer, fld, node, spc);
kono
parents: 68
diff changeset
2394 }
kono
parents: 68
diff changeset
2395
kono
parents: 68
diff changeset
2396 return 1;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2397 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2398
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2399 /* Dump in BUFFER a forward declaration for TYPE present inside T.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2400 SPC is the indentation level. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2401
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2402 static void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2403 dump_forward_type (pretty_printer *buffer, tree type, tree t, int spc)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2404 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2405 tree decl = get_underlying_decl (type);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2406
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2407 /* Anonymous pointer and function types. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2408 if (!decl)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2409 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2410 if (TREE_CODE (type) == POINTER_TYPE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2411 dump_forward_type (buffer, TREE_TYPE (type), t, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2412 else if (TREE_CODE (type) == FUNCTION_TYPE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2413 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2414 function_args_iterator args_iter;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2415 tree arg;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2416 dump_forward_type (buffer, TREE_TYPE (type), t, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2417 FOREACH_FUNCTION_ARGS (type, arg, args_iter)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2418 dump_forward_type (buffer, arg, t, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2419 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2420 return;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2421 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2422
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2423 if (DECL_IS_BUILTIN (decl) || TREE_VISITED (decl))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2424 return;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2425
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2426 /* Forward declarations are only needed within a given file. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2427 if (DECL_SOURCE_FILE (decl) != DECL_SOURCE_FILE (t))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2428 return;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2429
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2430 /* Generate an incomplete type declaration. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2431 pp_string (buffer, "type ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2432 dump_ada_node (buffer, decl, NULL_TREE, spc, false, true);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2433 pp_semicolon (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2434 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2435
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2436 /* Only one incomplete declaration is legal for a given type. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2437 TREE_VISITED (decl) = 1;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2438 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2439
111
kono
parents: 68
diff changeset
2440 static void dump_nested_type (pretty_printer *, tree, tree, tree, int);
kono
parents: 68
diff changeset
2441
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2442 /* Dump in BUFFER anonymous types nested inside T's definition.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2443 PARENT is the parent node of T. SPC is the indentation level.
111
kono
parents: 68
diff changeset
2444
kono
parents: 68
diff changeset
2445 In C anonymous nested tagged types have no name whereas in C++ they have
kono
parents: 68
diff changeset
2446 one. In C their TYPE_DECL is at top level whereas in C++ it is nested.
kono
parents: 68
diff changeset
2447 In both languages untagged types (pointers and arrays) have no name.
kono
parents: 68
diff changeset
2448 In C++ the nested TYPE_DECLs can come after their associated FIELD_DECL.
kono
parents: 68
diff changeset
2449
kono
parents: 68
diff changeset
2450 Therefore, in order to have a common processing for both languages, we
kono
parents: 68
diff changeset
2451 disregard anonymous TYPE_DECLs at top level and here we make a first
kono
parents: 68
diff changeset
2452 pass on the nested TYPE_DECLs and a second pass on the unnamed types. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2453
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2454 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2455 dump_nested_types (pretty_printer *buffer, tree t, tree parent, int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2456 {
111
kono
parents: 68
diff changeset
2457 tree type, field;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2458
111
kono
parents: 68
diff changeset
2459 /* Find possible anonymous pointers/arrays/structs/unions recursively. */
kono
parents: 68
diff changeset
2460 type = TREE_TYPE (t);
kono
parents: 68
diff changeset
2461 if (type == NULL_TREE)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2462 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2463
111
kono
parents: 68
diff changeset
2464 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
kono
parents: 68
diff changeset
2465 if (TREE_CODE (field) == TYPE_DECL
kono
parents: 68
diff changeset
2466 && DECL_NAME (field) != DECL_NAME (t)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2467 && !DECL_ORIGINAL_TYPE (field)
111
kono
parents: 68
diff changeset
2468 && TYPE_NAME (TREE_TYPE (field)) != TYPE_NAME (type))
kono
parents: 68
diff changeset
2469 dump_nested_type (buffer, field, t, parent, spc);
kono
parents: 68
diff changeset
2470
kono
parents: 68
diff changeset
2471 for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
kono
parents: 68
diff changeset
2472 if (TREE_CODE (field) == FIELD_DECL && !TYPE_NAME (TREE_TYPE (field)))
kono
parents: 68
diff changeset
2473 dump_nested_type (buffer, field, t, parent, spc);
kono
parents: 68
diff changeset
2474 }
kono
parents: 68
diff changeset
2475
kono
parents: 68
diff changeset
2476 /* Dump in BUFFER the anonymous type of FIELD inside T.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2477 PARENT is the parent node of T. SPC is the indentation level. */
111
kono
parents: 68
diff changeset
2478
kono
parents: 68
diff changeset
2479 static void
kono
parents: 68
diff changeset
2480 dump_nested_type (pretty_printer *buffer, tree field, tree t, tree parent,
kono
parents: 68
diff changeset
2481 int spc)
kono
parents: 68
diff changeset
2482 {
kono
parents: 68
diff changeset
2483 tree field_type = TREE_TYPE (field);
kono
parents: 68
diff changeset
2484 tree decl, tmp;
kono
parents: 68
diff changeset
2485
kono
parents: 68
diff changeset
2486 switch (TREE_CODE (field_type))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2487 {
111
kono
parents: 68
diff changeset
2488 case POINTER_TYPE:
kono
parents: 68
diff changeset
2489 tmp = TREE_TYPE (field_type);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2490 dump_forward_type (buffer, tmp, t, spc);
111
kono
parents: 68
diff changeset
2491 break;
kono
parents: 68
diff changeset
2492
kono
parents: 68
diff changeset
2493 case ARRAY_TYPE:
kono
parents: 68
diff changeset
2494 tmp = TREE_TYPE (field_type);
kono
parents: 68
diff changeset
2495 while (TREE_CODE (tmp) == ARRAY_TYPE)
kono
parents: 68
diff changeset
2496 tmp = TREE_TYPE (tmp);
kono
parents: 68
diff changeset
2497 decl = get_underlying_decl (tmp);
kono
parents: 68
diff changeset
2498 if (decl && !DECL_NAME (decl) && !TREE_VISITED (decl))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2499 {
111
kono
parents: 68
diff changeset
2500 /* Generate full declaration. */
kono
parents: 68
diff changeset
2501 dump_nested_type (buffer, decl, t, parent, spc);
kono
parents: 68
diff changeset
2502 TREE_VISITED (decl) = 1;
kono
parents: 68
diff changeset
2503 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2504 else if (!decl && TREE_CODE (tmp) == POINTER_TYPE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2505 dump_forward_type (buffer, TREE_TYPE (tmp), t, spc);
111
kono
parents: 68
diff changeset
2506
kono
parents: 68
diff changeset
2507 /* Special case char arrays. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2508 if (is_char_array (field_type))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2509 pp_string (buffer, "subtype ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2510 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2511 pp_string (buffer, "type ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2512
111
kono
parents: 68
diff changeset
2513 dump_ada_double_name (buffer, parent, field);
kono
parents: 68
diff changeset
2514 pp_string (buffer, " is ");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2515 dump_ada_array_type (buffer, field_type, parent, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2516 pp_semicolon (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2517 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2518 break;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2519
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2520 case ENUMERAL_TYPE:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2521 if (is_simple_enum (field_type))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2522 pp_string (buffer, "type ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2523 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2524 pp_string (buffer, "subtype ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2525
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2526 if (TYPE_NAME (field_type))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2527 dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2528 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2529 dump_ada_double_name (buffer, parent, field);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2530 pp_string (buffer, " is ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2531 dump_ada_enum_type (buffer, field_type, spc);
111
kono
parents: 68
diff changeset
2532 pp_semicolon (buffer);
kono
parents: 68
diff changeset
2533 newline_and_indent (buffer, spc);
kono
parents: 68
diff changeset
2534 break;
kono
parents: 68
diff changeset
2535
kono
parents: 68
diff changeset
2536 case RECORD_TYPE:
kono
parents: 68
diff changeset
2537 case UNION_TYPE:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2538 dump_nested_types (buffer, field, t, spc);
111
kono
parents: 68
diff changeset
2539
kono
parents: 68
diff changeset
2540 pp_string (buffer, "type ");
kono
parents: 68
diff changeset
2541
kono
parents: 68
diff changeset
2542 if (TYPE_NAME (field_type))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2543 dump_ada_node (buffer, field_type, NULL_TREE, spc, false, true);
111
kono
parents: 68
diff changeset
2544 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2545 dump_ada_double_name (buffer, parent, field);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2546
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2547 if (TREE_CODE (field_type) == UNION_TYPE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2548 pp_string (buffer, " (discr : unsigned := 0)");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2549
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2550 pp_string (buffer, " is ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2551 dump_ada_structure (buffer, field_type, t, true, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2552
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2553 pp_string (buffer, "with Convention => C_Pass_By_Copy");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2554
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2555 if (TREE_CODE (field_type) == UNION_TYPE)
111
kono
parents: 68
diff changeset
2556 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2557 pp_comma (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2558 newline_and_indent (buffer, spc + 5);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2559 pp_string (buffer, "Unchecked_Union => True");
111
kono
parents: 68
diff changeset
2560 }
kono
parents: 68
diff changeset
2561
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2562 pp_semicolon (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2563 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2564 break;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2565
111
kono
parents: 68
diff changeset
2566 default:
kono
parents: 68
diff changeset
2567 break;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2568 }
111
kono
parents: 68
diff changeset
2569 }
kono
parents: 68
diff changeset
2570
kono
parents: 68
diff changeset
2571 /* Dump in BUFFER constructor spec corresponding to T for TYPE. */
kono
parents: 68
diff changeset
2572
kono
parents: 68
diff changeset
2573 static void
kono
parents: 68
diff changeset
2574 print_constructor (pretty_printer *buffer, tree t, tree type)
kono
parents: 68
diff changeset
2575 {
kono
parents: 68
diff changeset
2576 tree decl_name = DECL_NAME (TYPE_NAME (type));
kono
parents: 68
diff changeset
2577
kono
parents: 68
diff changeset
2578 pp_string (buffer, "New_");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2579 pp_ada_tree_identifier (buffer, decl_name, t, false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2580 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2581
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2582 /* Dump in BUFFER destructor spec corresponding to T. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2583
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2584 static void
111
kono
parents: 68
diff changeset
2585 print_destructor (pretty_printer *buffer, tree t, tree type)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2586 {
111
kono
parents: 68
diff changeset
2587 tree decl_name = DECL_NAME (TYPE_NAME (type));
kono
parents: 68
diff changeset
2588
kono
parents: 68
diff changeset
2589 pp_string (buffer, "Delete_");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2590 pp_ada_tree_identifier (buffer, decl_name, t, false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2591 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2592
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2593 /* Return the name of type T. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2594
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2595 static const char *
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2596 type_name (tree t)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2597 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2598 tree n = TYPE_NAME (t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2599
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2600 if (TREE_CODE (n) == IDENTIFIER_NODE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2601 return IDENTIFIER_POINTER (n);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2602 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2603 return IDENTIFIER_POINTER (DECL_NAME (n));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2604 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2605
111
kono
parents: 68
diff changeset
2606 /* Dump in BUFFER the declaration of a variable T of type TYPE in Ada syntax.
kono
parents: 68
diff changeset
2607 SPC is the indentation level. Return 1 if a declaration was printed,
kono
parents: 68
diff changeset
2608 0 otherwise. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2609
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2610 static int
111
kono
parents: 68
diff changeset
2611 dump_ada_declaration (pretty_printer *buffer, tree t, tree type, int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2612 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2613 bool is_var = false;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2614 bool need_indent = false;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2615 bool is_class = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2616 tree name = TYPE_NAME (TREE_TYPE (t));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2617 tree decl_name = DECL_NAME (t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2618 tree orig = NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2619
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2620 if (cpp_check && cpp_check (t, IS_TEMPLATE))
111
kono
parents: 68
diff changeset
2621 return dump_ada_template (buffer, t, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2622
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2623 /* Skip enumeral values: will be handled as part of the type itself. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2624 if (TREE_CODE (t) == CONST_DECL && TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2625 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2626
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2627 if (TREE_CODE (t) == TYPE_DECL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2628 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2629 orig = DECL_ORIGINAL_TYPE (t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2630
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2631 if (orig && TYPE_STUB_DECL (orig))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2632 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2633 tree stub = TYPE_STUB_DECL (orig);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2634 tree typ = TREE_TYPE (stub);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2635
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2636 if (TYPE_NAME (typ))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2637 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2638 /* If the types have the same name (ignoring casing), then ignore
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2639 the second type, but forward declare the first if need be. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2640 if (type_name (typ) == type_name (TREE_TYPE (t))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2641 || !strcasecmp (type_name (typ), type_name (TREE_TYPE (t))))
111
kono
parents: 68
diff changeset
2642 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2643 if (RECORD_OR_UNION_TYPE_P (typ) && !TREE_VISITED (stub))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2644 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2645 INDENT (spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2646 dump_forward_type (buffer, typ, t, 0);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2647 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2648
111
kono
parents: 68
diff changeset
2649 TREE_VISITED (t) = 1;
kono
parents: 68
diff changeset
2650 return 0;
kono
parents: 68
diff changeset
2651 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2652
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2653 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2654
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2655 if (RECORD_OR_UNION_TYPE_P (typ) && !TREE_VISITED (stub))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2656 dump_forward_type (buffer, typ, t, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2657
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2658 pp_string (buffer, "subtype ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2659 dump_ada_node (buffer, t, type, spc, false, true);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2660 pp_string (buffer, " is ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2661 dump_ada_node (buffer, typ, type, spc, false, true);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2662 pp_string (buffer, "; -- ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2663 dump_sloc (buffer, t);
111
kono
parents: 68
diff changeset
2664
kono
parents: 68
diff changeset
2665 TREE_VISITED (t) = 1;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2666 return 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2667 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2668 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2669
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2670 /* Skip unnamed or anonymous structs/unions/enum types. */
111
kono
parents: 68
diff changeset
2671 if (!orig && !decl_name && !name
kono
parents: 68
diff changeset
2672 && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (t))
kono
parents: 68
diff changeset
2673 || TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE))
kono
parents: 68
diff changeset
2674 return 0;
kono
parents: 68
diff changeset
2675
kono
parents: 68
diff changeset
2676 /* Skip anonymous enum types (duplicates of real types). */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2677 if (!orig
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2678 && TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2679 && decl_name
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2680 && (*IDENTIFIER_POINTER (decl_name) == '.'
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2681 || *IDENTIFIER_POINTER (decl_name) == '$'))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2682 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2683
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2684 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2685
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2686 switch (TREE_CODE (TREE_TYPE (t)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2687 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2688 case RECORD_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2689 case UNION_TYPE:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2690 if (!COMPLETE_TYPE_P (TREE_TYPE (t)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2691 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2692 pp_string (buffer, "type ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2693 dump_ada_node (buffer, t, type, spc, false, true);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2694 pp_string (buffer, " is null record; -- incomplete struct");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2695 TREE_VISITED (t) = 1;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2696 return 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2697 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2698
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2699 if (decl_name
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2700 && (*IDENTIFIER_POINTER (decl_name) == '.'
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2701 || *IDENTIFIER_POINTER (decl_name) == '$'))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2702 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2703 pp_string (buffer, "-- skipped anonymous struct ");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2704 dump_ada_node (buffer, t, type, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2705 TREE_VISITED (t) = 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2706 return 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2707 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2708
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2709 /* ??? Packed record layout is not supported. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2710 if (TYPE_PACKED (TREE_TYPE (t)))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2711 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2712 warning_at (DECL_SOURCE_LOCATION (t), 0,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2713 "unsupported record layout");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2714 pp_string (buffer, "pragma Compile_Time_Warning (True, ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2715 pp_string (buffer, "\"probably incorrect record layout\");");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2716 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2717 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2718
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2719 if (orig && TYPE_NAME (orig))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2720 pp_string (buffer, "subtype ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2721 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2722 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2723 dump_nested_types (buffer, t, t, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2724
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2725 if (separate_class_package (t))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2726 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2727 is_class = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2728 pp_string (buffer, "package Class_");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2729 dump_ada_node (buffer, t, type, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2730 pp_string (buffer, " is");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2731 spc += INDENT_INCR;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2732 newline_and_indent (buffer, spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2733 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2734
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2735 pp_string (buffer, "type ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2736 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2737 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2738
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2739 case POINTER_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2740 case REFERENCE_TYPE:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2741 dump_forward_type (buffer, TREE_TYPE (TREE_TYPE (t)), t, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2742 /* fallthrough */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2743
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2744 case ARRAY_TYPE:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2745 if ((orig && TYPE_NAME (orig)) || is_char_array (TREE_TYPE (t)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2746 pp_string (buffer, "subtype ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2747 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2748 pp_string (buffer, "type ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2749 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2750
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2751 case FUNCTION_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2752 pp_string (buffer, "-- skipped function type ");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2753 dump_ada_node (buffer, t, type, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2754 return 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2755
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2756 case ENUMERAL_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2757 if ((orig && TYPE_NAME (orig) && orig != TREE_TYPE (t))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2758 || !is_simple_enum (TREE_TYPE (t)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2759 pp_string (buffer, "subtype ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2760 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2761 pp_string (buffer, "type ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2762 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2763
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2764 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2765 pp_string (buffer, "subtype ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2766 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2767 TREE_VISITED (t) = 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2768 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2769 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2770 {
111
kono
parents: 68
diff changeset
2771 if (VAR_P (t)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2772 && decl_name
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2773 && *IDENTIFIER_POINTER (decl_name) == '_')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2774 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2775
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2776 need_indent = true;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2777 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2778
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2779 /* Print the type and name. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2780 if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2781 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2782 if (need_indent)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2783 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2784
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2785 /* Print variable's name. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2786 dump_ada_node (buffer, t, type, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2787
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2788 if (TREE_CODE (t) == TYPE_DECL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2789 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2790 pp_string (buffer, " is ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2791
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2792 if (orig && TYPE_NAME (orig))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2793 dump_ada_node (buffer, TYPE_NAME (orig), type, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2794 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2795 dump_ada_array_type (buffer, TREE_TYPE (t), type, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2796 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2797 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2798 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2799 tree tmp = TYPE_NAME (TREE_TYPE (t));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2800
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2801 if (spc == INDENT_INCR || TREE_STATIC (t))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2802 is_var = true;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2803
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2804 pp_string (buffer, " : ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2805
111
kono
parents: 68
diff changeset
2806 if (TREE_CODE (TREE_TYPE (TREE_TYPE (t))) != POINTER_TYPE)
kono
parents: 68
diff changeset
2807 pp_string (buffer, "aliased ");
kono
parents: 68
diff changeset
2808
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2809 if (tmp)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2810 dump_ada_node (buffer, tmp, type, spc, false, true);
111
kono
parents: 68
diff changeset
2811 else if (type)
kono
parents: 68
diff changeset
2812 dump_ada_double_name (buffer, type, t);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2813 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2814 dump_ada_array_type (buffer, TREE_TYPE (t), type, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2815 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2816 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2817 else if (TREE_CODE (t) == FUNCTION_DECL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2818 {
111
kono
parents: 68
diff changeset
2819 bool is_abstract_class = false;
kono
parents: 68
diff changeset
2820 bool is_method = TREE_CODE (TREE_TYPE (t)) == METHOD_TYPE;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2821 tree decl_name = DECL_NAME (t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2822 bool is_abstract = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2823 bool is_constructor = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2824 bool is_destructor = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2825 bool is_copy_constructor = false;
111
kono
parents: 68
diff changeset
2826 bool is_move_constructor = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2827
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2828 if (!decl_name)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2829 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2830
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2831 if (cpp_check)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2832 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2833 is_abstract = cpp_check (t, IS_ABSTRACT);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2834 is_constructor = cpp_check (t, IS_CONSTRUCTOR);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2835 is_destructor = cpp_check (t, IS_DESTRUCTOR);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2836 is_copy_constructor = cpp_check (t, IS_COPY_CONSTRUCTOR);
111
kono
parents: 68
diff changeset
2837 is_move_constructor = cpp_check (t, IS_MOVE_CONSTRUCTOR);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2838 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2839
111
kono
parents: 68
diff changeset
2840 /* Skip copy constructors and C++11 move constructors: some are internal
kono
parents: 68
diff changeset
2841 only and those that are not cannot be called easily from Ada. */
kono
parents: 68
diff changeset
2842 if (is_copy_constructor || is_move_constructor)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2843 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2844
111
kono
parents: 68
diff changeset
2845 if (is_constructor || is_destructor)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2846 {
111
kono
parents: 68
diff changeset
2847 /* ??? Skip implicit constructors/destructors for now. */
kono
parents: 68
diff changeset
2848 if (DECL_ARTIFICIAL (t))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2849 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2850
111
kono
parents: 68
diff changeset
2851 /* Only consider constructors/destructors for complete objects. */
kono
parents: 68
diff changeset
2852 if (strncmp (IDENTIFIER_POINTER (decl_name), "__ct_comp", 9) != 0
kono
parents: 68
diff changeset
2853 && strncmp (IDENTIFIER_POINTER (decl_name), "__dt_comp", 9) != 0)
kono
parents: 68
diff changeset
2854 return 0;
kono
parents: 68
diff changeset
2855 }
kono
parents: 68
diff changeset
2856
kono
parents: 68
diff changeset
2857 /* If this function has an entry in the vtable, we cannot omit it. */
kono
parents: 68
diff changeset
2858 else if (!DECL_VINDEX (t) && *IDENTIFIER_POINTER (decl_name) == '_')
kono
parents: 68
diff changeset
2859 {
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2860 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2861 pp_string (buffer, "-- skipped func ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2862 pp_string (buffer, IDENTIFIER_POINTER (decl_name));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2863 return 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2864 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2865
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2866 if (need_indent)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2867 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2868
111
kono
parents: 68
diff changeset
2869 if (VOID_TYPE_P (TREE_TYPE (TREE_TYPE (t))) && !is_constructor)
kono
parents: 68
diff changeset
2870 pp_string (buffer, "procedure ");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2871 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2872 pp_string (buffer, "function ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2873
111
kono
parents: 68
diff changeset
2874 if (is_constructor)
kono
parents: 68
diff changeset
2875 print_constructor (buffer, t, type);
kono
parents: 68
diff changeset
2876 else if (is_destructor)
kono
parents: 68
diff changeset
2877 print_destructor (buffer, t, type);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2878 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2879 dump_ada_decl_name (buffer, t, false);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2880
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2881 dump_ada_function_declaration
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2882 (buffer, t, is_method, is_constructor, is_destructor, spc);
111
kono
parents: 68
diff changeset
2883
kono
parents: 68
diff changeset
2884 if (is_constructor && RECORD_OR_UNION_TYPE_P (type))
kono
parents: 68
diff changeset
2885 for (tree fld = TYPE_FIELDS (type); fld; fld = DECL_CHAIN (fld))
kono
parents: 68
diff changeset
2886 if (TREE_CODE (fld) == FUNCTION_DECL && cpp_check (fld, IS_ABSTRACT))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2887 {
111
kono
parents: 68
diff changeset
2888 is_abstract_class = true;
kono
parents: 68
diff changeset
2889 break;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2890 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2891
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2892 if (is_abstract || is_abstract_class)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2893 pp_string (buffer, " is abstract");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2894
111
kono
parents: 68
diff changeset
2895 if (is_abstract || !DECL_ASSEMBLER_NAME (t))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2896 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2897 pp_semicolon (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2898 pp_string (buffer, " -- ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2899 dump_sloc (buffer, t);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2900 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2901 else if (is_constructor)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2902 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2903 pp_semicolon (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2904 pp_string (buffer, " -- ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2905 dump_sloc (buffer, t);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2906
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2907 newline_and_indent (buffer, spc);
111
kono
parents: 68
diff changeset
2908 pp_string (buffer, "pragma CPP_Constructor (");
kono
parents: 68
diff changeset
2909 print_constructor (buffer, t, type);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2910 pp_string (buffer, ", \"");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2911 pp_asm_name (buffer, t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2912 pp_string (buffer, "\");");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2913 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2914 else
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2915 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2916 pp_string (buffer, " -- ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2917 dump_sloc (buffer, t);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2918
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2919 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2920 dump_ada_import (buffer, t, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2921 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2922
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2923 return 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2924 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2925 else if (TREE_CODE (t) == TYPE_DECL && !orig)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2926 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2927 bool is_interface = false;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2928 bool is_abstract_record = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2929
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2930 if (need_indent)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2931 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2932
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2933 /* Anonymous structs/unions. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2934 dump_ada_node (buffer, TREE_TYPE (t), t, spc, false, true);
111
kono
parents: 68
diff changeset
2935
kono
parents: 68
diff changeset
2936 if (TREE_CODE (TREE_TYPE (t)) == UNION_TYPE)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2937 pp_string (buffer, " (discr : unsigned := 0)");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2938
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2939 pp_string (buffer, " is ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2940
111
kono
parents: 68
diff changeset
2941 /* Check whether we have an Ada interface compatible class.
kono
parents: 68
diff changeset
2942 That is only have a vtable non-static data member and no
kono
parents: 68
diff changeset
2943 non-abstract methods. */
kono
parents: 68
diff changeset
2944 if (cpp_check
kono
parents: 68
diff changeset
2945 && RECORD_OR_UNION_TYPE_P (TREE_TYPE (t)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2946 {
111
kono
parents: 68
diff changeset
2947 bool has_fields = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2948
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2949 /* Check that there are no fields other than the virtual table. */
111
kono
parents: 68
diff changeset
2950 for (tree fld = TYPE_FIELDS (TREE_TYPE (t));
kono
parents: 68
diff changeset
2951 fld;
kono
parents: 68
diff changeset
2952 fld = TREE_CHAIN (fld))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2953 {
111
kono
parents: 68
diff changeset
2954 if (TREE_CODE (fld) == FIELD_DECL)
kono
parents: 68
diff changeset
2955 {
kono
parents: 68
diff changeset
2956 if (!has_fields && DECL_VIRTUAL_P (fld))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2957 is_interface = true;
111
kono
parents: 68
diff changeset
2958 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2959 is_interface = false;
111
kono
parents: 68
diff changeset
2960 has_fields = true;
kono
parents: 68
diff changeset
2961 }
kono
parents: 68
diff changeset
2962 else if (TREE_CODE (fld) == FUNCTION_DECL
kono
parents: 68
diff changeset
2963 && !DECL_ARTIFICIAL (fld))
kono
parents: 68
diff changeset
2964 {
kono
parents: 68
diff changeset
2965 if (cpp_check (fld, IS_ABSTRACT))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2966 is_abstract_record = true;
111
kono
parents: 68
diff changeset
2967 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2968 is_interface = false;
111
kono
parents: 68
diff changeset
2969 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2970 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2971 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2972
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2973 TREE_VISITED (t) = 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2974 if (is_interface)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2975 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2976 pp_string (buffer, "limited interface -- ");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2977 dump_sloc (buffer, t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2978 newline_and_indent (buffer, spc);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2979 pp_string (buffer, "with Import => True,");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2980 newline_and_indent (buffer, spc + 5);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2981 pp_string (buffer, "Convention => CPP");
111
kono
parents: 68
diff changeset
2982
kono
parents: 68
diff changeset
2983 dump_ada_methods (buffer, TREE_TYPE (t), spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2984 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2985 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2986 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2987 if (is_abstract_record)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2988 pp_string (buffer, "abstract ");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2989 dump_ada_node (buffer, t, t, spc, false, false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2990 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2991 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2992 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2993 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2994 if (need_indent)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2995 INDENT (spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2996
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2997 if (TREE_CODE (t) == FIELD_DECL && DECL_NAME (t))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2998 check_name (buffer, t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2999
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3000 /* Print variable/type's name. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3001 dump_ada_node (buffer, t, t, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3002
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3003 if (TREE_CODE (t) == TYPE_DECL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3004 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3005 const bool is_subtype = TYPE_NAME (orig);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3006
111
kono
parents: 68
diff changeset
3007 if (!is_subtype && TREE_CODE (TREE_TYPE (t)) == UNION_TYPE)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3008 pp_string (buffer, " (discr : unsigned := 0)");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3009
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3010 pp_string (buffer, " is ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3011
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3012 dump_ada_node (buffer, orig, t, spc, false, is_subtype);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3013 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3014 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3015 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3016 if (spc == INDENT_INCR || TREE_STATIC (t))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3017 is_var = true;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3018
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3019 pp_string (buffer, " : ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3020
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3021 if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (t))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3022 || TREE_CODE (TREE_TYPE (t)) == ENUMERAL_TYPE)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3023 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3024 if (TYPE_NAME (TREE_TYPE (t))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3025 || TREE_CODE (TREE_TYPE (t)) != ENUMERAL_TYPE)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3026 pp_string (buffer, "aliased ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3027
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3028 if (TREE_READONLY (t) && TREE_CODE (t) != FIELD_DECL)
111
kono
parents: 68
diff changeset
3029 pp_string (buffer, "constant ");
kono
parents: 68
diff changeset
3030
kono
parents: 68
diff changeset
3031 if (TYPE_NAME (TREE_TYPE (t)))
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3032 dump_ada_node (buffer, TREE_TYPE (t), t, spc, false, true);
111
kono
parents: 68
diff changeset
3033 else if (type)
kono
parents: 68
diff changeset
3034 dump_ada_double_name (buffer, type, t);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3035 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3036 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3037 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3038 if (TREE_CODE (TREE_TYPE (t)) != POINTER_TYPE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3039 && (TYPE_NAME (TREE_TYPE (t))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3040 || TREE_CODE (TREE_TYPE (t)) != INTEGER_TYPE))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3041 pp_string (buffer, "aliased ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3042
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3043 if (TREE_READONLY (t) && TREE_CODE (t) != FIELD_DECL)
111
kono
parents: 68
diff changeset
3044 pp_string (buffer, "constant ");
kono
parents: 68
diff changeset
3045
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3046 dump_ada_node (buffer, TREE_TYPE (t), t, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3047 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3048 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3049 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3050
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3051 if (is_class)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3052 {
111
kono
parents: 68
diff changeset
3053 spc -= INDENT_INCR;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3054 newline_and_indent (buffer, spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3055 pp_string (buffer, "end;");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3056 newline_and_indent (buffer, spc);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3057 pp_string (buffer, "use Class_");
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3058 dump_ada_node (buffer, t, type, spc, false, true);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3059 pp_semicolon (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3060 pp_newline (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3061
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3062 /* All needed indentation/newline performed already, so return 0. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3063 return 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3064 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3065 else if (is_var)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3066 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3067 pp_string (buffer, " -- ");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3068 dump_sloc (buffer, t);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3069 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3070 dump_ada_import (buffer, t, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3071 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3072
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3073 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3074 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3075 pp_string (buffer, "; -- ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3076 dump_sloc (buffer, t);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3077 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3078
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3079 return 1;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3080 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3081
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3082 /* Dump in BUFFER a structure NODE of type TYPE in Ada syntax. If NESTED is
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3083 true, it's an anonymous nested type. SPC is the indentation level. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3084
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3085 static void
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3086 dump_ada_structure (pretty_printer *buffer, tree node, tree type, bool nested,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3087 int spc)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3088 {
111
kono
parents: 68
diff changeset
3089 const bool is_union = (TREE_CODE (node) == UNION_TYPE);
kono
parents: 68
diff changeset
3090 char buf[32];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3091 int field_num = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3092 int field_spc = spc + INDENT_INCR;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3093 int need_semicolon;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3094
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3095 bitfield_used = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3096
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3097 /* Print the contents of the structure. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3098 pp_string (buffer, "record");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3099
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3100 if (is_union)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3101 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3102 newline_and_indent (buffer, spc + INDENT_INCR);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3103 pp_string (buffer, "case discr is");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3104 field_spc = spc + INDENT_INCR * 3;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3105 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3106
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3107 pp_newline (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3108
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3109 /* Print the non-static fields of the structure. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3110 for (tree tmp = TYPE_FIELDS (node); tmp; tmp = TREE_CHAIN (tmp))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3111 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3112 /* Add parent field if needed. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3113 if (!DECL_NAME (tmp))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3114 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3115 if (!is_tagged_type (TREE_TYPE (tmp)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3116 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3117 if (!TYPE_NAME (TREE_TYPE (tmp)))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3118 dump_ada_declaration (buffer, tmp, type, field_spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3119 else
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3120 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3121 INDENT (field_spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3122
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3123 if (field_num == 0)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3124 pp_string (buffer, "parent : aliased ");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3125 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3126 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3127 sprintf (buf, "field_%d : aliased ", field_num + 1);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3128 pp_string (buffer, buf);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3129 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3130 dump_ada_decl_name (buffer, TYPE_NAME (TREE_TYPE (tmp)),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3131 false);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3132 pp_semicolon (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3133 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3134
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3135 pp_newline (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3136 field_num++;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3137 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3138 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3139 else if (TREE_CODE (tmp) == FIELD_DECL)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3140 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3141 /* Skip internal virtual table field. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3142 if (!DECL_VIRTUAL_P (tmp))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3143 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3144 if (is_union)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3145 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3146 if (TREE_CHAIN (tmp)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3147 && TREE_TYPE (TREE_CHAIN (tmp)) != node
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3148 && TREE_CODE (TREE_CHAIN (tmp)) != TYPE_DECL)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3149 sprintf (buf, "when %d =>", field_num);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3150 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3151 sprintf (buf, "when others =>");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3152
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3153 INDENT (spc + INDENT_INCR * 2);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3154 pp_string (buffer, buf);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3155 pp_newline (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3156 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3157
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3158 if (dump_ada_declaration (buffer, tmp, type, field_spc))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3159 {
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3160 pp_newline (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3161 field_num++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3162 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3163 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3164 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3165 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3166
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3167 if (is_union)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3168 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3169 INDENT (spc + INDENT_INCR);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3170 pp_string (buffer, "end case;");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3171 pp_newline (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3172 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3173
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3174 if (field_num == 0)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3175 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3176 INDENT (spc + INDENT_INCR);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3177 pp_string (buffer, "null;");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3178 pp_newline (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3179 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3180
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3181 INDENT (spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3182 pp_string (buffer, "end record");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3183
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3184 newline_and_indent (buffer, spc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3185
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3186 /* We disregard the methods for anonymous nested types. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3187 if (nested)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3188 return;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3189
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3190 if (has_nontrivial_methods (node))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3191 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3192 pp_string (buffer, "with Import => True,");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3193 newline_and_indent (buffer, spc + 5);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3194 pp_string (buffer, "Convention => CPP");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3195 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3196 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3197 pp_string (buffer, "with Convention => C_Pass_By_Copy");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3198
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3199 if (is_union)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3200 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3201 pp_comma (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3202 newline_and_indent (buffer, spc + 5);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3203 pp_string (buffer, "Unchecked_Union => True");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3204 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3205
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3206 if (bitfield_used)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3207 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3208 pp_comma (buffer);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3209 newline_and_indent (buffer, spc + 5);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3210 pp_string (buffer, "Pack => True");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3211 bitfield_used = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3212 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3213
111
kono
parents: 68
diff changeset
3214 need_semicolon = !dump_ada_methods (buffer, node, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3215
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3216 /* Print the static fields of the structure, if any. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3217 for (tree tmp = TYPE_FIELDS (node); tmp; tmp = TREE_CHAIN (tmp))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3218 {
111
kono
parents: 68
diff changeset
3219 if (TREE_CODE (tmp) == VAR_DECL && DECL_NAME (tmp))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3220 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3221 if (need_semicolon)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3222 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3223 need_semicolon = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3224 pp_semicolon (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3225 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3226 pp_newline (buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3227 pp_newline (buffer);
111
kono
parents: 68
diff changeset
3228 dump_ada_declaration (buffer, tmp, type, spc);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3229 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3230 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3231 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3232
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3233 /* Dump all the declarations in SOURCE_FILE to an Ada spec.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3234 COLLECT_ALL_REFS is a front-end callback used to collect all relevant
111
kono
parents: 68
diff changeset
3235 nodes for SOURCE_FILE. CHECK is used to perform C++ queries on nodes. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3236
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3237 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3238 dump_ads (const char *source_file,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3239 void (*collect_all_refs)(const char *),
111
kono
parents: 68
diff changeset
3240 int (*check)(tree, cpp_operation))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3241 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3242 char *ads_name;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3243 char *pkg_name;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3244 char *s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3245 FILE *f;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3246
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3247 pkg_name = get_ada_package (source_file);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3248
111
kono
parents: 68
diff changeset
3249 /* Construct the .ads filename and package name. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3250 ads_name = xstrdup (pkg_name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3251
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3252 for (s = ads_name; *s; s++)
111
kono
parents: 68
diff changeset
3253 if (*s == '.')
kono
parents: 68
diff changeset
3254 *s = '-';
kono
parents: 68
diff changeset
3255 else
kono
parents: 68
diff changeset
3256 *s = TOLOWER (*s);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3257
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3258 ads_name = reconcat (ads_name, ads_name, ".ads", NULL);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3259
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3260 /* Write out the .ads file. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3261 f = fopen (ads_name, "w");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3262 if (f)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3263 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3264 pretty_printer pp;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3265
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3266 pp_needs_newline (&pp) = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3267 pp.buffer->stream = f;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3268
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3269 /* Dump all relevant macros. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3270 dump_ada_macros (&pp, source_file);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3271
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3272 /* Reset the table of withs for this file. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3273 reset_ada_withs ();
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3274
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3275 (*collect_all_refs) (source_file);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3276
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3277 /* Dump all references. */
111
kono
parents: 68
diff changeset
3278 cpp_check = check;
kono
parents: 68
diff changeset
3279 dump_ada_nodes (&pp, source_file);
kono
parents: 68
diff changeset
3280
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3281 /* We require Ada 2012 syntax, so generate corresponding pragma.
111
kono
parents: 68
diff changeset
3282 Also, disable style checks since this file is auto-generated. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
3283 fprintf (f, "pragma Ada_2012;\npragma Style_Checks (Off);\n\n");
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3284
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3285 /* Dump withs. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3286 dump_ada_withs (f);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3287
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3288 fprintf (f, "\npackage %s is\n\n", pkg_name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3289 pp_write_text_to_stream (&pp);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3290 /* ??? need to free pp */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3291 fprintf (f, "end %s;\n", pkg_name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3292 fclose (f);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3293 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3294
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3295 free (ads_name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3296 free (pkg_name);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3297 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3298
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3299 static const char **source_refs = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3300 static int source_refs_used = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3301 static int source_refs_allocd = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3302
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3303 /* Add an entry for FILENAME to the table SOURCE_REFS. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3304
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3305 void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3306 collect_source_ref (const char *filename)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3307 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3308 int i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3309
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3310 if (!filename)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3311 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3312
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3313 if (source_refs_allocd == 0)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3314 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3315 source_refs_allocd = 1024;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3316 source_refs = XNEWVEC (const char *, source_refs_allocd);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3317 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3318
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3319 for (i = 0; i < source_refs_used; i++)
111
kono
parents: 68
diff changeset
3320 if (filename == source_refs[i])
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3321 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3322
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3323 if (source_refs_used == source_refs_allocd)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3324 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3325 source_refs_allocd *= 2;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3326 source_refs = XRESIZEVEC (const char *, source_refs, source_refs_allocd);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3327 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3328
111
kono
parents: 68
diff changeset
3329 source_refs[source_refs_used++] = filename;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3330 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3331
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3332 /* Main entry point: dump all Ada specs corresponding to SOURCE_REFS
111
kono
parents: 68
diff changeset
3333 using callbacks COLLECT_ALL_REFS and CHECK.
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3334 COLLECT_ALL_REFS is a front-end callback used to collect all relevant
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3335 nodes for a given source file.
111
kono
parents: 68
diff changeset
3336 CHECK is used to perform C++ queries on nodes, or NULL for the C
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3337 front-end. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3338
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3339 void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3340 dump_ada_specs (void (*collect_all_refs)(const char *),
111
kono
parents: 68
diff changeset
3341 int (*check)(tree, cpp_operation))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3342 {
111
kono
parents: 68
diff changeset
3343 /* Iterate over the list of files to dump specs for. */
kono
parents: 68
diff changeset
3344 for (int i = 0; i < source_refs_used; i++)
kono
parents: 68
diff changeset
3345 dump_ads (source_refs[i], collect_all_refs, check);
kono
parents: 68
diff changeset
3346
kono
parents: 68
diff changeset
3347 /* Free various tables. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3348 free (source_refs);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3349 }