Ejemplo n.º 1
0
        public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
        {
            // An Array expression *may* be safe, if its components are safe
            var arrayExpressionAstResult = (object[])arrayExpressionAst.SubExpression.Accept(this);

            return(arrayExpressionAstResult);
        }
Ejemplo n.º 2
0
        public override AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
        {
            List<object> elements = new List<object>();
            var numStatements = arrayExpressionAst.SubExpression.Statements.Count;
            foreach (var stmt in arrayExpressionAst.SubExpression.Statements)
            {
                var result = EvaluateAst(stmt, false);
                // expand if only one element and it is enumerable
                var enumerator = GetEnumerator(result, false);
                if (numStatements > 1 || enumerator == null)
                {
                    elements.Add(result);
                }
                else
                {
                    while (enumerator.MoveNext())
                    {
                        elements.Add(enumerator.Current);
                    }
                }
            }

            this._pipelineCommandRuntime.WriteObject(elements.ToArray());

            return AstVisitAction.SkipChildren;
        }
Ejemplo n.º 3
0
    public System.Object VisitArrayExpression(System.Management.Automation.Language.ArrayExpressionAst arrayExpressionAst)
    {
        IScriptExtent mappedExtent = MapExtent(arrayExpressionAst.Extent);

        StatementBlockAst mappedStatementBlock = (StatementBlockAst)VisitStatementBlock(arrayExpressionAst.SubExpression);

        return(new System.Management.Automation.Language.ArrayExpressionAst(mappedExtent, mappedStatementBlock));
    }
Ejemplo n.º 4
0
        public override AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
        {
            foreach (var statement in arrayExpressionAst.SubExpression.Statements)
            {
                var value = EvaluateAst(statement, false);
                this._pipelineCommandRuntime.WriteObject(value, true);
            }

            return AstVisitAction.SkipChildren;
        }
Ejemplo n.º 5
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return(arrayExpressionAst.SubExpression.Accept(this));
 }
 /// <summary>
 /// Visit Array Expression
 /// </summary>
 /// <param name="arrayExpressionAst"></param>
 /// <returns></returns>
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     if (arrayExpressionAst == null) return null;
     arrayExpressionAst.SubExpression.Visit(this.Decorator);
     return null;
 }
 /// <summary/>
 public virtual object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return _decorated.VisitArrayExpression(arrayExpressionAst);
 }
Ejemplo n.º 8
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return(false);
 }
Ejemplo n.º 9
0
 public override AstVisitAction VisitArrayExpression(ArrayExpressionAst ast) { return CheckParent(ast); }
Ejemplo n.º 10
0
        public override AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
        {
            // Safe (if children are allowed)

            return AstVisitAction.Continue;
        }
Ejemplo n.º 11
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     Expression instance = this.CaptureAstResults(arrayExpressionAst.SubExpression, CaptureAstContext.Enumerable, null);
     if (instance.Type.IsArray)
     {
         return instance;
     }
     if (instance.Type.Equals(typeof(ArrayList)))
     {
         return Expression.Call(instance, CachedReflectionInfo.ArrayList_ToArray);
     }
     if (instance.Type.Equals(typeof(object[])))
     {
         return instance;
     }
     if (instance.Type.IsPrimitive)
     {
         return Expression.NewArrayInit(typeof(object), new Expression[] { instance.Cast(typeof(object)) });
     }
     if (instance.Type.Equals(typeof(void)))
     {
         return Expression.NewArrayInit(typeof(object), new Expression[0]);
     }
     return Expression.Dynamic(PSToObjectArrayBinder.Get(), typeof(object[]), instance);
 }
Ejemplo n.º 12
0
 public virtual AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return AstVisitAction.Continue;
 }
Ejemplo n.º 13
0
 /// <summary/>
 public virtual object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return(null);
 }
Ejemplo n.º 14
0
 public override AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     throw new NotImplementedException(); //VisitArrayExpression(arrayExpressionAst);
 }
