Exemplo n.º 1
0
 private void MoveInCase(IfStatement gotoStatement, SwitchCase switchCase, string label)
 {
     V_0             = new VariableReferenceExpression(this.GetLabelVariable(label), null);
     V_1             = this.GetOuterBlock(gotoStatement);
     V_2             = switchCase.get_Parent() as SwitchStatement;
     V_3             = V_1.get_Statements().IndexOf(gotoStatement);
     V_4             = V_1.get_Statements().IndexOf(V_2);
     V_12            = V_2.get_ConditionBlock().get_First().get_Offset();
     stackVariable26 = String.Concat("switch", V_12.ToString());
     V_5             = this.GetSwitchType(V_2);
     V_6             = new VariableDefinition(stackVariable26, V_5, this.methodContext.get_Method());
     this.switchVariables.Add(V_6);
     V_7 = new VariableReferenceExpression(V_6, null);
     this.ExtractConditionIntoVariable(V_7, V_2, V_1);
     V_8  = this.CollectStatements(V_3 + 1, V_4 + 1, V_1);
     V_9  = new BlockStatement();
     V_10 = new BinaryExpression(26, V_7.CloneExpressionOnly(), this.GetCaseConditionExpression(switchCase), this.typeSystem, null, false);
     V_9.AddStatement(new ExpressionStatement(V_10));
     V_11 = new IfStatement(new UnaryExpression(1, V_0, null), V_8, V_9);
     if (V_11.get_Then().get_Statements().get_Count() != 0)
     {
         V_1.AddStatementAt(V_3, V_11);
     }
     dummyVar0 = V_1.get_Statements().Remove(gotoStatement);
     switchCase.get_Body().AddStatementAt(0, gotoStatement);
     return;
 }
 protected override bool TryMatchInternal(StatementCollection statements, int startIndex, out Statement result, out int replacedStatementsCount)
 {
     result = null;
     replacedStatementsCount = 0;
     if (!this.TryGetObjectCreation(statements, startIndex, out V_0, out V_1))
     {
         return(false);
     }
     V_2 = new ExpressionCollection();
     V_3 = new HashSet <string>();
     if (V_0.get_Initializer() != null)
     {
         if (V_0.get_Initializer().get_InitializerType() != 1)
         {
             return(false);
         }
         V_4 = V_0.get_Initializer().get_Expressions().GetEnumerator();
         try
         {
             while (V_4.MoveNext())
             {
                 V_5       = V_4.get_Current();
                 V_6       = this.GetName((V_5 as BinaryExpression).get_Left());
                 dummyVar0 = V_3.Add(V_6);
             }
         }
         finally
         {
             if (V_4 != null)
             {
                 V_4.Dispose();
             }
         }
     }
     V_7 = startIndex + 1;
     while (V_7 < statements.get_Count() && this.TryGetNextExpression(statements.get_Item(V_7), out V_8))
     {
         V_9 = V_8 as BinaryExpression;
         if (!this.IsObjectPropertyOrFieldAssignment(V_9, V_1))
         {
             break;
         }
         V_10 = null;
         if (V_9.get_Left().get_CodeNodeType() != 42)
         {
             if (V_9.get_Left().get_CodeNodeType() == 30)
             {
                 V_13 = (V_9.get_Left() as FieldReferenceExpression).get_Field().Resolve();
                 if (!this.Visit(V_13.get_Name(), V_3))
                 {
                     break;
                 }
                 V_10 = new FieldInitializerExpression(V_13, V_13.get_FieldType(), V_9.get_Left().get_UnderlyingSameMethodInstructions());
             }
         }
         else
         {
             V_12 = (V_9.get_Left() as PropertyReferenceExpression).get_Property();
             if (!this.Visit(V_12.get_Name(), V_3))
             {
                 break;
             }
             V_10 = new PropertyInitializerExpression(V_12, V_12.get_PropertyType(), V_9.get_Left().get_UnderlyingSameMethodInstructions());
         }
         V_11 = new BinaryExpression(26, V_10, V_9.get_Right().Clone(), this.typeSystem, null, false);
         V_2.Add(V_11);
         V_7 = V_7 + 1;
     }
     if (V_2.get_Count() == 0)
     {
         return(false);
     }
     if (V_0.get_Initializer() != null)
     {
         V_4 = V_2.GetEnumerator();
         try
         {
             while (V_4.MoveNext())
             {
                 V_15 = V_4.get_Current();
                 V_0.get_Initializer().get_Expressions().Add(V_15);
             }
         }
         finally
         {
             if (V_4 != null)
             {
                 V_4.Dispose();
             }
         }
     }
     else
     {
         V_14 = new InitializerExpression(V_2, 1);
         V_14.set_IsMultiLine(true);
         V_0.set_Initializer(V_14);
     }
     result = statements.get_Item(startIndex);
     replacedStatementsCount = V_2.get_Count() + 1;
     return(true);
 }
