d: Merge upstream dmd 568496d5b, druntime 178c44ff, phobos 574bf883b.
[official-gcc.git] / gcc / d / dmd / mtype.h
blob430b39b205c94fbf6f12c66548fedaba1a3e7eb9
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * http://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * http://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/mtype.h
9 */
11 #pragma once
13 #include "root/dcompat.h" // for d_size_t
15 #include "arraytypes.h"
16 #include "ast_node.h"
17 #include "globals.h"
18 #include "visitor.h"
20 struct Scope;
21 class AggregateDeclaration;
22 class Identifier;
23 class Expression;
24 class StructDeclaration;
25 class ClassDeclaration;
26 class EnumDeclaration;
27 class TypeInfoDeclaration;
28 class Dsymbol;
29 class TemplateInstance;
30 class TemplateDeclaration;
32 class TypeBasic;
33 class Parameter;
35 // Back end
36 #ifdef IN_GCC
37 typedef union tree_node type;
38 #else
39 typedef struct TYPE type;
40 #endif
42 void semanticTypeInfo(Scope *sc, Type *t);
44 Type *typeSemantic(Type *t, const Loc &loc, Scope *sc);
45 Type *merge(Type *type);
47 enum class TY : uint8_t
49 Tarray, // slice array, aka T[]
50 Tsarray, // static array, aka T[dimension]
51 Taarray, // associative array, aka T[type]
52 Tpointer,
53 Treference,
54 Tfunction,
55 Tident,
56 Tclass,
57 Tstruct,
58 Tenum,
60 Tdelegate,
61 Tnone,
62 Tvoid,
63 Tint8,
64 Tuns8,
65 Tint16,
66 Tuns16,
67 Tint32,
68 Tuns32,
69 Tint64,
71 Tuns64,
72 Tfloat32,
73 Tfloat64,
74 Tfloat80,
75 Timaginary32,
76 Timaginary64,
77 Timaginary80,
78 Tcomplex32,
79 Tcomplex64,
80 Tcomplex80,
82 Tbool,
83 Tchar,
84 Twchar,
85 Tdchar,
86 Terror,
87 Tinstance,
88 Ttypeof,
89 Ttuple,
90 Tslice,
91 Treturn,
93 Tnull,
94 Tvector,
95 Tint128,
96 Tuns128,
97 Ttraits,
98 Tmixin,
99 Tnoreturn,
100 TMAX
103 #define SIZE_INVALID (~(d_uns64)0) // error return from size() functions
107 * type modifiers
108 * pick this order of numbers so switch statements work better
110 enum MODFlags
112 MODconst = 1, // type is const
113 MODimmutable = 4, // type is immutable
114 MODshared = 2, // type is shared
115 MODwild = 8, // type is wild
116 MODwildconst = (MODwild | MODconst), // type is wild const
117 MODmutable = 0x10 // type is mutable (only used in wildcard matching)
119 typedef unsigned char MOD;
121 enum class Covariant
123 distinct = 0,
124 yes = 1,
125 no = 2,
126 fwdref = 3,
129 enum VarArgValues
131 VARARGnone = 0, /// fixed number of arguments
132 VARARGvariadic = 1, /// T t, ...) can be C-style (core.stdc.stdarg) or D-style (core.vararg)
133 VARARGtypesafe = 2 /// T t ...) typesafe https://dlang.org/spec/function.html#typesafe_variadic_functions
134 /// or https://dlang.org/spec/function.html#typesafe_variadic_functions
136 typedef unsigned char VarArg;
138 class Type : public ASTNode
140 public:
141 TY ty;
142 MOD mod; // modifiers MODxxxx
143 char *deco;
145 private:
146 void* mcache;
148 public:
149 Type *pto; // merged pointer to this type
150 Type *rto; // reference to this type
151 Type *arrayof; // array of this type
152 TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type
154 type *ctype; // for back end
156 static Type *tvoid;
157 static Type *tint8;
158 static Type *tuns8;
159 static Type *tint16;
160 static Type *tuns16;
161 static Type *tint32;
162 static Type *tuns32;
163 static Type *tint64;
164 static Type *tuns64;
165 static Type *tint128;
166 static Type *tuns128;
167 static Type *tfloat32;
168 static Type *tfloat64;
169 static Type *tfloat80;
171 static Type *timaginary32;
172 static Type *timaginary64;
173 static Type *timaginary80;
175 static Type *tcomplex32;
176 static Type *tcomplex64;
177 static Type *tcomplex80;
179 static Type *tbool;
180 static Type *tchar;
181 static Type *twchar;
182 static Type *tdchar;
184 // Some special types
185 static Type *tshiftcnt;
186 static Type *tvoidptr; // void*
187 static Type *tstring; // immutable(char)[]
188 static Type *twstring; // immutable(wchar)[]
189 static Type *tdstring; // immutable(dchar)[]
190 static Type *terror; // for error recovery
191 static Type *tnull; // for null type
192 static Type *tnoreturn; // for bottom type typeof(*null)
194 static Type *tsize_t; // matches size_t alias
195 static Type *tptrdiff_t; // matches ptrdiff_t alias
196 static Type *thash_t; // matches hash_t alias
198 static ClassDeclaration *dtypeinfo;
199 static ClassDeclaration *typeinfoclass;
200 static ClassDeclaration *typeinfointerface;
201 static ClassDeclaration *typeinfostruct;
202 static ClassDeclaration *typeinfopointer;
203 static ClassDeclaration *typeinfoarray;
204 static ClassDeclaration *typeinfostaticarray;
205 static ClassDeclaration *typeinfoassociativearray;
206 static ClassDeclaration *typeinfovector;
207 static ClassDeclaration *typeinfoenum;
208 static ClassDeclaration *typeinfofunction;
209 static ClassDeclaration *typeinfodelegate;
210 static ClassDeclaration *typeinfotypelist;
211 static ClassDeclaration *typeinfoconst;
212 static ClassDeclaration *typeinfoinvariant;
213 static ClassDeclaration *typeinfoshared;
214 static ClassDeclaration *typeinfowild;
216 static TemplateDeclaration *rtinfo;
218 static Type *basic[(int)TY::TMAX];
220 virtual const char *kind();
221 Type *copy() const;
222 virtual Type *syntaxCopy();
223 bool equals(const RootObject *o) const;
224 bool equivalent(Type *t);
225 // kludge for template.isType()
226 DYNCAST dyncast() const { return DYNCAST_TYPE; }
227 size_t getUniqueID() const;
228 Covariant covariant(Type *t, StorageClass *pstc = NULL);
229 const char *toChars() const;
230 char *toPrettyChars(bool QualifyTypes = false);
231 static void _init();
233 d_uns64 size();
234 virtual d_uns64 size(const Loc &loc);
235 virtual unsigned alignsize();
236 Type *trySemantic(const Loc &loc, Scope *sc);
237 Type *merge2();
238 void modToBuffer(OutBuffer *buf) const;
239 char *modToChars() const;
241 virtual bool isintegral();
242 virtual bool isfloating(); // real, imaginary, or complex
243 virtual bool isreal();
244 virtual bool isimaginary();
245 virtual bool iscomplex();
246 virtual bool isscalar();
247 virtual bool isunsigned();
248 virtual bool isscope();
249 virtual bool isString();
250 virtual bool isAssignable();
251 virtual bool isBoolean();
252 virtual void checkDeprecated(const Loc &loc, Scope *sc);
253 bool isConst() const { return (mod & MODconst) != 0; }
254 bool isImmutable() const { return (mod & MODimmutable) != 0; }
255 bool isMutable() const { return (mod & (MODconst | MODimmutable | MODwild)) == 0; }
256 bool isShared() const { return (mod & MODshared) != 0; }
257 bool isSharedConst() const { return (mod & (MODshared | MODconst)) == (MODshared | MODconst); }
258 bool isWild() const { return (mod & MODwild) != 0; }
259 bool isWildConst() const { return (mod & MODwildconst) == MODwildconst; }
260 bool isSharedWild() const { return (mod & (MODshared | MODwild)) == (MODshared | MODwild); }
261 bool isNaked() const { return mod == 0; }
262 Type *nullAttributes() const;
263 Type *constOf();
264 Type *immutableOf();
265 Type *mutableOf();
266 Type *sharedOf();
267 Type *sharedConstOf();
268 Type *unSharedOf();
269 Type *wildOf();
270 Type *wildConstOf();
271 Type *sharedWildOf();
272 Type *sharedWildConstOf();
273 void fixTo(Type *t);
274 void check();
275 Type *addSTC(StorageClass stc);
276 Type *castMod(MOD mod);
277 Type *addMod(MOD mod);
278 virtual Type *addStorageClass(StorageClass stc);
279 Type *pointerTo();
280 Type *referenceTo();
281 Type *arrayOf();
282 Type *sarrayOf(dinteger_t dim);
283 bool hasDeprecatedAliasThis();
284 Type *aliasthisOf();
285 virtual Type *makeConst();
286 virtual Type *makeImmutable();
287 virtual Type *makeShared();
288 virtual Type *makeSharedConst();
289 virtual Type *makeWild();
290 virtual Type *makeWildConst();
291 virtual Type *makeSharedWild();
292 virtual Type *makeSharedWildConst();
293 virtual Type *makeMutable();
294 virtual Dsymbol *toDsymbol(Scope *sc);
295 Type *toBasetype();
296 virtual bool isBaseOf(Type *t, int *poffset);
297 virtual MATCH implicitConvTo(Type *to);
298 virtual MATCH constConv(Type *to);
299 virtual unsigned char deduceWild(Type *t, bool isRef);
300 virtual Type *substWildTo(unsigned mod);
302 Type *unqualify(unsigned m);
304 virtual Type *toHeadMutable();
305 virtual ClassDeclaration *isClassHandle();
306 virtual structalign_t alignment();
307 virtual Expression *defaultInitLiteral(const Loc &loc);
308 virtual bool isZeroInit(const Loc &loc = Loc()); // if initializer is 0
309 Identifier *getTypeInfoIdent();
310 virtual int hasWild() const;
311 virtual bool hasPointers();
312 virtual bool hasVoidInitPointers();
313 virtual bool hasInvariant();
314 virtual Type *nextOf();
315 Type *baseElemOf();
316 uinteger_t sizemask();
317 virtual bool needsDestruction();
318 virtual bool needsCopyOrPostblit();
319 virtual bool needsNested();
321 TypeFunction *toTypeFunction();
323 // For eliminating dynamic_cast
324 virtual TypeBasic *isTypeBasic();
325 TypeFunction *isPtrToFunction();
326 TypeFunction *isFunction_Delegate_PtrToFunction();
327 TypeError *isTypeError();
328 TypeVector *isTypeVector();
329 TypeSArray *isTypeSArray();
330 TypeDArray *isTypeDArray();
331 TypeAArray *isTypeAArray();
332 TypePointer *isTypePointer();
333 TypeReference *isTypeReference();
334 TypeFunction *isTypeFunction();
335 TypeDelegate *isTypeDelegate();
336 TypeIdentifier *isTypeIdentifier();
337 TypeInstance *isTypeInstance();
338 TypeTypeof *isTypeTypeof();
339 TypeReturn *isTypeReturn();
340 TypeStruct *isTypeStruct();
341 TypeEnum *isTypeEnum();
342 TypeClass *isTypeClass();
343 TypeTuple *isTypeTuple();
344 TypeSlice *isTypeSlice();
345 TypeNull *isTypeNull();
346 TypeMixin *isTypeMixin();
347 TypeTraits *isTypeTraits();
348 TypeNoreturn *isTypeNoreturn();
349 TypeTag *isTypeTag();
351 void accept(Visitor *v) { v->visit(this); }
354 class TypeError : public Type
356 public:
357 const char *kind();
358 TypeError *syntaxCopy();
360 d_uns64 size(const Loc &loc);
361 Expression *defaultInitLiteral(const Loc &loc);
362 void accept(Visitor *v) { v->visit(this); }
365 class TypeNext : public Type
367 public:
368 Type *next;
370 void checkDeprecated(const Loc &loc, Scope *sc);
371 int hasWild() const;
372 Type *nextOf();
373 Type *makeConst();
374 Type *makeImmutable();
375 Type *makeShared();
376 Type *makeSharedConst();
377 Type *makeWild();
378 Type *makeWildConst();
379 Type *makeSharedWild();
380 Type *makeSharedWildConst();
381 Type *makeMutable();
382 MATCH constConv(Type *to);
383 unsigned char deduceWild(Type *t, bool isRef);
384 void transitive();
385 void accept(Visitor *v) { v->visit(this); }
388 class TypeBasic : public Type
390 public:
391 const char *dstring;
392 unsigned flags;
394 const char *kind();
395 TypeBasic *syntaxCopy();
396 d_uns64 size(const Loc &loc) /*const*/;
397 unsigned alignsize();
398 bool isintegral();
399 bool isfloating() /*const*/;
400 bool isreal() /*const*/;
401 bool isimaginary() /*const*/;
402 bool iscomplex() /*const*/;
403 bool isscalar() /*const*/;
404 bool isunsigned() /*const*/;
405 MATCH implicitConvTo(Type *to);
406 bool isZeroInit(const Loc &loc) /*const*/;
408 // For eliminating dynamic_cast
409 TypeBasic *isTypeBasic();
410 void accept(Visitor *v) { v->visit(this); }
413 class TypeVector : public Type
415 public:
416 Type *basetype;
418 static TypeVector *create(Type *basetype);
419 const char *kind();
420 TypeVector *syntaxCopy();
421 d_uns64 size(const Loc &loc);
422 unsigned alignsize();
423 bool isintegral();
424 bool isfloating();
425 bool isscalar();
426 bool isunsigned();
427 bool isBoolean() /*const*/;
428 MATCH implicitConvTo(Type *to);
429 Expression *defaultInitLiteral(const Loc &loc);
430 TypeBasic *elementType();
431 bool isZeroInit(const Loc &loc);
433 void accept(Visitor *v) { v->visit(this); }
436 class TypeArray : public TypeNext
438 public:
439 void accept(Visitor *v) { v->visit(this); }
442 // Static array, one with a fixed dimension
443 class TypeSArray : public TypeArray
445 public:
446 Expression *dim;
448 const char *kind();
449 TypeSArray *syntaxCopy();
450 bool isIncomplete();
451 d_uns64 size(const Loc &loc);
452 unsigned alignsize();
453 bool isString();
454 bool isZeroInit(const Loc &loc);
455 structalign_t alignment();
456 MATCH constConv(Type *to);
457 MATCH implicitConvTo(Type *to);
458 Expression *defaultInitLiteral(const Loc &loc);
459 bool hasPointers();
460 bool hasInvariant();
461 bool needsDestruction();
462 bool needsCopyOrPostblit();
463 bool needsNested();
465 void accept(Visitor *v) { v->visit(this); }
468 // Dynamic array, no dimension
469 class TypeDArray : public TypeArray
471 public:
472 const char *kind();
473 TypeDArray *syntaxCopy();
474 d_uns64 size(const Loc &loc) /*const*/;
475 unsigned alignsize() /*const*/;
476 bool isString();
477 bool isZeroInit(const Loc &loc) /*const*/;
478 bool isBoolean() /*const*/;
479 MATCH implicitConvTo(Type *to);
480 bool hasPointers() /*const*/;
482 void accept(Visitor *v) { v->visit(this); }
485 class TypeAArray : public TypeArray
487 public:
488 Type *index; // key type
489 Loc loc;
491 static TypeAArray *create(Type *t, Type *index);
492 const char *kind();
493 TypeAArray *syntaxCopy();
494 d_uns64 size(const Loc &loc);
495 bool isZeroInit(const Loc &loc) /*const*/;
496 bool isBoolean() /*const*/;
497 bool hasPointers() /*const*/;
498 MATCH implicitConvTo(Type *to);
499 MATCH constConv(Type *to);
501 void accept(Visitor *v) { v->visit(this); }
504 class TypePointer : public TypeNext
506 public:
507 static TypePointer *create(Type *t);
508 const char *kind();
509 TypePointer *syntaxCopy();
510 d_uns64 size(const Loc &loc) /*const*/;
511 MATCH implicitConvTo(Type *to);
512 MATCH constConv(Type *to);
513 bool isscalar() /*const*/;
514 bool isZeroInit(const Loc &loc) /*const*/;
515 bool hasPointers() /*const*/;
517 void accept(Visitor *v) { v->visit(this); }
520 class TypeReference : public TypeNext
522 public:
523 const char *kind();
524 TypeReference *syntaxCopy();
525 d_uns64 size(const Loc &loc) /*const*/;
526 bool isZeroInit(const Loc &loc) /*const*/;
527 void accept(Visitor *v) { v->visit(this); }
530 enum RET
532 RETregs = 1, // returned in registers
533 RETstack = 2 // returned on stack
536 enum class TRUST : unsigned char
538 default_ = 0,
539 system = 1, // @system (same as TRUSTdefault)
540 trusted = 2, // @trusted
541 safe = 3 // @safe
544 enum TRUSTformat
546 TRUSTformatDefault, // do not emit @system when trust == TRUSTdefault
547 TRUSTformatSystem // emit @system when trust == TRUSTdefault
550 enum class PURE : unsigned char
552 impure = 0, // not pure at all
553 fwdref = 1, // it's pure, but not known which level yet
554 weak = 2, // no mutable globals are read or written
555 const_ = 3, // parameters are values or const
556 strong = 4 // parameters are values or immutable
559 class Parameter : public ASTNode
561 public:
562 StorageClass storageClass;
563 Type *type;
564 Identifier *ident;
565 Expression *defaultArg;
566 UserAttributeDeclaration *userAttribDecl; // user defined attributes
568 static Parameter *create(StorageClass storageClass, Type *type, Identifier *ident,
569 Expression *defaultArg, UserAttributeDeclaration *userAttribDecl);
570 Parameter *syntaxCopy();
571 Type *isLazyArray();
572 // kludge for template.isType()
573 DYNCAST dyncast() const { return DYNCAST_PARAMETER; }
574 void accept(Visitor *v) { v->visit(this); }
576 static size_t dim(Parameters *parameters);
577 static Parameter *getNth(Parameters *parameters, d_size_t nth);
578 const char *toChars() const;
579 bool isCovariant(bool returnByRef, const Parameter *p, bool previewIn) const;
582 struct ParameterList
584 Parameters* parameters;
585 StorageClass stc;
586 VarArg varargs;
587 bool hasIdentifierList; // true if C identifier-list style
589 size_t length();
590 Parameter *operator[](size_t i) { return Parameter::getNth(parameters, i); }
593 class TypeFunction : public TypeNext
595 public:
596 // .next is the return type
598 ParameterList parameterList; // function parameters
599 LINK linkage; // calling convention
600 unsigned funcFlags;
601 TRUST trust; // level of trust
602 PURE purity; // PURExxxx
603 char inuse;
604 Expressions *fargs; // function arguments
606 static TypeFunction *create(Parameters *parameters, Type *treturn, VarArg varargs, LINK linkage, StorageClass stc = 0);
607 const char *kind();
608 TypeFunction *syntaxCopy();
609 void purityLevel();
610 bool hasLazyParameters();
611 bool isDstyleVariadic() const;
612 bool parameterEscapes(Parameter *p);
613 StorageClass parameterStorageClass(Parameter *p);
614 Type *addStorageClass(StorageClass stc);
616 Type *substWildTo(unsigned mod);
617 MATCH constConv(Type *to);
619 bool isnothrow() const;
620 void isnothrow(bool v);
621 bool isnogc() const;
622 void isnogc(bool v);
623 bool isproperty() const;
624 void isproperty(bool v);
625 bool isref() const;
626 void isref(bool v);
627 bool isreturn() const;
628 void isreturn(bool v);
629 bool isScopeQual() const;
630 void isScopeQual(bool v);
631 bool isreturninferred() const;
632 void isreturninferred(bool v);
633 bool isscopeinferred() const;
634 void isscopeinferred(bool v);
635 bool islive() const;
636 void islive(bool v);
637 bool incomplete() const;
638 void incomplete(bool v);
639 bool isInOutParam() const;
640 void isInOutParam(bool v);
641 bool isInOutQual() const;
642 void isInOutQual(bool v);
643 bool iswild() const;
645 void accept(Visitor *v) { v->visit(this); }
648 class TypeDelegate : public TypeNext
650 public:
651 // .next is a TypeFunction
653 static TypeDelegate *create(TypeFunction *t);
654 const char *kind();
655 TypeDelegate *syntaxCopy();
656 Type *addStorageClass(StorageClass stc);
657 d_uns64 size(const Loc &loc) /*const*/;
658 unsigned alignsize() /*const*/;
659 MATCH implicitConvTo(Type *to);
660 bool isZeroInit(const Loc &loc) /*const*/;
661 bool isBoolean() /*const*/;
662 bool hasPointers() /*const*/;
664 void accept(Visitor *v) { v->visit(this); }
667 class TypeTraits : public Type
669 Loc loc;
670 /// The expression to resolve as type or symbol.
671 TraitsExp *exp;
672 /// The symbol when exp doesn't represent a type.
673 Dsymbol *sym;
675 const char *kind();
676 TypeTraits *syntaxCopy();
677 d_uns64 size(const Loc &loc);
678 Dsymbol *toDsymbol(Scope *sc);
679 void accept(Visitor *v) { v->visit(this); }
682 class TypeMixin : public Type
684 Loc loc;
685 Expressions *exps;
686 RootObject *obj;
688 const char *kind();
689 TypeMixin *syntaxCopy();
690 Dsymbol *toDsymbol(Scope *sc);
691 void accept(Visitor *v) { v->visit(this); }
694 class TypeQualified : public Type
696 public:
697 Loc loc;
698 // array of Identifier and TypeInstance,
699 // representing ident.ident!tiargs.ident. ... etc.
700 Objects idents;
702 void syntaxCopyHelper(TypeQualified *t);
703 void addIdent(Identifier *ident);
704 void addInst(TemplateInstance *inst);
705 void addIndex(RootObject *expr);
706 d_uns64 size(const Loc &loc);
708 void accept(Visitor *v) { v->visit(this); }
711 class TypeIdentifier : public TypeQualified
713 public:
714 Identifier *ident;
715 Dsymbol *originalSymbol; // The symbol representing this identifier, before alias resolution
717 static TypeIdentifier *create(const Loc &loc, Identifier *ident);
718 const char *kind();
719 TypeIdentifier *syntaxCopy();
720 Dsymbol *toDsymbol(Scope *sc);
721 void accept(Visitor *v) { v->visit(this); }
724 /* Similar to TypeIdentifier, but with a TemplateInstance as the root
726 class TypeInstance : public TypeQualified
728 public:
729 TemplateInstance *tempinst;
731 const char *kind();
732 TypeInstance *syntaxCopy();
733 Dsymbol *toDsymbol(Scope *sc);
734 void accept(Visitor *v) { v->visit(this); }
737 class TypeTypeof : public TypeQualified
739 public:
740 Expression *exp;
741 int inuse;
743 const char *kind();
744 TypeTypeof *syntaxCopy();
745 Dsymbol *toDsymbol(Scope *sc);
746 d_uns64 size(const Loc &loc);
747 void accept(Visitor *v) { v->visit(this); }
750 class TypeReturn : public TypeQualified
752 public:
753 const char *kind();
754 TypeReturn *syntaxCopy();
755 Dsymbol *toDsymbol(Scope *sc);
756 void accept(Visitor *v) { v->visit(this); }
759 // Whether alias this dependency is recursive or not.
760 enum AliasThisRec
762 RECno = 0, // no alias this recursion
763 RECyes = 1, // alias this has recursive dependency
764 RECfwdref = 2, // not yet known
765 RECtypeMask = 3,// mask to read no/yes/fwdref
767 RECtracing = 0x4, // mark in progress of implicitConvTo/deduceWild
768 RECtracingDT = 0x8 // mark in progress of deduceType
771 class TypeStruct : public Type
773 public:
774 StructDeclaration *sym;
775 AliasThisRec att;
776 bool inuse;
778 static TypeStruct *create(StructDeclaration *sym);
779 const char *kind();
780 d_uns64 size(const Loc &loc);
781 unsigned alignsize();
782 TypeStruct *syntaxCopy();
783 Dsymbol *toDsymbol(Scope *sc);
784 structalign_t alignment();
785 Expression *defaultInitLiteral(const Loc &loc);
786 bool isZeroInit(const Loc &loc);
787 bool isAssignable();
788 bool isBoolean() /*const*/;
789 bool needsDestruction() /*const*/;
790 bool needsCopyOrPostblit();
791 bool needsNested();
792 bool hasPointers();
793 bool hasVoidInitPointers();
794 bool hasInvariant();
795 MATCH implicitConvTo(Type *to);
796 MATCH constConv(Type *to);
797 unsigned char deduceWild(Type *t, bool isRef);
798 Type *toHeadMutable();
800 void accept(Visitor *v) { v->visit(this); }
803 class TypeEnum : public Type
805 public:
806 EnumDeclaration *sym;
808 const char *kind();
809 TypeEnum *syntaxCopy();
810 d_uns64 size(const Loc &loc);
811 unsigned alignsize();
812 Type *memType(const Loc &loc = Loc());
813 Dsymbol *toDsymbol(Scope *sc);
814 bool isintegral();
815 bool isfloating();
816 bool isreal();
817 bool isimaginary();
818 bool iscomplex();
819 bool isscalar();
820 bool isunsigned();
821 bool isBoolean();
822 bool isString();
823 bool isAssignable();
824 bool needsDestruction();
825 bool needsCopyOrPostblit();
826 bool needsNested();
827 MATCH implicitConvTo(Type *to);
828 MATCH constConv(Type *to);
829 bool isZeroInit(const Loc &loc);
830 bool hasPointers();
831 bool hasVoidInitPointers();
832 bool hasInvariant();
833 Type *nextOf();
835 void accept(Visitor *v) { v->visit(this); }
838 class TypeClass : public Type
840 public:
841 ClassDeclaration *sym;
842 AliasThisRec att;
843 CPPMANGLE cppmangle;
845 const char *kind();
846 d_uns64 size(const Loc &loc) /*const*/;
847 TypeClass *syntaxCopy();
848 Dsymbol *toDsymbol(Scope *sc);
849 ClassDeclaration *isClassHandle();
850 bool isBaseOf(Type *t, int *poffset);
851 MATCH implicitConvTo(Type *to);
852 MATCH constConv(Type *to);
853 unsigned char deduceWild(Type *t, bool isRef);
854 Type *toHeadMutable();
855 bool isZeroInit(const Loc &loc) /*const*/;
856 bool isscope() /*const*/;
857 bool isBoolean() /*const*/;
858 bool hasPointers() /*const*/;
860 void accept(Visitor *v) { v->visit(this); }
863 class TypeTuple : public Type
865 public:
866 // 'logically immutable' cached global - don't modify (neither pointer nor pointee)!
867 static TypeTuple *empty;
869 Parameters *arguments; // types making up the tuple
871 static TypeTuple *create(Parameters *arguments);
872 static TypeTuple *create();
873 static TypeTuple *create(Type *t1);
874 static TypeTuple *create(Type *t1, Type *t2);
875 const char *kind();
876 TypeTuple *syntaxCopy();
877 bool equals(const RootObject *o) const;
878 void accept(Visitor *v) { v->visit(this); }
881 class TypeSlice : public TypeNext
883 public:
884 Expression *lwr;
885 Expression *upr;
887 const char *kind();
888 TypeSlice *syntaxCopy();
889 void accept(Visitor *v) { v->visit(this); }
892 class TypeNull : public Type
894 public:
895 const char *kind();
897 TypeNull *syntaxCopy();
898 MATCH implicitConvTo(Type *to);
899 bool isBoolean() /*const*/;
901 d_uns64 size(const Loc &loc) /*const*/;
902 void accept(Visitor *v) { v->visit(this); }
905 class TypeNoreturn final : public Type
907 public:
908 const char *kind();
909 TypeNoreturn *syntaxCopy();
910 MATCH implicitConvTo(Type* to);
911 MATCH constConv(Type* to);
912 bool isBoolean() /* const */;
913 d_uns64 size(const Loc& loc) /* const */;
914 unsigned alignsize();
916 void accept(Visitor *v) { v->visit(this); }
919 class TypeTag final : public Type
921 public:
922 TypeTag *syntaxCopy();
924 void accept(Visitor *v) { v->visit(this); }
927 /**************************************************************/
929 bool arrayTypeCompatibleWithoutCasting(Type *t1, Type *t2);
931 // If the type is a class or struct, returns the symbol for it, else null.
932 AggregateDeclaration *isAggregate(Type *t);