Ejemplo n.º 1
0
        private void OnEval(MethodInvocationExpression node)
        {
            BoundSpillSequenceBuilder valueBuilder = null;
            var value = VisitExpression(ref valueBuilder, node.Arguments.Last);

            BoundSpillSequenceBuilder builder = null;
            var seCollection = new ExpressionCollection();

            seCollection.AddRange(node.Arguments.Where(a => a != node.Arguments.Last));
            var sideEffects = VisitExpressionList(ref builder, seCollection, forceSpill: valueBuilder != null, sideEffectsOnly: true);

            if (builder == null && valueBuilder == null)
            {
                node.Arguments = sideEffects;
                node.Arguments.Add(value);
                return;
            }

            if (builder == null)
            {
                builder = new BoundSpillSequenceBuilder();
            }

            builder.AddExpressions(sideEffects);
            builder.Include(valueBuilder);

            ReplaceCurrentNode(builder.Update(value));
        }
Ejemplo n.º 2
0
        private ExpressionPairCollection VisitExpressionPairList(
            ref BoundSpillSequenceBuilder builder,
            ExpressionPairCollection args,
            bool forceSpill      = false,
            bool sideEffectsOnly = false)
        {
            var args1 = new ExpressionCollection();

            args1.AddRange(args.Select(p => p.First));
            var args2 = new ExpressionCollection();

            args2.AddRange(args.Select(p => p.Second));
            args1 = VisitExpressionList(ref builder, args1, null, forceSpill, sideEffectsOnly);
            args2 = VisitExpressionList(ref builder, args2, null, forceSpill, sideEffectsOnly);
            args.Clear();
            args.AddRange(args1.Zip(args2, (l, r) => new ExpressionPair(l.LexicalInfo, l, r)));
            return(args);
        }
        public virtual IExpressionCollection TransformExpressionCollection(IExpressionCollection expressions)
        {
            IExpression[] array = new IExpression[expressions.Count];
            for (int i = 0; i < expressions.Count; i++)
            {
                array[i] = this.TransformExpression(expressions[i]);
            }

            IExpressionCollection target = new ExpressionCollection();
            target.AddRange(array);
            return target;
        }