Ejemplo n.º 15
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     CheckIsConstant(arrayExpressionAst, "Caller to verify ast is constant");
     return arrayExpressionAst.SubExpression.Accept(this);
 }
Ejemplo n.º 16
0
 public override AstVisitAction VisitArrayExpression(ArrayExpressionAst ast)
 {
     return this.Check(ast);
 }
Ejemplo n.º 17
0
 public override AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return(AstVisitAction.Continue);
 }
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return arrayExpressionAst.SubExpression.Visit(this);
 }
Ejemplo n.º 19
0
 /// <summary/>
 public virtual object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst) { return null; }
Ejemplo n.º 20
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return false;
 }
Ejemplo n.º 21
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     // An Array expression *may* be safe, if its components are safe
     return arrayExpressionAst.SubExpression.Accept(this);
 }
Ejemplo n.º 22
0
 /// <summary/>
 public virtual AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst) => DefaultVisit(arrayExpressionAst);
Ejemplo n.º 23
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     arrayExpressionAst.SubExpression.Accept(this);
     return(null);
 }
Ejemplo n.º 24
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     // An Array expression *may* be safe, if its components are safe
     var arrayExpressionAstResult = (object[])arrayExpressionAst.SubExpression.Accept(this);
     return arrayExpressionAstResult;
 }
Ejemplo n.º 25
0
 public override AstVisitAction VisitArrayExpression(ArrayExpressionAst ast)
 {
     return(Check(ast));
 }
Ejemplo n.º 26
0
        public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
        {
            Expression values = null;
            var subExpr = arrayExpressionAst.SubExpression;
            if (subExpr.Traps == null)
            {
                if (subExpr.Statements.Count == 1)
                {
                    var pipelineBase = subExpr.Statements[0] as PipelineBaseAst;
                    if (pipelineBase != null)
                    {
                        var exprAst = pipelineBase.GetPureExpression();
                        if (exprAst != null)
                        {
                            values = Compile(exprAst);
                        }
                    }
                }
                else if (subExpr.Statements.Count == 0)
                {
                    // A dynamic site can't take void - but a void value is just an empty array.
                    return Expression.NewArrayInit(typeof(object));
                }
            }
            values = values ?? CaptureAstResults(subExpr, CaptureAstContext.Enumerable);

            if (values.Type.IsArray)
            {
                // If the result is already an array, don't wrap the array.
                return values;
            }
            if (values.Type == typeof(List<object>))
            {
                return Expression.Call(values, CachedReflectionInfo.ObjectList_ToArray);
            }
            if (values.Type.GetTypeInfo().IsPrimitive || values.Type == typeof(string))
            {
                // Slight optimization - no need for a dynamic site.  We could special case other
                // types as well, but it's probably not worth it.
                return Expression.NewArrayInit(typeof(object), values.Cast(typeof(object)));
            }
            if (values.Type == typeof(void))
            {
                // A dynamic site can't take void - but a void value is just an empty array.
                return Expression.NewArrayInit(typeof(object));
            }

            return DynamicExpression.Dynamic(PSToObjectArrayBinder.Get(), typeof(object[]), values);
        }
Ejemplo n.º 27
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     // An Array expression *may* be safe, if its components are safe
     return(arrayExpressionAst.SubExpression.Accept(this));
 }
Ejemplo n.º 28
0
 public override AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return AstVisitAction.Continue;
 }
Ejemplo n.º 29
0
 /// <summary/>
 public virtual AstVisitAction VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return(AstVisitAction.Continue);
 }
Ejemplo n.º 30
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     arrayExpressionAst.SubExpression.Accept(this);
     return null;
 }
Ejemplo n.º 31
0
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     CheckIsConstant(arrayExpressionAst, "Caller to verify ast is constant");
     return(arrayExpressionAst.SubExpression.Accept(this));
 }
 public object VisitArrayExpression(ArrayExpressionAst arrayExpressionAst)
 {
     return Visit(arrayExpressionAst.SubExpression);
 }