annotate gcc/godump.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
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 /* Output Go language descriptions of types.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2008-2020 Free Software Foundation, Inc.
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Written by Ian Lance Taylor <iant@google.com>.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 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
8 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
9 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
10 version.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 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
13 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
14 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
15 for more details.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 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
18 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
19 <http://www.gnu.org/licenses/>. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 /* This file is used during the build process to emit Go language
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 descriptions of declarations from C header files. It uses the
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 debug info hooks to emit the descriptions. The Go language
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 descriptions then become part of the Go runtime support
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 library.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 All global names are output with a leading underscore, so that they
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 are all hidden in Go. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 #include "config.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 #include "system.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #include "coretypes.h"
111
kono
parents: 68
diff changeset
33 #include "tree.h"
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 #include "diagnostic-core.h"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #include "debug.h"
111
kono
parents: 68
diff changeset
36 #include "stor-layout.h"
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 /* We dump this information from the debug hooks. This gives us a
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 stable and maintainable API to hook into. In order to work
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 correctly when -g is used, we build our own hooks structure which
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 wraps the hooks we need to change. */
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 /* Our debug hooks. This is initialized by dump_go_spec_init. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 static struct gcc_debug_hooks go_debug_hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 /* The real debug hooks. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 static const struct gcc_debug_hooks *real_debug_hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 /* The file where we should write information. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 static FILE *go_dump_file;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 /* A queue of decls to output. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56
111
kono
parents: 68
diff changeset
57 static GTY(()) vec<tree, va_gc> *queue;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 /* A hash table of macros we have seen. */
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 static htab_t macro_hash;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
111
kono
parents: 68
diff changeset
63 /* The type of a value in macro_hash. */
kono
parents: 68
diff changeset
64
kono
parents: 68
diff changeset
65 struct macro_hash_value
kono
parents: 68
diff changeset
66 {
kono
parents: 68
diff changeset
67 /* The name stored in the hash table. */
kono
parents: 68
diff changeset
68 char *name;
kono
parents: 68
diff changeset
69 /* The value of the macro. */
kono
parents: 68
diff changeset
70 char *value;
kono
parents: 68
diff changeset
71 };
kono
parents: 68
diff changeset
72
kono
parents: 68
diff changeset
73 /* Returns the number of units necessary to represent an integer with the given
kono
parents: 68
diff changeset
74 PRECISION (in bits). */
kono
parents: 68
diff changeset
75
kono
parents: 68
diff changeset
76 static inline unsigned int
kono
parents: 68
diff changeset
77 precision_to_units (unsigned int precision)
kono
parents: 68
diff changeset
78 {
kono
parents: 68
diff changeset
79 return (precision + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
kono
parents: 68
diff changeset
80 }
kono
parents: 68
diff changeset
81
kono
parents: 68
diff changeset
82 /* Calculate the hash value for an entry in the macro hash table. */
kono
parents: 68
diff changeset
83
kono
parents: 68
diff changeset
84 static hashval_t
kono
parents: 68
diff changeset
85 macro_hash_hashval (const void *val)
kono
parents: 68
diff changeset
86 {
kono
parents: 68
diff changeset
87 const struct macro_hash_value *mhval = (const struct macro_hash_value *) val;
kono
parents: 68
diff changeset
88 return htab_hash_string (mhval->name);
kono
parents: 68
diff changeset
89 }
kono
parents: 68
diff changeset
90
kono
parents: 68
diff changeset
91 /* Compare values in the macro hash table for equality. */
kono
parents: 68
diff changeset
92
kono
parents: 68
diff changeset
93 static int
kono
parents: 68
diff changeset
94 macro_hash_eq (const void *v1, const void *v2)
kono
parents: 68
diff changeset
95 {
kono
parents: 68
diff changeset
96 const struct macro_hash_value *mhv1 = (const struct macro_hash_value *) v1;
kono
parents: 68
diff changeset
97 const struct macro_hash_value *mhv2 = (const struct macro_hash_value *) v2;
kono
parents: 68
diff changeset
98 return strcmp (mhv1->name, mhv2->name) == 0;
kono
parents: 68
diff changeset
99 }
kono
parents: 68
diff changeset
100
kono
parents: 68
diff changeset
101 /* Free values deleted from the macro hash table. */
kono
parents: 68
diff changeset
102
kono
parents: 68
diff changeset
103 static void
kono
parents: 68
diff changeset
104 macro_hash_del (void *v)
kono
parents: 68
diff changeset
105 {
kono
parents: 68
diff changeset
106 struct macro_hash_value *mhv = (struct macro_hash_value *) v;
kono
parents: 68
diff changeset
107 XDELETEVEC (mhv->name);
kono
parents: 68
diff changeset
108 XDELETEVEC (mhv->value);
kono
parents: 68
diff changeset
109 XDELETE (mhv);
kono
parents: 68
diff changeset
110 }
kono
parents: 68
diff changeset
111
kono
parents: 68
diff changeset
112 /* For the string hash tables. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114 static int
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 string_hash_eq (const void *y1, const void *y2)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117 return strcmp ((const char *) y1, (const char *) y2) == 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
119
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 /* A macro definition. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 go_define (unsigned int lineno, const char *buffer)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 const char *p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126 const char *name_end;
111
kono
parents: 68
diff changeset
127 size_t out_len;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128 char *out_buffer;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
129 char *q;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 bool saw_operand;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 bool need_operand;
111
kono
parents: 68
diff changeset
132 struct macro_hash_value *mhval;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 char *copy;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 hashval_t hashval;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 void **slot;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137 real_debug_hooks->define (lineno, buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 /* Skip macro functions. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 for (p = buffer; *p != '\0' && *p != ' '; ++p)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
141 if (*p == '(')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
144 if (*p == '\0')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 name_end = p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 ++p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150 if (*p == '\0')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 copy = XNEWVEC (char, name_end - buffer + 1);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 memcpy (copy, buffer, name_end - buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155 copy[name_end - buffer] = '\0';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156
111
kono
parents: 68
diff changeset
157 mhval = XNEW (struct macro_hash_value);
kono
parents: 68
diff changeset
158 mhval->name = copy;
kono
parents: 68
diff changeset
159 mhval->value = NULL;
kono
parents: 68
diff changeset
160
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 hashval = htab_hash_string (copy);
111
kono
parents: 68
diff changeset
162 slot = htab_find_slot_with_hash (macro_hash, mhval, hashval, NO_INSERT);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
163
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 /* For simplicity, we force all names to be hidden by adding an
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 initial underscore, and let the user undo this as needed. */
111
kono
parents: 68
diff changeset
166 out_len = strlen (p) * 2 + 1;
kono
parents: 68
diff changeset
167 out_buffer = XNEWVEC (char, out_len);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 q = out_buffer;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 saw_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 need_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 while (*p != '\0')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
173 switch (*p)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
174 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178 case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
179 case 'Y': case 'Z':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183 case 's': case 't': case 'u': case 'v': case 'w': case 'x':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
184 case 'y': case 'z':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
185 case '_':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
187 /* The start of an identifier. Technically we should also
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
188 worry about UTF-8 identifiers, but they are not a
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
189 problem for practical uses of -fdump-go-spec so we
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
190 don't worry about them. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 const char *start;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
192 char *n;
111
kono
parents: 68
diff changeset
193 struct macro_hash_value idval;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
194
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 if (saw_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 start = p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 while (ISALNUM (*p) || *p == '_')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
200 ++p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 n = XALLOCAVEC (char, p - start + 1);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 memcpy (n, start, p - start);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203 n[p - start] = '\0';
111
kono
parents: 68
diff changeset
204 idval.name = n;
kono
parents: 68
diff changeset
205 idval.value = NULL;
kono
parents: 68
diff changeset
206 if (htab_find (macro_hash, &idval) == NULL)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
208 /* This is a reference to a name which was not defined
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
209 as a macro. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
210 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
211 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
212
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 *q++ = '_';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214 memcpy (q, start, p - start);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 q += p - start;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
216
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 saw_operand = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 need_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
222 case '.':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 if (!ISDIGIT (p[1]))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
224 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
225 /* Fall through. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
226 case '0': case '1': case '2': case '3': case '4':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
227 case '5': case '6': case '7': case '8': case '9':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
229 const char *start;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
230 bool is_hex;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
231
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
232 start = p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
233 is_hex = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 if (*p == '0' && (p[1] == 'x' || p[1] == 'X'))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
236 p += 2;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 is_hex = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 while (ISDIGIT (*p) || *p == '.' || *p == 'e' || *p == 'E'
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 || (is_hex
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 && ((*p >= 'a' && *p <= 'f')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 || (*p >= 'A' && *p <= 'F'))))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
243 ++p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 memcpy (q, start, p - start);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 q += p - start;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 while (*p == 'u' || *p == 'U' || *p == 'l' || *p == 'L'
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 || *p == 'f' || *p == 'F'
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 || *p == 'd' || *p == 'D')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 /* Go doesn't use any of these trailing type
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 modifiers. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 ++p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 /* We'll pick up the exponent, if any, as an
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 expression. */
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 saw_operand = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
259 need_operand = false;
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 break;
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 case ' ': case '\t':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 case '(':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 /* Always OK, not part of an operand, presumed to start an
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 operand. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 saw_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 need_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 break;
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 case ')':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 /* OK if we don't need an operand, and presumed to indicate
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 an operand. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 if (need_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 saw_operand = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 break;
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 case '+': case '-':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 /* Always OK, but not part of an operand. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 saw_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 break;
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 case '*': case '/': case '%': case '|': case '&': case '^':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 /* Must be a binary operator. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 if (!saw_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 saw_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 need_operand = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 break;
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 case '=':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301 if (*p != '=')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 /* Must be a binary operator. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 if (!saw_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 saw_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 need_operand = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 case '!':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 if (*p == '=')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 /* Must be a binary operator. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316 if (!saw_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 saw_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 need_operand = true;
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 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 /* Must be a unary operator. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 if (saw_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 need_operand = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331 case '<': case '>':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 /* Must be a binary operand, may be << or >> or <= or >=. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 if (!saw_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 if (*p == *(p - 1) || *p == '=')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 saw_operand = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 need_operand = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 case '~':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 /* Must be a unary operand, must be translated for Go. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 if (saw_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346 *q++ = '^';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348 need_operand = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
349 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
350
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351 case '"':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 case '\'':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 {
111
kono
parents: 68
diff changeset
354 char quote;
kono
parents: 68
diff changeset
355 int count;
kono
parents: 68
diff changeset
356
kono
parents: 68
diff changeset
357 if (saw_operand)
kono
parents: 68
diff changeset
358 goto unknown;
kono
parents: 68
diff changeset
359 quote = *p;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 *q++ = *p++;
111
kono
parents: 68
diff changeset
361 count = 0;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 while (*p != quote)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 int c;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 if (*p == '\0')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368
111
kono
parents: 68
diff changeset
369 ++count;
kono
parents: 68
diff changeset
370
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 if (*p != '\\')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 continue;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 switch (*p)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 case '0': case '1': case '2': case '3':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 case '4': case '5': case '6': case '7':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 c = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 while (*p >= '0' && *p <= '7')
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 ++c;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388 /* Go octal characters are always 3
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 digits. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 if (c != 3)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 case 'x':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 c = 0;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 while (ISXDIGIT (*p))
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 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 ++c;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
402 /* Go hex characters are always 2 digits. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
403 if (c != 2)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
404 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
405 break;
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 case 'a': case 'b': case 'f': case 'n': case 'r':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
408 case 't': case 'v': case '\\': case '\'': case '"':
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 *q++ = *p++;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 }
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
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 *q++ = *p++;
111
kono
parents: 68
diff changeset
418
kono
parents: 68
diff changeset
419 if (quote == '\'' && count != 1)
kono
parents: 68
diff changeset
420 goto unknown;
kono
parents: 68
diff changeset
421
kono
parents: 68
diff changeset
422 saw_operand = true;
kono
parents: 68
diff changeset
423 need_operand = false;
kono
parents: 68
diff changeset
424
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
427
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 if (need_operand)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434 goto unknown;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435
111
kono
parents: 68
diff changeset
436 gcc_assert ((size_t) (q - out_buffer) < out_len);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
437 *q = '\0';
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
438
111
kono
parents: 68
diff changeset
439 mhval->value = out_buffer;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440
111
kono
parents: 68
diff changeset
441 if (slot == NULL)
kono
parents: 68
diff changeset
442 {
kono
parents: 68
diff changeset
443 slot = htab_find_slot_with_hash (macro_hash, mhval, hashval, INSERT);
kono
parents: 68
diff changeset
444 gcc_assert (slot != NULL && *slot == NULL);
kono
parents: 68
diff changeset
445 }
kono
parents: 68
diff changeset
446 else
kono
parents: 68
diff changeset
447 {
kono
parents: 68
diff changeset
448 if (*slot != NULL)
kono
parents: 68
diff changeset
449 macro_hash_del (*slot);
kono
parents: 68
diff changeset
450 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
451
111
kono
parents: 68
diff changeset
452 *slot = mhval;
kono
parents: 68
diff changeset
453
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 unknown:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457 fprintf (go_dump_file, "// unknowndefine %s\n", buffer);
111
kono
parents: 68
diff changeset
458 if (slot != NULL)
kono
parents: 68
diff changeset
459 htab_clear_slot (macro_hash, slot);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 XDELETEVEC (out_buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 XDELETEVEC (copy);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 /* A macro undef. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
467 go_undef (unsigned int lineno, const char *buffer)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 {
111
kono
parents: 68
diff changeset
469 struct macro_hash_value mhval;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 void **slot;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
471
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 real_debug_hooks->undef (lineno, buffer);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473
111
kono
parents: 68
diff changeset
474 mhval.name = CONST_CAST (char *, buffer);
kono
parents: 68
diff changeset
475 mhval.value = NULL;
kono
parents: 68
diff changeset
476 slot = htab_find_slot (macro_hash, &mhval, NO_INSERT);
kono
parents: 68
diff changeset
477 if (slot != NULL)
kono
parents: 68
diff changeset
478 htab_clear_slot (macro_hash, slot);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481 /* A function or variable decl. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 go_decl (tree decl)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 if (!TREE_PUBLIC (decl)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 || DECL_IS_BUILTIN (decl)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 || DECL_NAME (decl) == NULL_TREE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 return;
111
kono
parents: 68
diff changeset
490 vec_safe_push (queue, decl);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 /* A function decl. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
495 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 go_function_decl (tree decl)
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 real_debug_hooks->function_decl (decl);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 go_decl (decl);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501
111
kono
parents: 68
diff changeset
502 static void
kono
parents: 68
diff changeset
503 go_early_global_decl (tree decl)
kono
parents: 68
diff changeset
504 {
kono
parents: 68
diff changeset
505 go_decl (decl);
kono
parents: 68
diff changeset
506 if (TREE_CODE (decl) != FUNCTION_DECL || DECL_STRUCT_FUNCTION (decl) != NULL)
kono
parents: 68
diff changeset
507 real_debug_hooks->early_global_decl (decl);
kono
parents: 68
diff changeset
508 }
kono
parents: 68
diff changeset
509
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 /* A global variable decl. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 static void
111
kono
parents: 68
diff changeset
513 go_late_global_decl (tree decl)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 {
111
kono
parents: 68
diff changeset
515 real_debug_hooks->late_global_decl (decl);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 /* A type declaration. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 go_type_decl (tree decl, int local)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 real_debug_hooks->type_decl (decl, local);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 if (local || DECL_IS_BUILTIN (decl))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 if (DECL_NAME (decl) == NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
528 && (TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 || TREE_CODE (TYPE_NAME (TREE_TYPE (decl))) != IDENTIFIER_NODE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 && TREE_CODE (TREE_TYPE (decl)) != ENUMERAL_TYPE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531 return;
111
kono
parents: 68
diff changeset
532 vec_safe_push (queue, decl);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 /* A container for the data we pass around when generating information
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 at the end of the compilation. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
538 class godump_container
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
540 public:
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 /* DECLs that we have already seen. */
111
kono
parents: 68
diff changeset
542 hash_set<tree> decls_seen;
68
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 /* Types which may potentially have to be defined as dummy
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 types. */
111
kono
parents: 68
diff changeset
546 hash_set<const char *> pot_dummy_types;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 /* Go keywords. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 htab_t keyword_hash;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 /* Global type definitions. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 htab_t type_hash;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553
111
kono
parents: 68
diff changeset
554 /* Invalid types. */
kono
parents: 68
diff changeset
555 htab_t invalid_hash;
kono
parents: 68
diff changeset
556
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 /* Obstack used to write out a type definition. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 struct obstack type_obstack;
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
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 /* Append an IDENTIFIER_NODE to OB. */
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 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
564 go_append_string (struct obstack *ob, tree id)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 obstack_grow (ob, IDENTIFIER_POINTER (id), IDENTIFIER_LENGTH (id));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568
111
kono
parents: 68
diff changeset
569 /* Given an integer PRECISION in bits, returns a constant string that is the
kono
parents: 68
diff changeset
570 matching go int or uint type (depending on the IS_UNSIGNED flag). Returns a
kono
parents: 68
diff changeset
571 NULL pointer if there is no matching go type. */
kono
parents: 68
diff changeset
572
kono
parents: 68
diff changeset
573 static const char *
kono
parents: 68
diff changeset
574 go_get_uinttype_for_precision (unsigned int precision, bool is_unsigned)
kono
parents: 68
diff changeset
575 {
kono
parents: 68
diff changeset
576 switch (precision)
kono
parents: 68
diff changeset
577 {
kono
parents: 68
diff changeset
578 case 8:
kono
parents: 68
diff changeset
579 return is_unsigned ? "uint8" : "int8";
kono
parents: 68
diff changeset
580 case 16:
kono
parents: 68
diff changeset
581 return is_unsigned ? "uint16" : "int16";
kono
parents: 68
diff changeset
582 case 32:
kono
parents: 68
diff changeset
583 return is_unsigned ? "uint32" : "int32";
kono
parents: 68
diff changeset
584 case 64:
kono
parents: 68
diff changeset
585 return is_unsigned ? "uint64" : "int64";
kono
parents: 68
diff changeset
586 default:
kono
parents: 68
diff changeset
587 return NULL;
kono
parents: 68
diff changeset
588 }
kono
parents: 68
diff changeset
589 }
kono
parents: 68
diff changeset
590
kono
parents: 68
diff changeset
591 /* Append an artificial variable name with the suffix _INDEX to OB. Returns
kono
parents: 68
diff changeset
592 INDEX + 1. */
kono
parents: 68
diff changeset
593
kono
parents: 68
diff changeset
594 static unsigned int
kono
parents: 68
diff changeset
595 go_append_artificial_name (struct obstack *ob, unsigned int index)
kono
parents: 68
diff changeset
596 {
kono
parents: 68
diff changeset
597 char buf[100];
kono
parents: 68
diff changeset
598
kono
parents: 68
diff changeset
599 /* FIXME: identifier may not be unique. */
kono
parents: 68
diff changeset
600 obstack_grow (ob, "Godump_", 7);
kono
parents: 68
diff changeset
601 snprintf (buf, sizeof buf, "%u", index);
kono
parents: 68
diff changeset
602 obstack_grow (ob, buf, strlen (buf));
kono
parents: 68
diff changeset
603
kono
parents: 68
diff changeset
604 return index + 1;
kono
parents: 68
diff changeset
605 }
kono
parents: 68
diff changeset
606
kono
parents: 68
diff changeset
607 /* Append the variable name from DECL to OB. If the name is in the
kono
parents: 68
diff changeset
608 KEYWORD_HASH, prepend an '_'. */
kono
parents: 68
diff changeset
609
kono
parents: 68
diff changeset
610 static void
kono
parents: 68
diff changeset
611 go_append_decl_name (struct obstack *ob, tree decl, htab_t keyword_hash)
kono
parents: 68
diff changeset
612 {
kono
parents: 68
diff changeset
613 const char *var_name;
kono
parents: 68
diff changeset
614 void **slot;
kono
parents: 68
diff changeset
615
kono
parents: 68
diff changeset
616 /* Start variable name with an underscore if a keyword. */
kono
parents: 68
diff changeset
617 var_name = IDENTIFIER_POINTER (DECL_NAME (decl));
kono
parents: 68
diff changeset
618 slot = htab_find_slot (keyword_hash, var_name, NO_INSERT);
kono
parents: 68
diff changeset
619 if (slot != NULL)
kono
parents: 68
diff changeset
620 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
621 go_append_string (ob, DECL_NAME (decl));
kono
parents: 68
diff changeset
622 }
kono
parents: 68
diff changeset
623
kono
parents: 68
diff changeset
624 /* Appends a byte array with the necessary number of elements and the name
kono
parents: 68
diff changeset
625 "Godump_INDEX_pad" to pad from FROM_OFFSET to TO_OFFSET to OB assuming that
kono
parents: 68
diff changeset
626 the next field is automatically aligned to ALIGN_UNITS. Returns INDEX + 1,
kono
parents: 68
diff changeset
627 or INDEX if no padding had to be appended. The resulting offset where the
kono
parents: 68
diff changeset
628 next field is allocated is returned through RET_OFFSET. */
kono
parents: 68
diff changeset
629
kono
parents: 68
diff changeset
630 static unsigned int
kono
parents: 68
diff changeset
631 go_append_padding (struct obstack *ob, unsigned int from_offset,
kono
parents: 68
diff changeset
632 unsigned int to_offset, unsigned int align_units,
kono
parents: 68
diff changeset
633 unsigned int index, unsigned int *ret_offset)
kono
parents: 68
diff changeset
634 {
kono
parents: 68
diff changeset
635 if (from_offset % align_units > 0)
kono
parents: 68
diff changeset
636 from_offset += align_units - (from_offset % align_units);
kono
parents: 68
diff changeset
637 gcc_assert (to_offset >= from_offset);
kono
parents: 68
diff changeset
638 if (to_offset > from_offset)
kono
parents: 68
diff changeset
639 {
kono
parents: 68
diff changeset
640 char buf[100];
kono
parents: 68
diff changeset
641
kono
parents: 68
diff changeset
642 index = go_append_artificial_name (ob, index);
kono
parents: 68
diff changeset
643 snprintf (buf, sizeof buf, "_pad [%u]byte; ", to_offset - from_offset);
kono
parents: 68
diff changeset
644 obstack_grow (ob, buf, strlen (buf));
kono
parents: 68
diff changeset
645 }
kono
parents: 68
diff changeset
646 *ret_offset = to_offset;
kono
parents: 68
diff changeset
647
kono
parents: 68
diff changeset
648 return index;
kono
parents: 68
diff changeset
649 }
kono
parents: 68
diff changeset
650
kono
parents: 68
diff changeset
651 /* Appends an array of type TYPE_STRING with zero elements and the name
kono
parents: 68
diff changeset
652 "Godump_INDEX_align" to OB. If TYPE_STRING is a null pointer, ERROR_STRING
kono
parents: 68
diff changeset
653 is appended instead of the type. Returns INDEX + 1. */
kono
parents: 68
diff changeset
654
kono
parents: 68
diff changeset
655 static unsigned int
kono
parents: 68
diff changeset
656 go_force_record_alignment (struct obstack *ob, const char *type_string,
kono
parents: 68
diff changeset
657 unsigned int index, const char *error_string)
kono
parents: 68
diff changeset
658 {
kono
parents: 68
diff changeset
659 index = go_append_artificial_name (ob, index);
kono
parents: 68
diff changeset
660 obstack_grow (ob, "_align ", 7);
kono
parents: 68
diff changeset
661 if (type_string == NULL)
kono
parents: 68
diff changeset
662 obstack_grow (ob, error_string, strlen (error_string));
kono
parents: 68
diff changeset
663 else
kono
parents: 68
diff changeset
664 {
kono
parents: 68
diff changeset
665 obstack_grow (ob, "[0]", 3);
kono
parents: 68
diff changeset
666 obstack_grow (ob, type_string, strlen (type_string));
kono
parents: 68
diff changeset
667 }
kono
parents: 68
diff changeset
668 obstack_grow (ob, "; ", 2);
kono
parents: 68
diff changeset
669
kono
parents: 68
diff changeset
670 return index;
kono
parents: 68
diff changeset
671 }
kono
parents: 68
diff changeset
672
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
673 /* Write the Go version of TYPE to CONTAINER->TYPE_OBSTACK.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
674 USE_TYPE_NAME is true if we can simply use a type name here without
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
675 needing to define it. IS_FUNC_OK is true if we can output a func
111
kono
parents: 68
diff changeset
676 type here; the "func" keyword will already have been added.
kono
parents: 68
diff changeset
677 Return true if the type can be represented in Go, false otherwise.
kono
parents: 68
diff changeset
678 P_ART_I is used for indexing artificial elements in nested structures and
kono
parents: 68
diff changeset
679 should always be a NULL pointer when called, except by certain recursive
kono
parents: 68
diff changeset
680 calls from go_format_type() itself. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 static bool
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
683 go_format_type (class godump_container *container, tree type,
111
kono
parents: 68
diff changeset
684 bool use_type_name, bool is_func_ok, unsigned int *p_art_i,
kono
parents: 68
diff changeset
685 bool is_anon_record_or_union)
68
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 bool ret;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
688 struct obstack *ob;
111
kono
parents: 68
diff changeset
689 unsigned int art_i_dummy;
kono
parents: 68
diff changeset
690 bool is_union = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
691
111
kono
parents: 68
diff changeset
692 if (p_art_i == NULL)
kono
parents: 68
diff changeset
693 {
kono
parents: 68
diff changeset
694 art_i_dummy = 0;
kono
parents: 68
diff changeset
695 p_art_i = &art_i_dummy;
kono
parents: 68
diff changeset
696 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 ret = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698 ob = &container->type_obstack;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
700 if (TYPE_NAME (type) != NULL_TREE
111
kono
parents: 68
diff changeset
701 && (container->decls_seen.contains (type)
kono
parents: 68
diff changeset
702 || container->decls_seen.contains (TYPE_NAME (type)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 && (AGGREGATE_TYPE_P (type)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 || POINTER_TYPE_P (type)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 || TREE_CODE (type) == FUNCTION_TYPE))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
707 tree name;
111
kono
parents: 68
diff changeset
708 void **slot;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
709
111
kono
parents: 68
diff changeset
710 name = TYPE_IDENTIFIER (type);
kono
parents: 68
diff changeset
711
kono
parents: 68
diff changeset
712 slot = htab_find_slot (container->invalid_hash, IDENTIFIER_POINTER (name),
kono
parents: 68
diff changeset
713 NO_INSERT);
kono
parents: 68
diff changeset
714 if (slot != NULL)
kono
parents: 68
diff changeset
715 ret = false;
kono
parents: 68
diff changeset
716
kono
parents: 68
diff changeset
717 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
718 go_append_string (ob, name);
kono
parents: 68
diff changeset
719 return ret;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
721
111
kono
parents: 68
diff changeset
722 container->decls_seen.add (type);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 switch (TREE_CODE (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
725 {
111
kono
parents: 68
diff changeset
726 case TYPE_DECL:
kono
parents: 68
diff changeset
727 {
kono
parents: 68
diff changeset
728 void **slot;
kono
parents: 68
diff changeset
729
kono
parents: 68
diff changeset
730 slot = htab_find_slot (container->invalid_hash,
kono
parents: 68
diff changeset
731 IDENTIFIER_POINTER (DECL_NAME (type)),
kono
parents: 68
diff changeset
732 NO_INSERT);
kono
parents: 68
diff changeset
733 if (slot != NULL)
kono
parents: 68
diff changeset
734 ret = false;
kono
parents: 68
diff changeset
735
kono
parents: 68
diff changeset
736 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
737 go_append_string (ob, DECL_NAME (type));
kono
parents: 68
diff changeset
738 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
739 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
740
111
kono
parents: 68
diff changeset
741 case ENUMERAL_TYPE:
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 case INTEGER_TYPE:
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 const char *s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745 char buf[100];
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
746
111
kono
parents: 68
diff changeset
747 s = go_get_uinttype_for_precision (TYPE_PRECISION (type),
kono
parents: 68
diff changeset
748 TYPE_UNSIGNED (type));
kono
parents: 68
diff changeset
749 if (s == NULL)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
751 snprintf (buf, sizeof buf, "INVALID-int-%u%s",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 TYPE_PRECISION (type),
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 TYPE_UNSIGNED (type) ? "u" : "");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 s = buf;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 ret = false;
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 obstack_grow (ob, s, strlen (s));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
760
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 case REAL_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 const char *s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
764 char buf[100];
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
765
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 switch (TYPE_PRECISION (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
768 case 32:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 s = "float32";
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 case 64:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 s = "float64";
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 snprintf (buf, sizeof buf, "INVALID-float-%u",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 TYPE_PRECISION (type));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 s = buf;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 break;
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 obstack_grow (ob, s, strlen (s));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
783 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
784
111
kono
parents: 68
diff changeset
785 case COMPLEX_TYPE:
kono
parents: 68
diff changeset
786 {
kono
parents: 68
diff changeset
787 const char *s;
kono
parents: 68
diff changeset
788 char buf[100];
kono
parents: 68
diff changeset
789 tree real_type;
kono
parents: 68
diff changeset
790
kono
parents: 68
diff changeset
791 real_type = TREE_TYPE (type);
kono
parents: 68
diff changeset
792 if (TREE_CODE (real_type) == REAL_TYPE)
kono
parents: 68
diff changeset
793 {
kono
parents: 68
diff changeset
794 switch (TYPE_PRECISION (real_type))
kono
parents: 68
diff changeset
795 {
kono
parents: 68
diff changeset
796 case 32:
kono
parents: 68
diff changeset
797 s = "complex64";
kono
parents: 68
diff changeset
798 break;
kono
parents: 68
diff changeset
799 case 64:
kono
parents: 68
diff changeset
800 s = "complex128";
kono
parents: 68
diff changeset
801 break;
kono
parents: 68
diff changeset
802 default:
kono
parents: 68
diff changeset
803 snprintf (buf, sizeof buf, "INVALID-complex-%u",
kono
parents: 68
diff changeset
804 2 * TYPE_PRECISION (real_type));
kono
parents: 68
diff changeset
805 s = buf;
kono
parents: 68
diff changeset
806 ret = false;
kono
parents: 68
diff changeset
807 break;
kono
parents: 68
diff changeset
808 }
kono
parents: 68
diff changeset
809 }
kono
parents: 68
diff changeset
810 else
kono
parents: 68
diff changeset
811 {
kono
parents: 68
diff changeset
812 s = "INVALID-complex-non-real";
kono
parents: 68
diff changeset
813 ret = false;
kono
parents: 68
diff changeset
814 }
kono
parents: 68
diff changeset
815 obstack_grow (ob, s, strlen (s));
kono
parents: 68
diff changeset
816 }
kono
parents: 68
diff changeset
817 break;
kono
parents: 68
diff changeset
818
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 case BOOLEAN_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 obstack_grow (ob, "bool", 4);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
821 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
822
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 case POINTER_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
824 if (use_type_name
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
825 && TYPE_NAME (TREE_TYPE (type)) != NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
826 && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
827 || (POINTER_TYPE_P (TREE_TYPE (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 && (TREE_CODE (TREE_TYPE (TREE_TYPE (type)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 == FUNCTION_TYPE))))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
831 tree name;
111
kono
parents: 68
diff changeset
832 void **slot;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
833
111
kono
parents: 68
diff changeset
834 name = TYPE_IDENTIFIER (TREE_TYPE (type));
kono
parents: 68
diff changeset
835
kono
parents: 68
diff changeset
836 slot = htab_find_slot (container->invalid_hash,
kono
parents: 68
diff changeset
837 IDENTIFIER_POINTER (name), NO_INSERT);
kono
parents: 68
diff changeset
838 if (slot != NULL)
kono
parents: 68
diff changeset
839 ret = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
840
111
kono
parents: 68
diff changeset
841 obstack_grow (ob, "*_", 2);
kono
parents: 68
diff changeset
842 go_append_string (ob, name);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
843
111
kono
parents: 68
diff changeset
844 /* The pointer here can be used without the struct or union
kono
parents: 68
diff changeset
845 definition. So this struct or union is a potential dummy
kono
parents: 68
diff changeset
846 type. */
kono
parents: 68
diff changeset
847 if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type)))
kono
parents: 68
diff changeset
848 container->pot_dummy_types.add (IDENTIFIER_POINTER (name));
kono
parents: 68
diff changeset
849
kono
parents: 68
diff changeset
850 return ret;
68
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 if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 obstack_grow (ob, "func", 4);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 obstack_1grow (ob, '*');
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 if (VOID_TYPE_P (TREE_TYPE (type)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 obstack_grow (ob, "byte", 4);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 else
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 if (!go_format_type (container, TREE_TYPE (type), use_type_name,
111
kono
parents: 68
diff changeset
861 true, NULL, false))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864 break;
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 case ARRAY_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 obstack_1grow (ob, '[');
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 if (TYPE_DOMAIN (type) != NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 && TREE_CODE (TYPE_DOMAIN (type)) == INTEGER_TYPE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 && TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 && tree_int_cst_sgn (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) == 0
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
873 && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874 && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST
111
kono
parents: 68
diff changeset
875 && tree_fits_shwi_p (TYPE_MAX_VALUE (TYPE_DOMAIN (type))))
68
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 char buf[100];
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 snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_DEC "+1",
111
kono
parents: 68
diff changeset
880 tree_to_shwi (TYPE_MAX_VALUE (TYPE_DOMAIN (type))));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 obstack_grow (ob, buf, strlen (buf));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882 }
111
kono
parents: 68
diff changeset
883 else
kono
parents: 68
diff changeset
884 obstack_1grow (ob, '0');
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 obstack_1grow (ob, ']');
111
kono
parents: 68
diff changeset
886 if (!go_format_type (container, TREE_TYPE (type), use_type_name, false,
kono
parents: 68
diff changeset
887 NULL, false))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
891 case UNION_TYPE:
111
kono
parents: 68
diff changeset
892 is_union = true;
kono
parents: 68
diff changeset
893 /* Fall through to RECORD_TYPE case. */
kono
parents: 68
diff changeset
894 gcc_fallthrough ();
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 case RECORD_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
896 {
111
kono
parents: 68
diff changeset
897 unsigned int prev_field_end;
kono
parents: 68
diff changeset
898 unsigned int known_alignment;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 tree field;
111
kono
parents: 68
diff changeset
900 bool emitted_a_field;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
901
111
kono
parents: 68
diff changeset
902 /* FIXME: Why is this necessary? Without it we can get a core
kono
parents: 68
diff changeset
903 dump on the s390x headers, or from a file containing simply
kono
parents: 68
diff changeset
904 "typedef struct S T;". */
kono
parents: 68
diff changeset
905 layout_type (type);
kono
parents: 68
diff changeset
906
kono
parents: 68
diff changeset
907 prev_field_end = 0;
kono
parents: 68
diff changeset
908 known_alignment = 1;
kono
parents: 68
diff changeset
909 /* Anonymous records and unions are flattened, i.e. they are not put
kono
parents: 68
diff changeset
910 into "struct { ... }". */
kono
parents: 68
diff changeset
911 if (!is_anon_record_or_union)
kono
parents: 68
diff changeset
912 obstack_grow (ob, "struct { ", 9);
kono
parents: 68
diff changeset
913 for (field = TYPE_FIELDS (type), emitted_a_field = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
914 field != NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 field = TREE_CHAIN (field))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 {
111
kono
parents: 68
diff changeset
917 if (TREE_CODE (field) != FIELD_DECL)
kono
parents: 68
diff changeset
918 continue;
kono
parents: 68
diff changeset
919 if (DECL_BIT_FIELD (field))
kono
parents: 68
diff changeset
920 /* Bit fields are replaced by padding. */
kono
parents: 68
diff changeset
921 continue;
kono
parents: 68
diff changeset
922 /* Only the first non-bitfield field is emitted for unions. */
kono
parents: 68
diff changeset
923 if (!is_union || !emitted_a_field)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 {
111
kono
parents: 68
diff changeset
925 /* Emit the field. */
kono
parents: 68
diff changeset
926 bool field_ok;
kono
parents: 68
diff changeset
927 bool is_anon_substructure;
kono
parents: 68
diff changeset
928 unsigned int decl_align_unit;
kono
parents: 68
diff changeset
929 unsigned int decl_offset;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
930
111
kono
parents: 68
diff changeset
931 field_ok = true;
kono
parents: 68
diff changeset
932 emitted_a_field = true;
kono
parents: 68
diff changeset
933 is_anon_substructure =
kono
parents: 68
diff changeset
934 (DECL_NAME (field) == NULL
kono
parents: 68
diff changeset
935 && (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
kono
parents: 68
diff changeset
936 || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE));
kono
parents: 68
diff changeset
937 /* Keep track of the alignment of named substructures, either
kono
parents: 68
diff changeset
938 of the whole record, or the alignment of the emitted field
kono
parents: 68
diff changeset
939 (for unions). */
kono
parents: 68
diff changeset
940 decl_align_unit = DECL_ALIGN_UNIT (field);
kono
parents: 68
diff changeset
941 if (!is_anon_substructure && decl_align_unit > known_alignment)
kono
parents: 68
diff changeset
942 known_alignment = decl_align_unit;
kono
parents: 68
diff changeset
943 /* Pad to start of field. */
kono
parents: 68
diff changeset
944 decl_offset =
kono
parents: 68
diff changeset
945 TREE_INT_CST_LOW (DECL_FIELD_OFFSET (field))
kono
parents: 68
diff changeset
946 + precision_to_units
kono
parents: 68
diff changeset
947 (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)));
kono
parents: 68
diff changeset
948 {
kono
parents: 68
diff changeset
949 unsigned int align_unit;
kono
parents: 68
diff changeset
950
kono
parents: 68
diff changeset
951 /* For anonymous records and unions there is no automatic
kono
parents: 68
diff changeset
952 structure alignment, so use 1 as the alignment. */
kono
parents: 68
diff changeset
953 align_unit = (is_anon_substructure) ? 1 : decl_align_unit;
kono
parents: 68
diff changeset
954 *p_art_i = go_append_padding
kono
parents: 68
diff changeset
955 (ob, prev_field_end, decl_offset, align_unit, *p_art_i,
kono
parents: 68
diff changeset
956 &prev_field_end);
kono
parents: 68
diff changeset
957 }
kono
parents: 68
diff changeset
958 if (DECL_SIZE_UNIT (field))
kono
parents: 68
diff changeset
959 prev_field_end +=
kono
parents: 68
diff changeset
960 TREE_INT_CST_LOW (DECL_SIZE_UNIT (field));
kono
parents: 68
diff changeset
961 /* Emit the field name, but not for anonymous records and
kono
parents: 68
diff changeset
962 unions. */
kono
parents: 68
diff changeset
963 if (!is_anon_substructure)
kono
parents: 68
diff changeset
964 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
965 if (DECL_NAME (field) == NULL)
111
kono
parents: 68
diff changeset
966 *p_art_i = go_append_artificial_name (ob, *p_art_i);
kono
parents: 68
diff changeset
967 else
kono
parents: 68
diff changeset
968 go_append_decl_name
kono
parents: 68
diff changeset
969 (ob, field, container->keyword_hash);
kono
parents: 68
diff changeset
970 obstack_1grow (ob, ' ');
kono
parents: 68
diff changeset
971 }
kono
parents: 68
diff changeset
972 /* Do not expand type if a record or union type or a function
kono
parents: 68
diff changeset
973 pointer. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 if (TYPE_NAME (TREE_TYPE (field)) != NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 && (RECORD_OR_UNION_TYPE_P (TREE_TYPE (field))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 || (POINTER_TYPE_P (TREE_TYPE (field))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 && (TREE_CODE (TREE_TYPE (TREE_TYPE (field)))
111
kono
parents: 68
diff changeset
978 == FUNCTION_TYPE))))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
979 {
111
kono
parents: 68
diff changeset
980 tree name;
kono
parents: 68
diff changeset
981 void **slot;
kono
parents: 68
diff changeset
982
kono
parents: 68
diff changeset
983 name = TYPE_IDENTIFIER (TREE_TYPE (field));
kono
parents: 68
diff changeset
984
kono
parents: 68
diff changeset
985 slot = htab_find_slot (container->invalid_hash,
kono
parents: 68
diff changeset
986 IDENTIFIER_POINTER (name),
kono
parents: 68
diff changeset
987 NO_INSERT);
kono
parents: 68
diff changeset
988 if (slot != NULL)
kono
parents: 68
diff changeset
989 field_ok = false;
kono
parents: 68
diff changeset
990
kono
parents: 68
diff changeset
991 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
992 go_append_string (ob, name);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 if (!go_format_type (container, TREE_TYPE (field), true,
111
kono
parents: 68
diff changeset
997 false, p_art_i, is_anon_substructure))
kono
parents: 68
diff changeset
998 field_ok = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
999 }
111
kono
parents: 68
diff changeset
1000 if (!is_anon_substructure)
kono
parents: 68
diff changeset
1001 obstack_grow (ob, "; ", 2);
kono
parents: 68
diff changeset
1002 if (!field_ok)
kono
parents: 68
diff changeset
1003 ret = false;
kono
parents: 68
diff changeset
1004 }
kono
parents: 68
diff changeset
1005 }
kono
parents: 68
diff changeset
1006 /* Padding. */
kono
parents: 68
diff changeset
1007 *p_art_i = go_append_padding (ob, prev_field_end,
kono
parents: 68
diff changeset
1008 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)),
kono
parents: 68
diff changeset
1009 1, *p_art_i, &prev_field_end);
kono
parents: 68
diff changeset
1010 /* Alignment. */
kono
parents: 68
diff changeset
1011 if (!is_anon_record_or_union
kono
parents: 68
diff changeset
1012 && known_alignment < TYPE_ALIGN_UNIT (type))
kono
parents: 68
diff changeset
1013 {
kono
parents: 68
diff changeset
1014 const char *s;
kono
parents: 68
diff changeset
1015 char buf[100];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1016
111
kono
parents: 68
diff changeset
1017 /* Enforce proper record alignment. */
kono
parents: 68
diff changeset
1018 s = go_get_uinttype_for_precision
kono
parents: 68
diff changeset
1019 (TYPE_ALIGN (type), TYPE_UNSIGNED (type));
kono
parents: 68
diff changeset
1020 if (s == NULL)
kono
parents: 68
diff changeset
1021 {
kono
parents: 68
diff changeset
1022 snprintf (buf, sizeof buf, "INVALID-int-%u%s",
kono
parents: 68
diff changeset
1023 TYPE_ALIGN (type), TYPE_UNSIGNED (type) ? "u" : "");
kono
parents: 68
diff changeset
1024 s = buf;
kono
parents: 68
diff changeset
1025 ret = false;
kono
parents: 68
diff changeset
1026 }
kono
parents: 68
diff changeset
1027 *p_art_i = go_force_record_alignment (ob, s, *p_art_i, buf);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1028 }
111
kono
parents: 68
diff changeset
1029 if (!is_anon_record_or_union)
kono
parents: 68
diff changeset
1030 obstack_1grow (ob, '}');
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031 }
111
kono
parents: 68
diff changeset
1032 break;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 case FUNCTION_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 {
111
kono
parents: 68
diff changeset
1036 tree arg_type;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 bool is_varargs;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 tree result;
111
kono
parents: 68
diff changeset
1039 function_args_iterator iter;
kono
parents: 68
diff changeset
1040 bool seen_arg;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042 /* Go has no way to write a type which is a function but not a
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043 pointer to a function. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044 if (!is_func_ok)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1045 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 obstack_grow (ob, "func*", 5);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1048 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1050 obstack_1grow (ob, '(');
111
kono
parents: 68
diff changeset
1051 is_varargs = stdarg_p (type);
kono
parents: 68
diff changeset
1052 seen_arg = false;
kono
parents: 68
diff changeset
1053 FOREACH_FUNCTION_ARGS (type, arg_type, iter)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054 {
111
kono
parents: 68
diff changeset
1055 if (VOID_TYPE_P (arg_type))
kono
parents: 68
diff changeset
1056 break;
kono
parents: 68
diff changeset
1057 if (seen_arg)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1058 obstack_grow (ob, ", ", 2);
111
kono
parents: 68
diff changeset
1059 if (!go_format_type (container, arg_type, true, false, NULL, false))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 ret = false;
111
kono
parents: 68
diff changeset
1061 seen_arg = true;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 if (is_varargs)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064 {
111
kono
parents: 68
diff changeset
1065 if (prototype_p (type))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 obstack_grow (ob, ", ", 2);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 obstack_grow (ob, "...interface{}", 14);
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 obstack_1grow (ob, ')');
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 result = TREE_TYPE (type);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072 if (!VOID_TYPE_P (result))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1074 obstack_1grow (ob, ' ');
111
kono
parents: 68
diff changeset
1075 if (!go_format_type (container, result, use_type_name, false, NULL,
kono
parents: 68
diff changeset
1076 false))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 obstack_grow (ob, "INVALID-type", 12);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1086 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1087
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 return ret;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1089 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1090
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1091 /* Output the type which was built on the type obstack, and then free
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1092 it. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1095 go_output_type (class godump_container *container)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097 struct obstack *ob;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 ob = &container->type_obstack;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1100 obstack_1grow (ob, '\0');
111
kono
parents: 68
diff changeset
1101 fputs ((char *) obstack_base (ob), go_dump_file);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 obstack_free (ob, obstack_base (ob));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105 /* Output a function declaration. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1108 go_output_fndecl (class godump_container *container, tree decl)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1109 {
111
kono
parents: 68
diff changeset
1110 if (!go_format_type (container, TREE_TYPE (decl), false, true, NULL, false))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 fprintf (go_dump_file, "// ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 fprintf (go_dump_file, "func _%s ",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 IDENTIFIER_POINTER (DECL_NAME (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 go_output_type (container);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 fprintf (go_dump_file, " __asm__(\"%s\")\n",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1117 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1118
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1119 /* Output a typedef or something like a struct definition. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1122 go_output_typedef (class godump_container *container, tree decl)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1124 /* If we have an enum type, output the enum constants
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125 separately. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1126 if (TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1127 && TYPE_SIZE (TREE_TYPE (decl)) != 0
111
kono
parents: 68
diff changeset
1128 && !container->decls_seen.contains (TREE_TYPE (decl))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1129 && (TYPE_CANONICAL (TREE_TYPE (decl)) == NULL_TREE
111
kono
parents: 68
diff changeset
1130 || !container->decls_seen.contains
kono
parents: 68
diff changeset
1131 (TYPE_CANONICAL (TREE_TYPE (decl)))))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 tree element;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 for (element = TYPE_VALUES (TREE_TYPE (decl));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136 element != NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1137 element = TREE_CHAIN (element))
111
kono
parents: 68
diff changeset
1138 {
kono
parents: 68
diff changeset
1139 const char *name;
kono
parents: 68
diff changeset
1140 struct macro_hash_value *mhval;
kono
parents: 68
diff changeset
1141 void **slot;
kono
parents: 68
diff changeset
1142 char buf[WIDE_INT_PRINT_BUFFER_SIZE];
kono
parents: 68
diff changeset
1143
kono
parents: 68
diff changeset
1144 name = IDENTIFIER_POINTER (TREE_PURPOSE (element));
kono
parents: 68
diff changeset
1145
kono
parents: 68
diff changeset
1146 /* Sometimes a name will be defined as both an enum constant
kono
parents: 68
diff changeset
1147 and a macro. Avoid duplicate definition errors by
kono
parents: 68
diff changeset
1148 treating enum constants as macros. */
kono
parents: 68
diff changeset
1149 mhval = XNEW (struct macro_hash_value);
kono
parents: 68
diff changeset
1150 mhval->name = xstrdup (name);
kono
parents: 68
diff changeset
1151 mhval->value = NULL;
kono
parents: 68
diff changeset
1152 slot = htab_find_slot (macro_hash, mhval, INSERT);
kono
parents: 68
diff changeset
1153 if (*slot != NULL)
kono
parents: 68
diff changeset
1154 macro_hash_del (*slot);
kono
parents: 68
diff changeset
1155
kono
parents: 68
diff changeset
1156 if (tree_fits_shwi_p (TREE_VALUE (element)))
kono
parents: 68
diff changeset
1157 snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_DEC,
kono
parents: 68
diff changeset
1158 tree_to_shwi (TREE_VALUE (element)));
kono
parents: 68
diff changeset
1159 else if (tree_fits_uhwi_p (TREE_VALUE (element)))
kono
parents: 68
diff changeset
1160 snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_UNSIGNED,
kono
parents: 68
diff changeset
1161 tree_to_uhwi (TREE_VALUE (element)));
kono
parents: 68
diff changeset
1162 else
kono
parents: 68
diff changeset
1163 print_hex (wi::to_wide (element), buf);
kono
parents: 68
diff changeset
1164
kono
parents: 68
diff changeset
1165 mhval->value = xstrdup (buf);
kono
parents: 68
diff changeset
1166 *slot = mhval;
kono
parents: 68
diff changeset
1167 }
kono
parents: 68
diff changeset
1168 container->decls_seen.add (TREE_TYPE (decl));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1169 if (TYPE_CANONICAL (TREE_TYPE (decl)) != NULL_TREE)
111
kono
parents: 68
diff changeset
1170 container->decls_seen.add (TYPE_CANONICAL (TREE_TYPE (decl)));
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
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 if (DECL_NAME (decl) != NULL_TREE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1174 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1175 void **slot;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176 const char *type;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1178 type = IDENTIFIER_POINTER (DECL_NAME (decl));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1179 /* If type defined already, skip. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1180 slot = htab_find_slot (container->type_hash, type, INSERT);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1181 if (*slot != NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183 *slot = CONST_CAST (void *, (const void *) type);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1184
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1185 if (!go_format_type (container, TREE_TYPE (decl), true, false, NULL,
111
kono
parents: 68
diff changeset
1186 false))
kono
parents: 68
diff changeset
1187 {
kono
parents: 68
diff changeset
1188 fprintf (go_dump_file, "// ");
kono
parents: 68
diff changeset
1189 slot = htab_find_slot (container->invalid_hash, type, INSERT);
kono
parents: 68
diff changeset
1190 *slot = CONST_CAST (void *, (const void *) type);
kono
parents: 68
diff changeset
1191 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1192 fprintf (go_dump_file, "type _%s ",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1193 IDENTIFIER_POINTER (DECL_NAME (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1194 go_output_type (container);
111
kono
parents: 68
diff changeset
1195
kono
parents: 68
diff changeset
1196 if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl)))
kono
parents: 68
diff changeset
1197 {
kono
parents: 68
diff changeset
1198 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl));
kono
parents: 68
diff changeset
1199
kono
parents: 68
diff changeset
1200 if (size > 0)
kono
parents: 68
diff changeset
1201 fprintf (go_dump_file,
kono
parents: 68
diff changeset
1202 "\nconst _sizeof_%s = " HOST_WIDE_INT_PRINT_DEC,
kono
parents: 68
diff changeset
1203 IDENTIFIER_POINTER (DECL_NAME (decl)),
kono
parents: 68
diff changeset
1204 size);
kono
parents: 68
diff changeset
1205 }
kono
parents: 68
diff changeset
1206
kono
parents: 68
diff changeset
1207 container->decls_seen.add (decl);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1209 else if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1210 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211 void **slot;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1212 const char *type;
111
kono
parents: 68
diff changeset
1213 HOST_WIDE_INT size;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1214
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1215 type = IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE ((decl))));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1216 /* If type defined already, skip. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1217 slot = htab_find_slot (container->type_hash, type, INSERT);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1218 if (*slot != NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1219 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1220 *slot = CONST_CAST (void *, (const void *) type);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1221
111
kono
parents: 68
diff changeset
1222 if (!go_format_type (container, TREE_TYPE (decl), false, false, NULL,
kono
parents: 68
diff changeset
1223 false))
kono
parents: 68
diff changeset
1224 {
kono
parents: 68
diff changeset
1225 fprintf (go_dump_file, "// ");
kono
parents: 68
diff changeset
1226 slot = htab_find_slot (container->invalid_hash, type, INSERT);
kono
parents: 68
diff changeset
1227 *slot = CONST_CAST (void *, (const void *) type);
kono
parents: 68
diff changeset
1228 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1229 fprintf (go_dump_file, "type _%s ",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1230 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1231 go_output_type (container);
111
kono
parents: 68
diff changeset
1232
kono
parents: 68
diff changeset
1233 size = int_size_in_bytes (TREE_TYPE (decl));
kono
parents: 68
diff changeset
1234 if (size > 0)
kono
parents: 68
diff changeset
1235 fprintf (go_dump_file,
kono
parents: 68
diff changeset
1236 "\nconst _sizeof_%s = " HOST_WIDE_INT_PRINT_DEC,
kono
parents: 68
diff changeset
1237 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))),
kono
parents: 68
diff changeset
1238 size);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1239 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1240 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1241 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1242
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1243 fprintf (go_dump_file, "\n");
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
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1246 /* Output a variable. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1247
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1248 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1249 go_output_var (class godump_container *container, tree decl)
68
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 bool is_valid;
111
kono
parents: 68
diff changeset
1252 tree type_name;
kono
parents: 68
diff changeset
1253 tree id;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1254
111
kono
parents: 68
diff changeset
1255 if (container->decls_seen.contains (decl)
kono
parents: 68
diff changeset
1256 || container->decls_seen.contains (DECL_NAME (decl)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1257 return;
111
kono
parents: 68
diff changeset
1258 container->decls_seen.add (decl);
kono
parents: 68
diff changeset
1259 container->decls_seen.add (DECL_NAME (decl));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1260
111
kono
parents: 68
diff changeset
1261 type_name = TYPE_NAME (TREE_TYPE (decl));
kono
parents: 68
diff changeset
1262 id = NULL_TREE;
kono
parents: 68
diff changeset
1263 if (type_name != NULL_TREE && TREE_CODE (type_name) == IDENTIFIER_NODE)
kono
parents: 68
diff changeset
1264 id = type_name;
kono
parents: 68
diff changeset
1265 else if (type_name != NULL_TREE && TREE_CODE (type_name) == TYPE_DECL
kono
parents: 68
diff changeset
1266 && DECL_SOURCE_LOCATION (type_name) != BUILTINS_LOCATION
kono
parents: 68
diff changeset
1267 && DECL_NAME (type_name))
kono
parents: 68
diff changeset
1268 id = DECL_NAME (type_name);
kono
parents: 68
diff changeset
1269 if (id != NULL_TREE
kono
parents: 68
diff changeset
1270 && (!htab_find_slot (container->type_hash, IDENTIFIER_POINTER (id),
kono
parents: 68
diff changeset
1271 NO_INSERT)
kono
parents: 68
diff changeset
1272 || htab_find_slot (container->invalid_hash, IDENTIFIER_POINTER (id),
kono
parents: 68
diff changeset
1273 NO_INSERT)))
kono
parents: 68
diff changeset
1274 id = NULL_TREE;
kono
parents: 68
diff changeset
1275 if (id != NULL_TREE)
kono
parents: 68
diff changeset
1276 {
kono
parents: 68
diff changeset
1277 struct obstack *ob;
kono
parents: 68
diff changeset
1278
kono
parents: 68
diff changeset
1279 ob = &container->type_obstack;
kono
parents: 68
diff changeset
1280 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
1281 go_append_string (ob, id);
kono
parents: 68
diff changeset
1282 is_valid = htab_find_slot (container->type_hash, IDENTIFIER_POINTER (id),
kono
parents: 68
diff changeset
1283 NO_INSERT) != NULL;
kono
parents: 68
diff changeset
1284 }
kono
parents: 68
diff changeset
1285 else
kono
parents: 68
diff changeset
1286 is_valid = go_format_type (container, TREE_TYPE (decl), true, false, NULL,
kono
parents: 68
diff changeset
1287 false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1288 if (is_valid
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1289 && htab_find_slot (container->type_hash,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290 IDENTIFIER_POINTER (DECL_NAME (decl)),
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 NO_INSERT) != NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 /* There is already a type with this name, probably from a
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1294 struct tag. Prefer the type to the variable. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295 is_valid = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1297 if (!is_valid)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1298 fprintf (go_dump_file, "// ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1300 fprintf (go_dump_file, "var _%s ",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301 IDENTIFIER_POINTER (DECL_NAME (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1302 go_output_type (container);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303 fprintf (go_dump_file, "\n");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1305 /* Sometimes an extern variable is declared with an unknown struct
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1306 type. */
111
kono
parents: 68
diff changeset
1307 if (type_name != NULL_TREE && RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl)))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1308 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1309 if (TREE_CODE (type_name) == IDENTIFIER_NODE)
111
kono
parents: 68
diff changeset
1310 container->pot_dummy_types.add (IDENTIFIER_POINTER (type_name));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1311 else if (TREE_CODE (type_name) == TYPE_DECL)
111
kono
parents: 68
diff changeset
1312 container->pot_dummy_types.add
kono
parents: 68
diff changeset
1313 (IDENTIFIER_POINTER (DECL_NAME (type_name)));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1314 }
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
111
kono
parents: 68
diff changeset
1317 /* Output the final value of a preprocessor macro or enum constant.
kono
parents: 68
diff changeset
1318 This is called via htab_traverse_noresize. */
kono
parents: 68
diff changeset
1319
kono
parents: 68
diff changeset
1320 static int
kono
parents: 68
diff changeset
1321 go_print_macro (void **slot, void *arg ATTRIBUTE_UNUSED)
kono
parents: 68
diff changeset
1322 {
kono
parents: 68
diff changeset
1323 struct macro_hash_value *mhval = (struct macro_hash_value *) *slot;
kono
parents: 68
diff changeset
1324 fprintf (go_dump_file, "const _%s = %s\n", mhval->name, mhval->value);
kono
parents: 68
diff changeset
1325 return 1;
kono
parents: 68
diff changeset
1326 }
kono
parents: 68
diff changeset
1327
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1328 /* Build a hash table with the Go keywords. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1329
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1330 static const char * const keywords[] = {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1331 "__asm__", "break", "case", "chan", "const", "continue", "default",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1332 "defer", "else", "fallthrough", "for", "func", "go", "goto", "if",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1333 "import", "interface", "map", "package", "range", "return", "select",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1334 "struct", "switch", "type", "var"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1335 };
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1336
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1337 static void
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1338 keyword_hash_init (class godump_container *container)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1339 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1340 size_t i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1341 size_t count = sizeof (keywords) / sizeof (keywords[0]);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1342 void **slot;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1343
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1344 for (i = 0; i < count; i++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1345 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1346 slot = htab_find_slot (container->keyword_hash, keywords[i], INSERT);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1347 *slot = CONST_CAST (void *, (const void *) keywords[i]);
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 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1350
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1351 /* Traversing the pot_dummy_types and seeing which types are present
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1352 in the global types hash table and creating dummy definitions if
111
kono
parents: 68
diff changeset
1353 not found. This function is invoked by hash_set::traverse. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1354
111
kono
parents: 68
diff changeset
1355 bool
kono
parents: 68
diff changeset
1356 find_dummy_types (const char *const &ptr, godump_container *adata)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1357 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1358 class godump_container *data = (class godump_container *) adata;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1359 const char *type = (const char *) ptr;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1360 void **slot;
111
kono
parents: 68
diff changeset
1361 void **islot;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1362
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1363 slot = htab_find_slot (data->type_hash, type, NO_INSERT);
111
kono
parents: 68
diff changeset
1364 islot = htab_find_slot (data->invalid_hash, type, NO_INSERT);
kono
parents: 68
diff changeset
1365 if (slot == NULL || islot != NULL)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1366 fprintf (go_dump_file, "type _%s struct {}\n", type);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1367 return true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1368 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1369
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1370 /* Output symbols. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1371
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1372 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1373 go_finish (const char *filename)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1374 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
1375 class godump_container container;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1376 unsigned int ix;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1377 tree decl;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1378
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1379 real_debug_hooks->finish (filename);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1380
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1381 container.type_hash = htab_create (100, htab_hash_string,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1382 string_hash_eq, NULL);
111
kono
parents: 68
diff changeset
1383 container.invalid_hash = htab_create (10, htab_hash_string,
kono
parents: 68
diff changeset
1384 string_hash_eq, NULL);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1385 container.keyword_hash = htab_create (50, htab_hash_string,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1386 string_hash_eq, NULL);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1387 obstack_init (&container.type_obstack);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1388
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1389 keyword_hash_init (&container);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1390
111
kono
parents: 68
diff changeset
1391 FOR_EACH_VEC_SAFE_ELT (queue, ix, decl)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1392 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1393 switch (TREE_CODE (decl))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1394 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1395 case FUNCTION_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1396 go_output_fndecl (&container, decl);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1397 break;
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 case TYPE_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1400 go_output_typedef (&container, decl);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1401 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1402
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1403 case VAR_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1404 go_output_var (&container, decl);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1405 break;
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 default:
111
kono
parents: 68
diff changeset
1408 gcc_unreachable ();
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1409 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1410 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1411
111
kono
parents: 68
diff changeset
1412 htab_traverse_noresize (macro_hash, go_print_macro, NULL);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1413
111
kono
parents: 68
diff changeset
1414 /* To emit dummy definitions. */
kono
parents: 68
diff changeset
1415 container.pot_dummy_types.traverse<godump_container *, find_dummy_types>
kono
parents: 68
diff changeset
1416 (&container);
kono
parents: 68
diff changeset
1417
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1418 htab_delete (container.type_hash);
111
kono
parents: 68
diff changeset
1419 htab_delete (container.invalid_hash);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1420 htab_delete (container.keyword_hash);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1421 obstack_free (&container.type_obstack, NULL);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1422
111
kono
parents: 68
diff changeset
1423 vec_free (queue);
68
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 if (fclose (go_dump_file) != 0)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1426 error ("could not close Go dump file: %m");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1427 go_dump_file = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1428 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1429
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1430 /* Set up our hooks. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1431
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1432 const struct gcc_debug_hooks *
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1433 dump_go_spec_init (const char *filename, const struct gcc_debug_hooks *hooks)
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 go_dump_file = fopen (filename, "w");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1436 if (go_dump_file == NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1437 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1438 error ("could not open Go dump file %qs: %m", filename);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1439 return hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1440 }
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 go_debug_hooks = *hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1443 real_debug_hooks = hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1444
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1445 go_debug_hooks.finish = go_finish;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1446 go_debug_hooks.define = go_define;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1447 go_debug_hooks.undef = go_undef;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1448 go_debug_hooks.function_decl = go_function_decl;
111
kono
parents: 68
diff changeset
1449 go_debug_hooks.early_global_decl = go_early_global_decl;
kono
parents: 68
diff changeset
1450 go_debug_hooks.late_global_decl = go_late_global_decl;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1451 go_debug_hooks.type_decl = go_type_decl;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1452
111
kono
parents: 68
diff changeset
1453 macro_hash = htab_create (100, macro_hash_hashval, macro_hash_eq,
kono
parents: 68
diff changeset
1454 macro_hash_del);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1455
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1456 return &go_debug_hooks;
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
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1459 #include "gt-godump.h"