1 
2 /* Compiler implementation of the D programming language
3  * Copyright (C) 1999-2019 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  */
10 
11 #include "root/dsystem.h"
12 
13 #include "mtype.h"
14 
15 TY impcnvResultTab[TMAX][TMAX];
16 TY impcnvType1Tab[TMAX][TMAX];
17 TY impcnvType2Tab[TMAX][TMAX];
18 int impcnvWarnTab[TMAX][TMAX];
19 
integral_promotion(int t)20 int integral_promotion(int t)
21 {
22     switch (t)
23     {
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;
33     }
34 }
35 
init()36 void init()
37 {   int i, j;
38 
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;
46         }
47 
48 #define X(t1,t2, nt1,nt2, rt)           \
49         impcnvResultTab[t1][t2] = rt;      \
50         impcnvType1Tab[t1][t2] = nt1;      \
51         impcnvType2Tab[t1][t2] = nt2;
52 
53 
54     /* ======================= */
55 
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)
67 
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)
77 
78     /* ======================= */
79 
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)
90 
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)
100 
101     /* ======================= */
102 
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)
112 
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)
122 
123     /* ======================= */
124 
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)
133 
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)
143 
144     /* ======================= */
145 
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)
153 
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)
163 
164     /* ======================= */
165 
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)
172 
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)
182 
183     /* ======================= */
184 
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)
190 
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)
200 
201     /* ======================= */
202 
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)
207 
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)
217 
218     /* ======================= */
219 
220     X(Tuns64,Tuns64,  Tuns64,Tuns64,  Tuns64)
221     X(Tuns64,Tint128,  Tint128,Tint128,  Tint128)
222     X(Tuns64,Tuns128,  Tuns128,Tuns128,  Tuns128)
223 
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)
233 
234     /* ======================= */
235 
236     X(Tint128,Tint128,  Tint128,Tint128,  Tint128)
237     X(Tint128,Tuns128,  Tuns128,Tuns128,  Tuns128)
238 
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)
248 
249     /* ======================= */
250 
251     X(Tuns128,Tuns128,  Tuns128,Tuns128,  Tuns128)
252 
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)
262 
263     /* ======================= */
264 
265     X(Tfloat32,Tfloat32,  Tfloat32,Tfloat32, Tfloat32)
266     X(Tfloat32,Tfloat64,  Tfloat64,Tfloat64, Tfloat64)
267     X(Tfloat32,Tfloat80,  Tfloat80,Tfloat80, Tfloat80)
268 
269     X(Tfloat32,Timaginary32,  Tfloat32,Timaginary32, Tfloat32)
270     X(Tfloat32,Timaginary64,  Tfloat64,Timaginary64, Tfloat64)
271     X(Tfloat32,Timaginary80,  Tfloat80,Timaginary80, Tfloat80)
272 
273     X(Tfloat32,Tcomplex32,  Tfloat32,Tcomplex32, Tcomplex32)
274     X(Tfloat32,Tcomplex64,  Tfloat64,Tcomplex64, Tcomplex64)
275     X(Tfloat32,Tcomplex80,  Tfloat80,Tcomplex80, Tcomplex80)
276 
277     /* ======================= */
278 
279     X(Tfloat64,Tfloat64,  Tfloat64,Tfloat64, Tfloat64)
280     X(Tfloat64,Tfloat80,  Tfloat80,Tfloat80, Tfloat80)
281 
282     X(Tfloat64,Timaginary32,  Tfloat64,Timaginary64, Tfloat64)
283     X(Tfloat64,Timaginary64,  Tfloat64,Timaginary64, Tfloat64)
284     X(Tfloat64,Timaginary80,  Tfloat80,Timaginary80, Tfloat80)
285 
286     X(Tfloat64,Tcomplex32,  Tfloat64,Tcomplex64, Tcomplex64)
287     X(Tfloat64,Tcomplex64,  Tfloat64,Tcomplex64, Tcomplex64)
288     X(Tfloat64,Tcomplex80,  Tfloat80,Tcomplex80, Tcomplex80)
289 
290     /* ======================= */
291 
292     X(Tfloat80,Tfloat80,  Tfloat80,Tfloat80, Tfloat80)
293 
294     X(Tfloat80,Timaginary32,  Tfloat80,Timaginary80, Tfloat80)
295     X(Tfloat80,Timaginary64,  Tfloat80,Timaginary80, Tfloat80)
296     X(Tfloat80,Timaginary80,  Tfloat80,Timaginary80, Tfloat80)
297 
298     X(Tfloat80,Tcomplex32,  Tfloat80,Tcomplex80, Tcomplex80)
299     X(Tfloat80,Tcomplex64,  Tfloat80,Tcomplex80, Tcomplex80)
300     X(Tfloat80,Tcomplex80,  Tfloat80,Tcomplex80, Tcomplex80)
301 
302     /* ======================= */
303 
304     X(Timaginary32,Timaginary32,  Timaginary32,Timaginary32, Timaginary32)
305     X(Timaginary32,Timaginary64,  Timaginary64,Timaginary64, Timaginary64)
306     X(Timaginary32,Timaginary80,  Timaginary80,Timaginary80, Timaginary80)
307 
308     X(Timaginary32,Tcomplex32,  Timaginary32,Tcomplex32, Tcomplex32)
309     X(Timaginary32,Tcomplex64,  Timaginary64,Tcomplex64, Tcomplex64)
310     X(Timaginary32,Tcomplex80,  Timaginary80,Tcomplex80, Tcomplex80)
311 
312     /* ======================= */
313 
314     X(Timaginary64,Timaginary64,  Timaginary64,Timaginary64, Timaginary64)
315     X(Timaginary64,Timaginary80,  Timaginary80,Timaginary80, Timaginary80)
316 
317     X(Timaginary64,Tcomplex32,  Timaginary64,Tcomplex64, Tcomplex64)
318     X(Timaginary64,Tcomplex64,  Timaginary64,Tcomplex64, Tcomplex64)
319     X(Timaginary64,Tcomplex80,  Timaginary80,Tcomplex80, Tcomplex80)
320 
321     /* ======================= */
322 
323     X(Timaginary80,Timaginary80,  Timaginary80,Timaginary80, Timaginary80)
324 
325     X(Timaginary80,Tcomplex32,  Timaginary80,Tcomplex80, Tcomplex80)
326     X(Timaginary80,Tcomplex64,  Timaginary80,Tcomplex80, Tcomplex80)
327     X(Timaginary80,Tcomplex80,  Timaginary80,Tcomplex80, Tcomplex80)
328 
329     /* ======================= */
330 
331     X(Tcomplex32,Tcomplex32,  Tcomplex32,Tcomplex32, Tcomplex32)
332     X(Tcomplex32,Tcomplex64,  Tcomplex64,Tcomplex64, Tcomplex64)
333     X(Tcomplex32,Tcomplex80,  Tcomplex80,Tcomplex80, Tcomplex80)
334 
335     /* ======================= */
336 
337     X(Tcomplex64,Tcomplex64,  Tcomplex64,Tcomplex64, Tcomplex64)
338     X(Tcomplex64,Tcomplex80,  Tcomplex80,Tcomplex80, Tcomplex80)
339 
340     /* ======================= */
341 
342     X(Tcomplex80,Tcomplex80,  Tcomplex80,Tcomplex80, Tcomplex80)
343 
344 #undef X
345 
346 #define Y(t1,t2)        impcnvWarnTab[t1][t2] = 1;
347 
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)
357 
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)
367 
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)
377 
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)
385 
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)
393 
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)
401 
402 //    Y(Tuns32, Tint32)
403     Y(Tint64, Tint32)
404     Y(Tuns64, Tint32)
405     Y(Tint128, Tint32)
406     Y(Tuns128, Tint32)
407 
408 //    Y(Tint32, Tuns32)
409     Y(Tint64, Tuns32)
410     Y(Tuns64, Tuns32)
411     Y(Tint128, Tuns32)
412     Y(Tuns128, Tuns32)
413 
414     Y(Tint64, Tdchar)
415     Y(Tuns64, Tdchar)
416     Y(Tint128, Tdchar)
417     Y(Tuns128, Tdchar)
418 
419 //    Y(Tint64, Tuns64)
420 //    Y(Tuns64, Tint64)
421     Y(Tint128, Tint64)
422     Y(Tuns128, Tint64)
423     Y(Tint128, Tuns64)
424     Y(Tuns128, Tuns64)
425 
426 //    Y(Tint128, Tuns128)
427 //    Y(Tuns128, Tint128)
428 
429     for (i = 0; i < TMAX; i++)
430         for (j = 0; j < TMAX; j++)
431         {
432             if (impcnvResultTab[i][j] == Terror)
433             {
434                 impcnvResultTab[i][j] = impcnvResultTab[j][i];
435                 impcnvType1Tab[i][j] = impcnvType2Tab[j][i];
436                 impcnvType2Tab[i][j] = impcnvType1Tab[j][i];
437             }
438         }
439 }
440 
main()441 int main()
442 {
443     int i;
444     int j;
445 
446     init();
447 
448     {
449         FILE *fp = fopen("impcnvtab.c","wb");
450 
451         fprintf(fp,"// This file is generated by impcnvgen.c\n");
452         fprintf(fp,"#include \"mtype.h\"\n");
453 
454         fprintf(fp,"unsigned char impcnvResult[TMAX][TMAX] =\n{\n");
455         for (i = 0; i < TMAX; i++)
456         {
457             if (i)
458                 fprintf(fp, ",");
459             fprintf(fp, "{");
460             for (j = 0; j < TMAX; j++)
461             {
462                 if (j)
463                     fprintf(fp, ",");
464                 fprintf(fp, "%d",impcnvResultTab[i][j]);
465             }
466             fprintf(fp, "}\n");
467         }
468         fprintf(fp,"};\n");
469 
470         fprintf(fp,"unsigned char impcnvType1[TMAX][TMAX] =\n{\n");
471         for (i = 0; i < TMAX; i++)
472         {
473             if (i)
474                 fprintf(fp, ",");
475             fprintf(fp, "{");
476             for (j = 0; j < TMAX; j++)
477             {
478                 if (j)
479                     fprintf(fp, ",");
480                 fprintf(fp, "%d",impcnvType1Tab[i][j]);
481             }
482             fprintf(fp, "}\n");
483         }
484         fprintf(fp,"};\n");
485 
486         fprintf(fp,"unsigned char impcnvType2[TMAX][TMAX] =\n{\n");
487         for (i = 0; i < TMAX; i++)
488         {
489             if (i)
490                 fprintf(fp, ",");
491             fprintf(fp, "{");
492             for (j = 0; j < TMAX; j++)
493             {
494                 if (j)
495                     fprintf(fp, ",");
496                 fprintf(fp, "%d",impcnvType2Tab[i][j]);
497             }
498             fprintf(fp, "}\n");
499         }
500         fprintf(fp,"};\n");
501 
502         fprintf(fp,"unsigned char impcnvWarn[TMAX][TMAX] =\n{\n");
503         for (i = 0; i < TMAX; i++)
504         {
505             if (i)
506                 fprintf(fp, ",");
507             fprintf(fp, "{");
508             for (j = 0; j < TMAX; j++)
509             {
510                 if (j)
511                     fprintf(fp, ",");
512                 fprintf(fp, "%d",impcnvWarnTab[i][j]);
513             }
514             fprintf(fp, "}\n");
515         }
516         fprintf(fp,"};\n");
517 
518         fclose(fp);
519     }
520 
521     {
522         FILE *fp = fopen("impcnvtab.d", "wb");
523 
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");
529 
530         fprintf(fp, "extern (C++) __gshared ubyte[TMAX][TMAX] impcnvResult =\n[\n");
531         for (i = 0; i < TMAX; i++)
532         {
533             if (i)
534                 fprintf(fp, ",\n");
535             fprintf(fp, "    [");
536             for (j = 0; j < TMAX; j++)
537             {
538                 if (j)
539                     fprintf(fp, ",");
540                 fprintf(fp, "%d", impcnvResultTab[i][j]);
541             }
542             fprintf(fp, "]");
543         }
544         fprintf(fp, "\n];\n");
545 
546         fprintf(fp, "extern (C++) __gshared ubyte[TMAX][TMAX] impcnvType1 =\n[\n");
547         for (i = 0; i < TMAX; i++)
548         {
549             if (i)
550                 fprintf(fp, ",\n");
551             fprintf(fp, "    [");
552             for (j = 0; j < TMAX; j++)
553             {
554                 if (j)
555                     fprintf(fp, ",");
556                 fprintf(fp, "%d", impcnvType1Tab[i][j]);
557             }
558             fprintf(fp, "]");
559         }
560         fprintf(fp, "\n];\n");
561 
562         fprintf(fp, "extern (C++) __gshared ubyte[TMAX][TMAX] impcnvType2 =\n[\n");
563         for (i = 0; i < TMAX; i++)
564         {
565             if (i)
566                 fprintf(fp, ",\n");
567             fprintf(fp, "    [");
568             for (j = 0; j < TMAX; j++)
569             {
570                 if (j)
571                     fprintf(fp, ",");
572                 fprintf(fp, "%d",impcnvType2Tab[i][j]);
573             }
574             fprintf(fp, "]");
575         }
576         fprintf(fp,"\n];\n");
577 
578         fprintf(fp,"extern (C++) __gshared ubyte[TMAX][TMAX] impcnvWarn =\n[\n");
579         for (i = 0; i < TMAX; i++)
580         {
581             if (i)
582                 fprintf(fp, ",\n");
583             fprintf(fp, "    [");
584             for (j = 0; j < TMAX; j++)
585             {
586                 if (j)
587                     fprintf(fp, ",");
588                 fprintf(fp, "%d", impcnvWarnTab[i][j]);
589             }
590             fprintf(fp, "]");
591         }
592         fprintf(fp, "\n];\n");
593 
594         fclose(fp);
595     }
596 
597     return EXIT_SUCCESS;
598 }
599