PR libstdc++/87308 adjust regex used in std::any pretty printer
[official-gcc.git] / gcc / d / dmd / impcnvgen.c
blob15239fdc283bf714c790de0be46bf8469b278142
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * http://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * http://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/D-Programming-Language/dmd/blob/master/src/impcnvgen.c
9 */
11 #include "root/dsystem.h"
13 #include "mtype.h"
15 TY impcnvResultTab[TMAX][TMAX];
16 TY impcnvType1Tab[TMAX][TMAX];
17 TY impcnvType2Tab[TMAX][TMAX];
18 int impcnvWarnTab[TMAX][TMAX];
20 int integral_promotion(int t)
22 switch (t)
24 case Tchar:
25 case Twchar:
26 case Tbool:
27 case Tint8:
28 case Tuns8:
29 case Tint16:
30 case Tuns16: return Tint32;
31 case Tdchar: return Tuns32;
32 default: return t;
36 void init()
37 { int i, j;
39 // Set conversion tables
40 for (i = 0; i < TMAX; i++)
41 for (j = 0; j < TMAX; j++)
42 { impcnvResultTab[i][j] = Terror;
43 impcnvType1Tab[i][j] = Terror;
44 impcnvType2Tab[i][j] = Terror;
45 impcnvWarnTab[i][j] = 0;
48 #define X(t1,t2, nt1,nt2, rt) \
49 impcnvResultTab[t1][t2] = rt; \
50 impcnvType1Tab[t1][t2] = nt1; \
51 impcnvType2Tab[t1][t2] = nt2;
54 /* ======================= */
56 X(Tbool,Tbool, Tbool,Tbool, Tbool)
57 X(Tbool,Tint8, Tint32,Tint32, Tint32)
58 X(Tbool,Tuns8, Tint32,Tint32, Tint32)
59 X(Tbool,Tint16, Tint32,Tint32, Tint32)
60 X(Tbool,Tuns16, Tint32,Tint32, Tint32)
61 X(Tbool,Tint32, Tint32,Tint32, Tint32)
62 X(Tbool,Tuns32, Tuns32,Tuns32, Tuns32)
63 X(Tbool,Tint64, Tint64,Tint64, Tint64)
64 X(Tbool,Tuns64, Tuns64,Tuns64, Tuns64)
65 X(Tbool,Tint128, Tint128,Tint128, Tint128)
66 X(Tbool,Tuns128, Tuns128,Tuns128, Tuns128)
68 X(Tbool,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
69 X(Tbool,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
70 X(Tbool,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
71 X(Tbool,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
72 X(Tbool,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
73 X(Tbool,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
74 X(Tbool,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
75 X(Tbool,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
76 X(Tbool,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
78 /* ======================= */
80 X(Tint8,Tint8, Tint32,Tint32, Tint32)
81 X(Tint8,Tuns8, Tint32,Tint32, Tint32)
82 X(Tint8,Tint16, Tint32,Tint32, Tint32)
83 X(Tint8,Tuns16, Tint32,Tint32, Tint32)
84 X(Tint8,Tint32, Tint32,Tint32, Tint32)
85 X(Tint8,Tuns32, Tuns32,Tuns32, Tuns32)
86 X(Tint8,Tint64, Tint64,Tint64, Tint64)
87 X(Tint8,Tuns64, Tuns64,Tuns64, Tuns64)
88 X(Tint8,Tint128, Tint128,Tint128, Tint128)
89 X(Tint8,Tuns128, Tuns128,Tuns128, Tuns128)
91 X(Tint8,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
92 X(Tint8,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
93 X(Tint8,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
94 X(Tint8,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
95 X(Tint8,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
96 X(Tint8,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
97 X(Tint8,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
98 X(Tint8,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
99 X(Tint8,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
101 /* ======================= */
103 X(Tuns8,Tuns8, Tint32,Tint32, Tint32)
104 X(Tuns8,Tint16, Tint32,Tint32, Tint32)
105 X(Tuns8,Tuns16, Tint32,Tint32, Tint32)
106 X(Tuns8,Tint32, Tint32,Tint32, Tint32)
107 X(Tuns8,Tuns32, Tuns32,Tuns32, Tuns32)
108 X(Tuns8,Tint64, Tint64,Tint64, Tint64)
109 X(Tuns8,Tuns64, Tuns64,Tuns64, Tuns64)
110 X(Tuns8,Tint128, Tint128,Tint128, Tint128)
111 X(Tuns8,Tuns128, Tuns128,Tuns128, Tuns128)
113 X(Tuns8,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
114 X(Tuns8,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
115 X(Tuns8,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
116 X(Tuns8,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
117 X(Tuns8,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
118 X(Tuns8,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
119 X(Tuns8,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
120 X(Tuns8,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
121 X(Tuns8,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
123 /* ======================= */
125 X(Tint16,Tint16, Tint32,Tint32, Tint32)
126 X(Tint16,Tuns16, Tint32,Tint32, Tint32)
127 X(Tint16,Tint32, Tint32,Tint32, Tint32)
128 X(Tint16,Tuns32, Tuns32,Tuns32, Tuns32)
129 X(Tint16,Tint64, Tint64,Tint64, Tint64)
130 X(Tint16,Tuns64, Tuns64,Tuns64, Tuns64)
131 X(Tint16,Tint128, Tint128,Tint128, Tint128)
132 X(Tint16,Tuns128, Tuns128,Tuns128, Tuns128)
134 X(Tint16,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
135 X(Tint16,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
136 X(Tint16,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
137 X(Tint16,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
138 X(Tint16,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
139 X(Tint16,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
140 X(Tint16,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
141 X(Tint16,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
142 X(Tint16,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
144 /* ======================= */
146 X(Tuns16,Tuns16, Tint32,Tint32, Tint32)
147 X(Tuns16,Tint32, Tint32,Tint32, Tint32)
148 X(Tuns16,Tuns32, Tuns32,Tuns32, Tuns32)
149 X(Tuns16,Tint64, Tint64,Tint64, Tint64)
150 X(Tuns16,Tuns64, Tuns64,Tuns64, Tuns64)
151 X(Tuns16,Tint128, Tint128,Tint128, Tint128)
152 X(Tuns16,Tuns128, Tuns128,Tuns128, Tuns128)
154 X(Tuns16,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
155 X(Tuns16,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
156 X(Tuns16,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
157 X(Tuns16,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
158 X(Tuns16,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
159 X(Tuns16,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
160 X(Tuns16,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
161 X(Tuns16,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
162 X(Tuns16,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
164 /* ======================= */
166 X(Tint32,Tint32, Tint32,Tint32, Tint32)
167 X(Tint32,Tuns32, Tuns32,Tuns32, Tuns32)
168 X(Tint32,Tint64, Tint64,Tint64, Tint64)
169 X(Tint32,Tuns64, Tuns64,Tuns64, Tuns64)
170 X(Tint32,Tint128, Tint128,Tint128, Tint128)
171 X(Tint32,Tuns128, Tuns128,Tuns128, Tuns128)
173 X(Tint32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
174 X(Tint32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
175 X(Tint32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
176 X(Tint32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
177 X(Tint32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
178 X(Tint32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
179 X(Tint32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
180 X(Tint32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
181 X(Tint32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
183 /* ======================= */
185 X(Tuns32,Tuns32, Tuns32,Tuns32, Tuns32)
186 X(Tuns32,Tint64, Tint64,Tint64, Tint64)
187 X(Tuns32,Tuns64, Tuns64,Tuns64, Tuns64)
188 X(Tuns32,Tint128, Tint128,Tint128, Tint128)
189 X(Tuns32,Tuns128, Tuns128,Tuns128, Tuns128)
191 X(Tuns32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
192 X(Tuns32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
193 X(Tuns32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
194 X(Tuns32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
195 X(Tuns32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
196 X(Tuns32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
197 X(Tuns32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
198 X(Tuns32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
199 X(Tuns32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
201 /* ======================= */
203 X(Tint64,Tint64, Tint64,Tint64, Tint64)
204 X(Tint64,Tuns64, Tuns64,Tuns64, Tuns64)
205 X(Tint64,Tint128, Tint128,Tint128, Tint128)
206 X(Tint64,Tuns128, Tuns128,Tuns128, Tuns128)
208 X(Tint64,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
209 X(Tint64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
210 X(Tint64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
211 X(Tint64,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
212 X(Tint64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
213 X(Tint64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
214 X(Tint64,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
215 X(Tint64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
216 X(Tint64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
218 /* ======================= */
220 X(Tuns64,Tuns64, Tuns64,Tuns64, Tuns64)
221 X(Tuns64,Tint128, Tint128,Tint128, Tint128)
222 X(Tuns64,Tuns128, Tuns128,Tuns128, Tuns128)
224 X(Tuns64,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
225 X(Tuns64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
226 X(Tuns64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
227 X(Tuns64,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
228 X(Tuns64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
229 X(Tuns64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
230 X(Tuns64,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
231 X(Tuns64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
232 X(Tuns64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
234 /* ======================= */
236 X(Tint128,Tint128, Tint128,Tint128, Tint128)
237 X(Tint128,Tuns128, Tuns128,Tuns128, Tuns128)
239 X(Tint128,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
240 X(Tint128,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
241 X(Tint128,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
242 X(Tint128,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
243 X(Tint128,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
244 X(Tint128,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
245 X(Tint128,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
246 X(Tint128,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
247 X(Tint128,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
249 /* ======================= */
251 X(Tuns128,Tuns128, Tuns128,Tuns128, Tuns128)
253 X(Tuns128,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
254 X(Tuns128,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
255 X(Tuns128,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
256 X(Tuns128,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
257 X(Tuns128,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
258 X(Tuns128,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
259 X(Tuns128,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
260 X(Tuns128,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
261 X(Tuns128,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
263 /* ======================= */
265 X(Tfloat32,Tfloat32, Tfloat32,Tfloat32, Tfloat32)
266 X(Tfloat32,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
267 X(Tfloat32,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
269 X(Tfloat32,Timaginary32, Tfloat32,Timaginary32, Tfloat32)
270 X(Tfloat32,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
271 X(Tfloat32,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
273 X(Tfloat32,Tcomplex32, Tfloat32,Tcomplex32, Tcomplex32)
274 X(Tfloat32,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
275 X(Tfloat32,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
277 /* ======================= */
279 X(Tfloat64,Tfloat64, Tfloat64,Tfloat64, Tfloat64)
280 X(Tfloat64,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
282 X(Tfloat64,Timaginary32, Tfloat64,Timaginary64, Tfloat64)
283 X(Tfloat64,Timaginary64, Tfloat64,Timaginary64, Tfloat64)
284 X(Tfloat64,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
286 X(Tfloat64,Tcomplex32, Tfloat64,Tcomplex64, Tcomplex64)
287 X(Tfloat64,Tcomplex64, Tfloat64,Tcomplex64, Tcomplex64)
288 X(Tfloat64,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
290 /* ======================= */
292 X(Tfloat80,Tfloat80, Tfloat80,Tfloat80, Tfloat80)
294 X(Tfloat80,Timaginary32, Tfloat80,Timaginary80, Tfloat80)
295 X(Tfloat80,Timaginary64, Tfloat80,Timaginary80, Tfloat80)
296 X(Tfloat80,Timaginary80, Tfloat80,Timaginary80, Tfloat80)
298 X(Tfloat80,Tcomplex32, Tfloat80,Tcomplex80, Tcomplex80)
299 X(Tfloat80,Tcomplex64, Tfloat80,Tcomplex80, Tcomplex80)
300 X(Tfloat80,Tcomplex80, Tfloat80,Tcomplex80, Tcomplex80)
302 /* ======================= */
304 X(Timaginary32,Timaginary32, Timaginary32,Timaginary32, Timaginary32)
305 X(Timaginary32,Timaginary64, Timaginary64,Timaginary64, Timaginary64)
306 X(Timaginary32,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
308 X(Timaginary32,Tcomplex32, Timaginary32,Tcomplex32, Tcomplex32)
309 X(Timaginary32,Tcomplex64, Timaginary64,Tcomplex64, Tcomplex64)
310 X(Timaginary32,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
312 /* ======================= */
314 X(Timaginary64,Timaginary64, Timaginary64,Timaginary64, Timaginary64)
315 X(Timaginary64,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
317 X(Timaginary64,Tcomplex32, Timaginary64,Tcomplex64, Tcomplex64)
318 X(Timaginary64,Tcomplex64, Timaginary64,Tcomplex64, Tcomplex64)
319 X(Timaginary64,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
321 /* ======================= */
323 X(Timaginary80,Timaginary80, Timaginary80,Timaginary80, Timaginary80)
325 X(Timaginary80,Tcomplex32, Timaginary80,Tcomplex80, Tcomplex80)
326 X(Timaginary80,Tcomplex64, Timaginary80,Tcomplex80, Tcomplex80)
327 X(Timaginary80,Tcomplex80, Timaginary80,Tcomplex80, Tcomplex80)
329 /* ======================= */
331 X(Tcomplex32,Tcomplex32, Tcomplex32,Tcomplex32, Tcomplex32)
332 X(Tcomplex32,Tcomplex64, Tcomplex64,Tcomplex64, Tcomplex64)
333 X(Tcomplex32,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
335 /* ======================= */
337 X(Tcomplex64,Tcomplex64, Tcomplex64,Tcomplex64, Tcomplex64)
338 X(Tcomplex64,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
340 /* ======================= */
342 X(Tcomplex80,Tcomplex80, Tcomplex80,Tcomplex80, Tcomplex80)
344 #undef X
346 #define Y(t1,t2) impcnvWarnTab[t1][t2] = 1;
348 Y(Tuns8, Tint8)
349 Y(Tint16, Tint8)
350 Y(Tuns16, Tint8)
351 Y(Tint32, Tint8)
352 Y(Tuns32, Tint8)
353 Y(Tint64, Tint8)
354 Y(Tuns64, Tint8)
355 Y(Tint128, Tint8)
356 Y(Tuns128, Tint8)
358 Y(Tint8, Tuns8)
359 Y(Tint16, Tuns8)
360 Y(Tuns16, Tuns8)
361 Y(Tint32, Tuns8)
362 Y(Tuns32, Tuns8)
363 Y(Tint64, Tuns8)
364 Y(Tuns64, Tuns8)
365 Y(Tint128, Tuns8)
366 Y(Tuns128, Tuns8)
368 Y(Tint8, Tchar)
369 Y(Tint16, Tchar)
370 Y(Tuns16, Tchar)
371 Y(Tint32, Tchar)
372 Y(Tuns32, Tchar)
373 Y(Tint64, Tchar)
374 Y(Tuns64, Tchar)
375 Y(Tint128, Tchar)
376 Y(Tuns128, Tchar)
378 Y(Tuns16, Tint16)
379 Y(Tint32, Tint16)
380 Y(Tuns32, Tint16)
381 Y(Tint64, Tint16)
382 Y(Tuns64, Tint16)
383 Y(Tint128, Tint16)
384 Y(Tuns128, Tint16)
386 Y(Tint16, Tuns16)
387 Y(Tint32, Tuns16)
388 Y(Tuns32, Tuns16)
389 Y(Tint64, Tuns16)
390 Y(Tuns64, Tuns16)
391 Y(Tint128, Tuns16)
392 Y(Tuns128, Tuns16)
394 Y(Tint16, Twchar)
395 Y(Tint32, Twchar)
396 Y(Tuns32, Twchar)
397 Y(Tint64, Twchar)
398 Y(Tuns64, Twchar)
399 Y(Tint128, Twchar)
400 Y(Tuns128, Twchar)
402 // Y(Tuns32, Tint32)
403 Y(Tint64, Tint32)
404 Y(Tuns64, Tint32)
405 Y(Tint128, Tint32)
406 Y(Tuns128, Tint32)
408 // Y(Tint32, Tuns32)
409 Y(Tint64, Tuns32)
410 Y(Tuns64, Tuns32)
411 Y(Tint128, Tuns32)
412 Y(Tuns128, Tuns32)
414 Y(Tint64, Tdchar)
415 Y(Tuns64, Tdchar)
416 Y(Tint128, Tdchar)
417 Y(Tuns128, Tdchar)
419 // Y(Tint64, Tuns64)
420 // Y(Tuns64, Tint64)
421 Y(Tint128, Tint64)
422 Y(Tuns128, Tint64)
423 Y(Tint128, Tuns64)
424 Y(Tuns128, Tuns64)
426 // Y(Tint128, Tuns128)
427 // Y(Tuns128, Tint128)
429 for (i = 0; i < TMAX; i++)
430 for (j = 0; j < TMAX; j++)
432 if (impcnvResultTab[i][j] == Terror)
434 impcnvResultTab[i][j] = impcnvResultTab[j][i];
435 impcnvType1Tab[i][j] = impcnvType2Tab[j][i];
436 impcnvType2Tab[i][j] = impcnvType1Tab[j][i];
441 int main()
443 int i;
444 int j;
446 init();
449 FILE *fp = fopen("impcnvtab.c","wb");
451 fprintf(fp,"// This file is generated by impcnvgen.c\n");
452 fprintf(fp,"#include \"mtype.h\"\n");
454 fprintf(fp,"unsigned char impcnvResult[TMAX][TMAX] =\n{\n");
455 for (i = 0; i < TMAX; i++)
457 if (i)
458 fprintf(fp, ",");
459 fprintf(fp, "{");
460 for (j = 0; j < TMAX; j++)
462 if (j)
463 fprintf(fp, ",");
464 fprintf(fp, "%d",impcnvResultTab[i][j]);
466 fprintf(fp, "}\n");
468 fprintf(fp,"};\n");
470 fprintf(fp,"unsigned char impcnvType1[TMAX][TMAX] =\n{\n");
471 for (i = 0; i < TMAX; i++)
473 if (i)
474 fprintf(fp, ",");
475 fprintf(fp, "{");
476 for (j = 0; j < TMAX; j++)
478 if (j)
479 fprintf(fp, ",");
480 fprintf(fp, "%d",impcnvType1Tab[i][j]);
482 fprintf(fp, "}\n");
484 fprintf(fp,"};\n");
486 fprintf(fp,"unsigned char impcnvType2[TMAX][TMAX] =\n{\n");
487 for (i = 0; i < TMAX; i++)
489 if (i)
490 fprintf(fp, ",");
491 fprintf(fp, "{");
492 for (j = 0; j < TMAX; j++)
494 if (j)
495 fprintf(fp, ",");
496 fprintf(fp, "%d",impcnvType2Tab[i][j]);
498 fprintf(fp, "}\n");
500 fprintf(fp,"};\n");
502 fprintf(fp,"unsigned char impcnvWarn[TMAX][TMAX] =\n{\n");
503 for (i = 0; i < TMAX; i++)
505 if (i)
506 fprintf(fp, ",");
507 fprintf(fp, "{");
508 for (j = 0; j < TMAX; j++)
510 if (j)
511 fprintf(fp, ",");
512 fprintf(fp, "%d",impcnvWarnTab[i][j]);
514 fprintf(fp, "}\n");
516 fprintf(fp,"};\n");
518 fclose(fp);
522 FILE *fp = fopen("impcnvtab.d", "wb");
524 fprintf(fp, "// This file is generated by impcnvgen.c\n");
525 fprintf(fp, "module ddmd.impcnvtab;\n");
526 fprintf(fp, "\n");
527 fprintf(fp, "import ddmd.mtype;\n");
528 fprintf(fp, "\n");
530 fprintf(fp, "extern (C++) __gshared ubyte[TMAX][TMAX] impcnvResult =\n[\n");
531 for (i = 0; i < TMAX; i++)
533 if (i)
534 fprintf(fp, ",\n");
535 fprintf(fp, " [");
536 for (j = 0; j < TMAX; j++)
538 if (j)
539 fprintf(fp, ",");
540 fprintf(fp, "%d", impcnvResultTab[i][j]);
542 fprintf(fp, "]");
544 fprintf(fp, "\n];\n");
546 fprintf(fp, "extern (C++) __gshared ubyte[TMAX][TMAX] impcnvType1 =\n[\n");
547 for (i = 0; i < TMAX; i++)
549 if (i)
550 fprintf(fp, ",\n");
551 fprintf(fp, " [");
552 for (j = 0; j < TMAX; j++)
554 if (j)
555 fprintf(fp, ",");
556 fprintf(fp, "%d", impcnvType1Tab[i][j]);
558 fprintf(fp, "]");
560 fprintf(fp, "\n];\n");
562 fprintf(fp, "extern (C++) __gshared ubyte[TMAX][TMAX] impcnvType2 =\n[\n");
563 for (i = 0; i < TMAX; i++)
565 if (i)
566 fprintf(fp, ",\n");
567 fprintf(fp, " [");
568 for (j = 0; j < TMAX; j++)
570 if (j)
571 fprintf(fp, ",");
572 fprintf(fp, "%d",impcnvType2Tab[i][j]);
574 fprintf(fp, "]");
576 fprintf(fp,"\n];\n");
578 fprintf(fp,"extern (C++) __gshared ubyte[TMAX][TMAX] impcnvWarn =\n[\n");
579 for (i = 0; i < TMAX; i++)
581 if (i)
582 fprintf(fp, ",\n");
583 fprintf(fp, " [");
584 for (j = 0; j < TMAX; j++)
586 if (j)
587 fprintf(fp, ",");
588 fprintf(fp, "%d", impcnvWarnTab[i][j]);
590 fprintf(fp, "]");
592 fprintf(fp, "\n];\n");
594 fclose(fp);
597 return EXIT_SUCCESS;