using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for a compound assignment statement.
///
public sealed class CompoundAssignmentStatement : Statement
{
private readonly Expression _TargetExpression;
private readonly OperatorType _CompoundOperator;
private readonly Location _OperatorLocation;
private readonly Expression _SourceExpression;
///
/// The target of the assignment.
///
public Expression TargetExpression => _TargetExpression;
///
/// The compound operator.
///
public OperatorType CompoundOperator => _CompoundOperator;
///
/// The location of the operator.
///
public Location OperatorLocation => _OperatorLocation;
///
/// The source of the assignment.
///
public Expression SourceExpression => _SourceExpression;
///
/// Constructs a new parse tree for a compound assignment statement.
///
/// The compound operator.
/// The target of the assignment.
/// The location of the operator.
/// The source of the assignment.
/// The location of the parse tree.
/// The comments for the parse tree.
public CompoundAssignmentStatement(OperatorType compoundOperator, Expression targetExpression, Location operatorLocation, Expression sourceExpression, Span span, IList comments)
: base(TreeType.CompoundAssignmentStatement, span, comments)
{
if (compoundOperator < OperatorType.Plus || compoundOperator > OperatorType.Power)
{
throw new ArgumentOutOfRangeException("compoundOperator");
}
if (targetExpression == null)
{
throw new ArgumentNullException("targetExpression");
}
if (sourceExpression == null)
{
throw new ArgumentNullException("sourceExpression");
}
SetParent(targetExpression);
SetParent(sourceExpression);
_CompoundOperator = compoundOperator;
_TargetExpression = targetExpression;
_OperatorLocation = operatorLocation;
_SourceExpression = sourceExpression;
}
protected override void GetChildTrees(IList childList)
{
Tree.AddChild(childList, TargetExpression);
Tree.AddChild(childList, SourceExpression);
}
}