private static MethodCallCSharpExpression MakeAccess(ConditionalReceiver receiver, MethodInfo method, ReadOnlyCollection <ParameterAssignment> arguments)
        {
            if (method.IsStatic && method.IsDefined(typeof(ExtensionAttribute)))
            {
                var thisPar = method.GetParametersCached()[0];
                var thisArg = CSharpExpression.Bind(thisPar, receiver);

                var newArgs = new ParameterAssignment[arguments.Count + 1];
                newArgs[0] = thisArg;

                var i = 1;
                foreach (var arg in arguments)
                {
                    newArgs[i++] = arg;
                }

                var newArguments = new TrueReadOnlyCollection <ParameterAssignment>(newArgs);

                return(CSharpExpression.Call(null, method, newArguments)); // TODO: call ctor directly
            }
            else
            {
                return(CSharpExpression.Call(receiver, method, arguments)); // TODO: call ctor directly
            }
        }
예제 #2
0
        protected override ParameterAssignment VisitParameterAssignment(ParameterAssignment node)
        {
            var expr = Visit(node.Expression);

            var res = new XElement(nameof(ParameterAssignment), new XAttribute(nameof(node.Parameter), node.Parameter), new XElement(nameof(node.Expression), expr));

            _nodes.Push(res);

            return(node);
        }
예제 #3
0
        public static ReadOnlyCollection <ParameterAssignment> GetParameterBindings(ParameterInfo[] parameters, IEnumerable <Expression> expressions)
        {
            var arguments = expressions.ToReadOnly();

            var n = arguments.Count;

            if (n > parameters.Length)
            {
                throw Error.TooManyArguments();
            }

            var bindings = new ParameterAssignment[n];

            for (var i = 0; i < n; i++)
            {
                bindings[i] = CSharpExpression.Bind(parameters[i], arguments[i]);
            }

            return(new TrueReadOnlyCollection <ParameterAssignment>(bindings));
        }
 public ParameterAssignmentProxy(ParameterAssignment node)
 {
     _node = node;
 }
예제 #5
0
 protected virtual ParameterAssignment VisitParameterAssignment(ParameterAssignment node)
 {
     return(node.Update(Visit(node.Expression)));
 }
예제 #6
0
 public XNode GetDebugView(ParameterAssignment assignment)
 {
     return(Visit(assignment));
 }
예제 #7
0
 private XNode Visit(ParameterAssignment node)
 {
     VisitParameterAssignment(node);
     return(_nodes.Pop());
 }
예제 #8
0
        public static ReadOnlyCollection<ParameterAssignment> GetParameterBindings(ParameterInfo[] parameters, IEnumerable<Expression> expressions)
        {
            var arguments = expressions.ToReadOnly();

            var n = arguments.Count;

            if (n > parameters.Length)
            {
                throw Error.TooManyArguments();
            }

            var bindings = new ParameterAssignment[n];

            for (var i = 0; i < n; i++)
            {
                bindings[i] = CSharpExpression.Bind(parameters[i], arguments[i]);
            }

            return new TrueReadOnlyCollection<ParameterAssignment>(bindings);
        }
            protected override ParameterAssignment VisitParameterAssignment(ParameterAssignment node)
            {
                Visited = true;

                return base.VisitParameterAssignment(node);
            }
 public ParameterAssignmentProxy(ParameterAssignment node)
 {
     _node = node;
 }
 protected virtual ParameterAssignment VisitParameterAssignment(ParameterAssignment node)
 {
     return node.Update(Visit(node.Expression));
 }