public bool TryMatch(StatementCollection statements, out int startIndex, out Statement result, out int replacedStatementsCount) { replacedStatementsCount = 0; startIndex = -1; result = null; V_0 = false; if (statements.get_Count() == 0) { return(false); } V_1 = new HashSet <VariableDefinition>(); V_2 = this.GetStatementsToInline(statements); V_3 = V_2.get_Count() - 1; while (V_3 >= 0) { V_4 = V_2.get_Item(V_3); V_5 = statements.get_Item(V_4) as ExpressionStatement; V_6 = ((V_5.get_Expression() as BinaryExpression).get_Left() as VariableReferenceExpression).get_Variable().Resolve(); if (V_4 == statements.get_Count() - 1 || !String.IsNullOrEmpty(V_5.get_Label())) { dummyVar0 = V_1.Add(V_6); } else { V_7 = new List <Instruction>(V_5.get_Expression().get_MappedInstructions()); V_7.AddRange((V_5.get_Expression() as BinaryExpression).get_Left().get_UnderlyingSameMethodInstructions()); V_8 = (V_5.get_Expression() as BinaryExpression).get_Right().CloneAndAttachInstructions(V_7); if (this.inliner.TryInlineVariable(V_6, V_8, statements.get_Item(V_4 + 1), this.ShouldInlineAggressively(V_6), out V_9)) { statements.RemoveAt(V_4); V_0 = true; dummyVar1 = V_1.Add(V_6); this.methodContext.RemoveVariable(V_6); statements.set_Item(V_4, (Statement)this.dereferencer.Visit(statements.get_Item(V_4))); } } V_3 = V_3 - 1; } V_10 = V_1.GetEnumerator(); try { while (V_10.MoveNext()) { V_11 = V_10.get_Current(); dummyVar2 = this.patternsContext.get_VariableToSingleAssignmentMap().Remove(V_11); dummyVar3 = this.patternsContext.get_VariableToDefineUseCountContext().Remove(V_11); } } finally { ((IDisposable)V_10).Dispose(); } return(V_0); }
public override ICodeNode VisitObjectCreationExpression(ObjectCreationExpression node) { if (this.state != 2 || node.get_Arguments() == null || node.get_Arguments().get_Count() != 2 || node.get_Arguments().get_Item(0).get_CodeNodeType() != 26 || node.get_Arguments().get_Item(1).get_CodeNodeType() != 20 || !this.delegateCopies.Contains((node.get_Arguments().get_Item(0) as VariableReferenceExpression).get_Variable())) { return(this.VisitObjectCreationExpression(node)); } V_0 = node.get_Constructor().get_DeclaringType().Resolve(); if (V_0 == null || V_0.get_BaseType() == null || String.op_Inequality(V_0.get_BaseType().get_FullName(), "System.MulticastDelegate")) { return(this.VisitObjectCreationExpression(node)); } V_1 = (node.get_Arguments().get_Item(1) as MethodReferenceExpression).get_Method(); V_2 = (node.get_Arguments().get_Item(1) as MethodReferenceExpression).get_MethodDefinition(); stackVariable62 = new MethodSpecificContext(V_2.get_Body()); V_3 = new DecompilationContext(stackVariable62, this.context.get_TypeContext(), this.context.get_ModuleContext(), this.context.get_AssemblyContext(), this.context.get_Language()); stackVariable62.set_FieldToExpression(this.fieldDefToAssignedValueMap); V_4 = V_2.get_Body().DecompileLambda(this.context.get_Language(), V_3); if (V_4.get_Statements().get_Count() == 1 && V_4.get_Statements().get_Item(0).get_CodeNodeType() == 5 && (V_4.get_Statements().get_Item(0) as ExpressionStatement).get_Expression().get_CodeNodeType() == 57) { V_8 = (V_4.get_Statements().get_Item(0) as ExpressionStatement).get_Expression() as ReturnExpression; V_9 = new ShortFormReturnExpression(V_8.get_Value(), V_8.get_MappedInstructions()); V_4 = new BlockStatement(); V_4.get_Statements().Add(new ExpressionStatement(V_9)); } this.context.get_MethodContext().get_VariableDefinitionToNameMap().AddRange <VariableDefinition, string>(V_3.get_MethodContext().get_VariableDefinitionToNameMap()); this.context.get_MethodContext().get_VariableNamesCollection().UnionWith(V_3.get_MethodContext().get_VariableNamesCollection()); this.context.get_MethodContext().AddInnerMethodParametersToContext(V_3.get_MethodContext()); this.context.get_MethodContext().get_GotoStatements().AddRange(V_3.get_MethodContext().get_GotoStatements()); this.context.get_MethodContext().get_GotoLabels().AddRange <string, Statement>(V_3.get_MethodContext().get_GotoLabels()); V_5 = new ExpressionCollection(); V_6 = LambdaExpressionsHelper.HasAnonymousParameter(V_2.get_Parameters()); V_10 = V_2.get_Parameters().GetEnumerator(); try { while (V_10.MoveNext()) { V_11 = V_10.get_Current(); V_5.Add(new LambdaParameterExpression(V_11, !V_6, null)); } } finally { V_10.Dispose(); } this.delegatesFound.Add(V_4); stackVariable157 = new LambdaExpression(V_5, V_4, V_2.IsAsync(), V_2.IsFunction(), V_1.get_Parameters(), false, node.get_Arguments().get_Item(1).get_MappedInstructions()); stackVariable157.set_ExpressionType(V_0); V_7 = stackVariable157; return(new DelegateCreationExpression(node.get_Constructor().get_DeclaringType(), V_7, node.get_Arguments().get_Item(0), node.get_MappedInstructions())); }
private void RemoveBlockingEdges(List <IntervalConstruct> intervals) { V_0 = new IntervalConstruct(intervals.get_Item(0)); V_5 = 1; while (V_5 < intervals.get_Count()) { dummyVar0 = V_0.get_Children().Add(intervals.get_Item(V_5)); V_5 = V_5 + 1; } V_1 = DFSTBuilder.BuildTree(V_0); V_2 = V_1.get_BackEdges().FirstOrDefault <DFSTEdge>(); if (V_2 == null) { V_2 = V_1.get_CrossEdges().FirstOrDefault <DFSTEdge>(); } V_3 = V_2.get_Start().get_Construct() as IntervalConstruct; V_4 = V_2.get_End().get_Construct() as IntervalConstruct; V_6 = V_4.get_Entry().get_SameParentPredecessors().GetEnumerator(); try { while (V_6.MoveNext()) { V_7 = (ILogicalConstruct)V_6.get_Current(); if (!V_3.get_Children().Contains(V_7)) { continue; } V_8 = V_7; V_9 = V_4.get_Entry() as ILogicalConstruct; if (this.removedEdges.TryGetValue(V_8, out V_10) && V_10.Contains(V_9)) { continue; } this.MarkAsGotoEdge(V_8, V_9); goto Label0; } } finally { ((IDisposable)V_6).Dispose(); } Label0: return; }
public override WriterContext GetWriterContext(IMemberDefinition member, ILanguage language) { if (member as TypeDefinition == null || member != Utilities.GetOuterMostDeclaringType(member)) { V_1 = this.GetDecompiledType(member, language); V_0 = this.GetTypeContext(V_1, language); } else { V_7 = member as TypeDefinition; V_8 = this.GetNestedDecompiledTypes(V_7, language); V_0 = this.GetTypeContext(V_7, language, V_8); this.AddTypeContextsToCache(V_8, V_7, language); if (!V_8.TryGetValue(V_7.get_FullName(), out V_1)) { throw new Exception("Decompiled type not found in decompiled types cache."); } } V_2 = new TypeSpecificContext(V_0.get_CurrentType(), V_0.get_MethodDefinitionToNameMap(), V_0.get_BackingFieldToNameMap(), V_0.get_UsedNamespaces(), new HashSet <string>(), V_0.get_AssignmentData(), V_0.get_AutoImplementedProperties(), V_0.get_AutoImplementedEvents(), V_0.get_ExplicitlyImplementedMembers(), V_0.get_ExceptionWhileDecompiling(), V_0.get_GeneratedFilterMethods(), V_0.get_GeneratedMethodDefinitionToNameMap()); if (V_2.get_GeneratedFilterMethods().get_Count() > 0) { this.AddGeneratedFilterMethodsToDecompiledType(V_1, V_2, language); } V_3 = new Dictionary <string, MethodSpecificContext>(); V_4 = new Dictionary <string, Statement>(); V_9 = V_1.get_DecompiledMembers().GetEnumerator(); try { while (V_9.MoveNext()) { V_10 = V_9.get_Current(); V_3.Add(V_10.get_Key(), V_10.get_Value().get_Context()); V_4.Add(V_10.get_Key(), V_10.get_Value().get_Statement()); } } finally { ((IDisposable)V_9).Dispose(); } V_5 = Utilities.GetDeclaringTypeOrSelf(member); stackVariable66 = this.GetAssemblyContext(V_5.get_Module().get_Assembly(), language); V_6 = this.GetModuleContext(V_5.get_Module(), language); return(new WriterContext(stackVariable66, V_6, V_2, V_3, V_4)); }
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; }
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; }
private void Preprocess() { V_0 = 0; V_1 = new Dictionary <ParameterDefinition, string>(); V_2 = this.methodContext.get_ParameterDefinitionToNameMap().GetEnumerator(); try { while (V_2.MoveNext()) { V_3 = V_2.get_Current(); V_4 = V_3.get_Key(); V_5 = V_3.get_Value(); V_6 = V_5; V_7 = !V_6.IsValidIdentifier(); while (V_7 || this.HasMethodParameterWithSameName(V_6)) { V_7 = false; stackVariable22 = V_0; V_0 = stackVariable22 + 1; V_8 = stackVariable22; V_6 = String.Concat("argument", V_8.ToString()); } if (!String.op_Inequality(V_6, V_5)) { continue; } V_1.Add(V_4, V_6); } } finally { ((IDisposable)V_2).Dispose(); } V_2 = V_1.GetEnumerator(); try { while (V_2.MoveNext()) { V_9 = V_2.get_Current(); this.methodContext.get_ParameterDefinitionToNameMap().set_Item(V_9.get_Key(), V_9.get_Value()); } } finally { ((IDisposable)V_2).Dispose(); } V_10 = this.methodContext.get_Body().get_Method().get_Parameters().GetEnumerator(); try { while (V_10.MoveNext()) { V_11 = V_10.get_Current(); V_12 = V_11.get_Name(); if (String.IsNullOrEmpty(V_12)) { V_12 = this.GetNameByType(V_11.get_ParameterType()); } this.methodContext.get_ParameterDefinitionToNameMap().Add(V_11, V_12); } } finally { V_10.Dispose(); } if (this.methodContext.get_Method().get_IsSetter() && this.methodContext.get_Method().get_Parameters().get_Count() == 1) { V_13 = this.methodContext.get_Method().get_Parameters().get_Item(0); this.methodContext.get_ParameterDefinitionToNameMap().set_Item(V_13, "value"); } V_14 = this.methodContext.get_Body().get_Variables().GetEnumerator(); try { while (V_14.MoveNext()) { V_15 = V_14.get_Current(); if (!this.methodContext.get_ParameterDefinitionToNameMap().ContainsValue(V_15.get_Name())) { continue; } dummyVar0 = this.methodContext.get_VariablesToRename().Add(V_15); } } finally { V_14.Dispose(); } V_16 = this.methodContext.get_VariableDefinitionToNameMap().GetEnumerator(); try { while (V_16.MoveNext()) { V_17 = V_16.get_Current(); if (!this.methodContext.get_ParameterDefinitionToNameMap().ContainsValue(V_17.get_Value())) { continue; } dummyVar1 = this.methodContext.get_VariablesToRename().Add(V_17.get_Key()); } } finally { ((IDisposable)V_16).Dispose(); } return; }
private ICodeNode FixBranchingExpression(Expression expression, Instruction branch) { if (branch.get_OpCode().get_Code() == 57) { stackVariable5 = true; } else { V_5 = branch.get_OpCode(); stackVariable5 = V_5.get_Code() == 44; } V_0 = stackVariable5; V_1 = expression.get_ExpressionType(); V_3 = 9; stackVariable10 = new Instruction[1]; stackVariable10[0] = branch; V_4 = stackVariable10; if (V_0) { V_3 = 10; } if (String.op_Equality(V_1.get_Name(), "Boolean") || V_1.get_Name().Contains("Boolean ")) { if (V_0) { V_6 = expression; } else { V_6 = Negator.Negate(expression, this.typeSystem); } if (expression as SafeCastExpression == null) { V_7 = new UnaryExpression(11, V_6, V_4); } else { V_7 = new BinaryExpression(V_3, expression, this.GetLiteralExpression(false, null), this.typeSystem, V_4, false); } return V_7; } if (String.op_Equality(V_1.get_Name(), "Char")) { V_2 = new BinaryExpression(V_3, expression, this.GetLiteralExpression('\0', null), this.typeSystem, V_4, false); V_2.set_ExpressionType(this.typeSystem.get_Boolean()); } if (V_1.get_IsPrimitive()) { V_2 = new BinaryExpression(V_3, expression, this.GetLiteralExpression(0, null), this.typeSystem, V_4, false); V_2.set_ExpressionType(this.typeSystem.get_Boolean()); } else { V_8 = V_1.Resolve(); if (V_8 == null || !V_8.get_IsEnum() || V_1.get_IsArray()) { V_2 = new BinaryExpression(V_3, expression, this.GetLiteralExpression(null, null), this.typeSystem, V_4, false); V_2.set_ExpressionType(this.typeSystem.get_Boolean()); } else { V_9 = null; V_10 = V_8.get_Fields().GetEnumerator(); try { while (V_10.MoveNext()) { V_11 = V_10.get_Current(); if (V_11.get_Constant() == null || V_11.get_Constant().get_Value() == null || !V_11.get_Constant().get_Value().Equals(0)) { continue; } V_9 = V_11; goto Label0; } } finally { V_10.Dispose(); } Label0: if (V_9 != null) { V_2 = new BinaryExpression(V_3, expression, new EnumExpression(V_9, null), this.typeSystem, V_4, false); V_2.set_ExpressionType(this.typeSystem.get_Boolean()); } else { V_2 = new BinaryExpression(V_3, expression, this.GetLiteralExpression(0, null), this.typeSystem, V_4, false); V_2.set_ExpressionType(this.typeSystem.get_Boolean()); } } } return V_2; }
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); }
private void ProcessCurrentNode(YieldExceptionHandlerInfo handlerInfo, Queue <ILogicalConstruct> bfsQueue, ILogicalConstruct currentNode) { if (currentNode as CFGBlockLogicalConstruct == null) { if (currentNode as TryFinallyLogicalConstruct != null && this.createdConstructsToIntervalMap.TryGetValue(currentNode as TryFinallyLogicalConstruct, out V_10) && V_10.get_TryStates().IsProperSupersetOf(handlerInfo.get_TryStates())) { throw new Exception("This try/finally construct cannot be nested in the current construct"); } } else { V_0 = currentNode as CFGBlockLogicalConstruct; V_1 = 0; while (V_1 < V_0.get_LogicalConstructExpressions().get_Count()) { V_2 = V_0.get_LogicalConstructExpressions().get_Item(V_1); if (!this.TryGetStateAssignValue(V_2, out V_3)) { if (handlerInfo.get_HandlerType() == YieldExceptionHandlerType.Method && V_2.get_CodeNodeType() == 19 && (object)(V_2 as MethodInvocationExpression).get_MethodExpression().get_MethodDefinition() == (object)handlerInfo.get_FinallyMethodDefinition()) { if (V_0.get_LogicalConstructExpressions().get_Count() == 1) { if (this.newFinallyBody == null) { this.newFinallyBody = V_0; } dummyVar0 = this.finallyBlocks.Add(this.newFinallyBody); dummyVar1 = this.orderedCFGNodes.Remove(V_0); return; } if (V_1 != 0) { if (V_1 >= V_0.get_LogicalConstructExpressions().get_Count() - 1) { V_8 = LogicalFlowUtilities.SplitCFGBlockAt(this.logicalContext, V_0, V_1); dummyVar3 = this.newTryBody.Add(V_8.get_Key()); V_4 = V_8.get_Value(); dummyVar4 = this.orderedCFGNodes.Remove(V_0); } else { V_6 = LogicalFlowUtilities.SplitCFGBlockAt(this.logicalContext, V_0, V_1); dummyVar2 = this.newTryBody.Add(V_6.get_Key()); V_7 = LogicalFlowUtilities.SplitCFGBlockAt(this.logicalContext, V_6.get_Value(), 1); V_4 = V_7.get_Key(); this.orderedCFGNodes.set_Item(this.orderedCFGNodes.IndexOf(V_0), V_7.get_Value()); } } else { V_5 = LogicalFlowUtilities.SplitCFGBlockAt(this.logicalContext, V_0, V_1 + 1); V_4 = V_5.get_Key(); this.orderedCFGNodes.set_Item(this.orderedCFGNodes.IndexOf(V_0), V_5.get_Value()); } if (this.newFinallyBody == null) { this.newFinallyBody = V_4; } dummyVar5 = this.finallyBlocks.Add(V_4); return; } } else { if (!handlerInfo.get_TryStates().Contains(V_3)) { if (handlerInfo.get_HandlerType() == YieldExceptionHandlerType.Method || !this.TryProcessConditionalDisposeHandler(handlerInfo, V_0)) { throw new Exception("Invalid state value"); } return; } } V_1 = V_1 + 1; } } dummyVar6 = this.newTryBody.Add(currentNode); V_11 = currentNode.get_SameParentSuccessors().GetEnumerator(); try { while (V_11.MoveNext()) { V_12 = (ILogicalConstruct)V_11.get_Current(); bfsQueue.Enqueue(V_12); } } finally { ((IDisposable)V_11).Dispose(); } return; }
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); }
private bool TryMatchInternal(StatementCollection statements, int startIndex, out Statement result) { result = null; if (startIndex + 1 >= statements.get_Count()) { return(false); } if (statements.get_Item(startIndex).get_CodeNodeType() != 5 || statements.get_Item(startIndex + 1).get_CodeNodeType() != 3) { return(false); } V_0 = statements.get_Item(startIndex) as ExpressionStatement; if (V_0.get_Expression().get_CodeNodeType() != 24) { return(false); } V_1 = V_0.get_Expression() as BinaryExpression; if (V_1.get_Left().get_CodeNodeType() != 26 || V_1.get_Right().get_CodeNodeType() != 48) { return(false); } V_2 = V_1.get_Left() as VariableReferenceExpression; V_3 = V_1.get_Right() as EventReferenceExpression; V_4 = statements.get_Item(startIndex + 1) as IfStatement; if (V_4.get_Then() == null || V_4.get_Else() != null || V_4.get_Condition().get_CodeNodeType() != 24) { return(false); } V_5 = V_4.get_Condition() as BinaryExpression; if (V_5.get_Left().get_CodeNodeType() != 26 || V_5.get_Right().get_CodeNodeType() != 22 || V_5.get_Operator() != 10) { return(false); } V_6 = V_5.get_Left() as VariableReferenceExpression; if ((object)V_2.get_Variable() != (object)V_6.get_Variable()) { return(false); } if ((V_5.get_Right() as LiteralExpression).get_Value() != null) { return(false); } V_7 = V_4.get_Then().get_Statements(); if (V_7.get_Count() != 1 || V_7.get_Item(0).get_CodeNodeType() != 5) { return(false); } V_8 = V_7.get_Item(0) as ExpressionStatement; if (V_8.get_Expression().get_CodeNodeType() != 51) { return(false); } V_9 = V_8.get_Expression() as DelegateInvokeExpression; if (V_9.get_Target() == null || V_9.get_Target().get_CodeNodeType() != 26) { return(false); } V_10 = V_9.get_Target() as VariableReferenceExpression; if ((object)V_10.get_Variable() != (object)V_2.get_Variable()) { return(false); } V_11 = new List <Instruction>(); V_11.AddRange(V_0.get_UnderlyingSameMethodInstructions()); V_11.AddRange(V_5.get_UnderlyingSameMethodInstructions()); V_11.AddRange(V_9.get_MappedInstructions()); V_11.AddRange(V_10.get_UnderlyingSameMethodInstructions()); result = new ExpressionStatement(new RaiseEventExpression(V_3.get_Event(), V_9.get_InvokeMethodReference(), V_9.get_Arguments(), V_11)); return(true); }
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()); }
internal ICollection <ClassHierarchyNode> BuildHierarchy(HashSet <VariableReference> resolvedVariables) { V_1 = this.methodContext.get_StackData().get_VariableToDefineUseInfo().GetEnumerator(); try { while (V_1.MoveNext()) { V_2 = V_1.get_Current(); V_3 = V_2.get_Key(); if (resolvedVariables.Contains(V_3) || !this.ShouldConsiderVariable(V_3)) { continue; } V_4 = this.GetVariableNode(V_3); dummyVar0 = this.resultingGraph.Add(V_4); V_5 = V_2.get_Value().get_DefinedAt().GetEnumerator(); try { while (V_5.MoveNext()) { V_6 = V_5.get_Current(); this.OnPhiVariableAssigned(V_6, V_4); } } finally { ((IDisposable)V_5).Dispose(); } V_7 = V_2.get_Value().get_UsedAt().GetEnumerator(); try { while (V_7.MoveNext()) { V_8 = V_7.get_Current(); this.OnPhiVariableUsed(V_8, V_4); } } finally { ((IDisposable)V_7).Dispose(); } } } finally { ((IDisposable)V_1).Dispose(); } this.RemoveImpossibleEdges(); V_0 = new HashSet <ClassHierarchyNode>(); V_9 = this.resultingGraph.GetEnumerator(); try { while (V_9.MoveNext()) { V_10 = V_9.get_Current(); if (!V_10.get_IsHardNode()) { continue; } dummyVar1 = V_0.Add(V_10); } } finally { ((IDisposable)V_9).Dispose(); } this.BuildUpHardNodesHierarchy(V_0); return(this.resultingGraph); }
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; }