Exemplo n.º 3
0
 public static int CompareToSecurityAttribute(this SecurityAttribute first, SecurityAttribute second, SecurityDeclaration firstDeclaration, SecurityDeclaration secondDeclaration)
 {
     if ((object)first == (object)second)
     {
         return(0);
     }
     V_0 = firstDeclaration.get_Action().ToString();
     V_1 = secondDeclaration.get_Action().ToString();
     if (String.op_Inequality(V_0, V_1))
     {
         return(V_0.CompareTo(V_1));
     }
     V_2 = Math.Max(first.get_Properties().get_Count(), second.get_Properties().get_Count());
     V_5 = 0;
     while (V_5 < V_2)
     {
         if (V_5 >= first.get_Properties().get_Count())
         {
             return(1);
         }
         if (V_5 >= second.get_Properties().get_Count())
         {
             return(-1);
         }
         V_6 = first.get_Properties().get_Item(V_5);
         V_7 = second.get_Properties().get_Item(V_5);
         if (!String.op_Equality(V_6.get_Name(), V_7.get_Name()))
         {
             return(V_6.get_Name().CompareTo(V_7.get_Name()));
         }
         V_10 = V_6.get_Argument();
         V_8  = V_10.get_Value().ToString();
         V_10 = V_7.get_Argument();
         V_9  = V_10.get_Value().ToString();
         if (String.op_Inequality(V_8, V_9))
         {
             return(V_8.CompareTo(V_9));
         }
         V_5 = V_5 + 1;
     }
     V_3  = Math.Max(first.get_Fields().get_Count(), second.get_Fields().get_Count());
     V_11 = 0;
     while (V_11 < V_3)
     {
         if (V_11 >= first.get_Fields().get_Count())
         {
             return(1);
         }
         if (V_11 >= second.get_Fields().get_Count())
         {
             return(-1);
         }
         V_12 = first.get_Fields().get_Item(V_11);
         V_13 = second.get_Fields().get_Item(V_11);
         if (!String.op_Equality(V_12.get_Name(), V_13.get_Name()))
         {
             return(V_12.get_Name().CompareTo(V_13.get_Name()));
         }
         V_10 = V_12.get_Argument();
         V_14 = V_10.get_Value().ToString();
         V_10 = V_13.get_Argument();
         V_15 = V_10.get_Value().ToString();
         if (String.op_Inequality(V_14, V_15))
         {
             return(V_14.CompareTo(V_15));
         }
         V_11 = V_11 + 1;
     }
     return(0);
 }
