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());
            }
コード例 #2
0
    public virtual bool IsEvaluatableSwitch (SwitchExpression node)
    {
      ArgumentUtility.CheckNotNull ("node", node);

      return true;
    }
コード例 #3
0
 public SwitchExpressionProxy(SwitchExpression node)
 {
     _node = node;
 }
コード例 #4
0
 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
コード例 #6
0
ファイル: Switch.cs プロジェクト: takeshik/yacq
 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));
 }
コード例 #7
0
 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;
 }
コード例 #8
0
 protected override Expression VisitSwitch(SwitchExpression node)
 {
     throw new NotSupportedException();
 }
コード例 #9
0
 public SwitchExpressionProxy(SwitchExpression node)
 {
     ArgumentNullException.ThrowIfNull(node);
     _node = node;
 }
コード例 #10
0
ファイル: TreeComparer.cs プロジェクト: gaybro8777/ironruby
 protected internal override Expression VisitSwitch(SwitchExpression node)
 {
     Expressions.Add(node);
     return(base.VisitSwitch(node));
 }
コード例 #11
0
        protected internal virtual new Expression VisitSwitch(SwitchExpression node)
        {
            Contract.Requires(node != null);

            return(default(Expression));
        }
コード例 #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
                );
        }
コード例 #13
0
 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))));
 }
コード例 #14
0
 protected virtual Expression VisitSwitch(SwitchExpression node)
 {
     throw new NotImplementedException();
 }
 protected internal virtual new Expression VisitSwitch(SwitchExpression node)
 {
     return(default(Expression));
 }
コード例 #16
0
 public SwitchExpressionProxy(SwitchExpression node)
 {
     ContractUtils.RequiresNotNull(node, nameof(node));
     _node = node;
 }
コード例 #17
0
 public SwitchExpressionProxy(SwitchExpression node) {
     _node = node;
 }
コード例 #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;
            }
        }
コード例 #19
0
 private static string VisitSwitch(SwitchExpression node)
 {
     throw new NotImplementedException();
 }
コード例 #20
0
ファイル: BasicBlockBuilder.cs プロジェクト: xornand/rDSN
        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(") { ... }");
        }