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