private VariableReference GetArgumentArrayVariable(MethodInvocationExpression binderMethodInvocation)
 {
     V_0 = binderMethodInvocation.get_Arguments().get_Count() - 1;
     V_1 = binderMethodInvocation.get_Arguments().get_Item(V_0);
     V_2 = null;
     if (V_1.get_CodeNodeType() != 26)
     {
         if (V_1.get_CodeNodeType() == 31)
         {
             V_3 = V_1 as ExplicitCastExpression;
             if (String.op_Equality(V_3.get_ExpressionType().GetFriendlyFullName(null), "System.Collections.Generic.IEnumerable<Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo>") && V_3.get_Expression().get_CodeNodeType() == 26)
             {
                 V_2 = V_3.get_Expression() as VariableReferenceExpression;
             }
         }
     }
     else
     {
         V_2 = V_1 as VariableReferenceExpression;
     }
     if (V_2 == null)
     {
         throw new Exception("Invalid argument: argumentInfo.");
     }
     return(V_2.get_Variable());
 }
 private VariableReference GetTypeArrayVariable(MethodInvocationExpression binderMethodInvocation)
 {
     V_1 = binderMethodInvocation.get_Arguments().get_Item(2);
     if (V_1.get_CodeNodeType() == 22 && (V_1 as LiteralExpression).get_Value() == null)
     {
         return(null);
     }
     V_2 = null;
     if (V_1.get_CodeNodeType() != 26)
     {
         if (V_1.get_CodeNodeType() == 31)
         {
             V_3 = V_1 as ExplicitCastExpression;
             if (String.op_Equality(V_3.get_ExpressionType().GetFriendlyFullName(null), "System.Collections.Generic.IEnumerable<System.Type>") && V_3.get_Expression().get_CodeNodeType() == 26)
             {
                 V_2 = V_3.get_Expression() as VariableReferenceExpression;
             }
         }
     }
     else
     {
         V_2 = V_1 as VariableReferenceExpression;
     }
     if (V_2 == null)
     {
         throw new Exception("Invalid argument: typeArguments.");
     }
     return(V_2.get_Variable());
 }
