Mercurial > projects > ldc
annotate dmd/mtype.h @ 43:eb7bf7b7972e trunk
[svn r47] fixed a problem with gdc 4.1
author | lindquist |
---|---|
date | Fri, 19 Oct 2007 15:26:09 +0200 |
parents | d3ee9efe20e2 |
children | d7e764e62462 |
rev | line source |
---|---|
1 | 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 namespace llvm | |
25 { | |
26 class Value; | |
27 class Type; | |
28 class Instruction; | |
29 } | |
30 | |
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; | |
42 enum LINK; | |
43 | |
44 struct TypeBasic; | |
45 struct HdrGenState; | |
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, | |
104 TMAX | |
105 }; | |
106 | |
107 #define Tascii Tchar | |
108 | |
109 extern int Tsize_t; | |
110 extern int Tptrdiff_t; | |
111 | |
112 struct Type : Object | |
113 { | |
114 TY ty; | |
115 Type *next; | |
116 char *deco; | |
117 Type *pto; // merged pointer to this type | |
118 Type *rto; // reference to this type | |
119 Type *arrayof; // array of this type | |
120 TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type | |
121 | |
122 type *ctype; // for back end | |
123 | |
124 #define tvoid basic[Tvoid] | |
125 #define tint8 basic[Tint8] | |
126 #define tuns8 basic[Tuns8] | |
127 #define tint16 basic[Tint16] | |
128 #define tuns16 basic[Tuns16] | |
129 #define tint32 basic[Tint32] | |
130 #define tuns32 basic[Tuns32] | |
131 #define tint64 basic[Tint64] | |
132 #define tuns64 basic[Tuns64] | |
133 #define tfloat32 basic[Tfloat32] | |
134 #define tfloat64 basic[Tfloat64] | |
135 #define tfloat80 basic[Tfloat80] | |
136 | |
137 #define timaginary32 basic[Timaginary32] | |
138 #define timaginary64 basic[Timaginary64] | |
139 #define timaginary80 basic[Timaginary80] | |
140 | |
141 #define tcomplex32 basic[Tcomplex32] | |
142 #define tcomplex64 basic[Tcomplex64] | |
143 #define tcomplex80 basic[Tcomplex80] | |
144 | |
145 #define tbit basic[Tbit] | |
146 #define tbool basic[Tbool] | |
147 #define tchar basic[Tchar] | |
148 #define twchar basic[Twchar] | |
149 #define tdchar basic[Tdchar] | |
150 | |
151 // Some special types | |
152 #define tshiftcnt tint32 // right side of shift expression | |
153 // #define tboolean tint32 // result of boolean expression | |
154 #define tboolean tbool // result of boolean expression | |
155 #define tindex tint32 // array/ptr index | |
156 static Type *tvoidptr; // void* | |
157 #define terror basic[Terror] // for error recovery | |
158 | |
159 #define tsize_t basic[Tsize_t] // matches size_t alias | |
160 #define tptrdiff_t basic[Tptrdiff_t] // matches ptrdiff_t alias | |
161 #define thash_t tsize_t // matches hash_t alias | |
162 | |
163 static ClassDeclaration *typeinfo; | |
164 static ClassDeclaration *typeinfoclass; | |
165 static ClassDeclaration *typeinfointerface; | |
166 static ClassDeclaration *typeinfostruct; | |
167 static ClassDeclaration *typeinfotypedef; | |
168 static ClassDeclaration *typeinfopointer; | |
169 static ClassDeclaration *typeinfoarray; | |
170 static ClassDeclaration *typeinfostaticarray; | |
171 static ClassDeclaration *typeinfoassociativearray; | |
172 static ClassDeclaration *typeinfoenum; | |
173 static ClassDeclaration *typeinfofunction; | |
174 static ClassDeclaration *typeinfodelegate; | |
175 static ClassDeclaration *typeinfotypelist; | |
176 | |
177 static Type *basic[TMAX]; | |
178 static unsigned char mangleChar[TMAX]; | |
179 static StringTable stringtable; | |
180 | |
181 // These tables are for implicit conversion of binary ops; | |
182 // the indices are the type of operand one, followed by operand two. | |
183 static unsigned char impcnvResult[TMAX][TMAX]; | |
184 static unsigned char impcnvType1[TMAX][TMAX]; | |
185 static unsigned char impcnvType2[TMAX][TMAX]; | |
186 | |
187 // If !=0, give warning on implicit conversion | |
188 static unsigned char impcnvWarn[TMAX][TMAX]; | |
189 | |
190 Type(TY ty, Type *next); | |
191 virtual Type *syntaxCopy(); | |
192 int equals(Object *o); | |
193 int dyncast() { return DYNCAST_TYPE; } // kludge for template.isType() | |
194 int covariant(Type *t); | |
195 char *toChars(); | |
196 static char needThisPrefix(); | |
197 static void init(); | |
198 d_uns64 size(); | |
199 virtual d_uns64 size(Loc loc); | |
200 virtual unsigned alignsize(); | |
201 virtual Type *semantic(Loc loc, Scope *sc); | |
202 virtual void toDecoBuffer(OutBuffer *buf); | |
203 virtual void toTypeInfoBuffer(OutBuffer *buf); | |
204 Type *merge(); | |
205 void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
206 virtual void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
207 virtual int isbit(); | |
208 virtual int isintegral(); | |
209 virtual int isfloating(); // real, imaginary, or complex | |
210 virtual int isreal(); | |
211 virtual int isimaginary(); | |
212 virtual int iscomplex(); | |
213 virtual int isscalar(); | |
214 virtual int isunsigned(); | |
215 virtual int isauto(); | |
216 virtual int isString(); | |
217 virtual int checkBoolean(); // if can be converted to boolean value | |
218 void checkDeprecated(Loc loc, Scope *sc); | |
219 Type *pointerTo(); | |
220 Type *referenceTo(); | |
221 Type *arrayOf(); | |
222 virtual Dsymbol *toDsymbol(Scope *sc); | |
223 virtual Type *toBasetype(); | |
224 virtual int isBaseOf(Type *t, int *poffset); | |
225 virtual MATCH implicitConvTo(Type *to); | |
226 virtual ClassDeclaration *isClassHandle(); | |
227 virtual Expression *getProperty(Loc loc, Identifier *ident); | |
228 virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
229 virtual unsigned memalign(unsigned salign); | |
230 virtual Expression *defaultInit(); | |
231 virtual int isZeroInit(); // if initializer is 0 | |
232 virtual dt_t **toDt(dt_t **pdt); | |
233 Identifier *getTypeInfoIdent(int internal); | |
234 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
235 virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
236 Expression *getInternalTypeInfo(Scope *sc); | |
237 Expression *getTypeInfo(Scope *sc); | |
238 virtual TypeInfoDeclaration *getTypeInfoDeclaration(); | |
239 virtual int builtinTypeInfo(); | |
240 virtual Type *reliesOnTident(); | |
241 virtual Expression *toExpression(); | |
242 virtual int hasPointers(); | |
243 Type *nextOf() { return next; } | |
244 | |
245 static void error(Loc loc, const char *format, ...); | |
246 | |
247 // For backend | |
248 virtual unsigned totym(); | |
249 virtual type *toCtype(); | |
250 virtual type *toCParamtype(); | |
251 virtual Symbol *toSymbol(); | |
252 | |
11
d3ee9efe20e2
[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing.
lindquist
parents:
9
diff
changeset
|
253 const llvm::Type* llvmType; |
1 | 254 |
255 // For eliminating dynamic_cast | |
256 virtual TypeBasic *isTypeBasic(); | |
257 }; | |
258 | |
259 struct TypeBasic : Type | |
260 { | |
261 char *dstring; | |
262 char *cstring; | |
263 unsigned flags; | |
264 | |
265 TypeBasic(TY ty); | |
266 Type *syntaxCopy(); | |
267 d_uns64 size(Loc loc); | |
268 unsigned alignsize(); | |
269 Expression *getProperty(Loc loc, Identifier *ident); | |
270 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
271 char *toChars(); | |
272 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
273 int isintegral(); | |
274 int isbit(); | |
275 int isfloating(); | |
276 int isreal(); | |
277 int isimaginary(); | |
278 int iscomplex(); | |
279 int isscalar(); | |
280 int isunsigned(); | |
281 MATCH implicitConvTo(Type *to); | |
282 Expression *defaultInit(); | |
283 int isZeroInit(); | |
284 int builtinTypeInfo(); | |
285 | |
286 // For eliminating dynamic_cast | |
287 TypeBasic *isTypeBasic(); | |
288 }; | |
289 | |
290 struct TypeArray : Type | |
291 { | |
292 TypeArray(TY ty, Type *next); | |
293 virtual void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs) = 0; | |
294 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
295 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
296 }; | |
297 | |
298 // Static array, one with a fixed dimension | |
299 struct TypeSArray : TypeArray | |
300 { | |
301 Expression *dim; | |
302 | |
303 TypeSArray(Type *t, Expression *dim); | |
304 Type *syntaxCopy(); | |
305 d_uns64 size(Loc loc); | |
306 unsigned alignsize(); | |
307 Type *semantic(Loc loc, Scope *sc); | |
308 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
309 void toDecoBuffer(OutBuffer *buf); | |
310 void toTypeInfoBuffer(OutBuffer *buf); | |
311 void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs); | |
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(); | |
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 toTypeInfoBuffer(OutBuffer *buf); | |
339 void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs); | |
340 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
341 int isString(); | |
342 int isZeroInit(); | |
343 int checkBoolean(); | |
344 MATCH implicitConvTo(Type *to); | |
345 Expression *defaultInit(); | |
346 int builtinTypeInfo(); | |
347 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
348 int hasPointers(); | |
349 | |
350 type *toCtype(); | |
351 }; | |
352 | |
353 struct TypeAArray : TypeArray | |
354 { | |
355 Type *index; // key type for type checking | |
356 Type *key; // actual key type | |
357 | |
358 TypeAArray(Type *t, Type *index); | |
359 Type *syntaxCopy(); | |
360 d_uns64 size(Loc loc); | |
361 Type *semantic(Loc loc, Scope *sc); | |
362 void toDecoBuffer(OutBuffer *buf); | |
363 void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs); | |
364 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
365 Expression *defaultInit(); | |
366 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
367 int checkBoolean(); | |
368 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
369 int hasPointers(); | |
370 | |
371 // Back end | |
372 Symbol *aaGetSymbol(char *func, int flags); | |
373 | |
374 type *toCtype(); | |
375 }; | |
376 | |
377 struct TypePointer : Type | |
378 { | |
379 TypePointer(Type *t); | |
380 Type *syntaxCopy(); | |
381 Type *semantic(Loc loc, Scope *sc); | |
382 d_uns64 size(Loc loc); | |
383 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
384 MATCH implicitConvTo(Type *to); | |
385 int isscalar(); | |
386 Expression *defaultInit(); | |
387 int isZeroInit(); | |
388 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
389 int hasPointers(); | |
390 | |
391 type *toCtype(); | |
392 }; | |
393 | |
394 struct TypeReference : Type | |
395 { | |
396 TypeReference(Type *t); | |
397 Type *syntaxCopy(); | |
398 d_uns64 size(Loc loc); | |
399 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
400 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
401 Expression *defaultInit(); | |
402 int isZeroInit(); | |
403 }; | |
404 | |
405 enum RET | |
406 { | |
407 RETregs = 1, // returned in registers | |
408 RETstack = 2, // returned on stack | |
409 }; | |
410 | |
411 struct TypeFunction : Type | |
412 { | |
413 Arguments *parameters; // function parameters | |
414 int varargs; // 1: T t, ...) style for variable number of arguments | |
415 // 2: T t ...) style for variable number of arguments | |
416 enum LINK linkage; // calling convention | |
417 | |
418 int inuse; | |
419 | |
420 TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage); | |
421 Type *syntaxCopy(); | |
422 Type *semantic(Loc loc, Scope *sc); | |
423 void toDecoBuffer(OutBuffer *buf); | |
424 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
425 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
426 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
427 Type *reliesOnTident(); | |
428 | |
429 int callMatch(Expressions *toargs); | |
430 type *toCtype(); | |
431 enum RET retStyle(); | |
432 | |
433 unsigned totym(); | |
434 | |
435 bool llvmRetInPtr; | |
9 | 436 bool llvmUsesThis; |
1 | 437 llvm::Value* llvmRetArg; |
438 llvm::Instruction* llvmAllocaPoint; | |
439 }; | |
440 | |
441 struct TypeDelegate : Type | |
442 { | |
443 TypeDelegate(Type *t); | |
444 Type *syntaxCopy(); | |
445 Type *semantic(Loc loc, Scope *sc); | |
446 d_uns64 size(Loc loc); | |
447 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
448 Expression *defaultInit(); | |
449 int isZeroInit(); | |
450 int checkBoolean(); | |
451 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
452 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
453 int hasPointers(); | |
454 | |
455 type *toCtype(); | |
456 }; | |
457 | |
458 struct TypeQualified : Type | |
459 { | |
460 Loc loc; | |
461 Array idents; // array of Identifier's representing ident.ident.ident etc. | |
462 | |
463 TypeQualified(TY ty, Loc loc); | |
464 void syntaxCopyHelper(TypeQualified *t); | |
465 void addIdent(Identifier *ident); | |
466 void toCBuffer2Helper(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
467 d_uns64 size(Loc loc); | |
468 void resolveHelper(Loc loc, Scope *sc, Dsymbol *s, Dsymbol *scopesym, | |
469 Expression **pe, Type **pt, Dsymbol **ps); | |
470 }; | |
471 | |
472 struct TypeIdentifier : TypeQualified | |
473 { | |
474 Identifier *ident; | |
475 | |
476 TypeIdentifier(Loc loc, Identifier *ident); | |
477 Type *syntaxCopy(); | |
478 //char *toChars(); | |
479 void toDecoBuffer(OutBuffer *buf); | |
480 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
481 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
482 Dsymbol *toDsymbol(Scope *sc); | |
483 Type *semantic(Loc loc, Scope *sc); | |
484 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
485 Type *reliesOnTident(); | |
486 Expression *toExpression(); | |
487 }; | |
488 | |
489 /* Similar to TypeIdentifier, but with a TemplateInstance as the root | |
490 */ | |
491 struct TypeInstance : TypeQualified | |
492 { | |
493 TemplateInstance *tempinst; | |
494 | |
495 TypeInstance(Loc loc, TemplateInstance *tempinst); | |
496 Type *syntaxCopy(); | |
497 //char *toChars(); | |
498 //void toDecoBuffer(OutBuffer *buf); | |
499 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
500 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
501 Type *semantic(Loc loc, Scope *sc); | |
502 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
503 }; | |
504 | |
505 struct TypeTypeof : TypeQualified | |
506 { | |
507 Expression *exp; | |
508 | |
509 TypeTypeof(Loc loc, Expression *exp); | |
510 Type *syntaxCopy(); | |
511 Dsymbol *toDsymbol(Scope *sc); | |
512 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
513 Type *semantic(Loc loc, Scope *sc); | |
514 d_uns64 size(Loc loc); | |
515 }; | |
516 | |
517 struct TypeStruct : Type | |
518 { | |
519 StructDeclaration *sym; | |
520 | |
521 TypeStruct(StructDeclaration *sym); | |
522 d_uns64 size(Loc loc); | |
523 unsigned alignsize(); | |
524 char *toChars(); | |
525 Type *syntaxCopy(); | |
526 Type *semantic(Loc loc, Scope *sc); | |
527 Dsymbol *toDsymbol(Scope *sc); | |
528 void toDecoBuffer(OutBuffer *buf); | |
529 void toTypeInfoBuffer(OutBuffer *buf); | |
530 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
531 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
532 unsigned memalign(unsigned salign); | |
533 Expression *defaultInit(); | |
534 int isZeroInit(); | |
535 int checkBoolean(); | |
536 dt_t **toDt(dt_t **pdt); | |
537 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
538 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
539 int hasPointers(); | |
540 | |
541 type *toCtype(); | |
542 | |
543 llvm::Value* llvmInit; | |
544 }; | |
545 | |
546 struct TypeEnum : Type | |
547 { | |
548 EnumDeclaration *sym; | |
549 | |
550 TypeEnum(EnumDeclaration *sym); | |
551 d_uns64 size(Loc loc); | |
552 unsigned alignsize(); | |
553 char *toChars(); | |
554 Type *semantic(Loc loc, Scope *sc); | |
555 Dsymbol *toDsymbol(Scope *sc); | |
556 void toDecoBuffer(OutBuffer *buf); | |
557 void toTypeInfoBuffer(OutBuffer *buf); | |
558 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
559 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
560 Expression *getProperty(Loc loc, Identifier *ident); | |
561 int isintegral(); | |
562 int isfloating(); | |
563 int isscalar(); | |
564 int isunsigned(); | |
565 MATCH implicitConvTo(Type *to); | |
566 Type *toBasetype(); | |
567 Expression *defaultInit(); | |
568 int isZeroInit(); | |
569 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
570 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
571 int hasPointers(); | |
572 | |
573 type *toCtype(); | |
574 }; | |
575 | |
576 struct TypeTypedef : Type | |
577 { | |
578 TypedefDeclaration *sym; | |
579 | |
580 TypeTypedef(TypedefDeclaration *sym); | |
581 Type *syntaxCopy(); | |
582 d_uns64 size(Loc loc); | |
583 unsigned alignsize(); | |
584 char *toChars(); | |
585 Type *semantic(Loc loc, Scope *sc); | |
586 Dsymbol *toDsymbol(Scope *sc); | |
587 void toDecoBuffer(OutBuffer *buf); | |
588 void toTypeInfoBuffer(OutBuffer *buf); | |
589 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
590 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
591 int isbit(); | |
592 int isintegral(); | |
593 int isfloating(); | |
594 int isreal(); | |
595 int isimaginary(); | |
596 int iscomplex(); | |
597 int isscalar(); | |
598 int isunsigned(); | |
599 int checkBoolean(); | |
600 Type *toBasetype(); | |
601 MATCH implicitConvTo(Type *to); | |
602 Expression *defaultInit(); | |
603 int isZeroInit(); | |
604 dt_t **toDt(dt_t **pdt); | |
605 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
606 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
607 int hasPointers(); | |
608 | |
609 type *toCtype(); | |
610 type *toCParamtype(); | |
611 }; | |
612 | |
613 struct TypeClass : Type | |
614 { | |
615 ClassDeclaration *sym; | |
616 | |
617 TypeClass(ClassDeclaration *sym); | |
618 d_uns64 size(Loc loc); | |
619 char *toChars(); | |
620 Type *syntaxCopy(); | |
621 Type *semantic(Loc loc, Scope *sc); | |
622 Dsymbol *toDsymbol(Scope *sc); | |
623 void toDecoBuffer(OutBuffer *buf); | |
624 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
625 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); | |
626 ClassDeclaration *isClassHandle(); | |
627 int isBaseOf(Type *t, int *poffset); | |
628 MATCH implicitConvTo(Type *to); | |
629 Expression *defaultInit(); | |
630 int isZeroInit(); | |
631 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); | |
632 int isauto(); | |
633 int checkBoolean(); | |
634 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
635 int hasPointers(); | |
636 | |
637 type *toCtype(); | |
638 | |
639 Symbol *toSymbol(); | |
640 | |
641 llvm::Value* llvmInit; | |
642 }; | |
643 | |
644 struct TypeTuple : Type | |
645 { | |
646 Arguments *arguments; // types making up the tuple | |
647 | |
648 TypeTuple(Arguments *arguments); | |
649 TypeTuple(Expressions *exps); | |
650 Type *syntaxCopy(); | |
651 Type *semantic(Loc loc, Scope *sc); | |
652 int equals(Object *o); | |
653 Type *reliesOnTident(); | |
654 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
655 void toDecoBuffer(OutBuffer *buf); | |
656 Expression *getProperty(Loc loc, Identifier *ident); | |
657 TypeInfoDeclaration *getTypeInfoDeclaration(); | |
658 }; | |
659 | |
660 struct TypeSlice : Type | |
661 { | |
662 Expression *lwr; | |
663 Expression *upr; | |
664 | |
665 TypeSlice(Type *next, Expression *lwr, Expression *upr); | |
666 Type *syntaxCopy(); | |
667 Type *semantic(Loc loc, Scope *sc); | |
668 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); | |
669 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); | |
670 }; | |
671 | |
672 /**************************************************************/ | |
673 | |
674 //enum InOut { None, In, Out, InOut, Lazy }; | |
675 | |
676 struct Argument : Object | |
677 { | |
678 //enum InOut inout; | |
679 unsigned storageClass; | |
680 Type *type; | |
681 Identifier *ident; | |
682 Expression *defaultArg; | |
683 | |
684 Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg); | |
685 Argument *syntaxCopy(); | |
686 Type *isLazyArray(); | |
687 void toDecoBuffer(OutBuffer *buf); | |
688 static Arguments *arraySyntaxCopy(Arguments *args); | |
689 static char *argsTypesToChars(Arguments *args, int varargs); | |
690 static void argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *arguments, int varargs); | |
691 static void argsToDecoBuffer(OutBuffer *buf, Arguments *arguments); | |
692 static size_t dim(Arguments *arguments); | |
693 static Argument *getNth(Arguments *arguments, size_t nth, size_t *pn = NULL); | |
694 | |
695 // backend | |
696 bool llvmCopy; | |
697 VarDeclaration* vardecl; | |
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 */ |