public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst) { /* * The controlling expression for-condition must have type bool or * be implicitly convertible to that type. The loop body, which * consists of statement-block, is executed repeatedly while the * controlling expression tests True. The controlling expression * is evaluated before each execution of the loop body. * * Expression for-initializer is evaluated before the first * evaluation of the controlling expression. Expression * for-initializer is evaluated for its side effects only; any * value it produces is discarded and is not written to the * pipeline. * * Expression for-iterator is evaluated after each execution of * the loop body. Expression for-iterator is evaluated for its * side effects only; any value it produces is discarded and is * not written to the pipeline. * * If expression for-condition is omitted, the controlling * expression tests True. */ EvaluateAst(forStatementAst.Initializer); while ((bool)((PSObject)EvaluateAst(forStatementAst.Condition)).BaseObject) { this._pipelineCommandRuntime.WriteObject(EvaluateAst(forStatementAst.Body), true); EvaluateAst(forStatementAst.Iterator); } return(AstVisitAction.SkipChildren); }
public virtual object VisitForStatement(ForStatementAst forStatementAst) { VisitElement(forStatementAst.Initializer); VisitElement(forStatementAst.Condition); VisitElement(forStatementAst.Iterator); VisitElement(forStatementAst.Body); return(forStatementAst); }
public object VisitForStatement(ForStatementAst forStatementAst) { var initializer = VisitAst(forStatementAst.Initializer); var condition = VisitAst(forStatementAst.Condition); var iterator = VisitAst(forStatementAst.Iterator); var body = VisitAst(forStatementAst.Body); return(new ForStatementAst(forStatementAst.Extent, forStatementAst.Label, initializer, condition, iterator, body)); }
public object VisitForStatement(ForStatementAst forStatementAst) { var newInitializer = VisitElement(forStatementAst.Initializer); var newCondition = VisitElement(forStatementAst.Condition); var newIterator = VisitElement(forStatementAst.Iterator); var newBody = VisitElement(forStatementAst.Body); return(new ForStatementAst(forStatementAst.Extent, forStatementAst.Label, newInitializer, newCondition, newIterator, newBody)); }
public virtual StatementAst VisitForStatement(ForStatementAst forStatementAst) { return(new ForStatementAst( forStatementAst.Extent, forStatementAst.Label, forStatementAst.Initializer.Rewrite(this, SyntaxKind.Pipeline), forStatementAst.Condition.Rewrite(this, SyntaxKind.Pipeline), forStatementAst.Iterator.Rewrite(this, SyntaxKind.Pipeline), forStatementAst.Body.Rewrite(this, SyntaxKind.Pipeline))); }
public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst) { var body = VisitSyntaxNode(forStatementAst.Body); var condition = VisitSyntaxNode(forStatementAst.Condition); var initializer = VisitSyntaxNode(forStatementAst.Initializer); var iterator = VisitSyntaxNode(forStatementAst.Iterator); _currentNode = new ForStatement(initializer, iterator, condition, body); return(AstVisitAction.SkipChildren); }
public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst) { explanations.Add( new Explanation() { Description = $"Executes the code in the script block for as long as adding '{forStatementAst.Iterator.Extent.Text}' on '{forStatementAst.Initializer.Extent.Text}' results in '{forStatementAst.Condition.Extent.Text}' being true.", CommandName = "for statement", HelpResult = HelpTableQuery("about_for"), TextToHighlight = "for" }.AddDefaults(forStatementAst, explanations)); return(base.VisitForStatement(forStatementAst)); }
public static ForStatementAst Update( this ForStatementAst ast, PipelineBaseAst initializer = null, PipelineBaseAst condition = null, PipelineBaseAst iterator = null, IEnumerable <StatementAst> statements = null, string label = null) { return(new ForStatementAst( ast.Extent, label ?? ast.Label, initializer?.Clone() ?? ast.Initializer.Clone(), condition?.Clone() ?? ast.Condition.Clone(), iterator?.Clone() ?? ast.Iterator?.Clone(), ast.Body.Update(statements))); }
public override object VisitForStatement(ForStatementAst forStatementAst) { if (forStatementAst.Label != null) { script_.Write(":" + forStatementAst.Label + " "); } script_.Write("for("); VisitElement(forStatementAst.Initializer); script_.Write(";"); VisitElement(forStatementAst.Condition); script_.Write(";"); VisitElement(forStatementAst.Iterator); script_.Write("){"); VisitElement(forStatementAst.Body); script_.Write("}"); return(forStatementAst); }
/// <summary/> public virtual AstVisitAction VisitForStatement(ForStatementAst forStatementAst) => DefaultVisit(forStatementAst);
public object VisitForStatement(ForStatementAst forStatementAst) { throw PSTraceSource.NewArgumentException("ast"); }
public virtual TResult VisitForStatement(ForStatementAst forStatementAst) => default(TResult);
public void For() { ForStatementAst forStatementAst = ParseStatement("for ($i = 0; $i -ile 10; $i++) {Write-Host $i}"); }
object ICustomAstVisitor.VisitForStatement(ForStatementAst forStatementAst) => VisitForStatement(forStatementAst);
// ForStatementAst Extension Methods // New Methods Available: // - CreateNodeFromAST(NodeDepth, NodePosition) => Creates a Node // - CreateChildNodes ($item in $collection) {} => Creates Child Nodes public static ForNode CreateNodeFromAst(this ForStatementAst _ast, int _depth, int _position, Node _parent, Tree _tree) { return(new ForNode(_ast, _depth, _position, _parent, _tree)); }
object ICustomAstVisitor.VisitForStatement(ForStatementAst forStatementAst) => ProcessRewriter(VisitForStatement, forStatementAst);
public object VisitForStatement(ForStatementAst forStatementAst) { Console.WriteLine("Visited an ForStatementAst."); return(forStatementAst); }
public override AstVisitAction VisitForStatement(ForStatementAst ast) { return(AstVisitAction.Continue); }
public object VisitForStatement(ForStatementAst forStatementAst) { throw new NotImplementedException(); }
public object VisitForStatement(ForStatementAst forStatementAst) => null;
public object VisitForStatement(ForStatementAst forStatementAst) { return(false); }
public object VisitForStatement(ForStatementAst forStatementAst) { throw new UnexpectedElementException(); }
public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst) { Console.WriteLine("Visited an ForStatementAst."); Console.WriteLine(" " + forStatementAst.ToString().Replace(Environment.NewLine, Environment.NewLine + " ")); return(AstVisitAction.Continue); }
public override AstVisitAction VisitForStatement(ForStatementAst ast) { return(Check(ast)); }
public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst) { throw new NotImplementedException(); //VisitForStatement(forStatementAst); }
public override AstVisitAction VisitForStatement(ForStatementAst ast) { return(DoNextAction(ast)); }
public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst) { return(AstVisitAction.SkipChildren); }
public override StatementAst VisitForStatement(ForStatementAst forStatementAst) => VisitStatement(base.VisitForStatement(forStatementAst));
public static IEnumerable <Ast> GetChildAst(this ForStatementAst _ast) { return(_ast.Body.FindAll(Args => Args is Ast && Args.Parent == _ast.Body, false)); }
public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst) { return(Visit(forStatementAst)); }