aspclassic-core/AspClassic.Parser/CallStatement.cs
Jelle Luteijn 484dbfc9d9 progress
2022-05-15 11:19:49 +02:00

59 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
namespace AspClassic.Parser;
/// <summary>
/// A parse tree for a method call statement.
/// </summary>
public sealed class CallStatement : Statement
{
private readonly Location _CallLocation;
private readonly Expression _TargetExpression;
private readonly ArgumentCollection _Arguments;
/// <summary>
/// The location of the 'Call', if any.
/// </summary>
public Location CallLocation => _CallLocation;
/// <summary>
/// The target of the call.
/// </summary>
public Expression TargetExpression => _TargetExpression;
/// <summary>
/// The arguments to the call.
/// </summary>
public ArgumentCollection Arguments => _Arguments;
/// <summary>
/// Constructs a new parse tree for a method call statement.
/// </summary>
/// <param name="callLocation">The location of the 'Call', if any.</param>
/// <param name="targetExpression">The target of the call.</param>
/// <param name="arguments">The arguments to the call.</param>
/// <param name="span">The location of the parse tree.</param>
/// <param name="comments">The comments of the parse tree.</param>
public CallStatement(Location callLocation, Expression targetExpression, ArgumentCollection arguments, Span span, IList<Comment> comments)
: base(TreeType.CallStatement, span, comments)
{
if (targetExpression == null)
{
throw new ArgumentNullException("targetExpression");
}
SetParent(targetExpression);
SetParent(arguments);
_CallLocation = callLocation;
_TargetExpression = targetExpression;
_Arguments = arguments;
}
protected override void GetChildTrees(IList<Tree> childList)
{
Tree.AddChild(childList, TargetExpression);
Tree.AddChild(childList, Arguments);
}
}