46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using System.Collections.Immutable;
|
|
using System.Diagnostics;
|
|
using Microsoft.CodeAnalysis.CSharp.Symbols;
|
|
|
|
namespace Microsoft.CodeAnalysis.CSharp;
|
|
|
|
internal sealed class BoundSwitchExpressionArm : BoundNode
|
|
{
|
|
public ImmutableArray<LocalSymbol> Locals { get; }
|
|
|
|
public BoundPattern Pattern { get; }
|
|
|
|
public BoundExpression? WhenClause { get; }
|
|
|
|
public BoundExpression Value { get; }
|
|
|
|
public LabelSymbol Label { get; }
|
|
|
|
public BoundSwitchExpressionArm(SyntaxNode syntax, ImmutableArray<LocalSymbol> locals, BoundPattern pattern, BoundExpression? whenClause, BoundExpression value, LabelSymbol label, bool hasErrors = false)
|
|
: base(BoundKind.SwitchExpressionArm, syntax, hasErrors || pattern.HasErrors() || whenClause.HasErrors() || value.HasErrors())
|
|
{
|
|
Locals = locals;
|
|
Pattern = pattern;
|
|
WhenClause = whenClause;
|
|
Value = value;
|
|
Label = label;
|
|
}
|
|
|
|
[DebuggerStepThrough]
|
|
public override BoundNode? Accept(BoundTreeVisitor visitor)
|
|
{
|
|
return visitor.VisitSwitchExpressionArm(this);
|
|
}
|
|
|
|
public BoundSwitchExpressionArm Update(ImmutableArray<LocalSymbol> locals, BoundPattern pattern, BoundExpression? whenClause, BoundExpression value, LabelSymbol label)
|
|
{
|
|
if (locals != Locals || pattern != Pattern || whenClause != WhenClause || value != Value || !SymbolEqualityComparer.ConsiderEverything.Equals(label, Label))
|
|
{
|
|
BoundSwitchExpressionArm boundSwitchExpressionArm = new BoundSwitchExpressionArm(Syntax, locals, pattern, whenClause, value, label, base.HasErrors);
|
|
boundSwitchExpressionArm.CopyAttributes(this);
|
|
return boundSwitchExpressionArm;
|
|
}
|
|
return this;
|
|
}
|
|
}
|