Пример #1
0
        private static List <object> VisitDynamicCSharpExpression(DynamicCSharpExpression node)
        {
            var args = new List <object>();

            VisitDynamicCSharpExpression(node, args);

            return(args);
        }
Пример #2
0
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="object">The <see cref="Object" /> property of the result.</param>
        /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public GetMemberDynamicCSharpExpression Update(Expression @object, IEnumerable <DynamicCSharpArgument> arguments)
        {
            if (@object == Object && SameElements(ref arguments, Arguments))
            {
                return(this);
            }

            return(DynamicCSharpExpression.DynamicGetMember(@object, Name, arguments, Flags, Context));
        }
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="expression">The <see cref="Expression" /> property of the result.</param>
        /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public InvokeDynamicCSharpExpression Update(Expression expression, IEnumerable <DynamicCSharpArgument> arguments)
        {
            if (expression == Expression && SameElements(ref arguments, Arguments))
            {
                return(this);
            }

            return(DynamicCSharpExpression.DynamicInvoke(expression, arguments, Flags, Context));
        }
Пример #4
0
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="expression">The <see cref="Expression" /> property of the result.</param>
        /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public InvokeDynamicCSharpExpression Update(Expression expression, IEnumerable <DynamicCSharpArgument> arguments)
        {
            if (expression == this.Expression && arguments == this.Arguments)
            {
                return(this);
            }

            return(DynamicCSharpExpression.DynamicInvoke(expression, arguments, Flags, Context));
        }
Пример #5
0
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="expression">The <see cref="Expression" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public DynamicCSharpArgument Update(Expression expression)
        {
            if (expression == Expression)
            {
                return(this);
            }

            return(DynamicCSharpExpression.DynamicArgument(expression, Name, Flags));
        }
        public override InvokeMemberDynamicCSharpExpression Update(Expression @object, IEnumerable <DynamicCSharpArgument> arguments)
        {
            if (@object == this.Object && arguments == this.Arguments)
            {
                return(this);
            }

            return(DynamicCSharpExpression.DynamicInvokeMember(Target, Name, TypeArguments, arguments, Flags, Context));
        }
Пример #7
0
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="operand">The <see cref="Operand" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public AssignUnaryDynamicCSharpExpression Update(DynamicCSharpArgument operand)
        {
            if (operand == Operand)
            {
                return(this);
            }

            return(DynamicCSharpExpression.MakeDynamicUnaryAssign(OperationNodeType, operand, Flags, Context));
        }
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="left">The <see cref="Left" /> property of the result.</param>
        /// <param name="right">The <see cref="Right" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public BinaryDynamicCSharpExpression Update(DynamicCSharpArgument left, DynamicCSharpArgument right)
        {
            if (left == Left && right == Right)
            {
                return(this);
            }

            return(DynamicCSharpExpression.MakeDynamicBinary(OperationNodeType, left, right, Flags, Context));
        }
        public override InvokeMemberDynamicCSharpExpression Update(Expression @object, IEnumerable<DynamicCSharpArgument> arguments)
        {
            if (@object == Object && SameElements(ref arguments, Arguments))
            {
                return this;
            }

            return DynamicCSharpExpression.DynamicInvokeMember(Target, Name, TypeArguments, arguments, Flags, Context);
        }
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="expression">The <see cref="Expression" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public ConvertDynamicCSharpExpression Update(Expression expression)
        {
            if (expression == Expression)
            {
                return(this);
            }

            return(DynamicCSharpExpression.DynamicConvert(expression, Type, Flags, Context));
        }
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="object">The <see cref="Object" /> property of the result.</param>
        /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public GetIndexDynamicCSharpExpression Update(Expression @object, IEnumerable <DynamicCSharpArgument> arguments)
        {
            if (@object == this.Object && arguments == this.Arguments)
            {
                return(this);
            }

            return(DynamicCSharpExpression.DynamicGetIndex(@object, arguments, Flags, Context));
        }
