annotate gcc/godump.c @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Output Go language descriptions of types.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2008-2018 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
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538 struct godump_container
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 /* DECLs that we have already seen. */
111
kono
parents: 68
diff changeset
541 hash_set<tree> decls_seen;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 /* 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
544 types. */
111
kono
parents: 68
diff changeset
545 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
546
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 /* Go keywords. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 htab_t keyword_hash;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 /* Global type definitions. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551 htab_t type_hash;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552
111
kono
parents: 68
diff changeset
553 /* Invalid types. */
kono
parents: 68
diff changeset
554 htab_t invalid_hash;
kono
parents: 68
diff changeset
555
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 /* 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
557 struct obstack type_obstack;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 };
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 /* Append an IDENTIFIER_NODE to OB. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 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
564 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565 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
566 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567
111
kono
parents: 68
diff changeset
568 /* Given an integer PRECISION in bits, returns a constant string that is the
kono
parents: 68
diff changeset
569 matching go int or uint type (depending on the IS_UNSIGNED flag). Returns a
kono
parents: 68
diff changeset
570 NULL pointer if there is no matching go type. */
kono
parents: 68
diff changeset
571
kono
parents: 68
diff changeset
572 static const char *
kono
parents: 68
diff changeset
573 go_get_uinttype_for_precision (unsigned int precision, bool is_unsigned)
kono
parents: 68
diff changeset
574 {
kono
parents: 68
diff changeset
575 switch (precision)
kono
parents: 68
diff changeset
576 {
kono
parents: 68
diff changeset
577 case 8:
kono
parents: 68
diff changeset
578 return is_unsigned ? "uint8" : "int8";
kono
parents: 68
diff changeset
579 case 16:
kono
parents: 68
diff changeset
580 return is_unsigned ? "uint16" : "int16";
kono
parents: 68
diff changeset
581 case 32:
kono
parents: 68
diff changeset
582 return is_unsigned ? "uint32" : "int32";
kono
parents: 68
diff changeset
583 case 64:
kono
parents: 68
diff changeset
584 return is_unsigned ? "uint64" : "int64";
kono
parents: 68
diff changeset
585 default:
kono
parents: 68
diff changeset
586 return NULL;
kono
parents: 68
diff changeset
587 }
kono
parents: 68
diff changeset
588 }
kono
parents: 68
diff changeset
589
kono
parents: 68
diff changeset
590 /* Append an artificial variable name with the suffix _INDEX to OB. Returns
kono
parents: 68
diff changeset
591 INDEX + 1. */
kono
parents: 68
diff changeset
592
kono
parents: 68
diff changeset
593 static unsigned int
kono
parents: 68
diff changeset
594 go_append_artificial_name (struct obstack *ob, unsigned int index)
kono
parents: 68
diff changeset
595 {
kono
parents: 68
diff changeset
596 char buf[100];
kono
parents: 68
diff changeset
597
kono
parents: 68
diff changeset
598 /* FIXME: identifier may not be unique. */
kono
parents: 68
diff changeset
599 obstack_grow (ob, "Godump_", 7);
kono
parents: 68
diff changeset
600 snprintf (buf, sizeof buf, "%u", index);
kono
parents: 68
diff changeset
601 obstack_grow (ob, buf, strlen (buf));
kono
parents: 68
diff changeset
602
kono
parents: 68
diff changeset
603 return index + 1;
kono
parents: 68
diff changeset
604 }
kono
parents: 68
diff changeset
605
kono
parents: 68
diff changeset
606 /* Append the variable name from DECL to OB. If the name is in the
kono
parents: 68
diff changeset
607 KEYWORD_HASH, prepend an '_'. */
kono
parents: 68
diff changeset
608
kono
parents: 68
diff changeset
609 static void
kono
parents: 68
diff changeset
610 go_append_decl_name (struct obstack *ob, tree decl, htab_t keyword_hash)
kono
parents: 68
diff changeset
611 {
kono
parents: 68
diff changeset
612 const char *var_name;
kono
parents: 68
diff changeset
613 void **slot;
kono
parents: 68
diff changeset
614
kono
parents: 68
diff changeset
615 /* Start variable name with an underscore if a keyword. */
kono
parents: 68
diff changeset
616 var_name = IDENTIFIER_POINTER (DECL_NAME (decl));
kono
parents: 68
diff changeset
617 slot = htab_find_slot (keyword_hash, var_name, NO_INSERT);
kono
parents: 68
diff changeset
618 if (slot != NULL)
kono
parents: 68
diff changeset
619 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
620 go_append_string (ob, DECL_NAME (decl));
kono
parents: 68
diff changeset
621 }
kono
parents: 68
diff changeset
622
kono
parents: 68
diff changeset
623 /* Appends a byte array with the necessary number of elements and the name
kono
parents: 68
diff changeset
624 "Godump_INDEX_pad" to pad from FROM_OFFSET to TO_OFFSET to OB assuming that
kono
parents: 68
diff changeset
625 the next field is automatically aligned to ALIGN_UNITS. Returns INDEX + 1,
kono
parents: 68
diff changeset
626 or INDEX if no padding had to be appended. The resulting offset where the
kono
parents: 68
diff changeset
627 next field is allocated is returned through RET_OFFSET. */
kono
parents: 68
diff changeset
628
kono
parents: 68
diff changeset
629 static unsigned int
kono
parents: 68
diff changeset
630 go_append_padding (struct obstack *ob, unsigned int from_offset,
kono
parents: 68
diff changeset
631 unsigned int to_offset, unsigned int align_units,
kono
parents: 68
diff changeset
632 unsigned int index, unsigned int *ret_offset)
kono
parents: 68
diff changeset
633 {
kono
parents: 68
diff changeset
634 if (from_offset % align_units > 0)
kono
parents: 68
diff changeset
635 from_offset += align_units - (from_offset % align_units);
kono
parents: 68
diff changeset
636 gcc_assert (to_offset >= from_offset);
kono
parents: 68
diff changeset
637 if (to_offset > from_offset)
kono
parents: 68
diff changeset
638 {
kono
parents: 68
diff changeset
639 char buf[100];
kono
parents: 68
diff changeset
640
kono
parents: 68
diff changeset
641 index = go_append_artificial_name (ob, index);
kono
parents: 68
diff changeset
642 snprintf (buf, sizeof buf, "_pad [%u]byte; ", to_offset - from_offset);
kono
parents: 68
diff changeset
643 obstack_grow (ob, buf, strlen (buf));
kono
parents: 68
diff changeset
644 }
kono
parents: 68
diff changeset
645 *ret_offset = to_offset;
kono
parents: 68
diff changeset
646
kono
parents: 68
diff changeset
647 return index;
kono
parents: 68
diff changeset
648 }
kono
parents: 68
diff changeset
649
kono
parents: 68
diff changeset
650 /* Appends an array of type TYPE_STRING with zero elements and the name
kono
parents: 68
diff changeset
651 "Godump_INDEX_align" to OB. If TYPE_STRING is a null pointer, ERROR_STRING
kono
parents: 68
diff changeset
652 is appended instead of the type. Returns INDEX + 1. */
kono
parents: 68
diff changeset
653
kono
parents: 68
diff changeset
654 static unsigned int
kono
parents: 68
diff changeset
655 go_force_record_alignment (struct obstack *ob, const char *type_string,
kono
parents: 68
diff changeset
656 unsigned int index, const char *error_string)
kono
parents: 68
diff changeset
657 {
kono
parents: 68
diff changeset
658 index = go_append_artificial_name (ob, index);
kono
parents: 68
diff changeset
659 obstack_grow (ob, "_align ", 7);
kono
parents: 68
diff changeset
660 if (type_string == NULL)
kono
parents: 68
diff changeset
661 obstack_grow (ob, error_string, strlen (error_string));
kono
parents: 68
diff changeset
662 else
kono
parents: 68
diff changeset
663 {
kono
parents: 68
diff changeset
664 obstack_grow (ob, "[0]", 3);
kono
parents: 68
diff changeset
665 obstack_grow (ob, type_string, strlen (type_string));
kono
parents: 68
diff changeset
666 }
kono
parents: 68
diff changeset
667 obstack_grow (ob, "; ", 2);
kono
parents: 68
diff changeset
668
kono
parents: 68
diff changeset
669 return index;
kono
parents: 68
diff changeset
670 }
kono
parents: 68
diff changeset
671
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
672 /* 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
673 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
674 needing to define it. IS_FUNC_OK is true if we can output a func
111
kono
parents: 68
diff changeset
675 type here; the "func" keyword will already have been added.
kono
parents: 68
diff changeset
676 Return true if the type can be represented in Go, false otherwise.
kono
parents: 68
diff changeset
677 P_ART_I is used for indexing artificial elements in nested structures and
kono
parents: 68
diff changeset
678 should always be a NULL pointer when called, except by certain recursive
kono
parents: 68
diff changeset
679 calls from go_format_type() itself. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
680
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
681 static bool
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
682 go_format_type (struct godump_container *container, tree type,
111
kono
parents: 68
diff changeset
683 bool use_type_name, bool is_func_ok, unsigned int *p_art_i,
kono
parents: 68
diff changeset
684 bool is_anon_record_or_union)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
685 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
686 bool ret;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
687 struct obstack *ob;
111
kono
parents: 68
diff changeset
688 unsigned int art_i_dummy;
kono
parents: 68
diff changeset
689 bool is_union = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
690
111
kono
parents: 68
diff changeset
691 if (p_art_i == NULL)
kono
parents: 68
diff changeset
692 {
kono
parents: 68
diff changeset
693 art_i_dummy = 0;
kono
parents: 68
diff changeset
694 p_art_i = &art_i_dummy;
kono
parents: 68
diff changeset
695 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
696 ret = true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
697 ob = &container->type_obstack;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
698
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
699 if (TYPE_NAME (type) != NULL_TREE
111
kono
parents: 68
diff changeset
700 && (container->decls_seen.contains (type)
kono
parents: 68
diff changeset
701 || 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
702 && (AGGREGATE_TYPE_P (type)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
703 || POINTER_TYPE_P (type)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
704 || TREE_CODE (type) == FUNCTION_TYPE))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
705 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
706 tree name;
111
kono
parents: 68
diff changeset
707 void **slot;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
708
111
kono
parents: 68
diff changeset
709 name = TYPE_IDENTIFIER (type);
kono
parents: 68
diff changeset
710
kono
parents: 68
diff changeset
711 slot = htab_find_slot (container->invalid_hash, IDENTIFIER_POINTER (name),
kono
parents: 68
diff changeset
712 NO_INSERT);
kono
parents: 68
diff changeset
713 if (slot != NULL)
kono
parents: 68
diff changeset
714 ret = false;
kono
parents: 68
diff changeset
715
kono
parents: 68
diff changeset
716 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
717 go_append_string (ob, name);
kono
parents: 68
diff changeset
718 return ret;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
719 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
720
111
kono
parents: 68
diff changeset
721 container->decls_seen.add (type);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
722
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
723 switch (TREE_CODE (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
724 {
111
kono
parents: 68
diff changeset
725 case TYPE_DECL:
kono
parents: 68
diff changeset
726 {
kono
parents: 68
diff changeset
727 void **slot;
kono
parents: 68
diff changeset
728
kono
parents: 68
diff changeset
729 slot = htab_find_slot (container->invalid_hash,
kono
parents: 68
diff changeset
730 IDENTIFIER_POINTER (DECL_NAME (type)),
kono
parents: 68
diff changeset
731 NO_INSERT);
kono
parents: 68
diff changeset
732 if (slot != NULL)
kono
parents: 68
diff changeset
733 ret = false;
kono
parents: 68
diff changeset
734
kono
parents: 68
diff changeset
735 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
736 go_append_string (ob, DECL_NAME (type));
kono
parents: 68
diff changeset
737 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
738 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
739
111
kono
parents: 68
diff changeset
740 case ENUMERAL_TYPE:
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
741 case INTEGER_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
742 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
743 const char *s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
744 char buf[100];
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
745
111
kono
parents: 68
diff changeset
746 s = go_get_uinttype_for_precision (TYPE_PRECISION (type),
kono
parents: 68
diff changeset
747 TYPE_UNSIGNED (type));
kono
parents: 68
diff changeset
748 if (s == NULL)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
749 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
750 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
751 TYPE_PRECISION (type),
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
752 TYPE_UNSIGNED (type) ? "u" : "");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
753 s = buf;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
754 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
755 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
756 obstack_grow (ob, s, strlen (s));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
757 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
758 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
759
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
760 case REAL_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
761 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
762 const char *s;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
763 char buf[100];
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
764
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
765 switch (TYPE_PRECISION (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
766 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
767 case 32:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
768 s = "float32";
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
769 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
770 case 64:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
771 s = "float64";
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
772 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
773 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
774 snprintf (buf, sizeof buf, "INVALID-float-%u",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
775 TYPE_PRECISION (type));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
776 s = buf;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
777 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
778 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
779 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
780 obstack_grow (ob, s, strlen (s));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
781 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
782 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
783
111
kono
parents: 68
diff changeset
784 case COMPLEX_TYPE:
kono
parents: 68
diff changeset
785 {
kono
parents: 68
diff changeset
786 const char *s;
kono
parents: 68
diff changeset
787 char buf[100];
kono
parents: 68
diff changeset
788 tree real_type;
kono
parents: 68
diff changeset
789
kono
parents: 68
diff changeset
790 real_type = TREE_TYPE (type);
kono
parents: 68
diff changeset
791 if (TREE_CODE (real_type) == REAL_TYPE)
kono
parents: 68
diff changeset
792 {
kono
parents: 68
diff changeset
793 switch (TYPE_PRECISION (real_type))
kono
parents: 68
diff changeset
794 {
kono
parents: 68
diff changeset
795 case 32:
kono
parents: 68
diff changeset
796 s = "complex64";
kono
parents: 68
diff changeset
797 break;
kono
parents: 68
diff changeset
798 case 64:
kono
parents: 68
diff changeset
799 s = "complex128";
kono
parents: 68
diff changeset
800 break;
kono
parents: 68
diff changeset
801 default:
kono
parents: 68
diff changeset
802 snprintf (buf, sizeof buf, "INVALID-complex-%u",
kono
parents: 68
diff changeset
803 2 * TYPE_PRECISION (real_type));
kono
parents: 68
diff changeset
804 s = buf;
kono
parents: 68
diff changeset
805 ret = false;
kono
parents: 68
diff changeset
806 break;
kono
parents: 68
diff changeset
807 }
kono
parents: 68
diff changeset
808 }
kono
parents: 68
diff changeset
809 else
kono
parents: 68
diff changeset
810 {
kono
parents: 68
diff changeset
811 s = "INVALID-complex-non-real";
kono
parents: 68
diff changeset
812 ret = false;
kono
parents: 68
diff changeset
813 }
kono
parents: 68
diff changeset
814 obstack_grow (ob, s, strlen (s));
kono
parents: 68
diff changeset
815 }
kono
parents: 68
diff changeset
816 break;
kono
parents: 68
diff changeset
817
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
818 case BOOLEAN_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
819 obstack_grow (ob, "bool", 4);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
820 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
821
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
822 case POINTER_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
823 if (use_type_name
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
824 && TYPE_NAME (TREE_TYPE (type)) != NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
825 && (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
826 || (POINTER_TYPE_P (TREE_TYPE (type))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
827 && (TREE_CODE (TREE_TYPE (TREE_TYPE (type)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
828 == FUNCTION_TYPE))))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
829 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
830 tree name;
111
kono
parents: 68
diff changeset
831 void **slot;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
832
111
kono
parents: 68
diff changeset
833 name = TYPE_IDENTIFIER (TREE_TYPE (type));
kono
parents: 68
diff changeset
834
kono
parents: 68
diff changeset
835 slot = htab_find_slot (container->invalid_hash,
kono
parents: 68
diff changeset
836 IDENTIFIER_POINTER (name), NO_INSERT);
kono
parents: 68
diff changeset
837 if (slot != NULL)
kono
parents: 68
diff changeset
838 ret = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
839
111
kono
parents: 68
diff changeset
840 obstack_grow (ob, "*_", 2);
kono
parents: 68
diff changeset
841 go_append_string (ob, name);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
842
111
kono
parents: 68
diff changeset
843 /* The pointer here can be used without the struct or union
kono
parents: 68
diff changeset
844 definition. So this struct or union is a potential dummy
kono
parents: 68
diff changeset
845 type. */
kono
parents: 68
diff changeset
846 if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (type)))
kono
parents: 68
diff changeset
847 container->pot_dummy_types.add (IDENTIFIER_POINTER (name));
kono
parents: 68
diff changeset
848
kono
parents: 68
diff changeset
849 return ret;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
850 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
851 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
852 obstack_grow (ob, "func", 4);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
853 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
854 obstack_1grow (ob, '*');
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
855 if (VOID_TYPE_P (TREE_TYPE (type)))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
856 obstack_grow (ob, "byte", 4);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
857 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
858 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
859 if (!go_format_type (container, TREE_TYPE (type), use_type_name,
111
kono
parents: 68
diff changeset
860 true, NULL, false))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
861 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
864
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 case ARRAY_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 obstack_1grow (ob, '[');
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 if (TYPE_DOMAIN (type) != NULL_TREE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868 && TREE_CODE (TYPE_DOMAIN (type)) == INTEGER_TYPE
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 && 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
870 && 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
871 && 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
872 && 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
873 && TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) == INTEGER_CST
111
kono
parents: 68
diff changeset
874 && 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
875 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 char buf[100];
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
877
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878 snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_DEC "+1",
111
kono
parents: 68
diff changeset
879 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
880 obstack_grow (ob, buf, strlen (buf));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 }
111
kono
parents: 68
diff changeset
882 else
kono
parents: 68
diff changeset
883 obstack_1grow (ob, '0');
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 obstack_1grow (ob, ']');
111
kono
parents: 68
diff changeset
885 if (!go_format_type (container, TREE_TYPE (type), use_type_name, false,
kono
parents: 68
diff changeset
886 NULL, false))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
889
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 case UNION_TYPE:
111
kono
parents: 68
diff changeset
891 is_union = true;
kono
parents: 68
diff changeset
892 /* Fall through to RECORD_TYPE case. */
kono
parents: 68
diff changeset
893 gcc_fallthrough ();
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 case RECORD_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 {
111
kono
parents: 68
diff changeset
896 unsigned int prev_field_end;
kono
parents: 68
diff changeset
897 unsigned int known_alignment;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
898 tree field;
111
kono
parents: 68
diff changeset
899 bool emitted_a_field;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
900
111
kono
parents: 68
diff changeset
901 /* FIXME: Why is this necessary? Without it we can get a core
kono
parents: 68
diff changeset
902 dump on the s390x headers, or from a file containing simply
kono
parents: 68
diff changeset
903 "typedef struct S T;". */
kono
parents: 68
diff changeset
904 layout_type (type);
kono
parents: 68
diff changeset
905
kono
parents: 68
diff changeset
906 prev_field_end = 0;
kono
parents: 68
diff changeset
907 known_alignment = 1;
kono
parents: 68
diff changeset
908 /* Anonymous records and unions are flattened, i.e. they are not put
kono
parents: 68
diff changeset
909 into "struct { ... }". */
kono
parents: 68
diff changeset
910 if (!is_anon_record_or_union)
kono
parents: 68
diff changeset
911 obstack_grow (ob, "struct { ", 9);
kono
parents: 68
diff changeset
912 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
913 field != NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
914 field = TREE_CHAIN (field))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 {
111
kono
parents: 68
diff changeset
916 if (TREE_CODE (field) != FIELD_DECL)
kono
parents: 68
diff changeset
917 continue;
kono
parents: 68
diff changeset
918 if (DECL_BIT_FIELD (field))
kono
parents: 68
diff changeset
919 /* Bit fields are replaced by padding. */
kono
parents: 68
diff changeset
920 continue;
kono
parents: 68
diff changeset
921 /* Only the first non-bitfield field is emitted for unions. */
kono
parents: 68
diff changeset
922 if (!is_union || !emitted_a_field)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 {
111
kono
parents: 68
diff changeset
924 /* Emit the field. */
kono
parents: 68
diff changeset
925 bool field_ok;
kono
parents: 68
diff changeset
926 bool is_anon_substructure;
kono
parents: 68
diff changeset
927 unsigned int decl_align_unit;
kono
parents: 68
diff changeset
928 unsigned int decl_offset;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
929
111
kono
parents: 68
diff changeset
930 field_ok = true;
kono
parents: 68
diff changeset
931 emitted_a_field = true;
kono
parents: 68
diff changeset
932 is_anon_substructure =
kono
parents: 68
diff changeset
933 (DECL_NAME (field) == NULL
kono
parents: 68
diff changeset
934 && (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
kono
parents: 68
diff changeset
935 || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE));
kono
parents: 68
diff changeset
936 /* Keep track of the alignment of named substructures, either
kono
parents: 68
diff changeset
937 of the whole record, or the alignment of the emitted field
kono
parents: 68
diff changeset
938 (for unions). */
kono
parents: 68
diff changeset
939 decl_align_unit = DECL_ALIGN_UNIT (field);
kono
parents: 68
diff changeset
940 if (!is_anon_substructure && decl_align_unit > known_alignment)
kono
parents: 68
diff changeset
941 known_alignment = decl_align_unit;
kono
parents: 68
diff changeset
942 /* Pad to start of field. */
kono
parents: 68
diff changeset
943 decl_offset =
kono
parents: 68
diff changeset
944 TREE_INT_CST_LOW (DECL_FIELD_OFFSET (field))
kono
parents: 68
diff changeset
945 + precision_to_units
kono
parents: 68
diff changeset
946 (TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field)));
kono
parents: 68
diff changeset
947 {
kono
parents: 68
diff changeset
948 unsigned int align_unit;
kono
parents: 68
diff changeset
949
kono
parents: 68
diff changeset
950 /* For anonymous records and unions there is no automatic
kono
parents: 68
diff changeset
951 structure alignment, so use 1 as the alignment. */
kono
parents: 68
diff changeset
952 align_unit = (is_anon_substructure) ? 1 : decl_align_unit;
kono
parents: 68
diff changeset
953 *p_art_i = go_append_padding
kono
parents: 68
diff changeset
954 (ob, prev_field_end, decl_offset, align_unit, *p_art_i,
kono
parents: 68
diff changeset
955 &prev_field_end);
kono
parents: 68
diff changeset
956 }
kono
parents: 68
diff changeset
957 if (DECL_SIZE_UNIT (field))
kono
parents: 68
diff changeset
958 prev_field_end +=
kono
parents: 68
diff changeset
959 TREE_INT_CST_LOW (DECL_SIZE_UNIT (field));
kono
parents: 68
diff changeset
960 /* Emit the field name, but not for anonymous records and
kono
parents: 68
diff changeset
961 unions. */
kono
parents: 68
diff changeset
962 if (!is_anon_substructure)
kono
parents: 68
diff changeset
963 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
964 if (DECL_NAME (field) == NULL)
111
kono
parents: 68
diff changeset
965 *p_art_i = go_append_artificial_name (ob, *p_art_i);
kono
parents: 68
diff changeset
966 else
kono
parents: 68
diff changeset
967 go_append_decl_name
kono
parents: 68
diff changeset
968 (ob, field, container->keyword_hash);
kono
parents: 68
diff changeset
969 obstack_1grow (ob, ' ');
kono
parents: 68
diff changeset
970 }
kono
parents: 68
diff changeset
971 /* Do not expand type if a record or union type or a function
kono
parents: 68
diff changeset
972 pointer. */
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
973 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
974 && (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
975 || (POINTER_TYPE_P (TREE_TYPE (field))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
976 && (TREE_CODE (TREE_TYPE (TREE_TYPE (field)))
111
kono
parents: 68
diff changeset
977 == FUNCTION_TYPE))))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
978 {
111
kono
parents: 68
diff changeset
979 tree name;
kono
parents: 68
diff changeset
980 void **slot;
kono
parents: 68
diff changeset
981
kono
parents: 68
diff changeset
982 name = TYPE_IDENTIFIER (TREE_TYPE (field));
kono
parents: 68
diff changeset
983
kono
parents: 68
diff changeset
984 slot = htab_find_slot (container->invalid_hash,
kono
parents: 68
diff changeset
985 IDENTIFIER_POINTER (name),
kono
parents: 68
diff changeset
986 NO_INSERT);
kono
parents: 68
diff changeset
987 if (slot != NULL)
kono
parents: 68
diff changeset
988 field_ok = false;
kono
parents: 68
diff changeset
989
kono
parents: 68
diff changeset
990 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
991 go_append_string (ob, name);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 if (!go_format_type (container, TREE_TYPE (field), true,
111
kono
parents: 68
diff changeset
996 false, p_art_i, is_anon_substructure))
kono
parents: 68
diff changeset
997 field_ok = false;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 }
111
kono
parents: 68
diff changeset
999 if (!is_anon_substructure)
kono
parents: 68
diff changeset
1000 obstack_grow (ob, "; ", 2);
kono
parents: 68
diff changeset
1001 if (!field_ok)
kono
parents: 68
diff changeset
1002 ret = false;
kono
parents: 68
diff changeset
1003 }
kono
parents: 68
diff changeset
1004 }
kono
parents: 68
diff changeset
1005 /* Padding. */
kono
parents: 68
diff changeset
1006 *p_art_i = go_append_padding (ob, prev_field_end,
kono
parents: 68
diff changeset
1007 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type)),
kono
parents: 68
diff changeset
1008 1, *p_art_i, &prev_field_end);
kono
parents: 68
diff changeset
1009 /* Alignment. */
kono
parents: 68
diff changeset
1010 if (!is_anon_record_or_union
kono
parents: 68
diff changeset
1011 && known_alignment < TYPE_ALIGN_UNIT (type))
kono
parents: 68
diff changeset
1012 {
kono
parents: 68
diff changeset
1013 const char *s;
kono
parents: 68
diff changeset
1014 char buf[100];
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1015
111
kono
parents: 68
diff changeset
1016 /* Enforce proper record alignment. */
kono
parents: 68
diff changeset
1017 s = go_get_uinttype_for_precision
kono
parents: 68
diff changeset
1018 (TYPE_ALIGN (type), TYPE_UNSIGNED (type));
kono
parents: 68
diff changeset
1019 if (s == NULL)
kono
parents: 68
diff changeset
1020 {
kono
parents: 68
diff changeset
1021 snprintf (buf, sizeof buf, "INVALID-int-%u%s",
kono
parents: 68
diff changeset
1022 TYPE_ALIGN (type), TYPE_UNSIGNED (type) ? "u" : "");
kono
parents: 68
diff changeset
1023 s = buf;
kono
parents: 68
diff changeset
1024 ret = false;
kono
parents: 68
diff changeset
1025 }
kono
parents: 68
diff changeset
1026 *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
1027 }
111
kono
parents: 68
diff changeset
1028 if (!is_anon_record_or_union)
kono
parents: 68
diff changeset
1029 obstack_1grow (ob, '}');
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 }
111
kono
parents: 68
diff changeset
1031 break;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1032
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033 case FUNCTION_TYPE:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1034 {
111
kono
parents: 68
diff changeset
1035 tree arg_type;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1036 bool is_varargs;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 tree result;
111
kono
parents: 68
diff changeset
1038 function_args_iterator iter;
kono
parents: 68
diff changeset
1039 bool seen_arg;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1041 /* 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
1042 pointer to a function. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1043 if (!is_func_ok)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1044 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1045 obstack_grow (ob, "func*", 5);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1047 }
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 obstack_1grow (ob, '(');
111
kono
parents: 68
diff changeset
1050 is_varargs = stdarg_p (type);
kono
parents: 68
diff changeset
1051 seen_arg = false;
kono
parents: 68
diff changeset
1052 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
1053 {
111
kono
parents: 68
diff changeset
1054 if (VOID_TYPE_P (arg_type))
kono
parents: 68
diff changeset
1055 break;
kono
parents: 68
diff changeset
1056 if (seen_arg)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057 obstack_grow (ob, ", ", 2);
111
kono
parents: 68
diff changeset
1058 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
1059 ret = false;
111
kono
parents: 68
diff changeset
1060 seen_arg = true;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062 if (is_varargs)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 {
111
kono
parents: 68
diff changeset
1064 if (prototype_p (type))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 obstack_grow (ob, ", ", 2);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 obstack_grow (ob, "...interface{}", 14);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 obstack_1grow (ob, ')');
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 result = TREE_TYPE (type);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 if (!VOID_TYPE_P (result))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1072 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1073 obstack_1grow (ob, ' ');
111
kono
parents: 68
diff changeset
1074 if (!go_format_type (container, result, use_type_name, false, NULL,
kono
parents: 68
diff changeset
1075 false))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1077 }
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 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1080
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1081 default:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1082 obstack_grow (ob, "INVALID-type", 12);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1083 ret = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1084 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1085 }
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 return ret;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1088 }
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 /* 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
1091 it. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1092
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1093 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1094 go_output_type (struct godump_container *container)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1095 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1096 struct obstack *ob;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1097
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1098 ob = &container->type_obstack;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1099 obstack_1grow (ob, '\0');
111
kono
parents: 68
diff changeset
1100 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
1101 obstack_free (ob, obstack_base (ob));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1102 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1103
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1104 /* Output a function declaration. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1106 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1107 go_output_fndecl (struct godump_container *container, tree decl)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1108 {
111
kono
parents: 68
diff changeset
1109 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
1110 fprintf (go_dump_file, "// ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1111 fprintf (go_dump_file, "func _%s ",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1112 IDENTIFIER_POINTER (DECL_NAME (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1113 go_output_type (container);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1114 fprintf (go_dump_file, " __asm__(\"%s\")\n",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1115 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1116 }
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 /* 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
1119
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1120 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1121 go_output_typedef (struct godump_container *container, tree decl)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1122 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1123 /* 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
1124 separately. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1125 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
1126 && TYPE_SIZE (TREE_TYPE (decl)) != 0
111
kono
parents: 68
diff changeset
1127 && !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
1128 && (TYPE_CANONICAL (TREE_TYPE (decl)) == NULL_TREE
111
kono
parents: 68
diff changeset
1129 || !container->decls_seen.contains
kono
parents: 68
diff changeset
1130 (TYPE_CANONICAL (TREE_TYPE (decl)))))
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1131 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1132 tree element;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 for (element = TYPE_VALUES (TREE_TYPE (decl));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1135 element != NULL_TREE;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136 element = TREE_CHAIN (element))
111
kono
parents: 68
diff changeset
1137 {
kono
parents: 68
diff changeset
1138 const char *name;
kono
parents: 68
diff changeset
1139 struct macro_hash_value *mhval;
kono
parents: 68
diff changeset
1140 void **slot;
kono
parents: 68
diff changeset
1141 char buf[WIDE_INT_PRINT_BUFFER_SIZE];
kono
parents: 68
diff changeset
1142
kono
parents: 68
diff changeset
1143 name = IDENTIFIER_POINTER (TREE_PURPOSE (element));
kono
parents: 68
diff changeset
1144
kono
parents: 68
diff changeset
1145 /* Sometimes a name will be defined as both an enum constant
kono
parents: 68
diff changeset
1146 and a macro. Avoid duplicate definition errors by
kono
parents: 68
diff changeset
1147 treating enum constants as macros. */
kono
parents: 68
diff changeset
1148 mhval = XNEW (struct macro_hash_value);
kono
parents: 68
diff changeset
1149 mhval->name = xstrdup (name);
kono
parents: 68
diff changeset
1150 mhval->value = NULL;
kono
parents: 68
diff changeset
1151 slot = htab_find_slot (macro_hash, mhval, INSERT);
kono
parents: 68
diff changeset
1152 if (*slot != NULL)
kono
parents: 68
diff changeset
1153 macro_hash_del (*slot);
kono
parents: 68
diff changeset
1154
kono
parents: 68
diff changeset
1155 if (tree_fits_shwi_p (TREE_VALUE (element)))
kono
parents: 68
diff changeset
1156 snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_DEC,
kono
parents: 68
diff changeset
1157 tree_to_shwi (TREE_VALUE (element)));
kono
parents: 68
diff changeset
1158 else if (tree_fits_uhwi_p (TREE_VALUE (element)))
kono
parents: 68
diff changeset
1159 snprintf (buf, sizeof buf, HOST_WIDE_INT_PRINT_UNSIGNED,
kono
parents: 68
diff changeset
1160 tree_to_uhwi (TREE_VALUE (element)));
kono
parents: 68
diff changeset
1161 else
kono
parents: 68
diff changeset
1162 print_hex (wi::to_wide (element), buf);
kono
parents: 68
diff changeset
1163
kono
parents: 68
diff changeset
1164 mhval->value = xstrdup (buf);
kono
parents: 68
diff changeset
1165 *slot = mhval;
kono
parents: 68
diff changeset
1166 }
kono
parents: 68
diff changeset
1167 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
1168 if (TYPE_CANONICAL (TREE_TYPE (decl)) != NULL_TREE)
111
kono
parents: 68
diff changeset
1169 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
1170 }
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 if (DECL_NAME (decl) != NULL_TREE)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1174 void **slot;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1175 const char *type;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177 type = IDENTIFIER_POINTER (DECL_NAME (decl));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1178 /* If type defined already, skip. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1179 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
1180 if (*slot != NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1181 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182 *slot = CONST_CAST (void *, (const void *) type);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183
111
kono
parents: 68
diff changeset
1184 if (!go_format_type (container, TREE_TYPE (decl), false, false, NULL,
kono
parents: 68
diff changeset
1185 false))
kono
parents: 68
diff changeset
1186 {
kono
parents: 68
diff changeset
1187 fprintf (go_dump_file, "// ");
kono
parents: 68
diff changeset
1188 slot = htab_find_slot (container->invalid_hash, type, INSERT);
kono
parents: 68
diff changeset
1189 *slot = CONST_CAST (void *, (const void *) type);
kono
parents: 68
diff changeset
1190 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1191 fprintf (go_dump_file, "type _%s ",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1192 IDENTIFIER_POINTER (DECL_NAME (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1193 go_output_type (container);
111
kono
parents: 68
diff changeset
1194
kono
parents: 68
diff changeset
1195 if (RECORD_OR_UNION_TYPE_P (TREE_TYPE (decl)))
kono
parents: 68
diff changeset
1196 {
kono
parents: 68
diff changeset
1197 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl));
kono
parents: 68
diff changeset
1198
kono
parents: 68
diff changeset
1199 if (size > 0)
kono
parents: 68
diff changeset
1200 fprintf (go_dump_file,
kono
parents: 68
diff changeset
1201 "\nconst _sizeof_%s = " HOST_WIDE_INT_PRINT_DEC,
kono
parents: 68
diff changeset
1202 IDENTIFIER_POINTER (DECL_NAME (decl)),
kono
parents: 68
diff changeset
1203 size);
kono
parents: 68
diff changeset
1204 }
kono
parents: 68
diff changeset
1205
kono
parents: 68
diff changeset
1206 container->decls_seen.add (decl);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1207 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208 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
1209 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1210 void **slot;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211 const char *type;
111
kono
parents: 68
diff changeset
1212 HOST_WIDE_INT size;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1213
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1214 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
1215 /* If type defined already, skip. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1216 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
1217 if (*slot != NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1218 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1219 *slot = CONST_CAST (void *, (const void *) type);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1220
111
kono
parents: 68
diff changeset
1221 if (!go_format_type (container, TREE_TYPE (decl), false, false, NULL,
kono
parents: 68
diff changeset
1222 false))
kono
parents: 68
diff changeset
1223 {
kono
parents: 68
diff changeset
1224 fprintf (go_dump_file, "// ");
kono
parents: 68
diff changeset
1225 slot = htab_find_slot (container->invalid_hash, type, INSERT);
kono
parents: 68
diff changeset
1226 *slot = CONST_CAST (void *, (const void *) type);
kono
parents: 68
diff changeset
1227 }
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1228 fprintf (go_dump_file, "type _%s ",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1229 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1230 go_output_type (container);
111
kono
parents: 68
diff changeset
1231
kono
parents: 68
diff changeset
1232 size = int_size_in_bytes (TREE_TYPE (decl));
kono
parents: 68
diff changeset
1233 if (size > 0)
kono
parents: 68
diff changeset
1234 fprintf (go_dump_file,
kono
parents: 68
diff changeset
1235 "\nconst _sizeof_%s = " HOST_WIDE_INT_PRINT_DEC,
kono
parents: 68
diff changeset
1236 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))),
kono
parents: 68
diff changeset
1237 size);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1238 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1239 else
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1240 return;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1241
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1242 fprintf (go_dump_file, "\n");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1243 }
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 /* Output a variable. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1246
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1247 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1248 go_output_var (struct godump_container *container, tree decl)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1249 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1250 bool is_valid;
111
kono
parents: 68
diff changeset
1251 tree type_name;
kono
parents: 68
diff changeset
1252 tree id;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1253
111
kono
parents: 68
diff changeset
1254 if (container->decls_seen.contains (decl)
kono
parents: 68
diff changeset
1255 || 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
1256 return;
111
kono
parents: 68
diff changeset
1257 container->decls_seen.add (decl);
kono
parents: 68
diff changeset
1258 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
1259
111
kono
parents: 68
diff changeset
1260 type_name = TYPE_NAME (TREE_TYPE (decl));
kono
parents: 68
diff changeset
1261 id = NULL_TREE;
kono
parents: 68
diff changeset
1262 if (type_name != NULL_TREE && TREE_CODE (type_name) == IDENTIFIER_NODE)
kono
parents: 68
diff changeset
1263 id = type_name;
kono
parents: 68
diff changeset
1264 else if (type_name != NULL_TREE && TREE_CODE (type_name) == TYPE_DECL
kono
parents: 68
diff changeset
1265 && DECL_SOURCE_LOCATION (type_name) != BUILTINS_LOCATION
kono
parents: 68
diff changeset
1266 && DECL_NAME (type_name))
kono
parents: 68
diff changeset
1267 id = DECL_NAME (type_name);
kono
parents: 68
diff changeset
1268 if (id != NULL_TREE
kono
parents: 68
diff changeset
1269 && (!htab_find_slot (container->type_hash, IDENTIFIER_POINTER (id),
kono
parents: 68
diff changeset
1270 NO_INSERT)
kono
parents: 68
diff changeset
1271 || htab_find_slot (container->invalid_hash, IDENTIFIER_POINTER (id),
kono
parents: 68
diff changeset
1272 NO_INSERT)))
kono
parents: 68
diff changeset
1273 id = NULL_TREE;
kono
parents: 68
diff changeset
1274 if (id != NULL_TREE)
kono
parents: 68
diff changeset
1275 {
kono
parents: 68
diff changeset
1276 struct obstack *ob;
kono
parents: 68
diff changeset
1277
kono
parents: 68
diff changeset
1278 ob = &container->type_obstack;
kono
parents: 68
diff changeset
1279 obstack_1grow (ob, '_');
kono
parents: 68
diff changeset
1280 go_append_string (ob, id);
kono
parents: 68
diff changeset
1281 is_valid = htab_find_slot (container->type_hash, IDENTIFIER_POINTER (id),
kono
parents: 68
diff changeset
1282 NO_INSERT) != NULL;
kono
parents: 68
diff changeset
1283 }
kono
parents: 68
diff changeset
1284 else
kono
parents: 68
diff changeset
1285 is_valid = go_format_type (container, TREE_TYPE (decl), true, false, NULL,
kono
parents: 68
diff changeset
1286 false);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1287 if (is_valid
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1288 && htab_find_slot (container->type_hash,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1289 IDENTIFIER_POINTER (DECL_NAME (decl)),
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1290 NO_INSERT) != NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1291 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1292 /* 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
1293 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
1294 is_valid = false;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296 if (!is_valid)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1297 fprintf (go_dump_file, "// ");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1298
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299 fprintf (go_dump_file, "var _%s ",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1300 IDENTIFIER_POINTER (DECL_NAME (decl)));
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301 go_output_type (container);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1302 fprintf (go_dump_file, "\n");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304 /* 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
1305 type. */
111
kono
parents: 68
diff changeset
1306 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
1307 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1308 if (TREE_CODE (type_name) == IDENTIFIER_NODE)
111
kono
parents: 68
diff changeset
1309 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
1310 else if (TREE_CODE (type_name) == TYPE_DECL)
111
kono
parents: 68
diff changeset
1311 container->pot_dummy_types.add
kono
parents: 68
diff changeset
1312 (IDENTIFIER_POINTER (DECL_NAME (type_name)));
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1313 }
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
111
kono
parents: 68
diff changeset
1316 /* Output the final value of a preprocessor macro or enum constant.
kono
parents: 68
diff changeset
1317 This is called via htab_traverse_noresize. */
kono
parents: 68
diff changeset
1318
kono
parents: 68
diff changeset
1319 static int
kono
parents: 68
diff changeset
1320 go_print_macro (void **slot, void *arg ATTRIBUTE_UNUSED)
kono
parents: 68
diff changeset
1321 {
kono
parents: 68
diff changeset
1322 struct macro_hash_value *mhval = (struct macro_hash_value *) *slot;
kono
parents: 68
diff changeset
1323 fprintf (go_dump_file, "const _%s = %s\n", mhval->name, mhval->value);
kono
parents: 68
diff changeset
1324 return 1;
kono
parents: 68
diff changeset
1325 }
kono
parents: 68
diff changeset
1326
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1327 /* 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
1328
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1329 static const char * const keywords[] = {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1330 "__asm__", "break", "case", "chan", "const", "continue", "default",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1331 "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
1332 "import", "interface", "map", "package", "range", "return", "select",
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1333 "struct", "switch", "type", "var"
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1334 };
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 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1337 keyword_hash_init (struct godump_container *container)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1338 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1339 size_t i;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1340 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
1341 void **slot;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1342
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1343 for (i = 0; i < count; i++)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1344 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1345 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
1346 *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
1347 }
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 /* 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
1351 in the global types hash table and creating dummy definitions if
111
kono
parents: 68
diff changeset
1352 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
1353
111
kono
parents: 68
diff changeset
1354 bool
kono
parents: 68
diff changeset
1355 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
1356 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1357 struct godump_container *data = (struct godump_container *) adata;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1358 const char *type = (const char *) ptr;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1359 void **slot;
111
kono
parents: 68
diff changeset
1360 void **islot;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1361
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1362 slot = htab_find_slot (data->type_hash, type, NO_INSERT);
111
kono
parents: 68
diff changeset
1363 islot = htab_find_slot (data->invalid_hash, type, NO_INSERT);
kono
parents: 68
diff changeset
1364 if (slot == NULL || islot != NULL)
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1365 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
1366 return true;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1367 }
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 /* Output symbols. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1370
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1371 static void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1372 go_finish (const char *filename)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1373 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1374 struct godump_container container;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1375 unsigned int ix;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1376 tree decl;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1377
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1378 real_debug_hooks->finish (filename);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1379
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1380 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
1381 string_hash_eq, NULL);
111
kono
parents: 68
diff changeset
1382 container.invalid_hash = htab_create (10, htab_hash_string,
kono
parents: 68
diff changeset
1383 string_hash_eq, NULL);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1384 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
1385 string_hash_eq, NULL);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1386 obstack_init (&container.type_obstack);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1387
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1388 keyword_hash_init (&container);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1389
111
kono
parents: 68
diff changeset
1390 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
1391 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1392 switch (TREE_CODE (decl))
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1393 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1394 case FUNCTION_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1395 go_output_fndecl (&container, decl);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1396 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1397
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1398 case TYPE_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1399 go_output_typedef (&container, decl);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1400 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1401
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1402 case VAR_DECL:
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1403 go_output_var (&container, decl);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1404 break;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1405
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1406 default:
111
kono
parents: 68
diff changeset
1407 gcc_unreachable ();
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1408 }
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
111
kono
parents: 68
diff changeset
1411 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
1412
111
kono
parents: 68
diff changeset
1413 /* To emit dummy definitions. */
kono
parents: 68
diff changeset
1414 container.pot_dummy_types.traverse<godump_container *, find_dummy_types>
kono
parents: 68
diff changeset
1415 (&container);
kono
parents: 68
diff changeset
1416
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1417 htab_delete (container.type_hash);
111
kono
parents: 68
diff changeset
1418 htab_delete (container.invalid_hash);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1419 htab_delete (container.keyword_hash);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1420 obstack_free (&container.type_obstack, NULL);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1421
111
kono
parents: 68
diff changeset
1422 vec_free (queue);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1423
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1424 if (fclose (go_dump_file) != 0)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1425 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
1426 go_dump_file = NULL;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1427 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1428
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1429 /* Set up our hooks. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1430
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1431 const struct gcc_debug_hooks *
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1432 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
1433 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1434 go_dump_file = fopen (filename, "w");
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1435 if (go_dump_file == NULL)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1436 {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1437 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
1438 return hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1439 }
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 go_debug_hooks = *hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1442 real_debug_hooks = hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1443
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1444 go_debug_hooks.finish = go_finish;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1445 go_debug_hooks.define = go_define;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1446 go_debug_hooks.undef = go_undef;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1447 go_debug_hooks.function_decl = go_function_decl;
111
kono
parents: 68
diff changeset
1448 go_debug_hooks.early_global_decl = go_early_global_decl;
kono
parents: 68
diff changeset
1449 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
1450 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
1451
111
kono
parents: 68
diff changeset
1452 macro_hash = htab_create (100, macro_hash_hashval, macro_hash_eq,
kono
parents: 68
diff changeset
1453 macro_hash_del);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1454
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1455 return &go_debug_hooks;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1456 }
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 #include "gt-godump.h"