Files
2026-08-27 10:56:38 -06:00

40 lines
1.3 KiB
C#

using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
namespace Microsoft.CodeAnalysis.CSharp;
internal sealed class BoundRangeVariable : BoundExpression
{
public override Symbol ExpressionSymbol => RangeVariableSymbol;
public new TypeSymbol Type => base.Type;
public RangeVariableSymbol RangeVariableSymbol { get; }
public BoundExpression Value { get; }
public BoundRangeVariable(SyntaxNode syntax, RangeVariableSymbol rangeVariableSymbol, BoundExpression value, TypeSymbol type, bool hasErrors = false)
: base(BoundKind.RangeVariable, syntax, type, hasErrors || value.HasErrors())
{
RangeVariableSymbol = rangeVariableSymbol;
Value = value;
}
[DebuggerStepThrough]
public override BoundNode? Accept(BoundTreeVisitor visitor)
{
return visitor.VisitRangeVariable(this);
}
public BoundRangeVariable Update(RangeVariableSymbol rangeVariableSymbol, BoundExpression value, TypeSymbol type)
{
if (!SymbolEqualityComparer.ConsiderEverything.Equals(rangeVariableSymbol, RangeVariableSymbol) || value != Value || !TypeSymbol.Equals(type, Type, (TypeCompareKind)0))
{
BoundRangeVariable boundRangeVariable = new BoundRangeVariable(Syntax, rangeVariableSymbol, value, type, base.HasErrors);
boundRangeVariable.CopyAttributes(this);
return boundRangeVariable;
}
return this;
}
}