Ejemplo n.º 1
0
 protected virtual void BuildUpHardNodesHierarchy(IEnumerable <ClassHierarchyNode> hardNodes)
 {
     V_0 = new Queue <ClassHierarchyNode>(hardNodes);
     V_1 = new HashSet <ClassHierarchyNode>();
     while (V_0.get_Count() > 0)
     {
         V_2       = V_0.Dequeue();
         dummyVar0 = V_1.Add(V_2);
         dummyVar1 = this.resultingGraph.Add(V_2);
         V_3       = V_2.get_NodeType().Resolve();
         V_4       = null;
         if (V_3 == null)
         {
             continue;
         }
         V_4 = V_3.get_BaseType();
         if (V_4 != null)
         {
             V_5 = this.GetTypeNode(V_4);
             V_2.AddSupertype(V_5);
             if (!V_1.Contains(V_5))
             {
                 V_0.Enqueue(V_5);
             }
         }
         if (V_3.get_IsInterface())
         {
             V_2.AddSupertype(this.GetTypeNode(this.typeSystem.get_Object()));
         }
         V_7 = V_2.get_NodeType().Resolve().get_Interfaces().GetEnumerator();
         try
         {
             while (V_7.MoveNext())
             {
                 V_8 = V_7.get_Current();
                 V_9 = this.GetTypeNode(V_8);
                 V_2.AddSupertype(V_9);
                 if (V_1.Contains(V_9))
                 {
                     continue;
                 }
                 V_0.Enqueue(V_9);
             }
         }
         finally
         {
             if (V_7 != null)
             {
                 V_7.Dispose();
             }
         }
     }
     this.AddObjectClassNodeIfMIssing();
     return;
 }
 private Dictionary <string, List <string> > GetModuleCollisionTypesData(ModuleDefinition module, ILanguage language)
 {
     V_0 = new Dictionary <string, List <string> >(language.get_IdentifierComparer());
     V_1 = new Dictionary <string, string>(language.get_IdentifierComparer());
     this.UpdateCollisionTypesDataWithTypes(V_0, V_1, module.get_Types());
     V_2 = this.GetModuleDependsOnAnalysis(module);
     if (Mono.Cecil.AssemblyResolver.Extensions.IsReferenceAssembly(module))
     {
         stackVariable16 = 1;
     }
     else
     {
         stackVariable16 = 0;
     }
     V_3 = stackVariable16;
     V_4 = V_2.get_Keys().GetEnumerator();
     try
     {
         while (V_4.MoveNext())
         {
             V_5 = V_4.get_Current();
             V_6 = module.get_AssemblyResolver().Resolve(V_5, "", ModuleDefinitionExtensions.GetModuleArchitecture(module), V_3, true);
             if (V_6 == null)
             {
                 this.UpdateCollisionTypesDataWithTypes(V_0, V_1, V_2.get_Item(V_5));
             }
             else
             {
                 V_7 = V_6.get_Modules().GetEnumerator();
                 try
                 {
                     while (V_7.MoveNext())
                     {
                         V_8 = V_7.get_Current();
                         this.UpdateCollisionTypesDataWithTypes(V_0, V_1, V_8.get_Types());
                     }
                 }
                 finally
                 {
                     V_7.Dispose();
                 }
             }
         }
     }
     finally
     {
         ((IDisposable)V_4).Dispose();
     }
     return(V_0);
 }
