#define DEBUG using System; using System.Collections.Generic; using System.Diagnostics; namespace AspClassic.Parser; /// /// A parse tree for an expression that has an operand. /// public abstract class UnaryExpression : Expression { private readonly Expression _Operand; /// /// The operand of the expression. /// public Expression Operand => _Operand; public override bool IsConstant => Operand.IsConstant; protected UnaryExpression(TreeType type, Expression operand, Span span) : base(type, span) { Debug.Assert(type == TreeType.ParentheticalExpression || type == TreeType.TypeOfExpression || type == TreeType.CTypeExpression || type == TreeType.DirectCastExpression || type == TreeType.TryCastExpression || type == TreeType.IntrinsicCastExpression || (type >= TreeType.UnaryOperatorExpression && type <= TreeType.AddressOfExpression)); if (operand == null) { throw new ArgumentNullException("operand"); } SetParent(operand); _Operand = operand; } protected override void GetChildTrees(IList childList) { Tree.AddChild(childList, Operand); } }