123 lines
4.1 KiB
C#
123 lines
4.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AspClassic.Parser;
|
|
|
|
/// <summary>
|
|
/// A parse tree for a For statement.
|
|
/// </summary>
|
|
public sealed class ForBlockStatement : BlockStatement
|
|
{
|
|
private readonly Expression _ControlExpression;
|
|
|
|
private readonly VariableDeclarator _ControlVariableDeclarator;
|
|
|
|
private readonly Location _EqualsLocation;
|
|
|
|
private readonly Expression _LowerBoundExpression;
|
|
|
|
private readonly Location _ToLocation;
|
|
|
|
private readonly Expression _UpperBoundExpression;
|
|
|
|
private readonly Location _StepLocation;
|
|
|
|
private readonly Expression _StepExpression;
|
|
|
|
private readonly NextStatement _NextStatement;
|
|
|
|
/// <summary>
|
|
/// The control expression for the loop.
|
|
/// </summary>
|
|
public Expression ControlExpression => _ControlExpression;
|
|
|
|
/// <summary>
|
|
/// The control variable declarator, if any.
|
|
/// </summary>
|
|
public VariableDeclarator ControlVariableDeclarator => _ControlVariableDeclarator;
|
|
|
|
/// <summary>
|
|
/// The location of the '='.
|
|
/// </summary>
|
|
public Location EqualsLocation => _EqualsLocation;
|
|
|
|
/// <summary>
|
|
/// The lower bound of the loop.
|
|
/// </summary>
|
|
public Expression LowerBoundExpression => _LowerBoundExpression;
|
|
|
|
/// <summary>
|
|
/// The location of the 'To'.
|
|
/// </summary>
|
|
public Location ToLocation => _ToLocation;
|
|
|
|
/// <summary>
|
|
/// The upper bound of the loop.
|
|
/// </summary>
|
|
public Expression UpperBoundExpression => _UpperBoundExpression;
|
|
|
|
/// <summary>
|
|
/// The location of the 'Step', if any.
|
|
/// </summary>
|
|
public Location StepLocation => _StepLocation;
|
|
|
|
/// <summary>
|
|
/// The step of the loop, if any.
|
|
/// </summary>
|
|
public Expression StepExpression => _StepExpression;
|
|
|
|
/// <summary>
|
|
/// The Next statement, if any.
|
|
/// </summary>
|
|
public NextStatement NextStatement => _NextStatement;
|
|
|
|
/// <summary>
|
|
/// Constructs a new parse tree for a For statement.
|
|
/// </summary>
|
|
/// <param name="controlExpression">The control expression for the loop.</param>
|
|
/// <param name="controlVariableDeclarator">The control variable declarator, if any.</param>
|
|
/// <param name="equalsLocation">The location of the '='.</param>
|
|
/// <param name="lowerBoundExpression">The lower bound of the loop.</param>
|
|
/// <param name="toLocation">The location of the 'To'.</param>
|
|
/// <param name="upperBoundExpression">The upper bound of the loop.</param>
|
|
/// <param name="stepLocation">The location of the 'Step', if any.</param>
|
|
/// <param name="stepExpression">The step of the loop, if any.</param>
|
|
/// <param name="statements">The statements in the For loop.</param>
|
|
/// <param name="nextStatement">The Next statement, if any.</param>
|
|
/// <param name="span">The location of the parse tree.</param>
|
|
/// <param name="comments">The comments for the parse tree.</param>
|
|
public ForBlockStatement(Expression controlExpression, VariableDeclarator controlVariableDeclarator, Location equalsLocation, Expression lowerBoundExpression, Location toLocation, Expression upperBoundExpression, Location stepLocation, Expression stepExpression, StatementCollection statements, NextStatement nextStatement, Span span, IList<Comment> comments)
|
|
: base(TreeType.ForBlockStatement, statements, span, comments)
|
|
{
|
|
if (controlExpression == null)
|
|
{
|
|
throw new ArgumentNullException("controlExpression");
|
|
}
|
|
SetParent(controlExpression);
|
|
SetParent(controlVariableDeclarator);
|
|
SetParent(lowerBoundExpression);
|
|
SetParent(upperBoundExpression);
|
|
SetParent(stepExpression);
|
|
SetParent(nextStatement);
|
|
_ControlExpression = controlExpression;
|
|
_ControlVariableDeclarator = controlVariableDeclarator;
|
|
_EqualsLocation = equalsLocation;
|
|
_LowerBoundExpression = lowerBoundExpression;
|
|
_ToLocation = toLocation;
|
|
_UpperBoundExpression = upperBoundExpression;
|
|
_StepLocation = stepLocation;
|
|
_StepExpression = stepExpression;
|
|
_NextStatement = nextStatement;
|
|
}
|
|
|
|
protected override void GetChildTrees(IList<Tree> childList)
|
|
{
|
|
Tree.AddChild(childList, ControlExpression);
|
|
Tree.AddChild(childList, ControlVariableDeclarator);
|
|
Tree.AddChild(childList, LowerBoundExpression);
|
|
Tree.AddChild(childList, UpperBoundExpression);
|
|
Tree.AddChild(childList, StepExpression);
|
|
base.GetChildTrees(childList);
|
|
Tree.AddChild(childList, NextStatement);
|
|
}
|
|
}
|