Example #3
0
 private bool TryTransformTernary(ConditionExpression ternary, out Expression transformed)
 {
     transformed = null;
     V_2         = ternary.get_Then() as LiteralExpression;
     V_3         = ternary.get_Else() as LiteralExpression;
     if (V_2 != null && V_3 != null)
     {
         V_14 = false;
         V_15 = false;
         if (!String.op_Equality(V_2.get_ExpressionType().get_FullName(), "System.Int32") || !String.op_Equality(V_3.get_ExpressionType().get_FullName(), "System.Int32"))
         {
             if (String.op_Equality(V_2.get_ExpressionType().get_FullName(), "System.Boolean") && String.op_Equality(V_3.get_ExpressionType().get_FullName(), "System.Boolean"))
             {
                 V_18 = (Boolean)V_2.get_Value();
                 V_19 = (Boolean)V_3.get_Value();
                 if (!V_18 && V_19 || V_18 && !V_19)
                 {
                     V_14 = true;
                     if (!V_18 && V_19)
                     {
                         V_15 = true;
                     }
                 }
             }
         }
         else
         {
             V_16 = (Int32)V_2.get_Value();
             V_17 = (Int32)V_3.get_Value();
             if (V_16 == 0 && V_17 == 1 || V_16 == 1 && V_17 == 0)
             {
                 V_14 = true;
                 if (V_16 == 0 && V_17 == 1)
                 {
                     V_15 = true;
                 }
             }
         }
         if (V_14)
         {
             if (!V_15)
             {
                 transformed = this.Transform(ternary.get_Condition());
             }
             else
             {
                 transformed = this.Transform(Negator.Negate(ternary.get_Condition(), this.typeSystem));
             }
             return(true);
         }
     }
     if (V_2 == null)
     {
         if (V_3 == null)
         {
             V_20 = ternary.get_Then() as ExplicitCastExpression;
             V_21 = ternary.get_Else() as ExplicitCastExpression;
             if (V_20 == null || V_21 == null || !String.op_Equality(V_20.get_TargetType().get_FullName(), "System.Int32") || !String.op_Equality(V_20.get_Expression().get_ExpressionType().get_FullName(), "System.Boolean") || !String.op_Equality(V_21.get_TargetType().get_FullName(), "System.Int32") || !String.op_Equality(V_21.get_Expression().get_ExpressionType().get_FullName(), "System.Boolean"))
             {
                 return(false);
             }
             ternary.set_Then(V_20.get_Expression());
             ternary.set_Else(V_21.get_Expression());
             transformed = ternary;
             return(true);
         }
         V_0 = V_3;
         V_1 = false;
     }
     else
     {
         V_0 = V_2;
         V_1 = true;
     }
     if (!String.op_Equality(V_0.get_ExpressionType().get_FullName(), "System.Int32"))
     {
         if (!String.op_Equality(V_0.get_ExpressionType().get_FullName(), "System.Boolean"))
         {
             return(false);
         }
         V_4 = (Boolean)V_0.get_Value();
     }
     else
     {
         if ((Int32)V_0.get_Value() != 0)
         {
             stackVariable163 = true;
         }
         else
         {
             stackVariable163 = false;
         }
         V_4 = stackVariable163;
     }
     V_6 = null;
     V_7 = null;
     V_6 = this.Transform(ternary.get_Condition());
     if (!V_1)
     {
         V_8 = ternary.get_Then();
     }
     else
     {
         V_8 = ternary.get_Else();
     }
     V_9  = V_8 as ConditionExpression;
     V_10 = V_8 as ExplicitCastExpression;
     V_11 = null;
     V_12 = false;
     if (V_9 == null && V_10 == null || String.op_Inequality(V_10.get_TargetType().get_FullName(), "System.Int32") || String.op_Inequality(V_10.get_Expression().get_ExpressionType().get_FullName(), "System.Boolean") && !this.IsBinaryExpression(V_8, out V_11, out V_12) && String.op_Inequality(V_8.get_ExpressionType().get_FullName(), "System.Boolean"))
     {
         return(false);
     }
     V_13 = false;
     if (V_10 == null)
     {
         if (V_11 == null)
         {
             if (V_9 != null && this.TryTransformTernary(V_9, out V_7))
             {
                 V_13 = true;
             }
         }
         else
         {
             V_22 = TransformCatchClausesFilterExpressionStep.GetBinaryExpression(V_12, V_11);
             if (this.TryTransformBinary(V_22))
             {
                 V_7  = TransformCatchClausesFilterExpressionStep.GetResultExpression(V_12, V_11, V_22);
                 V_13 = true;
             }
         }
     }
     else
     {
         V_7  = V_10.get_Expression();
         V_13 = true;
     }
     if (!V_13)
     {
         V_7 = V_8;
     }
     if (V_6 == null || V_7 == null)
     {
         return(false);
     }
     if (!V_4)
     {
         V_5 = 12;
         if (V_1)
         {
             stackVariable97 = Negator.Negate(V_6, this.typeSystem);
         }
         else
         {
             stackVariable97 = V_6;
         }
         V_6 = stackVariable97;
     }
     else
     {
         V_5 = 11;
         if (V_1)
         {
             stackVariable111 = V_6;
         }
         else
         {
             stackVariable111 = Negator.Negate(V_6, this.typeSystem);
         }
         V_6 = stackVariable111;
     }
     transformed = new BinaryExpression(V_5, V_6, V_7, this.typeSystem, ternary.get_MappedInstructions(), false);
     return(true);
 }
 public override void VisitBinaryExpression(BinaryExpression node)
 {
     V_0 = this.GetExpressionTypeName(node.get_Left());
     V_1 = this.GetExpressionTypeName(node.get_Right());
     this.VisitBinaryExpression(node);
     if (String.op_Inequality(this.GetExpressionTypeName(node.get_Left()), V_0))
     {
         stackVariable16 = true;
     }
     else
     {
         stackVariable16 = String.op_Inequality(this.GetExpressionTypeName(node.get_Right()), V_1);
     }
     V_2 = stackVariable16;
     if (node.get_IsAssignmentExpression() || node.get_IsSelfAssign() && !node.get_IsEventHandlerAddOrRemove())
     {
         V_3 = node.get_Left();
         V_4 = node.get_Right();
         if (V_4.get_HasType() && V_3.get_HasType())
         {
             V_5 = V_3.get_ExpressionType();
             V_6 = V_4.get_ExpressionType().Resolve();
             if (this.ShouldAddCast(V_6, V_5))
             {
                 node.set_Right(new ExplicitCastExpression(V_4, V_5, null));
                 V_2 = true;
             }
             V_7 = V_5.Resolve();
             if (V_7 != null && V_6 != null && V_7.get_IsEnum() && V_6.get_IsValueType() && String.op_Inequality(V_7.get_FullName(), V_6.get_FullName()))
             {
                 node.set_Right(new ExplicitCastExpression(V_4, V_5, null));
                 V_2 = true;
             }
         }
     }
     else
     {
         if (!this.IsArithmeticOperator(node.get_Operator()))
         {
             if (this.IsBitwiseOperator(node.get_Operator()) || node.get_IsComparisonExpression())
             {
                 V_10 = node.get_Left();
                 V_11 = node.get_Right();
                 if (V_11.get_HasType() && V_10.get_HasType())
                 {
                     V_12 = V_10.get_ExpressionType();
                     V_13 = V_11.get_ExpressionType().Resolve();
                     if (this.ShouldAddCast(V_13, V_12))
                     {
                         node.set_Right(new ExplicitCastExpression(V_11, V_12, null));
                         V_2 = true;
                     }
                     V_14 = V_11.get_ExpressionType();
                     V_15 = V_10.get_ExpressionType().Resolve();
                     if (this.ShouldAddCast(V_15, V_14))
                     {
                         node.set_Left(new ExplicitCastExpression(V_10, V_14, null));
                         V_2 = true;
                     }
                     if (V_15 != null && V_15.get_IsEnum() && V_13 != null && V_13.get_IsEnum() && String.op_Inequality(V_15.get_FullName(), V_13.get_FullName()))
                     {
                         node.set_Left(new ExplicitCastExpression(V_10, this.GetEnumUnderlyingType(V_15), null));
                         node.set_Right(new ExplicitCastExpression(V_11, this.GetEnumUnderlyingType(V_15), null));
                         V_2 = true;
                     }
                 }
             }
             else
             {
                 if (this.IsShiftOperator(node.get_Operator()))
                 {
                     if (node.get_Left().get_HasType())
                     {
                         V_16 = node.get_Left().get_ExpressionType().Resolve();
                         if (V_16 != null && V_16.get_IsEnum())
                         {
                             node.set_Left(new ExplicitCastExpression(node.get_Left(), this.GetEnumUnderlyingType(V_16), null));
                             V_2 = true;
                         }
                     }
                     if (node.get_Right().get_HasType())
                     {
                         V_17 = node.get_Right().get_ExpressionType().Resolve();
                         if (V_17 != null && V_17.get_IsEnum())
                         {
                             node.set_Right(new ExplicitCastExpression(node.get_Right(), this.GetEnumUnderlyingType(V_17), null));
                             V_2 = true;
                         }
                     }
                 }
             }
         }
         else
         {
             if (node.get_Left().get_HasType())
             {
                 V_8 = node.get_Left().get_ExpressionType().Resolve();
                 if (V_8 != null && V_8.get_IsEnum())
                 {
                     node.set_Left(new ExplicitCastExpression(node.get_Left(), this.GetEnumUnderlyingType(V_8), null));
                     V_2 = true;
                 }
             }
             if (node.get_Right().get_HasType())
             {
                 V_9 = node.get_Right().get_ExpressionType().Resolve();
                 if (V_9 != null && V_9.get_IsEnum())
                 {
                     node.set_Right(new ExplicitCastExpression(node.get_Right(), this.GetEnumUnderlyingType(V_9), null));
                     V_2 = true;
                 }
             }
         }
     }
     if (V_2)
     {
         node.UpdateType();
     }
     return;
 }
			public override ICodeNode VisitBinaryExpression(BinaryExpression node)
			{
				V_0 = false;
				if (node.get_Left().get_CodeNodeType() == 24)
				{
					V_2 = node.get_Left() as BinaryExpression;
					if (V_2.CompareOperators(node) <= 0)
					{
						if (V_2.get_IsOverridenOperation())
						{
							V_0 = true;
						}
					}
					else
					{
						V_0 = true;
					}
				}
				if (V_0)
				{
					node.set_Left(new ParenthesesExpression(node.get_Left()));
				}
				V_1 = false;
				if (node.get_Right().get_CodeNodeType() == 24)
				{
					V_3 = node.get_Right() as BinaryExpression;
					V_4 = V_3.CompareOperators(node);
					if (V_4 <= 0)
					{
						if (V_4 != 0)
						{
							if (!node.get_IsAssignmentExpression() && V_3.get_IsOverridenOperation())
							{
								V_1 = true;
							}
						}
						else
						{
							if (node.get_Operator() == V_3.get_Operator())
							{
								if (this.IsCommutative(node.get_Operator()))
								{
									if ((object)V_3.get_ExpressionType() == (object)V_3.get_ExpressionType().get_Module().get_TypeSystem().get_Single() || (object)V_3.get_ExpressionType() == (object)V_3.get_ExpressionType().get_Module().get_TypeSystem().get_Double())
									{
										V_1 = true;
									}
								}
								else
								{
									V_1 = true;
								}
							}
							else
							{
								V_1 = true;
							}
						}
					}
					else
					{
						V_1 = true;
					}
				}
				if (V_1)
				{
					node.set_Right(new ParenthesesExpression(node.get_Right()));
				}
				return this.VisitBinaryExpression(node);
			}