Ejemplo n.º 3
0
 private void EliminateViaDoWhile(IfStatement gotoStatement, Statement labeledStatement)
 {
     V_0 = new List <BreakStatement>();
     V_1 = new List <ContinueStatement>();
     V_2 = this.GetOuterBlock(labeledStatement);
     V_3 = V_2.get_Statements().IndexOf(labeledStatement);
     V_4 = V_2.get_Statements().IndexOf(gotoStatement);
     V_5 = this.CollectStatements(V_3, V_4, V_2);
     if (this.ShouldCheck(gotoStatement))
     {
         stackVariable127 = new ContinueAndBreakFinder();
         stackVariable127.Visit(V_5);
         V_0 = stackVariable127.get_Breaks();
         V_1 = stackVariable127.get_Continues();
     }
     V_7 = V_0.GetEnumerator();
     try
     {
         while (V_7.MoveNext())
         {
             V_8                    = V_7.get_Current();
             stackVariable29        = this.GetOuterBlock(V_8);
             V_9                    = stackVariable29.get_Statements().IndexOf(V_8);
             this.usedBreakVariable = true;
             V_10                   = new ExpressionStatement(new BinaryExpression(26, new VariableReferenceExpression(this.breakVariable, null), this.GetLiteralExpression(true), this.typeSystem, null, false));
             stackVariable29.AddStatementAt(V_9, V_10);
         }
     }
     finally
     {
         if (V_7 != null)
         {
             V_7.Dispose();
         }
     }
     V_11 = V_1.GetEnumerator();
     try
     {
         while (V_11.MoveNext())
         {
             V_12                      = V_11.get_Current();
             stackVariable60           = this.GetOuterBlock(V_12);
             V_13                      = stackVariable60.get_Statements().IndexOf(V_12);
             this.usedContinueVariable = true;
             V_14                      = new ExpressionStatement(new BinaryExpression(26, new VariableReferenceExpression(this.continueVariable, null), this.GetLiteralExpression(true), this.typeSystem, null, false));
             stackVariable60.get_Statements().RemoveAt(V_13);
             stackVariable60.AddStatementAt(V_13, new BreakStatement(null));
             stackVariable60.AddStatementAt(V_13, V_14);
         }
     }
     finally
     {
         if (V_11 != null)
         {
             V_11.Dispose();
         }
     }
     V_6 = new DoWhileStatement(gotoStatement.get_Condition(), V_5);
     V_4 = V_2.get_Statements().IndexOf(gotoStatement);
     V_2.AddStatementAt(V_4, V_6);
     dummyVar0 = V_2.get_Statements().Remove(gotoStatement);
     if (V_0.get_Count() > 0)
     {
         this.AddBreakContinueConditional(V_4 + 1, V_2, new BreakStatement(null), this.breakVariable);
     }
     if (V_1.get_Count() > 0)
     {
         this.AddBreakContinueConditional(V_4 + 1, V_2, new ContinueStatement(null), this.continueVariable);
     }
     return;
 }
 private void ManageIsEventOperations(HashSet <Statement> statementsToRemove)
 {
     V_0 = this.isEventIfStatements.GetEnumerator();
     try
     {
         while (V_0.MoveNext())
         {
             V_1 = V_0.get_Current();
             V_2 = V_1.get_Key();
             V_3 = V_1.get_Value();
             if (V_2.get_Condition().get_CodeNodeType() != 23 || (V_2.get_Condition() as UnaryExpression).get_Operator() != 11 || (V_2.get_Condition() as UnaryExpression).get_Operand() != V_3)
             {
                 if (V_2.get_Condition().get_CodeNodeType() != 23 || (V_2.get_Condition() as UnaryExpression).get_Operator() != UnaryOperator.Negate || (V_2.get_Condition() as UnaryExpression).get_Operand() != V_3)
                 {
                     throw new Exception("Invalid invocation of IsEvent operation.");
                 }
                 this.ReplaceIfWith(V_2, V_2.get_Else());
             }
             else
             {
                 V_4 = V_2.get_Then().get_Statements().get_Item(V_2.get_Then().get_Statements().get_Count() - 1);
                 if (V_4.get_CodeNodeType() == 5 && ((ExpressionStatement)V_4).get_Expression().get_CodeNodeType() == 57)
                 {
                     V_5 = (BlockStatement)V_2.get_Parent();
                     V_6 = V_5.get_Statements().IndexOf(V_2) + 1;
                     while (V_6 < V_5.get_Statements().get_Count())
                     {
                         dummyVar0 = statementsToRemove.Add(V_5.get_Statements().get_Item(V_6));
                         V_6       = V_6 + 1;
                     }
                 }
                 this.ReplaceIfWith(V_2, V_2.get_Then());
             }
             V_7 = V_2.get_Then().get_Statements().GetEnumerator();
             try
             {
                 while (V_7.MoveNext())
                 {
                     V_8       = V_7.get_Current();
                     dummyVar1 = statementsToRemove.Remove(V_8);
                 }
             }
             finally
             {
                 if (V_7 != null)
                 {
                     V_7.Dispose();
                 }
             }
             if (V_2.get_Else() == null)
             {
                 continue;
             }
             V_7 = V_2.get_Else().get_Statements().GetEnumerator();
             try
             {
                 while (V_7.MoveNext())
                 {
                     V_9       = V_7.get_Current();
                     dummyVar2 = statementsToRemove.Remove(V_9);
                 }
             }
             finally
             {
                 if (V_7 != null)
                 {
                     V_7.Dispose();
                 }
             }
         }
     }
     finally
     {
         ((IDisposable)V_0).Dispose();
     }
     return;
 }
		public static ICollection<TypeReference> GetAssemblyAttributesUsedTypes(AssemblyDefinition assembly)
		{
			V_0 = new List<TypeReference>();
			V_1 = new List<ICustomAttribute>();
			V_1.Add(AttributesUtilities.GetAssemblyVersionAttribute(assembly));
			V_3 = assembly.get_CustomAttributes().GetEnumerator();
			try
			{
				while (V_3.MoveNext())
				{
					V_4 = V_3.get_Current();
					V_4.Resolve();
					V_1.Add(V_4);
				}
			}
			finally
			{
				V_3.Dispose();
			}
			if (assembly.get_HasSecurityDeclarations())
			{
				V_5 = assembly.get_SecurityDeclarations().GetEnumerator();
				try
				{
					while (V_5.MoveNext())
					{
						V_6 = V_5.get_Current();
						if (!V_6.get_HasSecurityAttributes())
						{
							continue;
						}
						V_7 = V_6.get_SecurityAttributes().GetEnumerator();
						try
						{
							while (V_7.MoveNext())
							{
								V_8 = V_7.get_Current();
								V_1.Add(V_8);
							}
						}
						finally
						{
							V_7.Dispose();
						}
					}
				}
				finally
				{
					V_5.Dispose();
				}
			}
			if (assembly.get_MainModule().get_HasExportedTypes())
			{
				V_9 = assembly.get_MainModule().get_ExportedTypes().GetEnumerator();
				try
				{
					while (V_9.MoveNext())
					{
						V_10 = V_9.get_Current();
						if (V_10.get_Scope() as ModuleReference != null)
						{
							continue;
						}
						V_1.Add(AttributesUtilities.GetExportedTypeAttribute(V_10, assembly.get_MainModule()));
					}
				}
				finally
				{
					V_9.Dispose();
				}
			}
			V_11 = V_1.GetEnumerator();
			try
			{
				while (V_11.MoveNext())
				{
					V_12 = V_11.get_Current();
					if (V_12 as CustomAttribute == null)
					{
						if (V_12 as SecurityAttribute == null)
						{
							continue;
						}
						V_13 = AttributesUtilities.GetSecurityAttributeUsedTypes(V_12 as SecurityAttribute).GetEnumerator();
						try
						{
							while (V_13.MoveNext())
							{
								V_15 = V_13.get_Current();
								V_0.Add(V_15);
							}
						}
						finally
						{
							if (V_13 != null)
							{
								V_13.Dispose();
							}
						}
					}
					else
					{
						V_13 = AttributesUtilities.GetCustomAttributeUsedTypes(V_12 as CustomAttribute).GetEnumerator();
						try
						{
							while (V_13.MoveNext())
							{
								V_14 = V_13.get_Current();
								V_0.Add(V_14);
							}
						}
						finally
						{
							if (V_13 != null)
							{
								V_13.Dispose();
							}
						}
					}
				}
			}
			finally
			{
				((IDisposable)V_11).Dispose();
			}
			return V_0;
		}
