示例#1
0
        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);
        }
示例#2
0
 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);
        }
示例#7
0
 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)));
 }
示例#9
0
            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);
            }
示例#10
0
 /// <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);
示例#13
0
 public void For()
 {
     ForStatementAst forStatementAst = ParseStatement("for ($i = 0; $i -ile 10; $i++) {Write-Host $i}");
 }
 object ICustomAstVisitor.VisitForStatement(ForStatementAst forStatementAst) => VisitForStatement(forStatementAst);
示例#15
0
 // 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);
示例#17
0
 public object VisitForStatement(ForStatementAst forStatementAst)
 {
     Console.WriteLine("Visited an ForStatementAst.");
     return(forStatementAst);
 }
示例#18
0
 public override AstVisitAction VisitForStatement(ForStatementAst ast)
 {
     return(AstVisitAction.Continue);
 }
示例#19
0
 public object VisitForStatement(ForStatementAst forStatementAst)
 {
     throw new NotImplementedException();
 }
 public object VisitForStatement(ForStatementAst forStatementAst) => null;
示例#21
0
 public object VisitForStatement(ForStatementAst forStatementAst)
 {
     return(false);
 }
示例#22
0
 public object VisitForStatement(ForStatementAst forStatementAst)
 {
     throw new UnexpectedElementException();
 }
示例#23
0
 public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst)
 {
     Console.WriteLine("Visited an ForStatementAst.");
     Console.WriteLine("    " + forStatementAst.ToString().Replace(Environment.NewLine, Environment.NewLine + "    "));
     return(AstVisitAction.Continue);
 }
示例#24
0
 public override AstVisitAction VisitForStatement(ForStatementAst ast)
 {
     return(Check(ast));
 }
示例#25
0
 public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst)
 {
     throw new NotImplementedException(); //VisitForStatement(forStatementAst);
 }
示例#26
0
 public override AstVisitAction VisitForStatement(ForStatementAst ast)
 {
     return(DoNextAction(ast));
 }
示例#27
0
 public override AstVisitAction VisitForStatement(ForStatementAst forStatementAst)
 {
     return(AstVisitAction.SkipChildren);
 }
示例#28
0
 public override StatementAst VisitForStatement(ForStatementAst forStatementAst)
 => VisitStatement(base.VisitForStatement(forStatementAst));
示例#29
0
 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));
 }