protected override Expression VisitRuntimeVariables(RuntimeVariablesExpression node)
        {
            int count = node.Variables.Count;
            List <Expression>          initializers = new List <Expression>();
            List <ParameterExpression> variables    = new List <ParameterExpression>();

            int[] numArray = new int[count];
            for (int i = 0; i < count; i++)
            {
                Expression closureItem = this.GetClosureItem(node.Variables[i], false);
                if (closureItem == null)
                {
                    numArray[i] = variables.Count;
                    variables.Add(node.Variables[i]);
                }
                else
                {
                    numArray[i] = -1 - initializers.Count;
                    initializers.Add(closureItem);
                }
            }
            if (initializers.Count == 0)
            {
                return(node);
            }
            NewArrayExpression expression2 = Expression.NewArrayInit(typeof(IStrongBox), initializers);

            if (variables.Count == 0)
            {
                return(Expression.Invoke(Expression.Constant(new Func <IStrongBox[], IRuntimeVariables>(System.Management.Automation.Interpreter.RuntimeVariables.Create)), new Expression[] { expression2 }));
            }
            Func <IRuntimeVariables, IRuntimeVariables, int[], IRuntimeVariables> func = new Func <IRuntimeVariables, IRuntimeVariables, int[], IRuntimeVariables>(MergedRuntimeVariables.Create);

            return(Expression.Invoke(Utils.Constant(func), new Expression[] { Expression.RuntimeVariables(variables), expression2, Utils.Constant(numArray) }));
        }
Ejemplo n.º 2
0
 public DynamicMetaObject GetMetaObject(Expression parameter, int index)
 {
     return(DynamicMetaObject.Create(
                GetArgument(index),
                Expression.Call(
                    s_getArgMethod,
                    AstUtils.Convert(parameter, typeof(ArgumentArray)),
                    AstUtils.Constant(index)
                    )
                ));
 }