Ejemplo n.º 6
0
 internal void RemoveBlockAt(int index)
 {
     V_0 = this.get_Blocks()[index];
     V_1 = V_0.get_Last().get_Next();
     if (V_0.get_Predecessors().get_Count() > 0)
     {
         throw new Exception("The block to be removed cannot have predecessors");
     }
     V_2 = this.get_Blocks();
     this.set_Blocks(new InstructionBlock[(int)this.get_Blocks().Length - 1]);
     V_3 = 0;
     while (V_3 < (int)this.get_Blocks().Length)
     {
         if (V_3 >= index)
         {
             stackVariable29 = 1;
         }
         else
         {
             stackVariable29 = 0;
         }
         V_4 = stackVariable29;
         this.get_Blocks()[V_3] = V_2[V_3 + V_4];
         this.get_Blocks()[V_3].set_Index(V_3);
         dummyVar0 = this.get_Blocks()[V_3].get_Predecessors().Remove(V_0);
         if ((object)this.get_Blocks()[V_3].get_First().get_Previous() == (object)V_0.get_Last())
         {
             this.get_Blocks()[V_3].get_First().set_Previous(V_0.get_First().get_Previous());
         }
         if ((object)this.get_Blocks()[V_3].get_Last().get_Next() == (object)V_0.get_First())
         {
             this.get_Blocks()[V_3].get_Last().set_Next(V_0.get_Last().get_Next());
         }
         V_3 = V_3 + 1;
     }
     dummyVar1 = this.get_InstructionToBlockMapping().Remove(V_0.get_First().get_Offset());
     dummyVar2 = this.get_SwitchBlocksInformation().Remove(V_0);
     V_0.set_Successors(new InstructionBlock[0]);
     V_5 = V_0.GetEnumerator();
     try
     {
         while (V_5.MoveNext())
         {
             V_6       = V_5.get_Current();
             dummyVar3 = this.get_OffsetToInstruction().Remove(V_6.get_Offset());
         }
     }
     finally
     {
         if (V_5 != null)
         {
             V_5.Dispose();
         }
     }
     V_7 = this.get_MethodBody().get_ExceptionHandlers().GetEnumerator();
     try
     {
         while (V_7.MoveNext())
         {
             V_8 = V_7.get_Current();
             if ((object)V_8.get_TryStart() == (object)V_0.get_First())
             {
                 V_8.set_TryStart(V_1);
             }
             if ((object)V_8.get_TryEnd() == (object)V_0.get_First())
             {
                 V_8.set_TryEnd(V_1);
             }
             if ((object)V_8.get_HandlerStart() == (object)V_0.get_First())
             {
                 V_8.set_HandlerStart(V_1);
             }
             if ((object)V_8.get_HandlerEnd() == (object)V_0.get_First())
             {
                 V_8.set_HandlerEnd(V_1);
             }
             if ((object)V_8.get_FilterStart() == (object)V_0.get_First())
             {
                 V_8.set_FilterStart(V_1);
             }
             if ((object)V_8.get_FilterEnd() != (object)V_0.get_First())
             {
                 continue;
             }
             V_8.set_FilterEnd(V_1);
         }
     }
     finally
     {
         V_7.Dispose();
     }
     V_0.set_Index(-1);
     return;
 }
        private bool TryProcessConditionalDisposeHandler(YieldExceptionHandlerInfo yieldExceptionHandler, CFGBlockLogicalConstruct startBlock)
        {
            if (this.finallyBlocks.get_Count() > 0)
            {
                return(false);
            }
            if (startBlock as PartialCFGBlockLogicalConstruct == null || startBlock.get_CFGSuccessors().get_Count() != 1)
            {
                return(false);
            }
            if (startBlock.get_LogicalConstructExpressions().get_Count() == 0)
            {
                return(false);
            }
            V_0 = startBlock.get_LogicalConstructExpressions().get_Item(0) as BinaryExpression;
            if (V_0 == null || !V_0.get_IsAssignmentExpression() || V_0.get_Left().get_CodeNodeType() != 30 || (V_0.get_Left() as FieldReferenceExpression).get_Field().Resolve() != this.stateFieldRef || V_0.get_Right().get_CodeNodeType() != 22 || (Int32)(V_0.get_Right() as LiteralExpression).get_Value() != yieldExceptionHandler.get_NextState())
            {
                return(false);
            }
            if (startBlock.get_LogicalConstructExpressions().get_Count() != 2 || yieldExceptionHandler.get_HandlerType() != 2)
            {
                if (startBlock.get_LogicalConstructExpressions().get_Count() != 1 || yieldExceptionHandler.get_HandlerType() != 1)
                {
                    return(false);
                }
            }
            else
            {
                V_6 = startBlock.get_LogicalConstructExpressions().get_Item(1) as BinaryExpression;
                if (V_6 == null || !V_6.get_IsAssignmentExpression() || V_6.get_Left().get_CodeNodeType() != 30 || (object)(V_6.get_Left() as FieldReferenceExpression).get_Field() != (object)yieldExceptionHandler.get_DisposableField() || V_6.get_Right().get_CodeNodeType() != 33 || (V_6.get_Right() as SafeCastExpression).get_Expression().get_CodeNodeType() != 30 || (object)((V_6.get_Right() as SafeCastExpression).get_Expression() as FieldReferenceExpression).get_Field() != (object)yieldExceptionHandler.get_EnumeratorField())
                {
                    return(false);
                }
            }
            V_2 = startBlock.get_CFGSuccessors().GetEnumerator();
            V_7 = V_2;
            try
            {
                dummyVar0 = V_2.MoveNext();
                V_1       = V_2.get_Current();
            }
            finally
            {
                if (V_7 != null)
                {
                    V_7.Dispose();
                }
            }
            if (V_1.get_LogicalConstructExpressions().get_Count() != 1)
            {
                return(false);
            }
            V_3 = V_1.get_LogicalConstructExpressions().get_Item(0) as BinaryExpression;
            if (V_3 == null || V_3.get_Operator() != 9 || V_3.get_Left().get_CodeNodeType() != 30 || (object)(V_3.get_Left() as FieldReferenceExpression).get_Field() != (object)yieldExceptionHandler.get_DisposableField() || V_3.get_Right().get_CodeNodeType() != 22 || (V_3.get_Right() as LiteralExpression).get_Value() != null)
            {
                return(false);
            }
            V_4 = null;
            V_8 = V_1.get_CFGSuccessors().GetEnumerator();
            try
            {
                while (V_8.MoveNext())
                {
                    V_9 = V_8.get_Current() as CFGBlockLogicalConstruct;
                    if (V_9 == null || V_9.get_CFGPredecessors().get_Count() != 1)
                    {
                        continue;
                    }
                    V_4 = V_9;
                    goto Label0;
                }
            }
            finally
            {
                ((IDisposable)V_8).Dispose();
            }
Label0:
            if (V_4 == null || V_4.get_LogicalConstructExpressions().get_Count() != 1)
            {
                return(false);
            }
            V_5 = V_4.get_LogicalConstructExpressions().get_Item(0) as MethodInvocationExpression;
            if (V_5 == null || !V_5.get_VirtualCall() || V_5.get_MethodExpression().get_Target().get_CodeNodeType() != 30 || (object)(V_5.get_MethodExpression().get_Target() as FieldReferenceExpression).get_Field() != (object)yieldExceptionHandler.get_DisposableField() || String.op_Inequality(V_5.get_MethodExpression().get_Method().get_Name(), "Dispose"))
            {
                return(false);
            }
            this.finallyEntryBlock = startBlock;
            dummyVar1             = this.finallyBlocks.Add(startBlock);
            this.conditionBlock   = V_1;
            dummyVar2             = this.finallyBlocks.Add(V_1);
            this.disposeCallBlock = V_4;
            dummyVar3             = this.finallyBlocks.Add(V_4);
            return(true);
        }
 private Dictionary <AssemblyNameReference, List <TypeReference> > GetModuleDependsOnAnalysis(ModuleDefinition module)
 {
     stackVariable1 = module.get_Types();
     V_0            = new HashSet <TypeReference>();
     V_3            = stackVariable1.GetEnumerator();
     try
     {
         while (V_3.MoveNext())
         {
             V_4 = V_3.get_Current();
             if (V_0.Contains(V_4))
             {
                 continue;
             }
             dummyVar0 = V_0.Add(V_4);
         }
     }
     finally
     {
         V_3.Dispose();
     }
     V_5 = module.GetTypeReferences().GetEnumerator();
     try
     {
         while (V_5.MoveNext())
         {
             V_6 = V_5.get_Current();
             if (V_0.Contains(V_6))
             {
                 continue;
             }
             dummyVar1 = V_0.Add(V_6);
         }
     }
     finally
     {
         if (V_5 != null)
         {
             V_5.Dispose();
         }
     }
     V_2 = Utilities.GetAssembliesDependingOnToUsedTypesMap(module, Utilities.GetExpandedTypeDependanceList(V_0));
     V_7 = module.get_AssemblyReferences().GetEnumerator();
     try
     {
         while (V_7.MoveNext())
         {
             V_8 = V_7.get_Current();
             if (V_2.ContainsKey(V_8))
             {
                 continue;
             }
             V_2.Add(V_8, new List <TypeReference>());
         }
     }
     finally
     {
         V_7.Dispose();
     }
     return(V_2);
 }