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, out int replacedStatementsCount, out VariableDefinition xVariableDef) { result = null; replacedStatementsCount = 0; xVariableDef = null; if (statements.get_Count() < 1 || statements.get_Item(startIndex).get_CodeNodeType() != 5) { return(false); } V_2 = (statements.get_Item(startIndex) as ExpressionStatement).get_Expression() as BinaryExpression; if (!this.IsAssignToVariableExpression(V_2, out V_0) || !this.methodContext.get_StackData().get_VariableToDefineUseInfo().ContainsKey(V_0.Resolve())) { return(false); } V_1 = V_2.get_Right(); V_3 = startIndex + 1; while (V_3 < statements.get_Count()) { V_5 = statements.get_Item(V_3); if (V_5.get_CodeNodeType() != 5 || !String.IsNullOrEmpty(V_5.get_Label())) { break; } V_6 = (V_5 as ExpressionStatement).get_Expression() as BinaryExpression; if (V_6 == null || !V_6.get_IsAssignmentExpression() || V_6.get_Right().get_CodeNodeType() != 26 || (object)(V_6.get_Right() as VariableReferenceExpression).get_Variable() != (object)V_0) { break; } if (V_6.get_Left().get_CodeNodeType() == 30) { return(false); } if (V_6.get_Left().get_CodeNodeType() == 26) { V_7 = (V_6.get_Left() as VariableReferenceExpression).get_Variable().Resolve(); if (V_7 == V_0) { return(false); } dummyVar0 = this.variablesToRemove.Add(V_7); } V_1 = new BinaryExpression(26, V_6.get_Left(), V_1, this.typeSystem, null, false); V_3 = V_3 + 1; } replacedStatementsCount = V_3 - startIndex; if (replacedStatementsCount == 1) { return(false); } V_4 = new BinaryExpression(26, new VariableReferenceExpression(V_0, null), V_1, this.typeSystem, null, false); stackVariable66 = new ExpressionStatement(V_4); stackVariable66.set_Parent(statements.get_Item(startIndex).get_Parent()); result = stackVariable66; xVariableDef = V_0.Resolve(); return(true); }
private void ReplaceIfWith(IfStatement theIf, BlockStatement statementBlock) { if (!this.CanReplaceIf(statementBlock)) { throw new Exception("Invalid IsEvent construction"); } V_0 = (statementBlock.get_Statements().get_Item(1) as ExpressionStatement).get_Expression() as DynamicMemberReferenceExpression; if (V_0 == null) { V_0 = ((statementBlock.get_Statements().get_Item(1) as ExpressionStatement).get_Expression() as BinaryExpression).get_Right() as DynamicMemberReferenceExpression; } if (V_0.get_MemberName() == null || !V_0.get_IsMethodInvocation() || V_0.get_IsGenericMethod() || V_0.get_InvocationArguments().get_Count() != 1) { throw new Exception("Invalid IsEvent construction"); } V_1 = V_0.get_MemberName().IndexOf('\u005F'); if (V_1 != 3 && V_1 != 6) { throw new Exception("Invalid IsEvent construction"); } V_2 = new DynamicMemberReferenceExpression(V_0.get_Target(), V_0.get_MemberName().Substring(V_1 + 1), V_0.get_ExpressionType(), V_0.get_MappedInstructions()); if (V_1 == 3) { stackVariable44 = 2; } else { stackVariable44 = 4; } stackVariable56 = new BinaryExpression(stackVariable44, V_2, V_0.get_InvocationArguments().get_Item(0), V_2.get_ExpressionType(), this.typeSystem, null, false); V_3 = (BlockStatement)theIf.get_Parent(); V_4 = V_3.get_Statements().IndexOf(theIf); V_5 = new ExpressionStatement(stackVariable56); V_5.set_Parent(V_3); V_3.get_Statements().set_Item(V_4, V_5); if (statementBlock.get_Statements().get_Count() == 3) { V_3.AddStatementAt(V_4 + 1, statementBlock.get_Statements().get_Item(2).Clone()); } return; }
public bool TryMatchInternal(IfStatement theIfStatement, out Statement result) { result = null; if (theIfStatement == null) { return(false); } V_0 = null; V_1 = null; if (theIfStatement.get_Else() == null || theIfStatement.get_Then().get_Statements().get_Count() != 1 || theIfStatement.get_Else().get_Statements().get_Count() != 1 || theIfStatement.get_Then().get_Statements().get_Item(0).get_CodeNodeType() != 5 || theIfStatement.get_Else().get_Statements().get_Item(0).get_CodeNodeType() != 5) { return(false); } V_4 = (theIfStatement.get_Then().get_Statements().get_Item(0) as ExpressionStatement).get_Expression() as BinaryExpression; V_5 = (theIfStatement.get_Else().get_Statements().get_Item(0) as ExpressionStatement).get_Expression() as BinaryExpression; if (!this.IsAssignToVariableExpression(V_4, out V_1) || !this.IsAssignToVariableExpression(V_5, out V_0)) { return(false); } if ((object)V_0 != (object)V_1) { return(false); } if (!this.ShouldInlineExpressions(V_4, V_5)) { return(false); } V_2 = this.GetRightExpressionMapped(V_4); V_3 = this.GetRightExpressionMapped(V_5); V_6 = new ConditionExpression(theIfStatement.get_Condition(), V_2, V_3, null); V_7 = new BinaryExpression(26, new VariableReferenceExpression(V_0, null), V_6, this.typeSystem, null, false); stackVariable87 = new ExpressionStatement(V_7); stackVariable87.set_Parent(theIfStatement.get_Parent()); result = stackVariable87; this.FixContext(V_0.Resolve(), 1, 0, result as ExpressionStatement); return(true); }