private static Expression ReduceDynamicIndex(GetIndexDynamicCSharpExpression index, Func <Expression, Expression> functionalOp, CSharpBinderFlags flags, bool prefix)
        {
            var args  = default(DynamicCSharpArgument[]);
            var block = default(Expression[]);
            var temps = default(ParameterExpression[]);
            var i     = CopyArguments(index.Object, index.Arguments, prefix, out args, out block, out temps);

            index = index.Update(temps[0], new TrueReadOnlyCollection <DynamicCSharpArgument>(args));

            if (prefix)
            {
                block[i++] = index.ReduceAssignment(functionalOp(index), flags);
            }
            else
            {
                var lastTemp = temps[i] = Expression.Parameter(index.Type, "__index");

                block[i] = Expression.Assign(temps[i], index);
                i++;

                block[i++] = index.ReduceAssignment(functionalOp(lastTemp), flags);
                block[i++] = lastTemp;
            }

            var res = Expression.Block(temps, block);

            return(res);
        }
Exemple #2
0
        private Expression ReduceAssign()
        {
            var lhs = Left.Expression;

            return(lhs switch
            {
                GetMemberDynamicCSharpExpression getMember => getMember.ReduceAssignment(Right.Expression, Flags, Left.Flags, Right.Flags),
                GetIndexDynamicCSharpExpression getIndex => getIndex.ReduceAssignment(Right.Expression, Flags, Left.Flags, Right.Flags),
                _ => ReduceStaticAssign(),
            });
        private static Expression ReduceDynamicIndex(GetIndexDynamicCSharpExpression index, Func<Expression, Expression> functionalOp, CSharpBinderFlags flags, bool prefix)
        {
            var args = default(DynamicCSharpArgument[]);
            var block = default(Expression[]);
            var temps = default(ParameterExpression[]);
            var i = CopyArguments(index.Object, index.Arguments, prefix, out args, out block, out temps);

            index = index.Update(temps[0], new TrueReadOnlyCollection<DynamicCSharpArgument>(args));

            if (prefix)
            {
                block[i++] = index.ReduceAssignment(functionalOp(index), flags);
            }
            else
            {
                var lastTemp = temps[i] = Expression.Parameter(index.Type, "__index");

                block[i] = Expression.Assign(temps[i], index);
                i++;

                block[i++] = index.ReduceAssignment(functionalOp(lastTemp), flags);
                block[i++] = lastTemp;
            }

            var res = Expression.Block(temps, block);
            return res;
        }