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