Mercurial > projects > ldc
annotate dmd/mtype.h @ 1146:1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
* Added #if IN_DMD versioning around DMD backend specific code in the D1 frontend, D2 is currently broken.
* All part of a greater cleanup scheme.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Thu, 26 Mar 2009 20:45:53 +0100 |
parents | b30fe7e1dbb9 |
children | dbe4af57b240 |
rev | line source |
---|---|
159 | 1 |
2 // Compiler implementation of the D programming language | |
3 // Copyright (c) 1999-2007 by Digital Mars | |
4 // All Rights Reserved | |
5 // written by Walter Bright | |
6 // http://www.digitalmars.com | |
7 // License for redistribution is by either the Artistic License | |
8 // in artistic.txt, or the GNU General Public License in gnu.txt. | |
9 // See the included readme.txt for details. | |
10 | |
11 #ifndef DMD_MTYPE_H | |
12 #define DMD_MTYPE_H | |
13 | |
14 #ifdef __DMC__ | |
15 #pragma once | |
16 #endif /* __DMC__ */ | |
17 | |
18 #include "root.h" | |
19 #include "stringtable.h" | |
20 | |
21 #include "arraytypes.h" | |
22 #include "expression.h" | |
23 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
24 #if IN_LLVM |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
162
diff
changeset
|
25 // llvm |
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
162
diff
changeset
|
26 #include "../ir/irtype.h" |
1051
dc608dc33081
Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents:
1029
diff
changeset
|
27 #include "../ir/irfuncty.h" |
938
a904cc9bc064
Convert struct arg to integer when passing inreg to make sure LLVM doesn't
Christian Kamm <kamm incasoftware de>
parents:
930
diff
changeset
|
28 namespace llvm { class Type; } |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
29 #endif |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
162
diff
changeset
|
30 |
159 | 31 struct Scope; |
32 struct Identifier; | |
33 struct Expression; | |
34 struct StructDeclaration; | |
35 struct ClassDeclaration; | |
36 struct VarDeclaration; | |
37 struct EnumDeclaration; | |
38 struct TypedefDeclaration; | |
39 struct TypeInfoDeclaration; | |
40 struct Dsymbol; | |
41 struct TemplateInstance; | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
42 struct CppMangleState; |
159 | 43 enum LINK; |
44 | |
45 struct TypeBasic; | |
46 struct HdrGenState; | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
47 struct Argument; |
159 | 48 |
49 // Back end | |
50 #if IN_GCC | |
51 union tree_node; typedef union tree_node TYPE; | |
52 typedef TYPE type; | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
53 #endif |
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
54 |
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
55 #if IN_DMD |
159 | 56 typedef struct TYPE type; |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
57 struct Symbol; |
159 | 58 #endif |
59 | |
60 enum TY | |
61 { | |
62 Tarray, // dynamic array | |
63 Tsarray, // static array | |
64 Taarray, // associative array | |
65 Tpointer, | |
66 Treference, | |
67 Tfunction, | |
68 Tident, | |
69 Tclass, | |
70 Tstruct, | |
71 Tenum, | |
72 Ttypedef, | |
73 Tdelegate, | |
74 | |
75 Tnone, | |
76 Tvoid, | |
77 Tint8, | |
78 Tuns8, | |
79 Tint16, | |
80 Tuns16, | |
81 Tint32, | |
82 Tuns32, | |
83 Tint64, | |
84 Tuns64, | |
85 Tfloat32, | |
86 Tfloat64, | |
87 Tfloat80, | |
88 | |
89 Timaginary32, | |
90 Timaginary64, | |
91 Timaginary80, | |
92 | |
93 Tcomplex32, | |
94 Tcomplex64, | |
95 Tcomplex80, | |
96 | |
97 Tbit, | |
98 Tbool, | |
99 Tchar, | |
100 Twchar, | |
101 Tdchar, | |
102 | |
103 Terror, | |
104 Tinstance, | |
105 Ttypeof, | |
106 Ttuple, | |
107 Tslice, | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
108 Treturn, |
159 | 109 TMAX |
110 }; | |
111 | |
112 #define Tascii Tchar | |
113 | |
114 extern int Tsize_t; | |
115 extern int Tptrdiff_t; | |
116 | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
117 |
159 | 118 struct Type : Object |
119 { | |
120 TY ty; | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
121 unsigned char mod; // modifiers MODxxxx |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
122 /* pick this order of numbers so switch statements work better |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
123 */ |
159 | 124 #define MODconst 1 // type is const |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
125 #define MODinvariant 4 // type is invariant |
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
126 #define MODshared 2 // type is shared |
159 | 127 char *deco; |
128 Type *pto; // merged pointer to this type | |
129 Type *rto; // reference to this type | |
130 Type *arrayof; // array of this type | |
131 TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type | |
132 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
133 #if IN_DMD |
159 | 134 type *ctype; // for back end |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
135 #endif |
159 | 136 |
137 #define tvoid basic[Tvoid] | |
138 #define tint8 basic[Tint8] | |
139 #define tuns8 basic[Tuns8] | |
140 #define tint16 basic[Tint16] | |
141 #define tuns16 basic[Tuns16] | |
142 #define tint32 basic[Tint32] | |
143 #define tuns32 basic[Tuns32] | |
144 #define tint64 basic[Tint64] | |
145 #define tuns64 basic[Tuns64] | |
146 #define tfloat32 basic[Tfloat32] | |
147 #define tfloat64 basic[Tfloat64] | |
148 #define tfloat80 basic[Tfloat80] | |
149 | |
150 #define timaginary32 basic[Timaginary32] | |
151 #define timaginary64 basic[Timaginary64] | |
152 #define timaginary80 basic[Timaginary80] | |
153 | |
154 #define tcomplex32 basic[Tcomplex32] | |
155 #define tcomplex64 basic[Tcomplex64] | |
156 #define tcomplex80 basic[Tcomplex80] | |
157 | |
158 #define tbit basic[Tbit] | |
159 #define tbool basic[Tbool] | |
160 #define tchar basic[Tchar] | |
161 #define twchar basic[Twchar] | |
162 #define tdchar basic[Tdchar] | |
163 | |
164 // Some special types | |
165 #define tshiftcnt tint32 // right side of shift expression | |
166 // #define tboolean tint32 // result of boolean expression | |
167 #define tboolean tbool // result of boolean expression | |
168 #define tindex tint32 // array/ptr index | |
169 static Type *tvoidptr; // void* | |
170 #define terror basic[Terror] // for error recovery | |
171 | |
172 #define tsize_t basic[Tsize_t] // matches size_t alias | |
173 #define tptrdiff_t basic[Tptrdiff_t] // matches ptrdiff_t alias | |
174 #define thash_t tsize_t // matches hash_t alias | |
175 | |
176 static ClassDeclaration *typeinfo; | |
177 static ClassDeclaration *typeinfoclass; | |
178 static ClassDeclaration *typeinfointerface; | |
179 static ClassDeclaration *typeinfostruct; | |
180 static ClassDeclaration *typeinfotypedef; | |
181 static ClassDeclaration *typeinfopointer; | |
182 static ClassDeclaration *typeinfoarray; | |
183 static ClassDeclaration *typeinfostaticarray; | |
184 static ClassDeclaration *typeinfoassociativearray; | |
185 static ClassDeclaration *typeinfoenum; | |
186 static ClassDeclaration *typeinfofunction; | |
187 static ClassDeclaration *typeinfodelegate; | |
188 static ClassDeclaration *typeinfotypelist; | |
189 | |
190 static Type *basic[TMAX]; | |
191 static unsigned char mangleChar[TMAX]; | |
192 static StringTable stringtable; | |
193 | |
194 // These tables are for implicit conversion of binary ops; | |
195 // the indices are the type of operand one, followed by operand two. | |
196 static unsigned char impcnvResult[TMAX][TMAX]; | |
197 static unsigned char impcnvType1[TMAX][TMAX]; | |
198 static unsigned char impcnvType2[TMAX][TMAX]; | |
199 | |
200 // If !=0, give warning on implicit conversion | |
201 static unsigned char impcnvWarn[TMAX][TMAX]; | |
202 | |
203 Type(TY ty, Type *next); | |
204 virtual Type *syntaxCopy(); | |
205 int equals(Object *o); | |
206 int dyncast() { return DYNCAST_TYPE; } // kludge for template.isType() | |
207 int covariant(Type *t); | |
208 char *toChars(); | |
209 static char needThisPrefix(); | |
210 static void init(); | |
211 d_uns64 size(); | |
212 virtual d_uns64 size(Loc loc); | |
213 virtual unsigned alignsize(); | |
214 virtual Type *semantic(Loc loc, Scope *sc); | |
215 virtual void toDecoBuffer(OutBuffer *buf); | |
216 Type *merge(); | |
217 virtual void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
218 virtual void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
219 void toCBuffer3(OutBuffer *buf, HdrGenState *hgs, int mod); | |
220 virtual int isbit(); | |
221 virtual int isintegral(); | |
222 virtual int isfloating(); // real, imaginary, or complex | |
223 virtual int isreal(); | |
224 virtual int isimaginary(); | |
225 virtual int iscomplex(); | |
226 virtual int isscalar(); | |
227 virtual int isunsigned(); | |
228 virtual int isauto(); | |
229 virtual int isString(); | |
230 virtual int checkBoolean(); // if can be converted to boolean value | |
231 void checkDeprecated(Loc loc, Scope *sc); | |
232 Type *pointerTo(); | |
233 Type *referenceTo(); | |
234 Type *arrayOf(); | |
235 virtual Dsymbol *toDsymbol(Scope *sc); | |
236 virtual Type *toBasetype(); | |
237 virtual int isBaseOf(Type *t, int *poffset); | |
238 virtual MATCH implicitConvTo(Type *to); | |
239 virtual ClassDeclaration *isClassHandle(); | |
240 virtual Expression *getProperty(Loc loc, Identifier *ident); | |
241 virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
242 virtual unsigned memalign(unsigned salign); | |
243 virtual Expression *defaultInit(Loc loc = 0); | |
244 virtual int isZeroInit(); // if initializer is 0 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
245 #if IN_DMD |
159 | 246 virtual dt_t **toDt(dt_t **pdt); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
247 #endif |
159 | 248 Identifier *getTypeInfoIdent(int internal); |
249 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
250 virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
251 Expression *getInternalTypeInfo(Scope *sc); | |
252 Expression *getTypeInfo(Scope *sc); | |
253 virtual TypeInfoDeclaration *getTypeInfoDeclaration(); | |
254 virtual int builtinTypeInfo(); | |
255 virtual Type *reliesOnTident(); | |
256 virtual Expression *toExpression(); | |
257 virtual int hasPointers(); | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
258 Type *next; |
159 | 259 Type *nextOf() { return next; } |
260 | |
261 static void error(Loc loc, const char *format, ...); | |
1103
b30fe7e1dbb9
- Updated to DMD frontend 1.041.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1051
diff
changeset
|
262 static void warning(Loc loc, const char *format, ...); |
159 | 263 |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
264 #if IN_DMD |
159 | 265 // For backend |
266 virtual unsigned totym(); | |
267 virtual type *toCtype(); | |
268 virtual type *toCParamtype(); | |
269 virtual Symbol *toSymbol(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
270 #endif |
159 | 271 |
272 // For eliminating dynamic_cast | |
273 virtual TypeBasic *isTypeBasic(); | |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
162
diff
changeset
|
274 |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
275 #if IN_LLVM |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
276 // LDC |
173
db9890b3fb64
[svn r189] moving IR data back into DMD frontend nodes
ChristianK
parents:
162
diff
changeset
|
277 IrType ir; |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
278 #endif |
159 | 279 }; |
280 | |
281 struct TypeBasic : Type | |
282 { | |
658
50383e476c7e
Upgraded frontend to DMD 1.035
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
508
diff
changeset
|
283 const char *dstring; |
50383e476c7e
Upgraded frontend to DMD 1.035
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
508
diff
changeset
|
284 const char *cstring; |
159 | 285 unsigned flags; |
286 | |
287 TypeBasic(TY ty); | |
288 Type *syntaxCopy(); | |
289 d_uns64 size(Loc loc); | |
290 unsigned alignsize(); | |
291 Expression *getProperty(Loc loc, Identifier *ident); | |
292 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
293 char *toChars(); | |
294 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
295 int isintegral(); | |
296 int isbit(); | |
297 int isfloating(); | |
298 int isreal(); | |
299 int isimaginary(); | |
300 int iscomplex(); | |
301 int isscalar(); | |
302 int isunsigned(); | |
303 MATCH implicitConvTo(Type *to); | |
304 Expression *defaultInit(Loc loc); | |
305 int isZeroInit(); | |
306 int builtinTypeInfo(); | |
307 | |
308 // For eliminating dynamic_cast | |
309 TypeBasic *isTypeBasic(); | |
310 }; | |
311 | |
312 struct TypeArray : Type | |
313 { | |
314 TypeArray(TY ty, Type *next); | |
315 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
316 }; | |
317 | |
318 // Static array, one with a fixed dimension | |
319 struct TypeSArray : TypeArray | |
320 { | |
321 Expression *dim; | |
322 | |
323 TypeSArray(Type *t, Expression *dim); | |
324 Type *syntaxCopy(); | |
325 d_uns64 size(Loc loc); | |
326 unsigned alignsize(); | |
327 Type *semantic(Loc loc, Scope *sc); | |
328 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
329 void toDecoBuffer(OutBuffer *buf); | |
330 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
331 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
332 int isString(); | |
333 int isZeroInit(); | |
334 unsigned memalign(unsigned salign); | |
335 MATCH implicitConvTo(Type *to); | |
336 Expression *defaultInit(Loc loc); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
337 #if IN_DMD |
159 | 338 dt_t **toDt(dt_t **pdt); |
339 dt_t **toDtElem(dt_t **pdt, Expression *e); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
340 #endif |
159 | 341 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); |
342 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
343 Expression *toExpression(); | |
344 int hasPointers(); | |
345 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
346 #if IN_DMD |
159 | 347 type *toCtype(); |
348 type *toCParamtype(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
349 #endif |
159 | 350 }; |
351 | |
352 // Dynamic array, no dimension | |
353 struct TypeDArray : TypeArray | |
354 { | |
355 TypeDArray(Type *t); | |
356 Type *syntaxCopy(); | |
357 d_uns64 size(Loc loc); | |
358 unsigned alignsize(); | |
359 Type *semantic(Loc loc, Scope *sc); | |
360 void toDecoBuffer(OutBuffer *buf); | |
361 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
362 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
363 int isString(); | |
364 int isZeroInit(); | |
365 int checkBoolean(); | |
366 MATCH implicitConvTo(Type *to); | |
367 Expression *defaultInit(Loc loc); | |
368 int builtinTypeInfo(); | |
369 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
370 int hasPointers(); | |
371 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
372 #if IN_DMD |
159 | 373 type *toCtype(); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
374 #endif |
159 | 375 }; |
376 | |
377 struct TypeAArray : TypeArray | |
378 { | |
379 Type *index; // key type for type checking | |
380 Type *key; // actual key type | |
381 | |
382 TypeAArray(Type *t, Type *index); | |
383 Type *syntaxCopy(); | |
384 d_uns64 size(Loc loc); | |
385 Type *semantic(Loc loc, Scope *sc); | |
336 | 386 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); |
159 | 387 void toDecoBuffer(OutBuffer *buf); |
388 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
389 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
390 Expression *defaultInit(Loc loc); | |
391 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
211
f66219e0d530
[svn r227] Fixed: crash in lifetime.d when resizing array of AAs by .length assignment.
lindquist
parents:
173
diff
changeset
|
392 int isZeroInit(); |
159 | 393 int checkBoolean(); |
394 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
395 int hasPointers(); | |
396 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
397 #if IN_DMD |
159 | 398 // Back end |
758
f04dde6e882c
Added initial D2 support, D2 frontend and changes to codegen to make things compile.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
723
diff
changeset
|
399 Symbol *aaGetSymbol(const char *func, int flags); |
159 | 400 |
401 type *toCtype(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
402 #endif |
159 | 403 }; |
404 | |
405 struct TypePointer : Type | |
406 { | |
407 TypePointer(Type *t); | |
408 Type *syntaxCopy(); | |
409 Type *semantic(Loc loc, Scope *sc); | |
410 d_uns64 size(Loc loc); | |
411 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
412 MATCH implicitConvTo(Type *to); | |
413 int isscalar(); | |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
414 // LDC: pointers are unsigned |
411
3545f9eddbfc
Switch TypePointer::isunsigned from false to true, so CmpExp::toElem chooses the right operand for pointer comparisons.
Christian Kamm <kamm incasoftware de>
parents:
379
diff
changeset
|
415 int isunsigned() { return TRUE; }; |
159 | 416 Expression *defaultInit(Loc loc); |
417 int isZeroInit(); | |
418 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
419 int hasPointers(); | |
420 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
421 #if IN_DMD |
159 | 422 type *toCtype(); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
423 #endif |
159 | 424 }; |
425 | |
426 struct TypeReference : Type | |
427 { | |
428 TypeReference(Type *t); | |
429 Type *syntaxCopy(); | |
430 d_uns64 size(Loc loc); | |
431 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
432 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
433 Expression *defaultInit(Loc loc); | |
434 int isZeroInit(); | |
435 }; | |
436 | |
437 enum RET | |
438 { | |
439 RETregs = 1, // returned in registers | |
440 RETstack = 2, // returned on stack | |
441 }; | |
442 | |
443 struct TypeFunction : Type | |
444 { | |
445 Arguments *parameters; // function parameters | |
446 int varargs; // 1: T t, ...) style for variable number of arguments | |
447 // 2: T t ...) style for variable number of arguments | |
448 enum LINK linkage; // calling convention | |
449 | |
450 int inuse; | |
451 | |
452 TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage); | |
453 Type *syntaxCopy(); | |
454 Type *semantic(Loc loc, Scope *sc); | |
455 void toDecoBuffer(OutBuffer *buf); | |
456 void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
457 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
458 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
459 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
460 Type *reliesOnTident(); | |
461 | |
462 int callMatch(Expressions *toargs); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
463 #if IN_DMD |
159 | 464 type *toCtype(); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
465 #endif |
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
466 |
159 | 467 enum RET retStyle(); |
468 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
469 #if IN_DMD |
159 | 470 unsigned totym(); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
471 #elif IN_LLVM |
663
6aaa3d3c1183
First part of rename to LDC.
Christian Kamm <kamm incasoftware de>
parents:
658
diff
changeset
|
472 // LDC |
1051
dc608dc33081
Make IrFuncTy a member of TypeFunction. Reset between modules compiled in the
Christian Kamm <kamm incasoftware de>
parents:
1029
diff
changeset
|
473 IrFuncTy fty; |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
474 #endif |
159 | 475 }; |
476 | |
477 struct TypeDelegate : Type | |
478 { | |
479 TypeDelegate(Type *t); | |
480 Type *syntaxCopy(); | |
481 Type *semantic(Loc loc, Scope *sc); | |
482 d_uns64 size(Loc loc); | |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
758
diff
changeset
|
483 unsigned alignsize(); // added in LDC |
159 | 484 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); |
485 Expression *defaultInit(Loc loc); | |
486 int isZeroInit(); | |
487 int checkBoolean(); | |
488 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
489 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
490 int hasPointers(); | |
491 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
492 #if IN_DMD |
159 | 493 type *toCtype(); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
494 #endif |
159 | 495 }; |
496 | |
497 struct TypeQualified : Type | |
498 { | |
499 Loc loc; | |
500 Array idents; // array of Identifier's representing ident.ident.ident etc. | |
501 | |
502 TypeQualified(TY ty, Loc loc); | |
503 void syntaxCopyHelper(TypeQualified *t); | |
504 void addIdent(Identifier *ident); | |
505 void toCBuffer2Helper(OutBuffer *buf, HdrGenState *hgs); | |
506 d_uns64 size(Loc loc); | |
507 void resolveHelper(Loc loc, Scope *sc, Dsymbol *s, Dsymbol *scopesym, | |
508 Expression **pe, Type **pt, Dsymbol **ps); | |
509 }; | |
510 | |
511 struct TypeIdentifier : TypeQualified | |
512 { | |
513 Identifier *ident; | |
514 | |
515 TypeIdentifier(Loc loc, Identifier *ident); | |
516 Type *syntaxCopy(); | |
517 //char *toChars(); | |
518 void toDecoBuffer(OutBuffer *buf); | |
519 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
520 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
521 Dsymbol *toDsymbol(Scope *sc); | |
522 Type *semantic(Loc loc, Scope *sc); | |
523 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
524 Type *reliesOnTident(); | |
525 Expression *toExpression(); | |
526 }; | |
527 | |
528 /* Similar to TypeIdentifier, but with a TemplateInstance as the root | |
529 */ | |
530 struct TypeInstance : TypeQualified | |
531 { | |
532 TemplateInstance *tempinst; | |
533 | |
534 TypeInstance(Loc loc, TemplateInstance *tempinst); | |
535 Type *syntaxCopy(); | |
536 //char *toChars(); | |
537 //void toDecoBuffer(OutBuffer *buf); | |
538 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
539 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
540 Type *semantic(Loc loc, Scope *sc); | |
875
330f999ade44
Merged DMD 1.038
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
541 Dsymbol *toDsymbol(Scope *sc); |
159 | 542 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); |
543 }; | |
544 | |
545 struct TypeTypeof : TypeQualified | |
546 { | |
547 Expression *exp; | |
548 | |
549 TypeTypeof(Loc loc, Expression *exp); | |
550 Type *syntaxCopy(); | |
551 Dsymbol *toDsymbol(Scope *sc); | |
552 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
553 Type *semantic(Loc loc, Scope *sc); | |
554 d_uns64 size(Loc loc); | |
555 }; | |
556 | |
557 struct TypeStruct : Type | |
558 { | |
559 StructDeclaration *sym; | |
560 | |
561 TypeStruct(StructDeclaration *sym); | |
562 d_uns64 size(Loc loc); | |
563 unsigned alignsize(); | |
564 char *toChars(); | |
565 Type *syntaxCopy(); | |
566 Type *semantic(Loc loc, Scope *sc); | |
567 Dsymbol *toDsymbol(Scope *sc); | |
568 void toDecoBuffer(OutBuffer *buf); | |
569 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
570 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
571 unsigned memalign(unsigned salign); | |
572 Expression *defaultInit(Loc loc); | |
573 int isZeroInit(); | |
574 int checkBoolean(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
575 #if IN_DMD |
159 | 576 dt_t **toDt(dt_t **pdt); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
577 #endif |
159 | 578 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); |
579 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
580 int hasPointers(); | |
581 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
582 #if IN_DMD |
159 | 583 type *toCtype(); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
584 #elif IN_LLVM |
1029
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1024
diff
changeset
|
585 // LDC |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1024
diff
changeset
|
586 // cache the hasUnalignedFields check |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1024
diff
changeset
|
587 // 0 = not checked, 1 = aligned, 2 = unaligned |
4d366a75d95f
Added hasUnalignedFields helper to check if a type has unaligned fields - as per request from fvbommel. Result is cached in TypeStruct.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
1024
diff
changeset
|
588 int unaligned; |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
589 #endif |
159 | 590 }; |
591 | |
592 struct TypeEnum : Type | |
593 { | |
594 EnumDeclaration *sym; | |
595 | |
596 TypeEnum(EnumDeclaration *sym); | |
597 d_uns64 size(Loc loc); | |
598 unsigned alignsize(); | |
599 char *toChars(); | |
486
a34078905d01
Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
445
diff
changeset
|
600 Type *syntaxCopy(); |
159 | 601 Type *semantic(Loc loc, Scope *sc); |
602 Dsymbol *toDsymbol(Scope *sc); | |
603 void toDecoBuffer(OutBuffer *buf); | |
604 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
605 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
606 Expression *getProperty(Loc loc, Identifier *ident); | |
607 int isintegral(); | |
608 int isfloating(); | |
609 int isscalar(); | |
610 int isunsigned(); | |
611 MATCH implicitConvTo(Type *to); | |
612 Type *toBasetype(); | |
613 Expression *defaultInit(Loc loc); | |
614 int isZeroInit(); | |
615 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
616 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
617 int hasPointers(); | |
618 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
619 #if IN_DMD |
159 | 620 type *toCtype(); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
621 #endif |
159 | 622 }; |
623 | |
624 struct TypeTypedef : Type | |
625 { | |
626 TypedefDeclaration *sym; | |
627 | |
628 TypeTypedef(TypedefDeclaration *sym); | |
629 Type *syntaxCopy(); | |
630 d_uns64 size(Loc loc); | |
631 unsigned alignsize(); | |
632 char *toChars(); | |
633 Type *semantic(Loc loc, Scope *sc); | |
634 Dsymbol *toDsymbol(Scope *sc); | |
635 void toDecoBuffer(OutBuffer *buf); | |
636 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
637 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
638 Expression *getProperty(Loc loc, Identifier *ident); | |
639 int isbit(); | |
640 int isintegral(); | |
641 int isfloating(); | |
642 int isreal(); | |
643 int isimaginary(); | |
644 int iscomplex(); | |
645 int isscalar(); | |
646 int isunsigned(); | |
647 int checkBoolean(); | |
648 Type *toBasetype(); | |
649 MATCH implicitConvTo(Type *to); | |
650 Expression *defaultInit(Loc loc); | |
651 int isZeroInit(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
652 #if IN_DMD |
159 | 653 dt_t **toDt(dt_t **pdt); |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
654 #endif |
159 | 655 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); |
656 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
657 int hasPointers(); | |
658 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
659 #if IN_DMD |
159 | 660 type *toCtype(); |
661 type *toCParamtype(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
662 #endif |
159 | 663 }; |
664 | |
665 struct TypeClass : Type | |
666 { | |
667 ClassDeclaration *sym; | |
668 | |
669 TypeClass(ClassDeclaration *sym); | |
670 d_uns64 size(Loc loc); | |
671 char *toChars(); | |
672 Type *syntaxCopy(); | |
673 Type *semantic(Loc loc, Scope *sc); | |
674 Dsymbol *toDsymbol(Scope *sc); | |
675 void toDecoBuffer(OutBuffer *buf); | |
676 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
677 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
678 ClassDeclaration *isClassHandle(); | |
679 int isBaseOf(Type *t, int *poffset); | |
680 MATCH implicitConvTo(Type *to); | |
681 Expression *defaultInit(Loc loc); | |
682 int isZeroInit(); | |
683 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
684 int isauto(); | |
685 int checkBoolean(); | |
686 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
687 int hasPointers(); | |
688 | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
689 #if IN_DMD |
159 | 690 type *toCtype(); |
691 | |
692 Symbol *toSymbol(); | |
1146
1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
parents:
1103
diff
changeset
|
693 #endif |
159 | 694 }; |
695 | |
696 struct TypeTuple : Type | |
697 { | |
698 Arguments *arguments; // types making up the tuple | |
699 | |
700 TypeTuple(Arguments *arguments); | |
701 TypeTuple(Expressions *exps); | |
702 Type *syntaxCopy(); | |
703 Type *semantic(Loc loc, Scope *sc); | |
704 int equals(Object *o); | |
705 Type *reliesOnTident(); | |
706 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
707 void toDecoBuffer(OutBuffer *buf); | |
708 Expression *getProperty(Loc loc, Identifier *ident); | |
709 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
710 }; | |
711 | |
712 struct TypeSlice : Type | |
713 { | |
714 Expression *lwr; | |
715 Expression *upr; | |
716 | |
717 TypeSlice(Type *next, Expression *lwr, Expression *upr); | |
718 Type *syntaxCopy(); | |
719 Type *semantic(Loc loc, Scope *sc); | |
720 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
721 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); | |
722 }; | |
723 | |
724 /**************************************************************/ | |
725 | |
726 //enum InOut { None, In, Out, InOut, Lazy }; | |
727 | |
728 struct Argument : Object | |
729 { | |
730 //enum InOut inout; | |
731 unsigned storageClass; | |
732 Type *type; | |
733 Identifier *ident; | |
734 Expression *defaultArg; | |
735 | |
736 Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg); | |
737 Argument *syntaxCopy(); | |
738 Type *isLazyArray(); | |
739 void toDecoBuffer(OutBuffer *buf); | |
740 static Arguments *arraySyntaxCopy(Arguments *args); | |
741 static char *argsTypesToChars(Arguments *args, int varargs); | |
742 static void argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *arguments, int varargs); | |
743 static void argsToDecoBuffer(OutBuffer *buf, Arguments *arguments); | |
744 static size_t dim(Arguments *arguments); | |
745 static Argument *getNth(Arguments *arguments, size_t nth, size_t *pn = NULL); | |
746 }; | |
747 | |
748 extern int PTRSIZE; | |
749 extern int REALSIZE; | |
750 extern int REALPAD; | |
751 extern int Tsize_t; | |
752 extern int Tptrdiff_t; | |
753 | |
754 #endif /* DMD_MTYPE_H */ |