protected override SystemLinq.Expression VisitSwitch(SystemLinq.SwitchExpression node)
            {
                var defaultExpression = Visit(node.DefaultBody).UnwrapNullable();

                var switchValue = Visit(node.SwitchValue).Unwrap();
                var cases       = (node.Cases ?? Enumerable.Empty <SystemLinq.SwitchCase>()).Select(VisitSwitchCase).ToList();

                return(new RemoteLinq.SwitchExpression(switchValue, node.Comparison, defaultExpression, cases).Wrap());
            }
    public virtual bool IsEvaluatableSwitch (SwitchExpression node)
    {
      ArgumentUtility.CheckNotNull ("node", node);

      return true;
    }
Example #3
0
 public SwitchExpressionProxy(SwitchExpression node)
 {
     _node = node;
 }
 public SwitchExpressionProxy(SwitchExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }
		}//end static method
		internal XElement SwitchExpressionToXElement(SwitchExpression e)
		{
			object value;
			string xName = "SwitchExpression";
			object[] XElementValues = new object[7];
			value = ((SwitchExpression)e).Type;
			XElementValues[0] = GenerateXmlFromProperty(typeof(System.Type),
				"Type", value ?? string.Empty);
			value = ((SwitchExpression)e).NodeType;
			XElementValues[1] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.ExpressionType),
				"NodeType", value ?? string.Empty);
			value = ((SwitchExpression)e).SwitchValue;
			XElementValues[2] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.Expression),
				"SwitchValue", value ?? string.Empty);
			value = ((SwitchExpression)e).Cases;
			XElementValues[3] = GenerateXmlFromProperty(typeof(System.Collections.ObjectModel.ReadOnlyCollection<System.Linq.Expressions.SwitchCase>),
				"Cases", value ?? string.Empty);
			value = ((SwitchExpression)e).DefaultBody;
			XElementValues[4] = GenerateXmlFromProperty(typeof(System.Linq.Expressions.Expression),
				"DefaultBody", value ?? string.Empty);
			value = ((SwitchExpression)e).Comparison;
			XElementValues[5] = GenerateXmlFromProperty(typeof(System.Reflection.MethodInfo),
				"Comparison", value ?? string.Empty);
			value = ((SwitchExpression)e).CanReduce;
			XElementValues[6] = GenerateXmlFromProperty(typeof(System.Boolean),
				"CanReduce", value ?? string.Empty);
			return new XElement(xName, XElementValues);
		}//end static method
Example #6
0
 internal static Switch Switch(SwitchExpression expression)
 {
     return new Switch()
     {
         Type = expression.Type != expression.Cases[0].Body.Type
             ? TypeRef.Serialize(expression.Type)
             : null,
         SwitchValue = Serialize(expression.SwitchValue),
         Cases = expression.Cases.Select(SwitchCase.Serialize).ToArray(),
         DefaultBody = expression.DefaultBody.Null(e => Serialize(e)),
         Comparison = expression.Comparison.Null(m => MethodRef.Serialize(m)),
     }.If(n => n.Type == null, n => n.TypeHint = TypeRef.Serialize(expression.Type));
 }
 protected override Expression VisitSwitch(SwitchExpression node)
 {
     // NB: Nested switch statements end the reach of "goto case" and "goto default" statements.
     // DESIGN: Should we just not care about non-C# switches here?
     return node;
 }
 protected override Expression VisitSwitch(SwitchExpression node)
 {
     throw new NotSupportedException();
 }
Example #9
0
 public SwitchExpressionProxy(SwitchExpression node)
 {
     ArgumentNullException.ThrowIfNull(node);
     _node = node;
 }
Example #10
0
 protected internal override Expression VisitSwitch(SwitchExpression node)
 {
     Expressions.Add(node);
     return(base.VisitSwitch(node));
 }
Example #11
0
        protected internal virtual new Expression VisitSwitch(SwitchExpression node)
        {
            Contract.Requires(node != null);

            return(default(Expression));
        }
