private HashSet <ILogicalConstruct> BuildLoop(DFSTree tree, out HashSet <ILogicalConstruct> loopBody) { loopBody = new HashSet <ILogicalConstruct>(); V_0 = new HashSet <ILogicalConstruct>(); V_1 = tree.get_BackEdges().GetEnumerator(); try { while (V_1.MoveNext()) { V_2 = V_1.get_Current(); V_3 = V_2.get_End().get_Construct() as ILogicalConstruct; V_4 = V_2.get_Start().get_Construct() as ILogicalConstruct; if (this.removedEdges.ContainsKey(V_4) && this.removedEdges.get_Item(V_4).Contains(V_3)) { continue; } V_5 = tree.GetPath(V_2.get_End(), V_2.get_Start()); V_6 = this.ExpandLoopBodyWithCrossEdges(V_5); V_7 = this.GetConstructsCollection(V_6); if (!this.CanBeLoop(V_3, V_4, V_6)) { continue; } dummyVar0 = V_0.Add(V_4); V_8 = V_7.GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = V_8.get_Current(); dummyVar1 = loopBody.Add(V_9); } } finally { if (V_8 != null) { V_8.Dispose(); } } } } finally { ((IDisposable)V_1).Dispose(); } return(V_0); }
public override ICodeNode VisitMethodReferenceExpression(MethodReferenceExpression node) { V_0 = node.get_Method().Resolve(); V_1 = this.context.get_TypeContext().get_CurrentType(); if (V_0 == null || (object)V_0.get_DeclaringType() != (object)V_1 && !V_0.get_DeclaringType().IsNestedIn(V_1)) { return(this.VisitMethodReferenceExpression(node)); } if (V_0.get_IsGetter() || V_0.get_IsSetter() || !V_0.IsCompilerGenerated(true) && !this.CheckTypeForCompilerGeneratedAttribute(V_0.get_DeclaringType())) { return(this.VisitMethodReferenceExpression(node)); } V_2 = null; if (V_0.get_Body() != null) { V_5 = this.CreateDecompilationContext(V_0); V_2 = V_0.get_Body().DecompileLambda(this.context.get_Language(), V_5); if (V_2.get_Statements().get_Count() == 1 && V_2.get_Statements().get_Item(0).get_CodeNodeType() == 5 && (V_2.get_Statements().get_Item(0) as ExpressionStatement).get_Expression().get_CodeNodeType() == 57) { V_6 = (V_2.get_Statements().get_Item(0) as ExpressionStatement).get_Expression() as ReturnExpression; V_7 = new ShortFormReturnExpression(V_6.get_Value(), V_6.get_MappedInstructions()); V_2 = new BlockStatement(); V_2.get_Statements().Add(new ExpressionStatement(V_7)); } this.context.get_MethodContext().get_VariableDefinitionToNameMap().AddRange <VariableDefinition, string>(V_5.get_MethodContext().get_VariableDefinitionToNameMap()); this.context.get_MethodContext().get_VariableNamesCollection().UnionWith(V_5.get_MethodContext().get_VariableNamesCollection()); this.context.get_MethodContext().AddInnerMethodParametersToContext(V_5.get_MethodContext()); this.context.get_MethodContext().get_GotoStatements().AddRange(V_5.get_MethodContext().get_GotoStatements()); this.context.get_MethodContext().get_GotoLabels().AddRange <string, Statement>(V_5.get_MethodContext().get_GotoLabels()); } V_3 = new ExpressionCollection(); V_4 = LambdaExpressionsHelper.HasAnonymousParameter(V_0.get_Parameters()); V_8 = V_0.get_Parameters().GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = V_8.get_Current(); V_3.Add(new LambdaParameterExpression(V_9, !V_4, null)); } } finally { V_8.Dispose(); } return(new LambdaExpression(V_3, V_2, V_0.IsAsync(), V_0.IsFunction(), node.get_Method().get_Parameters(), false, node.get_MappedInstructions())); }
private void CreateSwitchConstruct(CFGBlockLogicalConstruct switchBlock, ILogicalConstruct parentConstruct, SwitchData switchData, DominatorTree dominatorTree) { stackVariable2 = this.GetOrderedCFGSuccessorToLabelsMap(switchData); V_0 = this.GetValidCases(dominatorTree, switchBlock); V_1 = new List <CaseLogicalConstruct>(); V_2 = new PairList <List <int>, CFGBlockLogicalConstruct>(); V_8 = stackVariable2.GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = V_8.get_Current(); if (!LogicalFlowUtilities.TryGetParentConstructWithGivenParent(V_9.get_Key(), parentConstruct, out V_10) || !V_0.TryGetValue(V_10, out V_11)) { V_2.Add(V_9.get_Value(), V_9.get_Key()); } else { V_12 = new CaseLogicalConstruct(V_10); V_12.get_CaseNumbers().AddRange(V_9.get_Value()); V_12.get_Body().UnionWith(V_11.Cast <ILogicalConstruct>()); V_12.AttachCaseConstructToGraph(); V_1.Add(V_12); } } } finally { ((IDisposable)V_8).Dispose(); } V_3 = null; V_4 = this.GetCFGLogicalConstructFromBlock(switchData.get_DefaultCase()); if (LogicalFlowUtilities.TryGetParentConstructWithGivenParent(V_4, parentConstruct, out V_5) && V_0.TryGetValue(V_5, out V_6)) { V_3 = new CaseLogicalConstruct(V_5); if (this.HasSuccessors(V_6)) { V_3.get_Body().UnionWith(V_6.Cast <ILogicalConstruct>()); } V_3.AttachCaseConstructToGraph(); } V_7 = SwitchLogicalConstruct.GroupInSwitchConstruct(switchBlock, V_1, V_2, V_3, V_4); this.UpdateDominatorTree(dominatorTree, V_7); return; }
private LoopType DetermineLoopType(HashSet <ILogicalConstruct> loopBody, HashSet <ILogicalConstruct> latchingNodes, IntervalConstruct interval, DominatorTree dominatorTree, out ConditionLogicalConstruct loopCondition) { V_0 = interval.get_Entry() as ILogicalConstruct; V_1 = new HashSet <ILogicalConstruct>(latchingNodes); dummyVar0 = V_1.Add(V_0); V_2 = DFSTBuilder.BuildTree(V_0.get_Parent() as ILogicalConstruct); V_3 = new HashSet <ILogicalConstruct>(); V_4 = loopBody.GetEnumerator(); try { while (V_4.MoveNext()) { V_5 = V_4.get_Current(); V_6 = dominatorTree.GetDominanceFrontier(V_5).GetEnumerator(); try { while (V_6.MoveNext()) { V_7 = (ILogicalConstruct)V_6.get_Current(); if (!interval.get_Children().Contains(V_7) || loopBody.Contains(V_7)) { continue; } dummyVar1 = V_3.Add(V_7); } } finally { ((IDisposable)V_6).Dispose(); } } } finally { ((IDisposable)V_4).Dispose(); } if (V_3.get_Count() == 0) { V_8 = V_2.get_ReversePostOrder().GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = V_8.get_Current().get_Construct() as ILogicalConstruct; if (loopBody.Contains(V_9)) { continue; } loopCondition = this.GetLoopConditionWithMaxIndex(V_2, loopBody, V_1, V_9); if (loopCondition == null) { continue; } this.ExpandLoopBody(interval, loopBody, V_9); if (loopCondition != V_0) { V_10 = 2; goto Label1; } else { V_10 = 1; goto Label1; } } goto Label0; } finally { ((IDisposable)V_8).Dispose(); } Label1: return(V_10); } V_11 = V_2.get_ReversePostOrder().get_Count(); V_4 = V_3.GetEnumerator(); try { while (V_4.MoveNext()) { V_13 = V_4.get_Current(); V_14 = V_2.get_ConstructToNodeMap().get_Item(V_13).get_ReversePostOrderIndex(); if (V_14 >= V_11) { continue; } V_11 = V_14; } } finally { ((IDisposable)V_4).Dispose(); } V_12 = V_2.get_ReversePostOrder().get_Item(V_11).get_Construct() as ILogicalConstruct; loopCondition = this.GetLoopConditionWithMaxIndex(V_2, loopBody, V_1, V_12); this.ExpandLoopBody(interval, loopBody, V_12); if (loopCondition == null) { return(0); } if (loopCondition == V_0) { return(1); } return(2); Label0: if (!this.CanBeLoopCondition(V_0, loopBody)) { loopCondition = null; return(0); } loopCondition = V_0 as ConditionLogicalConstruct; return(1); }
protected virtual ClassHierarchyNode FindLowestCommonAncestor(ICollection <ClassHierarchyNode> typeNodes) { V_0 = 0; V_1 = null; V_4 = typeNodes.GetEnumerator(); try { while (V_4.MoveNext()) { V_0 = V_0 + 1; V_1 = V_4.get_Current(); } } finally { if (V_4 != null) { V_4.Dispose(); } } if (V_0 == 1) { return(V_1); } V_2 = new Queue <ClassHierarchyNode>(); V_3 = new HashSet <ClassHierarchyNode>(); V_4 = typeNodes.GetEnumerator(); try { while (V_4.MoveNext()) { V_5 = V_4.get_Current(); if (V_2.get_Count() != 0) { V_10 = V_5; while (!V_3.Contains(V_10)) { stackVariable28 = V_5.get_CanAssignTo(); stackVariable29 = TypeInferer.u003cu003ec.u003cu003e9__18_0; if (stackVariable29 == null) { dummyVar1 = stackVariable29; stackVariable29 = new Func <ClassHierarchyNode, bool>(TypeInferer.u003cu003ec.u003cu003e9.u003cFindLowestCommonAncestoru003eb__18_0); TypeInferer.u003cu003ec.u003cu003e9__18_0 = stackVariable29; } if (stackVariable28.Count <ClassHierarchyNode>(stackVariable29) <= 1) { stackVariable33 = V_10.get_CanAssignTo(); stackVariable34 = TypeInferer.u003cu003ec.u003cu003e9__18_1; if (stackVariable34 == null) { dummyVar2 = stackVariable34; stackVariable34 = new Func <ClassHierarchyNode, bool>(TypeInferer.u003cu003ec.u003cu003e9.u003cFindLowestCommonAncestoru003eb__18_1); TypeInferer.u003cu003ec.u003cu003e9__18_1 = stackVariable34; } V_10 = stackVariable33.FirstOrDefault <ClassHierarchyNode>(stackVariable34); } else { V_11 = null; goto Label1; } } while (V_2.Peek() != V_10) { dummyVar3 = V_3.Remove(V_2.Dequeue()); } } else { V_6 = V_5; while (V_6 != null) { V_2.Enqueue(V_6); dummyVar0 = V_3.Add(V_6); V_7 = null; V_8 = V_6.get_CanAssignTo().GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = V_8.get_Current(); if (!V_9.get_IsHardNode()) { continue; } V_7 = V_9; goto Label2; } } finally { if (V_8 != null) { V_8.Dispose(); } } Label2: V_6 = V_7; } } } goto Label0; } finally { if (V_4 != null) { V_4.Dispose(); } } Label1: return(V_11); Label0: return(V_2.Peek()); }
protected void DecompileConstructorChain(MethodDefinition method, ILanguage language, DecompiledType decompiledType) { if (this.cacheService.IsDecompiledMemberInCache(method, language, this.renameInvalidMembers)) { V_3 = this.cacheService.GetDecompiledMemberFromCache(method, language, this.renameInvalidMembers); this.AddDecompiledMemberToDecompiledType(V_3, decompiledType); BaseWriterContextService.AddAssignmentDataToDecompiledType(V_3, decompiledType); return; } if (method.get_Body() == null) { V_4 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(method), null, null)); this.cacheService.AddDecompiledMemberToCache(method, language, this.renameInvalidMembers, V_4); return; } V_0 = this.DecompileMethod(language, method, decompiledType.get_TypeContext().ShallowPartialClone()); V_1 = new List <CachedDecompiledMember>(); V_2 = method.get_DeclaringType(); if (!method.get_IsStatic()) { V_5 = V_2.get_Methods().GetEnumerator(); try { while (V_5.MoveNext()) { V_6 = V_5.get_Current(); if (!V_6.get_IsConstructor() || String.op_Equality(V_6.get_FullName(), V_0.get_Member().get_MemberFullName()) || V_6.get_IsStatic()) { continue; } if (V_6.get_Body() != null) { V_1.Add(this.DecompileMethod(language, V_6, decompiledType.get_TypeContext().ShallowPartialClone())); } else { V_7 = new CachedDecompiledMember(new DecompiledMember(Utilities.GetMemberUniqueName(V_6), null, null)); V_1.Add(V_7); } } } finally { V_5.Dispose(); } V_1.Add(V_0); this.MergeConstructorsTypeContexts(V_1, decompiledType); V_8 = V_1.GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = new BaseWriterContextService.u003cu003ec__DisplayClass15_0(); V_9.constructor = V_8.get_Current(); if (language as IntermediateLanguage == null) { this.RemoveBaseCtorInvocationStatements(V_9.constructor, decompiledType); } if (V_9.constructor.get_Member().get_Context() != null) { if (!this.cacheService.IsDecompiledMemberInCache(V_9.constructor.get_Member().get_Context().get_Method(), language, this.renameInvalidMembers)) { this.cacheService.AddDecompiledMemberToCache(V_9.constructor.get_Member().get_Context().get_Method(), language, this.renameInvalidMembers, V_9.constructor); } } else { V_10 = decompiledType.get_Type().get_Methods().First <MethodDefinition>(new Func <MethodDefinition, bool>(V_9.u003cDecompileConstructorChainu003eb__0)); if (!this.cacheService.IsDecompiledMemberInCache(V_10, language, this.renameInvalidMembers)) { this.cacheService.AddDecompiledMemberToCache(V_10, language, this.renameInvalidMembers, V_9.constructor); } } this.AddDecompiledMemberToDecompiledType(V_9.constructor, decompiledType); } } finally { ((IDisposable)V_8).Dispose(); } } 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); }
public virtual void WriteAssemblyAttributes(AssemblyDefinition assembly, ICollection <string> attributesToIgnore = null) { V_0 = new List <ICustomAttribute>(); this.securityAttributeToDeclaration = new Dictionary <SecurityAttribute, SecurityDeclaration>(); V_0.Add(AttributesUtilities.GetAssemblyVersionAttribute(assembly)); V_2 = assembly.get_CustomAttributes().GetEnumerator(); try { while (V_2.MoveNext()) { V_3 = V_2.get_Current(); V_3.Resolve(); V_0.Add(V_3); } } finally { V_2.Dispose(); } if (assembly.get_HasSecurityDeclarations()) { V_4 = assembly.get_SecurityDeclarations().GetEnumerator(); try { while (V_4.MoveNext()) { V_5 = V_4.get_Current(); V_0.AddRange(this.GetSecurityDeclaration(V_5)); } } finally { V_4.Dispose(); } } if (assembly.get_MainModule().get_HasExportedTypes()) { V_6 = assembly.get_MainModule().get_ExportedTypes().GetEnumerator(); try { while (V_6.MoveNext()) { V_7 = V_6.get_Current(); if (V_7.get_Scope() as ModuleReference != null) { continue; } V_0.Add(AttributesUtilities.GetExportedTypeAttribute(V_7, assembly.get_MainModule())); } } finally { V_6.Dispose(); } } V_0.Sort(new Comparison <ICustomAttribute>(this.u003cWriteAssemblyAttributesu003eb__18_0)); V_8 = V_0.GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = V_8.get_Current(); if (attributesToIgnore != null && attributesToIgnore.Contains(V_9.get_AttributeType().get_FullName())) { continue; } if (V_9 as CustomAttribute == null) { if (V_9 as SecurityAttribute == null) { continue; } dummyVar0 = this.WriteSecurityAttribute(assembly.get_MainModule(), true, V_9 as SecurityAttribute, this.securityAttributeToDeclaration.get_Item(V_9 as SecurityAttribute), out V_10, false, false); } else { this.WriteAssemblyAttribute(V_9 as CustomAttribute); } } } finally { ((IDisposable)V_8).Dispose(); } return; }
private List<TypeDefinition> GetInheritanceChain(TypeDefinition targetType, string definingTypeFullName) { V_0 = new List<TypeDefinition>(); V_1 = new List<int>(); V_0.Add(targetType); V_1.Add(-1); V_2 = -1; V_4 = 0; while (V_4 < V_0.get_Count()) { V_5 = V_0.get_Item(V_4); if (V_5 == null || String.op_Equality(V_5.get_FullName(), definingTypeFullName)) { V_2 = V_4; break; } else { V_6 = V_5.get_BaseType(); if (V_6 != null) { V_7 = V_6.Resolve(); if (V_7 != null) { V_0.Add(V_7); V_1.Add(V_4); } } V_8 = V_5.get_Interfaces().GetEnumerator(); try { while (V_8.MoveNext()) { V_9 = V_8.get_Current(); if (V_9 == null) { continue; } V_10 = V_9.Resolve(); if (V_10 == null) { continue; } V_0.Add(V_10); V_1.Add(V_4); } } finally { V_8.Dispose(); } V_4 = V_4 + 1; } } V_3 = new List<TypeDefinition>(); while (V_2 != -1) { V_3.Add(V_0.get_Item(V_2)); V_2 = V_1.get_Item(V_2); } return V_3; }