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