using System; using System.Collections.Generic; namespace AspClassic.Parser; /// /// A parse tree for a case clause that compares values. /// public sealed class ComparisonCaseClause : CaseClause { private readonly Location _IsLocation; private readonly OperatorType _ComparisonOperator; private readonly Location _OperatorLocation; private readonly Expression _Operand; /// /// The location of the 'Is', if any. /// public Location IsLocation => _IsLocation; /// /// The comparison operator used in the case clause. /// public OperatorType ComparisonOperator => _ComparisonOperator; /// /// The location of the comparison operator. /// public Location OperatorLocation => _OperatorLocation; /// /// The operand of the case clause. /// public Expression Operand => _Operand; /// /// Constructs a new parse tree for a comparison case clause. /// /// The location of the 'Is', if any. /// The comparison operator used. /// The location of the comparison operator. /// The operand of the comparison. /// The location of the parse tree. public ComparisonCaseClause(Location isLocation, OperatorType comparisonOperator, Location operatorLocation, Expression operand, Span span) : base(TreeType.ComparisonCaseClause, span) { if (operand == null) { throw new ArgumentNullException("operand"); } if (comparisonOperator < OperatorType.Equals || comparisonOperator > OperatorType.GreaterThanEquals) { throw new ArgumentOutOfRangeException("comparisonOperator"); } SetParent(operand); _IsLocation = isLocation; _ComparisonOperator = comparisonOperator; _OperatorLocation = operatorLocation; _Operand = operand; } protected override void GetChildTrees(IList childList) { Tree.AddChild(childList, Operand); } }