Ejemplo n.º 1
0
        private static void VerifyGetArguments(InvocationExpression invoke)
        {
            var args = invoke.Arguments;

            Assert.Equal(args.Count, invoke.ArgumentCount);
            AssertExtensions.Throws <ArgumentOutOfRangeException>("index", () => invoke.GetArgument(-1));
            AssertExtensions.Throws <ArgumentOutOfRangeException>("index", () => invoke.GetArgument(args.Count));
            for (int i = 0; i != args.Count; ++i)
            {
                Assert.Same(args[i], invoke.GetArgument(i));
                Assert.Equal(i, ((ConstantExpression)invoke.GetArgument(i)).Value);
            }
        }
Ejemplo n.º 2
0
        protected internal override Expression VisitInvocation(InvocationExpression node)
        {
            var lambda = node.LambdaOperand;

            // optimization: inline code for literal lambda's directly
            if (lambda == null)
            {
                return(base.VisitInvocation(node));
            }

            // visit the lambda, but treat it like a scope associated with invocation
            var createdScope = new CompilerScope(lambda, false);

            _tree.Scopes[node] = createdScope;
            _scopes.Push(createdScope);
            Visit(MergeScopes(lambda));
            _scopes.Pop();
            // visit the invoke arguments
            for (int i = 0, n = node.ArgumentCount; i < n; i++)
            {
                Visit(node.GetArgument(i));
            }

            return(node);
        }
Ejemplo n.º 3
0
        protected override Expression VisitInvocation(InvocationExpression node)
        {
            Out("Invoke(");
            Visit(node.Expression);
            string sep = ", ";

            for (int i = 0, n = node.ArgumentCount(); i < n; i++)
            {
                Out(sep);
                Visit(node.GetArgument(i));
            }
            Out(')');
            return(node);
        }
Ejemplo n.º 4
0
 private static void VerifyGetArguments(InvocationExpression invoke)
 {
     var args = invoke.Arguments;
     Assert.Equal(args.Count, invoke.ArgumentCount);
     Assert.Throws<ArgumentOutOfRangeException>("index", () => invoke.GetArgument(-1));
     Assert.Throws<ArgumentOutOfRangeException>("index", () => invoke.GetArgument(args.Count));
     for (int i = 0; i != args.Count; ++i)
     {
         Assert.Same(args[i], invoke.GetArgument(i));
         Assert.Equal(i, ((ConstantExpression)invoke.GetArgument(i)).Value);
     }
 }