Exemplo n.º 4
0
 private void RedirectConstraints()
 {
     V_0 = new List <KeyValuePair <ClassHierarchyNode, ClassHierarchyNode> >();
     V_1 = this.get_ContainedNodes().GetEnumerator();
     try
     {
         while (V_1.MoveNext())
         {
             V_2 = V_1.get_Current();
             V_3 = V_2.get_CanAssignTo().GetEnumerator();
             try
             {
                 while (V_3.MoveNext())
                 {
                     V_4 = V_3.get_Current();
                     if (this.get_ContainedNodes().Contains(V_4))
                     {
                         continue;
                     }
                     if (!V_4.get_IsHardNode() || !V_4.get_NodeType().get_IsPrimitive() || !V_2.get_IsHardNode() || this.IsAssignable(V_2.get_NodeType(), V_4.get_NodeType()))
                     {
                         V_0.Add(new KeyValuePair <ClassHierarchyNode, ClassHierarchyNode>(V_2, V_4));
                     }
                     else
                     {
                         dummyVar0 = V_4.get_SubTypes().Remove(V_2);
                     }
                 }
             }
             finally
             {
                 if (V_3 != null)
                 {
                     V_3.Dispose();
                 }
             }
         }
     }
     finally
     {
         if (V_1 != null)
         {
             V_1.Dispose();
         }
     }
     V_5 = V_0.GetEnumerator();
     try
     {
         while (V_5.MoveNext())
         {
             V_6 = V_5.get_Current();
             V_7 = V_6.get_Key();
             V_8 = V_6.get_Value();
             this.get_CanAssignTo().Add(V_8);
             dummyVar1 = V_7.get_CanAssignTo().Remove(V_8);
             dummyVar2 = V_8.get_SubTypes().Remove(V_7);
             if (V_8.get_SubTypes().Contains(this))
             {
                 continue;
             }
             V_8.get_SubTypes().Add(this);
         }
     }
     finally
     {
         ((IDisposable)V_5).Dispose();
     }
     V_0 = new List <KeyValuePair <ClassHierarchyNode, ClassHierarchyNode> >();
     V_1 = this.get_ContainedNodes().GetEnumerator();
     try
     {
         while (V_1.MoveNext())
         {
             V_9 = V_1.get_Current();
             V_3 = V_9.get_SubTypes().GetEnumerator();
             try
             {
                 while (V_3.MoveNext())
                 {
                     V_10 = V_3.get_Current();
                     if (this.get_ContainedNodes().Contains(V_10))
                     {
                         continue;
                     }
                     if (!V_10.get_IsHardNode() || !V_10.get_NodeType().get_IsPrimitive() || !V_9.get_IsHardNode() || this.IsAssignable(V_10.get_NodeType(), V_9.get_NodeType()))
                     {
                         V_0.Add(new KeyValuePair <ClassHierarchyNode, ClassHierarchyNode>(V_9, V_10));
                     }
                     else
                     {
                         dummyVar3 = V_10.get_CanAssignTo().Remove(V_9);
                     }
                 }
             }
             finally
             {
                 if (V_3 != null)
                 {
                     V_3.Dispose();
                 }
             }
         }
     }
     finally
     {
         if (V_1 != null)
         {
             V_1.Dispose();
         }
     }
     V_5 = V_0.GetEnumerator();
     try
     {
         while (V_5.MoveNext())
         {
             V_11 = V_5.get_Current();
             V_12 = V_11.get_Key();
             V_13 = V_11.get_Value();
             this.get_SubTypes().Add(V_13);
             dummyVar4 = V_12.get_SubTypes().Remove(V_13);
             dummyVar5 = V_13.get_CanAssignTo().Remove(V_12);
             if (V_13.get_CanAssignTo().Contains(this))
             {
                 continue;
             }
             V_13.get_CanAssignTo().Add(this);
         }
     }
     finally
     {
         ((IDisposable)V_5).Dispose();
     }
     return;
 }
 public static bool TryMatch(BlockStatement filter, out VariableDeclarationExpression variableDeclaration, out Expression filterExpression)
 {
     variableDeclaration = null;
     filterExpression    = null;
     if (!CatchClausesFilterPattern.TryMatchVariableDeclaration(filter, out variableDeclaration))
     {
         return(false);
     }
     if (filter.get_Statements().get_Count() != 3)
     {
         return(false);
     }
     V_0 = filter.get_Statements().get_Item(1) as IfStatement;
     if (V_0 == null)
     {
         return(false);
     }
     V_1 = null;
     V_2 = null;
     if ((V_0.get_Condition() as BinaryExpression).get_Operator() != 10)
     {
         V_1 = V_0.get_Else();
         V_2 = V_0.get_Then();
     }
     else
     {
         V_1 = V_0.get_Then();
         V_2 = V_0.get_Else();
     }
     V_3 = null;
     V_4 = null;
     if (V_1.get_Statements().get_Count() != 1 && V_1.get_Statements().get_Count() != 2 && V_1.get_Statements().get_Count() != 3 || V_2.get_Statements().get_Count() != 1)
     {
         return(false);
     }
     if (V_1.get_Statements().get_Count() != 2)
     {
         if (V_1.get_Statements().get_Count() == 3)
         {
             V_8 = V_1.get_Statements().get_Item(0) as ExpressionStatement;
             V_9 = V_1.get_Statements().get_Item(1) as ExpressionStatement;
             if (V_8 == null || V_9 == null)
             {
                 return(false);
             }
             if (V_8.get_Expression().get_CodeNodeType() != 24 || V_9.get_Expression().get_CodeNodeType() != 19)
             {
                 if (V_8.get_Expression().get_CodeNodeType() != 19 || V_9.get_Expression().get_CodeNodeType() != 24)
                 {
                     return(false);
                 }
                 V_4 = V_8;
                 V_3 = V_9;
             }
             else
             {
                 V_3 = V_8;
                 V_4 = V_9;
             }
         }
     }
     else
     {
         V_7 = V_1.get_Statements().get_Item(0) as ExpressionStatement;
         if (V_7 == null)
         {
             return(false);
         }
         if (V_7.get_Expression().get_CodeNodeType() != 24)
         {
             if (V_7.get_Expression().get_CodeNodeType() != 19)
             {
                 return(false);
             }
             V_4 = V_7;
         }
         else
         {
             V_3 = V_7;
         }
     }
     if (V_3 != null)
     {
         V_10 = V_3.get_Expression() as BinaryExpression;
         if (V_10 == null || !V_10.get_IsAssignmentExpression() || String.op_Inequality(V_10.get_ExpressionType().get_FullName(), variableDeclaration.get_ExpressionType().get_FullName()))
         {
             return(false);
         }
         stackVariable98 = V_10.get_Left() as VariableReferenceExpression;
         V_11            = V_10.get_Right() as VariableReferenceExpression;
         if (stackVariable98 == null || V_11 == null)
         {
             return(false);
         }
     }
     if (V_4 != null)
     {
         V_12 = V_4.get_Expression() as MethodInvocationExpression;
         if (V_12 == null || String.op_Inequality(V_12.get_MethodExpression().get_Method().get_FullName(), "System.Void Microsoft.VisualBasic.CompilerServices.ProjectData::SetProjectError(System.Exception)"))
         {
             return(false);
         }
     }
     V_5 = filter.get_Statements().get_Item(2) as ExpressionStatement;
     if (V_5 == null)
     {
         return(false);
     }
     V_6 = V_5.get_Expression() as VariableReferenceExpression;
     if (V_6 == null)
     {
         return(false);
     }
     if (!CatchClausesFilterPattern.TryMatchFilterExpression(V_0, variableDeclaration.get_Variable().get_VariableType(), V_6, out filterExpression))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
		public override ICodeNode VisitBinaryExpression(BinaryExpression expression)
		{
			expression.set_Left((Expression)this.Visit(expression.get_Left()));
			expression.set_Right((Expression)this.Visit(expression.get_Right()));
			V_0 = expression.get_Left().get_ExpressionType();
			V_0 = this.GetElementType(V_0);
			if (V_0 != null)
			{
				if (String.op_Equality(V_0.get_FullName(), this.typeSystem.get_Char().get_FullName()))
				{
					if (expression.get_Right().get_CodeNodeType() == 22)
					{
						if (this.IsArithmeticOperator(expression.get_Operator()))
						{
							expression.set_ExpressionType(this.typeSystem.get_Char());
							return expression;
						}
						if (expression.get_Right().get_HasType())
						{
							V_2 = this.GetElementType(expression.get_Right().get_ExpressionType());
							if (String.op_Equality(V_0.get_FullName(), V_2.get_FullName()))
							{
								return expression;
							}
						}
						V_1 = expression.get_Right() as LiteralExpression;
						expression.set_Right(this.GetLiteralExpression((char)((Int32)V_1.get_Value()), V_1.get_MappedInstructions()));
					}
					if (String.op_Inequality(this.GetElementType(expression.get_Right().get_ExpressionType()).get_FullName(), this.typeSystem.get_Char().get_FullName()))
					{
						if (expression.get_Right().get_CodeNodeType() != 31 || !String.op_Equality(expression.get_Right().get_ExpressionType().get_FullName(), this.typeSystem.get_UInt16().get_FullName()))
						{
							expression.set_Right(new ExplicitCastExpression(expression.get_Right(), this.typeSystem.get_Char(), null));
						}
						else
						{
							((ExplicitCastExpression)expression.get_Right()).set_TargetType(this.typeSystem.get_Char());
						}
					}
				}
				if (String.op_Equality(V_0.get_FullName(), this.typeSystem.get_Boolean().get_FullName()) && expression.get_Right().get_CodeNodeType() == 22)
				{
					if (expression.get_Operator() == 9 || expression.get_Operator() == 10 || this.IsBooleanAssignmentOperator(expression.get_Operator()))
					{
						V_3 = expression.get_Right() as LiteralExpression;
						V_4 = true;
						if (V_3.get_Value() == null || V_3.get_Value().Equals(0) || V_3.get_Value().Equals(false) || V_3.get_Value().Equals(null))
						{
							V_4 = false;
						}
						expression.set_Right(this.GetLiteralExpression(V_4, V_3.get_MappedInstructions()));
					}
					if (expression.get_Operator() == 9 || expression.get_Operator() == 10)
					{
						return this.SimplifyBooleanComparison(expression);
					}
				}
			}
			if (expression.get_Operator() == 9 || expression.get_Operator() == 10)
			{
				V_5 = this.GetElementType(expression.get_Right().get_ExpressionType());
				if (V_5 != null && V_0 != null && String.op_Inequality(V_5.get_FullName(), V_0.get_FullName()))
				{
					return this.FixEqualityComparisonExpression(expression);
				}
			}
			if (expression.get_IsAssignmentExpression())
			{
				if (!this.NeedsPointerCast(expression))
				{
					if (expression.get_Left().get_HasType() && expression.get_Left().get_ExpressionType().get_IsByReference() || expression.get_Left().get_ExpressionType().get_IsPointer() || expression.get_Left().get_ExpressionType().get_IsArray() || !expression.get_Left().get_ExpressionType().get_IsPrimitive())
					{
						V_6 = expression.get_Left().get_ExpressionType().Resolve();
						if (V_6 != null && !V_6.get_IsEnum() && expression.get_Right() as LiteralExpression != null)
						{
							V_7 = expression.get_Right() as LiteralExpression;
							if (V_7.get_Value() != null && V_7.get_Value().Equals(0))
							{
								expression.set_Right(new LiteralExpression(null, this.typeSystem, expression.get_Right().get_UnderlyingSameMethodInstructions()));
							}
						}
					}
				}
				else
				{
					if (expression.get_Right().get_CodeNodeType() != 45)
					{
						expression.set_Right(new ExplicitCastExpression(expression.get_Right(), expression.get_Left().get_ExpressionType(), null));
					}
					else
					{
						expression.get_Right().set_ExpressionType(expression.get_Left().get_ExpressionType());
					}
				}
			}
			if (expression.get_Operator() == 15 && expression.get_MappedInstructions().Count<Instruction>() == 1 && expression.get_MappedInstructions().First<Instruction>().get_OpCode().get_Code() == 194)
			{
				V_9 = null;
				if (expression.get_Right().get_CodeNodeType() != 22)
				{
					if (expression.get_Right().get_CodeNodeType() == 31)
					{
						V_10 = expression.get_Right() as ExplicitCastExpression;
						if (V_10.get_Expression().get_CodeNodeType() == 22)
						{
							V_9 = V_10.get_Expression() as LiteralExpression;
						}
					}
				}
				else
				{
					V_9 = expression.get_Right() as LiteralExpression;
				}
				if (V_9 != null && V_9.get_Value() == null || V_9.get_Value().Equals(0))
				{
					expression.set_Operator(10);
				}
			}
			if (expression.get_IsObjectComparison())
			{
				V_11 = expression.get_Left();
				V_12 = expression.get_Right();
				if (this.CheckForOverloadedEqualityOperators(expression.get_Left(), out V_13) && this.CheckForOverloadedEqualityOperators(expression.get_Right(), out V_14))
				{
					expression.set_Left(new ExplicitCastExpression(V_11, V_11.get_ExpressionType().get_Module().get_TypeSystem().get_Object(), null, V_13));
					expression.set_Right(new ExplicitCastExpression(V_12, V_12.get_ExpressionType().get_Module().get_TypeSystem().get_Object(), null, V_14));
				}
			}
			return expression;
		}