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