Example #12
0
        /// <summary>
        /// Creates expression that is iterating over input with given processor.
        /// </summary>
        /// <param name="inputProcessor">Processor to iterate the input.</param>
        /// <returns>The created expression.</returns>
        internal Expression IterateInput(SwitchExpression inputProcessor)
        {
            var hasNextInput = Expression.LessThan(_inputsActualOffset, _inputsEndOffset);
            var offsetStep = Expression.Assign(InputVariable, ReadInputsAtOffset(Expression.PostIncrementAssign(_inputsActualOffset)));

            var inputReadLoop =
                Expression.Loop(
                    Expression.IfThenElse(
                        hasNextInput,
                        Expression.Block(
                            offsetStep,
                            inputProcessor
                            ),
                        Expression.Break(EndInputReading)
                        ),
                    EndInputReading,
                    MoveNextByteLabel
                    );

            return Expression.Block(new ParameterExpression[] { _inputsActualOffset, InputVariable },
                ///initialize actual offset
                Expression.Assign(_inputsActualOffset, _inputsStartOffset),

                //process input read
                inputReadLoop
                );
        }
 protected internal virtual Expression VisitSwitch(SwitchExpression node)
 {
     return(ValidateSwitch(node, node.Update(this.Visit(node.SwitchValue), Visit <SwitchCase>(node.Cases, new Func <SwitchCase, SwitchCase>(this.VisitSwitchCase)), this.Visit(node.DefaultBody))));
 }
Example #14
0
 protected virtual Expression VisitSwitch(SwitchExpression node)
 {
     throw new NotImplementedException();
 }
 protected internal virtual new Expression VisitSwitch(SwitchExpression node)
 {
     return(default(Expression));
 }
Example #16
0
 public SwitchExpressionProxy(SwitchExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }
 public SwitchExpressionProxy(SwitchExpression node) {
     _node = node;
 }
Example #18
0
        protected override Expression VisitSwitch(SwitchExpression node)
        {
            if (node.SwitchValue.Type.GetUnwrappedNullableType().IsIntegerType()
                || node.SwitchValue.Type.GetUnwrappedNullableType().BaseType == typeof(Enum))
            {
                this.Write("switch");
                this.Write(" (");
                this.Visit(node.SwitchValue);
                this.WriteLine(")");

                using (this.AcquireIndentationContext(BraceLanguageStyleIndentationOptions.IncludeBracesNewLineAfter))
                {
                    foreach (var switchCase in node.Cases)
                    {
                        this.VisitSwitchCase(switchCase);
                    }

                    this.WriteLine("default:");

                    using (this.AcquireIndentationContext(BraceLanguageStyleIndentationOptions.Default))
                    {
                        this.Visit(node.DefaultBody);
                    }
                }

                return node;
            }
            else
            {
                var j = 0;

                foreach (var switchCase in node.Cases)
                {
                    if (j++ > 0)
                    {
                        this.Write("else ");
                    }

                    this.Write("if (");

                    var i = 0;

                    foreach (var testValue in switchCase.TestValues)
                    {
                        this.Write("([");
                        this.Visit(node.SwitchValue);
                        this.Write(" caseInsensitiveCompare:");
                        this.Visit(testValue);
                        this.Write("] == NSOrderedSame)");

                        if (i++ < switchCase.TestValues.Count - 1)
                        {
                            this.Write(" || ");
                        }
                    }

                    this.WriteLine(")");

                    if (switchCase.Body.NodeType != ExpressionType.Block)
                    {
                        using (this.AcquireIndentationContext(BraceLanguageStyleIndentationOptions.IncludeBraces))
                        {
                            this.Visit(switchCase.Body);
                        }

                        this.WriteLine();
                    }
                    else
                    {
                        this.Visit(switchCase.Body);
                        this.WriteLine();
                    }
                }

                if (node.DefaultBody != null)
                {
                    if (node.Cases.Count > 0)
                    {
                        this.WriteLine("else");
                    }

                    using (this.AcquireIndentationContext(BraceLanguageStyleIndentationOptions.IncludeBracesNewLineAfter))
                    {
                        this.Visit(node.DefaultBody);
                    }
                }

                return node;
            }
        }
Example #19
0
 private static string VisitSwitch(SwitchExpression node)
 {
     throw new NotImplementedException();
 }
Example #20
0
        private Variable VisitSwitch(SwitchExpression node)
        {
            throw new NotSupportedException("Expression of type " + node.NodeType + " is not supported");

            //this.Out("switch ");
            //this.Out("(");
            //this.Visit(node.SwitchValue);
            //this.Out(") { ... }");
        }