Пример #12
0
        /// <summary>
        /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression.
        /// </summary>
        /// <param name="arguments">The <see cref="Arguments" /> property of the result.</param>
        /// <returns>This expression if no children changed, or an expression with the updated children.</returns>
        public InvokeConstructorDynamicCSharpExpression Update(IEnumerable <DynamicCSharpArgument> arguments)
        {
            if (arguments == this.Arguments)
            {
                return(this);
            }

            return(DynamicCSharpExpression.DynamicInvokeConstructor(Type, arguments, Flags, Context));
        }
Пример #13
0
 internal override Expression ReduceGetResult(Expression awaiter)
 {
     return
         (DynamicCSharpExpression.DynamicInvokeMember(
              awaiter,
              "GetResult",
              Array.Empty <Type>(),
              Array.Empty <DynamicCSharpArgument>(),
              ResultDiscarded ? CSharpBinderFlags.ResultDiscarded : CSharpBinderFlags.None,
              Context
              ));
 }
Пример #14
0
        private static void VisitDynamicCSharpExpression(DynamicCSharpExpression node, List <object> args)
        {
            if (node.Flags != CSharpBinderFlags.None)
            {
                args.Add(new XAttribute(nameof(node.Flags), node.Flags));
            }

            if (node.Context != null)
            {
                args.Add(new XAttribute(nameof(node.Context), node.Context));
            }
        }
Пример #15
0
 internal override Expression ReduceGetAwaiter(Expression operand)
 {
     // TODO: support ICriticalNotifyCompletion?
     return
         (Expression.Convert(
              DynamicCSharpExpression.DynamicInvokeMember(
                  operand,
                  "GetAwaiter",
                  Array.Empty <Type>(),
                  Array.Empty <DynamicCSharpArgument>(),
                  CSharpBinderFlags.None,
                  Context
                  ),
              typeof(INotifyCompletion)
              ));
 }
Пример #16
0
 internal override Expression ReduceIsCompleted(Expression awaiter)
 {
     return
         (DynamicCSharpExpression.DynamicConvert(
              DynamicCSharpExpression.DynamicGetMember(
                  awaiter,
                  "IsCompleted",
                  Array.Empty <DynamicCSharpArgument>(),
                  CSharpBinderFlags.None,
                  Context
                  ),
              typeof(bool),
              CSharpBinderFlags.ConvertExplicit,
              Context
              ));
 }
        private Expression ReduceLogical(bool isAndAlso)
        {
            var leftVariable   = Expression.Parameter(Type, "__left");
            var resultVariable = Expression.Parameter(Type, "__result");
            var left           = Left.Update(leftVariable);

            Expression     check;
            ExpressionType underlyingOperation;

            if (isAndAlso)
            {
                check = DynamicCSharpExpression.DynamicIsFalse(left, CSharpBinderFlags.None, Context);
                underlyingOperation = ExpressionType.And;
            }
            else
            {
                check = DynamicCSharpExpression.DynamicIsTrue(left, CSharpBinderFlags.None, Context);
                underlyingOperation = ExpressionType.Or;
            }

            var flags = Flags & ~CSharpBinderFlags.BinaryOperationLogical;

            var operation = DynamicCSharpExpression.MakeDynamicBinary(underlyingOperation, left, Right, flags, Context);

            var body =
                Expression.IfThenElse(
                    check,
                    Expression.Assign(resultVariable, leftVariable),
                    Expression.Assign(resultVariable, operation)
                    );

            var res =
                Expression.Block(
                    Type,
                    new[] { leftVariable, resultVariable },
                    Expression.Assign(leftVariable, Left.Expression),
                    body,
                    resultVariable
                    );

            return(res);
        }
 /// <summary>
 /// Creates a new expression that is like this one, but using the supplied children.
 /// </summary>
 /// <param name="operand">The <see cref="UnaryCSharpExpression.Operand" /> property of the result.</param>
 /// <returns>An expression with the updated children.</returns>
 protected internal override AwaitCSharpExpression Rewrite(Expression operand)
 {
     return(DynamicCSharpExpression.DynamicAwait(operand, Type == typeof(void), Context));
 }
 public DynamicCSharpExpressionProxy(DynamicCSharpExpression node)
 {
     _node = node;
 }
 public DynamicCSharpExpressionProxy(DynamicCSharpExpression node)
 {
     _node = node;
 }