@@ -684,7 +684,7 @@ class Formatter(Sink)
684
684
/**
685
685
Type type;
686
686
CastQualifier castQualifier;
687
- UnaryExpression unaryExpression;
687
+ UnaryExpressionNode unaryExpression;
688
688
**/
689
689
690
690
with (castExpression)
@@ -1330,7 +1330,7 @@ class Formatter(Sink)
1330
1330
else if (cast (TraitsExpression) n) format(cast (TraitsExpression) n);
1331
1331
else if (cast (TypeidExpression) n) format(cast (TypeidExpression) n);
1332
1332
else if (cast (TypeofExpression) n) format(cast (TypeofExpression) n);
1333
- else if (cast (UnaryExpression ) n) format(cast (UnaryExpression ) n);
1333
+ else if (cast (UnaryExpressionNode ) n) format(cast (UnaryExpressionNode ) n);
1334
1334
else if (cast (XorExpression) n) format(cast (XorExpression) n);
1335
1335
}
1336
1336
@@ -1502,7 +1502,7 @@ class Formatter(Sink)
1502
1502
1503
1503
/**
1504
1504
Type type;
1505
- UnaryExpression unaryExpression;
1505
+ UnaryExpressionNode unaryExpression;
1506
1506
TemplateArguments templateArguments;
1507
1507
Arguments arguments;
1508
1508
**/
@@ -1886,7 +1886,7 @@ class Formatter(Sink)
1886
1886
debug (verbose) writeln(" IndexExpression" );
1887
1887
1888
1888
/**
1889
- UnaryExpression unaryExpression;
1889
+ UnaryExpressionNode unaryExpression;
1890
1890
ArgumentList argumentList;
1891
1891
**/
1892
1892
@@ -3606,59 +3606,115 @@ class Formatter(Sink)
3606
3606
put(" )" );
3607
3607
}
3608
3608
3609
- void format (const UnaryExpression unary)
3609
+ void format (const UnaryExpressionNode unary)
3610
+ {
3611
+ debug (verbose) writeln(" UnaryExpressionNode(" );
3612
+
3613
+ if (auto p = cast (RefPrefixUnaryExpression) unary) format(p);
3614
+ else if (auto p = cast (NotPrefixUnaryExpression) unary) format(p);
3615
+ else if (auto p = cast (DerefPrefixUnaryExpression) unary) format(p);
3616
+ else if (auto p = cast (PlusPrefixUnaryExpression) unary) format(p);
3617
+ else if (auto p = cast (MinusPrefixUnaryExpression) unary) format(p);
3618
+ else if (auto p = cast (TildePrefixUnaryExpression) unary) format(p);
3619
+ else if (auto p = cast (PlusPlusPrefixUnaryExpression) unary) format(p);
3620
+ else if (auto p = cast (MinusMinusPrefixUnaryExpression) unary) format(p);
3621
+ else if (auto p = cast (PlusPlusPostfixUnaryExpression) unary) format(p);
3622
+ else if (auto p = cast (MinusMinusPostfixUnaryExpression) unary) format(p);
3623
+ else if (auto p = cast (UnaryDotIdentifierExpression) unary) format(p);
3624
+ else if (auto p = cast (UnaryDotNewExpression) unary) format(p);
3625
+ else if (auto p = cast (TypeDotIdentifierExpression) unary) format(p);
3626
+ else if (auto p = cast (AssertExpression) unary) format(p);
3627
+ else if (auto p = cast (CastExpression) unary) format(p);
3628
+ else if (auto p = cast (DeleteExpression) unary) format(p);
3629
+ else if (auto p = cast (FunctionCallExpression) unary) format(p);
3630
+ else if (auto p = cast (IndexExpression) unary) format(p);
3631
+ else if (auto p = cast (NewExpression) unary) format(p);
3632
+ else if (auto p = cast (PrimaryExpression) unary) format(p);
3633
+ else if (auto p = cast (ThrowExpression) unary) format(p);
3634
+
3635
+ debug (verbose) writeln(" )" );
3636
+ }
3637
+
3638
+ void format (const RefPrefixUnaryExpression unary)
3610
3639
{
3611
- debug (verbose) writeln(" UnaryExpression(" );
3640
+ put(" &" );
3641
+ format(unary.unaryExpression);
3642
+ }
3612
3643
3613
- /**
3614
- Type type;
3615
- PrimaryExpression primaryExpression;
3616
- Token prefix;
3617
- Token suffix;
3618
- UnaryExpression unaryExpression;
3619
- NewExpression newExpression;
3620
- DeleteExpression deleteExpression;
3621
- CastExpression castExpression;
3622
- FunctionCallExpression functionCallExpression;
3623
- ArgumentList argumentList;
3624
- IdentifierOrTemplateInstance identifierOrTemplateInstance;
3625
- AssertExpression assertExpression;
3626
- SliceExpression sliceExpression;
3627
- IndexExpression indexExpression;
3628
- **/
3644
+ void format (const NotPrefixUnaryExpression unary)
3645
+ {
3646
+ put(" !" );
3647
+ format(unary.unaryExpression);
3648
+ }
3629
3649
3630
- with (unary)
3631
- {
3632
- if (prefix != tok! " " ) format(prefix);
3650
+ void format (const DerefPrefixUnaryExpression unary)
3651
+ {
3652
+ put(" *" );
3653
+ format(unary.unaryExpression);
3654
+ }
3633
3655
3634
- if (type && identifierOrTemplateInstance)
3635
- {
3636
- // handle things like (void*).sizeof
3637
- put(" (" );
3638
- format(type);
3639
- put(" )" );
3640
- }
3656
+ void format (const PlusPrefixUnaryExpression unary)
3657
+ {
3658
+ put(" +" );
3659
+ format(unary.unaryExpression);
3660
+ }
3641
3661
3642
- if (primaryExpression) format(primaryExpression);
3643
- if (newExpression) format(newExpression);
3644
- if (deleteExpression) format(deleteExpression);
3645
- if (castExpression) format(castExpression);
3646
- if (functionCallExpression) format(functionCallExpression);
3647
- if (assertExpression) format(assertExpression);
3648
- if (throwExpression) format(throwExpression);
3649
- if (indexExpression) format(indexExpression);
3662
+ void format (const MinusPrefixUnaryExpression unary)
3663
+ {
3664
+ put(" -" );
3665
+ format(unary.unaryExpression);
3666
+ }
3650
3667
3651
- if (unaryExpression) format(unaryExpression);
3652
- if (suffix != tok! " " ) format(suffix);
3668
+ void format (const TildePrefixUnaryExpression unary)
3669
+ {
3670
+ put(" ~" );
3671
+ format(unary.unaryExpression);
3672
+ }
3653
3673
3654
- if (identifierOrTemplateInstance)
3655
- {
3656
- put(" ." );
3657
- format(identifierOrTemplateInstance);
3658
- }
3659
- }
3674
+ void format (const PlusPlusPrefixUnaryExpression unary)
3675
+ {
3676
+ put(" ++" );
3677
+ format(unary.unaryExpression);
3678
+ }
3660
3679
3661
- debug (verbose) writeln(" )" );
3680
+ void format (const MinusMinusPrefixUnaryExpression unary)
3681
+ {
3682
+ put(" --" );
3683
+ format(unary.unaryExpression);
3684
+ }
3685
+
3686
+ void format (const PlusPlusPostfixUnaryExpression unary)
3687
+ {
3688
+ format(unary.unaryExpression);
3689
+ put(" ++" );
3690
+ }
3691
+
3692
+ void format (const MinusMinusPostfixUnaryExpression unary)
3693
+ {
3694
+ format(unary.unaryExpression);
3695
+ put(" --" );
3696
+ }
3697
+
3698
+ void format (const UnaryDotIdentifierExpression unary)
3699
+ {
3700
+ format(unary.unaryExpression);
3701
+ put(" ." );
3702
+ format(unary.identifierOrTemplateInstance);
3703
+ }
3704
+
3705
+ void format (const UnaryDotNewExpression unary)
3706
+ {
3707
+ format(unary.unaryExpression);
3708
+ put(" ." );
3709
+ format(unary.newExpression);
3710
+ }
3711
+
3712
+ void format (const TypeDotIdentifierExpression unary)
3713
+ {
3714
+ put(" (" );
3715
+ format(unary.type);
3716
+ put(" )." );
3717
+ format(unary.identifierOrTemplateInstance);
3662
3718
}
3663
3719
3664
3720
void format (const UnionDeclaration decl, const Attribute [] attrs = null )
@@ -4178,6 +4234,9 @@ unittest
4178
4234
testFormatNode! (VariableDeclaration)(` T!(0)[] t;` );
4179
4235
testFormatNode! (VariableDeclaration)(` T!(0)[dim] t;` );
4180
4236
testFormatNode! (VariableDeclaration)(` const shared t = [0, 1];` );
4237
+ testFormatNode! (VariableDeclaration)(` auto x = foo();` );
4238
+ testFormatNode! (VariableDeclaration)(` auto x = foo("bar");` );
4239
+ testFormatNode! (VariableDeclaration)(` auto x = foo(baz: "bar");` );
4181
4240
4182
4241
testFormatNode! (OutStatement)(
4183
4242
`
0 commit comments