using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
///
/// A parse tree for an assignment statement.
///
public sealed class AssignmentStatement : Statement
{
private readonly Expression _TargetExpression;
private readonly Location _OperatorLocation;
private readonly Expression _SourceExpression;
private readonly bool _IsSetStatement;
///
/// The target of the assignment.
///
public Expression TargetExpression => _TargetExpression;
///
/// The location of the operator.
///
public Location OperatorLocation => _OperatorLocation;
///
/// The source of the assignment.
///
public Expression SourceExpression => _SourceExpression;
public bool IsSetStatement => _IsSetStatement;
///
/// Constructs a new parse tree for an assignment statement.
///
/// 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.
/// Whether is is a set statement
public AssignmentStatement(Expression targetExpression, Location operatorLocation, Expression sourceExpression, Span span, IList comments, bool isSetStatement)
: base(TreeType.AssignmentStatement, span, comments)
{
if (targetExpression == null)
{
throw new ArgumentNullException("targetExpression");
}
if (sourceExpression == null)
{
throw new ArgumentNullException("sourceExpression");
}
SetParent(targetExpression);
SetParent(sourceExpression);
_TargetExpression = targetExpression;
_OperatorLocation = operatorLocation;
_SourceExpression = sourceExpression;
_IsSetStatement = isSetStatement;
}
///
/// Constructs a new parse tree for an assignment statement.
///
/// 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 AssignmentStatement(Expression targetExpression, Location operatorLocation, Expression sourceExpression, Span span, IList comments)
: this(targetExpression, operatorLocation, sourceExpression, span, comments, isSetStatement: false)
{
}
protected override void GetChildTrees(IList childList)
{
Tree.AddChild(childList, TargetExpression);
Tree.AddChild(childList, SourceExpression);
}
}