예제 #1
0
        public override AstVisitAction VisitPipeline(PipelineAst pipelineAst)
        {
            if (pipelineAst.PipelineElements[0] is CommandExpressionAst)
            {
                // If the first element is a CommandExpression, this pipeline should be the value
                // of a parameter. We want to avoid a scriptblock that contains only a pure expression.
                // The check "pipelineAst.Parent.Parent == ScriptBeingConverted" guarantees we throw
                // error on that kind of scriptblock.

                // Disallow pure expressions at the "top" level, but allow them otherwise.
                // We want to catch:
                //     1 | echo
                // But we don't want to error out on:
                //     echo $(1)
                // See the comment in VisitCommand on why it's safe to check Parent.Parent, we
                // know that we have at least:
                //     * a NamedBlockAst (the end block)
                //     * a ScriptBlockAst (the ast we're comparing to)
                if (pipelineAst.GetPureExpression() == null || pipelineAst.Parent.Parent == ScriptBeingConverted)
                {
                    ThrowError(
                        new ScriptBlockToPowerShellNotSupportedException(
                            "CantConvertPipelineStartsWithExpression", null,
                            AutomationExceptions.CantConvertPipelineStartsWithExpression),
                        pipelineAst);
                }
            }

            return AstVisitAction.Continue;
        }
 public override AstVisitAction VisitPipeline(PipelineAst pipelineAst)
 {
     if ((pipelineAst.PipelineElements[0] is CommandExpressionAst) && ((pipelineAst.GetPureExpression() == null) || (pipelineAst.Parent.Parent == this.ScriptBeingConverted)))
     {
         ThrowError(new ScriptBlockToPowerShellNotSupportedException("CantConvertPipelineStartsWithExpression", null, AutomationExceptions.CantConvertPipelineStartsWithExpression, new object[0]), pipelineAst);
     }
     return AstVisitAction.Continue;
 }
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     var expr = pipelineAst.GetPureExpression();
     if (expr != null)
     {
         return expr.Visit(this);
     }
     throw new UnexpectedElementException();
 }
예제 #4
0
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     var expr = pipelineAst.GetPureExpression();
     if (expr != null)
     {
         return expr.Accept(this);
     }
     throw PSTraceSource.NewArgumentException("ast");
 }
예제 #5
0
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     CheckIsConstant(pipelineAst, "Caller to verify ast is constant");
     return(pipelineAst.GetPureExpression().Accept(this));
 }
예제 #6
0
        public object VisitPipeline(PipelineAst pipelineAst)
        {
            var expr = pipelineAst.GetPureExpression();

            return(expr != null && (bool)expr.Accept(this));
        }
예제 #7
0
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     ExpressionAst pureExpression = pipelineAst.GetPureExpression();
     return ((pureExpression == null) ? ((object) false) : ((object) ((bool) pureExpression.Accept(this))));
 }
예제 #8
0
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     return(pipelineAst.GetPureExpression().Accept(this));
 }
예제 #9
0
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     var expr = pipelineAst.GetPureExpression();
     if (expr != null)
     {
         return expr.Accept(this);
     }
     throw PSTraceSource.NewArgumentException("ast");
 }
예제 #10
0
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     var expr = pipelineAst.GetPureExpression();
     return expr != null && (bool)expr.Accept(this);
 }
예제 #11
0
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     CheckIsConstant(pipelineAst, "Caller to verify ast is constant");
     return pipelineAst.GetPureExpression().Accept(this);
 }
예제 #12
0
        public object VisitPipeline(PipelineAst pipelineAst)
        {
            ExpressionAst pureExpression = pipelineAst.GetPureExpression();

            return((pureExpression == null) ? ((object)false) : ((object)((bool)pureExpression.Accept(this))));
        }
예제 #13
0
 public object VisitPipeline(PipelineAst pipelineAst)
 {
     return pipelineAst.GetPureExpression().Accept(this);
 }