private bool TryMatchInternal(StatementCollection statements, int startIndex, out Statement result) { result = null; if (statements.get_Count() < startIndex + 2) { return(false); } if (statements.get_Item(startIndex).get_CodeNodeType() != 5 || statements.get_Item(startIndex + 1).get_CodeNodeType() != 3) { return(false); } if (!String.IsNullOrEmpty(statements.get_Item(startIndex + 1).get_Label())) { return(false); } V_3 = (statements.get_Item(startIndex) as ExpressionStatement).get_Expression() as BinaryExpression; if (!this.IsAssignToVariableExpression(V_3, out V_0)) { return(false); } V_1 = V_3.get_Right(); V_4 = statements.get_Item(startIndex + 1) as IfStatement; if (this.ContainsDummyAssignment(V_4.get_Then(), V_0)) { stackVariable50 = 1; } else { stackVariable50 = 0; } V_5 = stackVariable50; if (V_4.get_Else() != null || V_4.get_Then().get_Statements().get_Count() != 1 + V_5 || V_4.get_Then().get_Statements().get_Item(V_5).get_CodeNodeType() != 5 || !String.IsNullOrEmpty(V_4.get_Then().get_Statements().get_Item(V_5).get_Label())) { return(false); } V_6 = V_4.get_Condition() as BinaryExpression; if (V_6 == null || V_6.get_Operator() != 9 || V_6.get_Left().get_CodeNodeType() != 26 || (object)(V_6.get_Left() as VariableReferenceExpression).get_Variable() != (object)V_0 || V_6.get_Right().get_CodeNodeType() != 22 || (V_6.get_Right() as LiteralExpression).get_Value() != null) { return(false); } V_7 = (V_4.get_Then().get_Statements().get_Item(V_5) as ExpressionStatement).get_Expression() as BinaryExpression; if (V_7 == null || !this.IsAssignToVariableExpression(V_7, out V_8) || (object)V_8 != (object)V_0) { return(false); } V_2 = V_7.get_Right(); if (!V_1.get_HasType() || !V_2.get_HasType() || String.op_Inequality(V_1.get_ExpressionType().get_FullName(), V_2.get_ExpressionType().get_FullName())) { return(false); } V_9 = new BinaryExpression(27, V_1, V_2, this.typeSystem, null, false); V_10 = new BinaryExpression(26, new VariableReferenceExpression(V_0, null), V_9, this.typeSystem, null, false); stackVariable150 = new ExpressionStatement(V_10); stackVariable150.set_Parent(statements.get_Item(startIndex).get_Parent()); result = stackVariable150; this.FixContext(V_0.Resolve(), 1, V_5 + 1, result as ExpressionStatement); 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); }
private void ProcessLogicalConstruct(ILogicalConstruct theConstruct) { if (theConstruct as BlockLogicalConstruct == null) { if (theConstruct as ExceptionHandlingLogicalConstruct == null) { if (theConstruct as IfLogicalConstruct == null) { if (theConstruct as LoopLogicalConstruct == null) { if (theConstruct as SwitchLogicalConstruct == null) { if (theConstruct as ConditionLogicalConstruct != null) { this.ProcessLogicalConstruct((theConstruct as ConditionLogicalConstruct).get_FirstBlock()); } } else { V_6 = theConstruct as SwitchLogicalConstruct; V_7 = V_6.get_ConditionCases(); V_2 = 0; while (V_2 < (int)V_7.Length) { this.ProcessLogicalConstruct(V_7[V_2]); V_2 = V_2 + 1; } this.ProcessLogicalConstruct(V_6.get_DefaultCase()); } } else { V_5 = theConstruct as LoopLogicalConstruct; this.ProcessLogicalConstruct(V_5.get_LoopBodyBlock()); this.ProcessLogicalConstruct(V_5.get_LoopCondition()); } } else { V_4 = theConstruct as IfLogicalConstruct; this.ProcessLogicalConstruct(V_4.get_Then()); if (V_4.get_Else() != null) { this.ProcessLogicalConstruct(V_4.get_Else()); } } } else { this.ProcessLogicalConstruct((theConstruct as ExceptionHandlingLogicalConstruct).get_Try()); if (theConstruct as TryCatchFilterLogicalConstruct == null) { if (theConstruct as TryFaultLogicalConstruct == null) { if (theConstruct as TryFinallyLogicalConstruct != null) { this.ProcessLogicalConstruct((theConstruct as TryFinallyLogicalConstruct).get_Finally()); } } else { this.ProcessLogicalConstruct((theConstruct as TryFaultLogicalConstruct).get_Fault()); } } else { V_1 = (theConstruct as TryCatchFilterLogicalConstruct).get_Handlers(); V_2 = 0; while (V_2 < (int)V_1.Length) { V_3 = V_1[V_2]; if (V_3.get_HandlerType() != 1) { if (V_3.get_HandlerType() == FilteringExceptionHandlerType.Catch) { this.ProcessLogicalConstruct(V_3 as ExceptionHandlingBlockCatch); } } else { this.ProcessLogicalConstruct((V_3 as ExceptionHandlingBlockFilter).get_Filter()); this.ProcessLogicalConstruct((V_3 as ExceptionHandlingBlockFilter).get_Handler()); } V_2 = V_2 + 1; } } } } else { V_0 = (ILogicalConstruct)theConstruct.get_Entry(); while (V_0 != null) { this.ProcessLogicalConstruct(V_0); if (this.visitedConstructs.Contains(V_0.get_FollowNode())) { V_0.set_CFGFollowNode(null); } V_0 = V_0.get_FollowNode(); } this.ProcessGotoFlowConstructs(theConstruct as BlockLogicalConstruct); } dummyVar0 = this.visitedConstructs.Add(theConstruct); return; }