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