2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2024 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * https://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * https://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/mtype.h
13 #include "root/dcompat.h" // for d_size_t
15 #include "arraytypes.h"
21 class AggregateDeclaration
;
24 class StructDeclaration
;
25 class ClassDeclaration
;
26 class EnumDeclaration
;
27 class TypeInfoDeclaration
;
29 class TemplateInstance
;
30 class TemplateDeclaration
;
37 typedef union tree_node type
;
39 typedef struct TYPE type
;
42 extern const char* toChars(const Type
* const t
);
43 Type
*typeSemantic(Type
*t
, const Loc
&loc
, Scope
*sc
);
44 Type
*merge(Type
*type
);
46 enum class TY
: uint8_t
48 Tarray
, // slice array, aka T[]
49 Tsarray
, // static array, aka T[dimension]
50 Taarray
, // associative array, aka T[type]
102 #define SIZE_INVALID (~(uinteger_t)0) // error return from size() functions
107 * pick this order of numbers so switch statements work better
111 MODnone
= 0, // default (mutable)
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
;
123 VARARGnone
= 0, /// fixed number of arguments
124 VARARGvariadic
= 1, /// T t, ...) can be C-style (core.stdc.stdarg) or D-style (core.vararg)
125 VARARGtypesafe
= 2, /// T t ...) typesafe https://dlang.org/spec/function.html#typesafe_variadic_functions
126 /// or https://dlang.org/spec/function.html#typesafe_variadic_functions
127 VARARGKRvariadic
= 3 /// K+R C style variadics (no function prototype)
129 typedef unsigned char VarArg
;
133 distinct
= 0, /// types are distinct
134 yes
= 1, /// types are covariant
135 no
= 2, /// arguments match as far as overloading goes, but types are not covariant
136 fwdref
= 3, /// cannot determine covariance because of forward references
139 class Type
: public ASTNode
143 MOD mod
; // modifiers MODxxxx
150 Type
*pto
; // merged pointer to this type
151 Type
*rto
; // reference to this type
152 Type
*arrayof
; // array of this type
153 TypeInfoDeclaration
*vtinfo
; // TypeInfo object for this Type
155 type
*ctype
; // for back end
166 static Type
*tint128
;
167 static Type
*tuns128
;
168 static Type
*tfloat32
;
169 static Type
*tfloat64
;
170 static Type
*tfloat80
;
172 static Type
*timaginary32
;
173 static Type
*timaginary64
;
174 static Type
*timaginary80
;
176 static Type
*tcomplex32
;
177 static Type
*tcomplex64
;
178 static Type
*tcomplex80
;
185 // Some special types
186 static Type
*tshiftcnt
;
187 static Type
*tvoidptr
; // void*
188 static Type
*tstring
; // immutable(char)[]
189 static Type
*twstring
; // immutable(wchar)[]
190 static Type
*tdstring
; // immutable(dchar)[]
191 static Type
*terror
; // for error recovery
192 static Type
*tnull
; // for null type
193 static Type
*tnoreturn
; // for bottom type typeof(*null)
195 static Type
*tsize_t
; // matches size_t alias
196 static Type
*tptrdiff_t
; // matches ptrdiff_t alias
197 static Type
*thash_t
; // matches hash_t alias
199 static ClassDeclaration
*dtypeinfo
;
200 static ClassDeclaration
*typeinfoclass
;
201 static ClassDeclaration
*typeinfointerface
;
202 static ClassDeclaration
*typeinfostruct
;
203 static ClassDeclaration
*typeinfopointer
;
204 static ClassDeclaration
*typeinfoarray
;
205 static ClassDeclaration
*typeinfostaticarray
;
206 static ClassDeclaration
*typeinfoassociativearray
;
207 static ClassDeclaration
*typeinfovector
;
208 static ClassDeclaration
*typeinfoenum
;
209 static ClassDeclaration
*typeinfofunction
;
210 static ClassDeclaration
*typeinfodelegate
;
211 static ClassDeclaration
*typeinfotypelist
;
212 static ClassDeclaration
*typeinfoconst
;
213 static ClassDeclaration
*typeinfoinvariant
;
214 static ClassDeclaration
*typeinfoshared
;
215 static ClassDeclaration
*typeinfowild
;
217 static TemplateDeclaration
*rtinfo
;
219 static Type
*basic
[(int)TY::TMAX
];
221 virtual const char *kind();
223 virtual Type
*syntaxCopy();
224 bool equals(const RootObject
* const o
) const override
;
225 bool equivalent(Type
*t
);
226 // kludge for template.isType()
227 DYNCAST
dyncast() const override final
{ return DYNCAST_TYPE
; }
228 size_t getUniqueID() const;
229 const char *toChars() const override
;
230 char *toPrettyChars(bool QualifyTypes
= false);
234 virtual uinteger_t
size(const Loc
&loc
);
235 virtual unsigned alignsize();
236 Type
*trySemantic(const Loc
&loc
, Scope
*sc
);
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 bool isConst() const { return (mod
& MODconst
) != 0; }
253 bool isImmutable() const { return (mod
& MODimmutable
) != 0; }
254 bool isMutable() const { return (mod
& (MODconst
| MODimmutable
| MODwild
)) == 0; }
255 bool isShared() const { return (mod
& MODshared
) != 0; }
256 bool isSharedConst() const { return (mod
& (MODshared
| MODconst
)) == (MODshared
| MODconst
); }
257 bool isWild() const { return (mod
& MODwild
) != 0; }
258 bool isWildConst() const { return (mod
& MODwildconst
) == MODwildconst
; }
259 bool isSharedWild() const { return (mod
& (MODshared
| MODwild
)) == (MODshared
| MODwild
); }
260 bool isNaked() const { return mod
== 0; }
261 Type
*nullAttributes() const;
266 Type
*sharedConstOf();
270 Type
*sharedWildOf();
271 Type
*sharedWildConstOf();
272 Type
*castMod(MOD mod
);
273 Type
*addMod(MOD mod
);
274 virtual Type
*addStorageClass(StorageClass stc
);
278 Type
*sarrayOf(dinteger_t dim
);
279 bool hasDeprecatedAliasThis();
281 virtual Type
*makeConst();
282 virtual Type
*makeImmutable();
283 virtual Type
*makeShared();
284 virtual Type
*makeSharedConst();
285 virtual Type
*makeWild();
286 virtual Type
*makeWildConst();
287 virtual Type
*makeSharedWild();
288 virtual Type
*makeSharedWildConst();
289 virtual Type
*makeMutable();
290 virtual Dsymbol
*toDsymbol(Scope
*sc
);
292 virtual bool isBaseOf(Type
*t
, int *poffset
);
293 virtual MATCH
implicitConvTo(Type
*to
);
294 virtual MATCH
constConv(Type
*to
);
295 virtual unsigned char deduceWild(Type
*t
, bool isRef
);
296 virtual Type
*substWildTo(unsigned mod
);
298 Type
*unqualify(unsigned m
);
300 virtual Type
*toHeadMutable();
301 virtual ClassDeclaration
*isClassHandle();
302 virtual structalign_t
alignment();
303 virtual Expression
*defaultInitLiteral(const Loc
&loc
);
304 virtual bool isZeroInit(const Loc
&loc
= Loc()); // if initializer is 0
305 Identifier
*getTypeInfoIdent();
306 virtual int hasWild() const;
307 virtual bool hasPointers();
308 virtual bool hasVoidInitPointers();
309 virtual bool hasSystemFields();
310 virtual bool hasInvariant();
311 virtual Type
*nextOf();
313 virtual bool needsDestruction();
314 virtual bool needsCopyOrPostblit();
315 virtual bool needsNested();
317 TypeFunction
*toTypeFunction();
319 // For eliminating dynamic_cast
320 virtual TypeBasic
*isTypeBasic();
321 TypeFunction
*isPtrToFunction();
322 TypeFunction
*isFunction_Delegate_PtrToFunction();
323 TypeError
*isTypeError();
324 TypeVector
*isTypeVector();
325 TypeSArray
*isTypeSArray();
326 TypeDArray
*isTypeDArray();
327 TypeAArray
*isTypeAArray();
328 TypePointer
*isTypePointer();
329 TypeReference
*isTypeReference();
330 TypeFunction
*isTypeFunction();
331 TypeDelegate
*isTypeDelegate();
332 TypeIdentifier
*isTypeIdentifier();
333 TypeInstance
*isTypeInstance();
334 TypeTypeof
*isTypeTypeof();
335 TypeReturn
*isTypeReturn();
336 TypeStruct
*isTypeStruct();
337 TypeEnum
*isTypeEnum();
338 TypeClass
*isTypeClass();
339 TypeTuple
*isTypeTuple();
340 TypeSlice
*isTypeSlice();
341 TypeNull
*isTypeNull();
342 TypeMixin
*isTypeMixin();
343 TypeTraits
*isTypeTraits();
344 TypeNoreturn
*isTypeNoreturn();
345 TypeTag
*isTypeTag();
347 void accept(Visitor
*v
) override
{ v
->visit(this); }
350 class TypeError final
: public Type
353 const char *kind() override
;
354 TypeError
*syntaxCopy() override
;
356 uinteger_t
size(const Loc
&loc
) override
;
357 Expression
*defaultInitLiteral(const Loc
&loc
) override
;
358 void accept(Visitor
*v
) override
{ v
->visit(this); }
361 class TypeNext
: public Type
366 int hasWild() const override final
;
367 Type
*nextOf() override final
;
368 Type
*makeConst() override final
;
369 Type
*makeImmutable() override final
;
370 Type
*makeShared() override final
;
371 Type
*makeSharedConst() override final
;
372 Type
*makeWild() override final
;
373 Type
*makeWildConst() override final
;
374 Type
*makeSharedWild() override final
;
375 Type
*makeSharedWildConst() override final
;
376 Type
*makeMutable() override final
;
377 MATCH
constConv(Type
*to
) override
;
378 unsigned char deduceWild(Type
*t
, bool isRef
) override final
;
380 void accept(Visitor
*v
) override
{ v
->visit(this); }
383 class TypeBasic final
: public Type
389 const char *kind() override
;
390 TypeBasic
*syntaxCopy() override
;
391 uinteger_t
size(const Loc
&loc
) override
;
392 unsigned alignsize() override
;
393 bool isintegral() override
;
394 bool isfloating() override
;
395 bool isreal() override
;
396 bool isimaginary() override
;
397 bool iscomplex() override
;
398 bool isscalar() override
;
399 bool isunsigned() override
;
400 MATCH
implicitConvTo(Type
*to
) override
;
401 bool isZeroInit(const Loc
&loc
) override
;
403 // For eliminating dynamic_cast
404 TypeBasic
*isTypeBasic() override
;
405 void accept(Visitor
*v
) override
{ v
->visit(this); }
408 class TypeVector final
: public Type
413 static TypeVector
*create(Type
*basetype
);
414 const char *kind() override
;
415 TypeVector
*syntaxCopy() override
;
416 uinteger_t
size(const Loc
&loc
) override
;
417 unsigned alignsize() override
;
418 bool isintegral() override
;
419 bool isfloating() override
;
420 bool isscalar() override
;
421 bool isunsigned() override
;
422 bool isBoolean() override
;
423 MATCH
implicitConvTo(Type
*to
) override
;
424 Expression
*defaultInitLiteral(const Loc
&loc
) override
;
425 TypeBasic
*elementType();
426 bool isZeroInit(const Loc
&loc
) override
;
428 void accept(Visitor
*v
) override
{ v
->visit(this); }
431 class TypeArray
: public TypeNext
434 void accept(Visitor
*v
) override
{ v
->visit(this); }
437 // Static array, one with a fixed dimension
438 class TypeSArray final
: public TypeArray
443 const char *kind() override
;
444 TypeSArray
*syntaxCopy() override
;
446 uinteger_t
size(const Loc
&loc
) override
;
447 unsigned alignsize() override
;
448 bool isString() override
;
449 bool isZeroInit(const Loc
&loc
) override
;
450 structalign_t
alignment() override
;
451 MATCH
constConv(Type
*to
) override
;
452 MATCH
implicitConvTo(Type
*to
) override
;
453 Expression
*defaultInitLiteral(const Loc
&loc
) override
;
454 bool hasPointers() override
;
455 bool hasSystemFields() override
;
456 bool hasVoidInitPointers() override
;
457 bool hasInvariant() override
;
458 bool needsDestruction() override
;
459 bool needsCopyOrPostblit() override
;
460 bool needsNested() override
;
462 void accept(Visitor
*v
) override
{ v
->visit(this); }
465 // Dynamic array, no dimension
466 class TypeDArray final
: public TypeArray
469 const char *kind() override
;
470 TypeDArray
*syntaxCopy() override
;
471 uinteger_t
size(const Loc
&loc
) override
;
472 unsigned alignsize() override
;
473 bool isString() override
;
474 bool isZeroInit(const Loc
&loc
) override
;
475 bool isBoolean() override
;
476 MATCH
implicitConvTo(Type
*to
) override
;
477 bool hasPointers() override
;
479 void accept(Visitor
*v
) override
{ v
->visit(this); }
482 class TypeAArray final
: public TypeArray
485 Type
*index
; // key type
488 static TypeAArray
*create(Type
*t
, Type
*index
);
489 const char *kind() override
;
490 TypeAArray
*syntaxCopy() override
;
491 uinteger_t
size(const Loc
&loc
) override
;
492 bool isZeroInit(const Loc
&loc
) override
;
493 bool isBoolean() override
;
494 bool hasPointers() override
;
495 MATCH
implicitConvTo(Type
*to
) override
;
496 MATCH
constConv(Type
*to
) override
;
498 void accept(Visitor
*v
) override
{ v
->visit(this); }
501 class TypePointer final
: public TypeNext
504 static TypePointer
*create(Type
*t
);
505 const char *kind() override
;
506 TypePointer
*syntaxCopy() override
;
507 uinteger_t
size(const Loc
&loc
) override
;
508 MATCH
implicitConvTo(Type
*to
) override
;
509 MATCH
constConv(Type
*to
) override
;
510 bool isscalar() override
;
511 bool isZeroInit(const Loc
&loc
) override
;
512 bool hasPointers() override
;
514 void accept(Visitor
*v
) override
{ v
->visit(this); }
517 class TypeReference final
: public TypeNext
520 const char *kind() override
;
521 TypeReference
*syntaxCopy() override
;
522 uinteger_t
size(const Loc
&loc
) override
;
523 bool isZeroInit(const Loc
&loc
) override
;
524 void accept(Visitor
*v
) override
{ v
->visit(this); }
529 RETregs
= 1, // returned in registers
530 RETstack
= 2 // returned on stack
533 enum class TRUST
: unsigned char
536 system
= 1, // @system (same as TRUSTdefault)
537 trusted
= 2, // @trusted
543 TRUSTformatDefault
, // do not emit @system when trust == TRUSTdefault
544 TRUSTformatSystem
// emit @system when trust == TRUSTdefault
547 enum class PURE
: unsigned char
549 impure
= 0, // not pure at all
550 fwdref
= 1, // it's pure, but not known which level yet
551 weak
= 2, // no mutable globals are read or written
552 const_
= 3, // parameters are values or const
555 class Parameter final
: public ASTNode
559 StorageClass storageClass
;
562 Expression
*defaultArg
;
563 UserAttributeDeclaration
*userAttribDecl
; // user defined attributes
565 static Parameter
*create(const Loc
&loc
, StorageClass storageClass
, Type
*type
, Identifier
*ident
,
566 Expression
*defaultArg
, UserAttributeDeclaration
*userAttribDecl
);
567 Parameter
*syntaxCopy();
570 bool isReference() const;
571 // kludge for template.isType()
572 DYNCAST
dyncast() const override
{ return DYNCAST_PARAMETER
; }
573 void accept(Visitor
*v
) override
{ v
->visit(this); }
575 static size_t dim(Parameters
*parameters
);
576 static Parameter
*getNth(Parameters
*parameters
, d_size_t nth
);
577 const char *toChars() const override
;
578 bool isCovariant(bool returnByRef
, const Parameter
*p
, bool previewIn
) const;
583 Parameters
* parameters
;
586 d_bool hasIdentifierList
; // true if C identifier-list style
589 Parameter
*operator[](size_t i
) { return Parameter::getNth(parameters
, i
); }
592 class TypeFunction final
: public TypeNext
595 // .next is the return type
597 ParameterList parameterList
; // function parameters
599 LINK linkage
; // calling convention
600 TRUST trust
; // level of trust
601 PURE purity
; // PURExxxx
603 Expressions
*fargs
; // function arguments
605 static TypeFunction
*create(Parameters
*parameters
, Type
*treturn
, VarArg varargs
, LINK linkage
, StorageClass stc
= 0);
606 const char *kind() override
;
607 TypeFunction
*syntaxCopy() override
;
609 bool hasLazyParameters();
610 bool isDstyleVariadic() const;
611 StorageClass
parameterStorageClass(Type
* tthis
, Parameter
*p
, VarDeclarations
* outerVars
= nullptr, bool indirect
= false);
612 Type
*addStorageClass(StorageClass stc
) override
;
614 Type
*substWildTo(unsigned mod
) override
;
615 MATCH
constConv(Type
*to
) override
;
617 bool isnothrow() const;
618 void isnothrow(bool v
);
621 bool isproperty() const;
622 void isproperty(bool v
);
625 bool isreturn() const;
626 void isreturn(bool v
);
627 bool isreturnscope() const;
628 void isreturnscope(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
);
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
);
645 void accept(Visitor
*v
) override
{ v
->visit(this); }
648 class TypeDelegate final
: public TypeNext
651 // .next is a TypeFunction
653 static TypeDelegate
*create(TypeFunction
*t
);
654 const char *kind() override
;
655 TypeDelegate
*syntaxCopy() override
;
656 Type
*addStorageClass(StorageClass stc
) override
;
657 uinteger_t
size(const Loc
&loc
) override
;
658 unsigned alignsize() override
;
659 MATCH
implicitConvTo(Type
*to
) override
;
660 bool isZeroInit(const Loc
&loc
) override
;
661 bool isBoolean() override
;
662 bool hasPointers() override
;
664 void accept(Visitor
*v
) override
{ v
->visit(this); }
667 class TypeTraits final
: public Type
670 /// The expression to resolve as type or symbol.
672 /// Cached type/symbol after semantic analysis.
675 const char *kind() override
;
676 TypeTraits
*syntaxCopy() override
;
677 uinteger_t
size(const Loc
&loc
) override
;
678 Dsymbol
*toDsymbol(Scope
*sc
) override
;
679 void accept(Visitor
*v
) override
{ v
->visit(this); }
682 class TypeMixin final
: public Type
688 const char *kind() override
;
689 TypeMixin
*syntaxCopy() override
;
690 Dsymbol
*toDsymbol(Scope
*sc
) override
;
691 void accept(Visitor
*v
) override
{ v
->visit(this); }
694 class TypeQualified
: public Type
698 // array of Identifier and TypeInstance,
699 // representing ident.ident!tiargs.ident. ... etc.
702 uinteger_t
size(const Loc
&loc
) override
;
704 void accept(Visitor
*v
) override
{ v
->visit(this); }
707 class TypeIdentifier final
: public TypeQualified
711 Dsymbol
*originalSymbol
; // The symbol representing this identifier, before alias resolution
713 static TypeIdentifier
*create(const Loc
&loc
, Identifier
*ident
);
714 const char *kind() override
;
715 TypeIdentifier
*syntaxCopy() override
;
716 Dsymbol
*toDsymbol(Scope
*sc
) override
;
717 void accept(Visitor
*v
) override
{ v
->visit(this); }
720 /* Similar to TypeIdentifier, but with a TemplateInstance as the root
722 class TypeInstance final
: public TypeQualified
725 TemplateInstance
*tempinst
;
727 const char *kind() override
;
728 TypeInstance
*syntaxCopy() override
;
729 Dsymbol
*toDsymbol(Scope
*sc
) override
;
730 void accept(Visitor
*v
) override
{ v
->visit(this); }
733 class TypeTypeof final
: public TypeQualified
739 const char *kind() override
;
740 TypeTypeof
*syntaxCopy() override
;
741 Dsymbol
*toDsymbol(Scope
*sc
) override
;
742 uinteger_t
size(const Loc
&loc
) override
;
743 void accept(Visitor
*v
) override
{ v
->visit(this); }
746 class TypeReturn final
: public TypeQualified
749 const char *kind() override
;
750 TypeReturn
*syntaxCopy() override
;
751 Dsymbol
*toDsymbol(Scope
*sc
) override
;
752 void accept(Visitor
*v
) override
{ v
->visit(this); }
755 // Whether alias this dependency is recursive or not.
758 RECno
= 0, // no alias this recursion
759 RECyes
= 1, // alias this has recursive dependency
760 RECfwdref
= 2, // not yet known
761 RECtypeMask
= 3,// mask to read no/yes/fwdref
763 RECtracing
= 0x4, // mark in progress of implicitConvTo/deduceWild
764 RECtracingDT
= 0x8 // mark in progress of deduceType
767 class TypeStruct final
: public Type
770 StructDeclaration
*sym
;
774 static TypeStruct
*create(StructDeclaration
*sym
);
775 const char *kind() override
;
776 uinteger_t
size(const Loc
&loc
) override
;
777 unsigned alignsize() override
;
778 TypeStruct
*syntaxCopy() override
;
779 Dsymbol
*toDsymbol(Scope
*sc
) override
;
780 structalign_t
alignment() override
;
781 Expression
*defaultInitLiteral(const Loc
&loc
) override
;
782 bool isZeroInit(const Loc
&loc
) override
;
783 bool isAssignable() override
;
784 bool isBoolean() override
;
785 bool needsDestruction() override
;
786 bool needsCopyOrPostblit() override
;
787 bool needsNested() override
;
788 bool hasPointers() override
;
789 bool hasVoidInitPointers() override
;
790 bool hasSystemFields() override
;
791 bool hasInvariant() override
;
792 MATCH
implicitConvTo(Type
*to
) override
;
793 MATCH
constConv(Type
*to
) override
;
794 unsigned char deduceWild(Type
*t
, bool isRef
) override
;
795 Type
*toHeadMutable() override
;
797 void accept(Visitor
*v
) override
{ v
->visit(this); }
800 class TypeEnum final
: public Type
803 EnumDeclaration
*sym
;
805 const char *kind() override
;
806 TypeEnum
*syntaxCopy() override
;
807 uinteger_t
size(const Loc
&loc
) override
;
808 unsigned alignsize() override
;
809 Type
*memType(const Loc
&loc
= Loc());
810 Dsymbol
*toDsymbol(Scope
*sc
) override
;
811 bool isintegral() override
;
812 bool isfloating() override
;
813 bool isreal() override
;
814 bool isimaginary() override
;
815 bool iscomplex() override
;
816 bool isscalar() override
;
817 bool isunsigned() override
;
818 bool isBoolean() override
;
819 bool isString() override
;
820 bool isAssignable() override
;
821 bool needsDestruction() override
;
822 bool needsCopyOrPostblit() override
;
823 bool needsNested() override
;
824 MATCH
implicitConvTo(Type
*to
) override
;
825 MATCH
constConv(Type
*to
) override
;
826 bool isZeroInit(const Loc
&loc
) override
;
827 bool hasPointers() override
;
828 bool hasVoidInitPointers() override
;
829 bool hasSystemFields() override
;
830 bool hasInvariant() override
;
831 Type
*nextOf() override
;
833 void accept(Visitor
*v
) override
{ v
->visit(this); }
836 class TypeClass final
: public Type
839 ClassDeclaration
*sym
;
843 const char *kind() override
;
844 uinteger_t
size(const Loc
&loc
) override
;
845 TypeClass
*syntaxCopy() override
;
846 Dsymbol
*toDsymbol(Scope
*sc
) override
;
847 ClassDeclaration
*isClassHandle() override
;
848 bool isBaseOf(Type
*t
, int *poffset
) override
;
849 MATCH
implicitConvTo(Type
*to
) override
;
850 MATCH
constConv(Type
*to
) override
;
851 unsigned char deduceWild(Type
*t
, bool isRef
) override
;
852 Type
*toHeadMutable() override
;
853 bool isZeroInit(const Loc
&loc
) override
;
854 bool isscope() override
;
855 bool isBoolean() override
;
856 bool hasPointers() override
;
858 void accept(Visitor
*v
) override
{ v
->visit(this); }
861 class TypeTuple final
: public Type
864 // 'logically immutable' cached global - don't modify (neither pointer nor pointee)!
865 static TypeTuple
*empty
;
867 Parameters
*arguments
; // types making up the tuple
869 static TypeTuple
*create(Parameters
*arguments
);
870 static TypeTuple
*create();
871 static TypeTuple
*create(Type
*t1
);
872 static TypeTuple
*create(Type
*t1
, Type
*t2
);
873 const char *kind() override
;
874 TypeTuple
*syntaxCopy() override
;
875 bool equals(const RootObject
* const o
) const override
;
876 void accept(Visitor
*v
) override
{ v
->visit(this); }
879 class TypeSlice final
: public TypeNext
885 const char *kind() override
;
886 TypeSlice
*syntaxCopy() override
;
887 void accept(Visitor
*v
) override
{ v
->visit(this); }
890 class TypeNull final
: public Type
893 const char *kind() override
;
895 TypeNull
*syntaxCopy() override
;
896 MATCH
implicitConvTo(Type
*to
) override
;
897 bool hasPointers() override
;
898 bool isBoolean() override
;
900 uinteger_t
size(const Loc
&loc
) override
;
901 void accept(Visitor
*v
) override
{ v
->visit(this); }
904 class TypeNoreturn final
: public Type
907 const char *kind() override
;
908 TypeNoreturn
*syntaxCopy() override
;
909 MATCH
implicitConvTo(Type
* to
) override
;
910 MATCH
constConv(Type
* to
) override
;
911 bool isBoolean() override
;
912 uinteger_t
size(const Loc
& loc
) override
;
913 unsigned alignsize() override
;
915 void accept(Visitor
*v
) override
{ v
->visit(this); }
918 class TypeTag final
: public Type
921 TypeTag
*syntaxCopy() override
;
923 void accept(Visitor
*v
) override
{ v
->visit(this); }
926 /**************************************************************/
928 // If the type is a class or struct, returns the symbol for it, else null.
929 AggregateDeclaration
*isAggregate(Type
*t
);
930 Covariant
covariant(Type
*, Type
*, StorageClass
* = NULL
, bool = false);