@@ -2702,6 +2702,7 @@ struct ASTBase
27022702 sizeTy[Tmixin] = __traits(classInstanceSize, TypeMixin);
27032703 sizeTy[Tnoreturn] = __traits(classInstanceSize, TypeNoreturn);
27042704 sizeTy[Ttag] = __traits(classInstanceSize, TypeTag);
2705+ sizeTy[Tsumtype] = __traits(classInstanceSize, TypeSumType);
27052706 return sizeTy;
27062707 }();
27072708
@@ -3784,6 +3785,39 @@ struct ASTBase
37843785 }
37853786 }
37863787
3788+ struct SumTypeVariantInfo
3789+ {
3790+ Type type;
3791+ Identifier name;
3792+ Expressions* udas;
3793+ const (char )* comment;
3794+ }
3795+
3796+ alias SumTypeVariantInfos = Array! (SumTypeVariantInfo);
3797+
3798+ extern (C++ ) final class TypeSumType : Type
3799+ {
3800+ SumTypeVariantInfos* variantInfos;
3801+ StructDeclaration loweredStruct;
3802+ size_t defaultVariantIdx;
3803+
3804+ extern (D ) this (SumTypeVariantInfos* variantInfos = null )
3805+ {
3806+ super (Tsumtype);
3807+ this .variantInfos = variantInfos;
3808+ }
3809+
3810+ override TypeSumType syntaxCopy ()
3811+ {
3812+ return this ;
3813+ }
3814+
3815+ override void accept (Visitor v)
3816+ {
3817+ v.visit(this );
3818+ }
3819+ }
3820+
37873821 extern (C++ ) final class TypeReference : TypeNext
37883822 {
37893823 extern (D ) this (Type t)
@@ -6270,6 +6304,35 @@ struct ASTBase
62706304 }
62716305 }
62726306
6307+ struct SumTypeMatchArmInfo
6308+ {
6309+ VarDeclaration vd;
6310+ Expression guard;
6311+ int variantIndex;
6312+ int originalIndex;
6313+ }
6314+
6315+ alias SumTypeMatchArmInfos = Array! (SumTypeMatchArmInfo);
6316+
6317+ extern (C++ ) final class MatchExp : Expression
6318+ {
6319+ Expression arg;
6320+ SumTypeMatchArmInfos* armInfos;
6321+ Type resultType;
6322+
6323+ extern (D ) this (Loc loc, Expression arg, SumTypeMatchArmInfos* armInfos)
6324+ {
6325+ super (loc, EXP .matchExp, __traits(classInstanceSize, MatchExp));
6326+ this .arg = arg;
6327+ this .armInfos = armInfos;
6328+ }
6329+
6330+ override void accept (Visitor v)
6331+ {
6332+ v.visit(this );
6333+ }
6334+ }
6335+
62736336 extern (C++ ) final class ErrorExp : Expression
62746337 {
62756338 extern (D ) this ()
0 commit comments