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