using System; using System.Collections.Generic; namespace AspClassic.Parser; /// /// A parse tree for a For statement. /// 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; /// /// The control expression for the loop. /// public Expression ControlExpression => _ControlExpression; /// /// The control variable declarator, if any. /// public VariableDeclarator ControlVariableDeclarator => _ControlVariableDeclarator; /// /// The location of the '='. /// public Location EqualsLocation => _EqualsLocation; /// /// The lower bound of the loop. /// public Expression LowerBoundExpression => _LowerBoundExpression; /// /// The location of the 'To'. /// public Location ToLocation => _ToLocation; /// /// The upper bound of the loop. /// public Expression UpperBoundExpression => _UpperBoundExpression; /// /// The location of the 'Step', if any. /// public Location StepLocation => _StepLocation; /// /// The step of the loop, if any. /// public Expression StepExpression => _StepExpression; /// /// The Next statement, if any. /// public NextStatement NextStatement => _NextStatement; /// /// Constructs a new parse tree for a For statement. /// /// The control expression for the loop. /// The control variable declarator, if any. /// The location of the '='. /// The lower bound of the loop. /// The location of the 'To'. /// The upper bound of the loop. /// The location of the 'Step', if any. /// The step of the loop, if any. /// The statements in the For loop. /// The Next statement, if any. /// The location of the parse tree. /// The comments for the parse tree. 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 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 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); } }