private bool CheckIfStatementStructure(IfStatement theIf) { if (theIf.get_Else() == null && theIf.get_Condition().get_CodeNodeType() == 24) { if (theIf.get_Then().get_Statements().get_Count() == 1 && theIf.get_Then().get_Statements().get_Item(0).get_CodeNodeType() == 5) { this.cachingVersion = 0; return(true); } if (theIf.get_Then().get_Statements().get_Count() == 3) { V_0 = theIf.get_Then().get_Statements().get_Item(0) as ExpressionStatement; if (V_0 == null) { return(false); } V_1 = V_0.get_Expression() as BinaryExpression; if (V_1 == null) { return(false); } if (!V_1.get_IsAssignmentExpression() || V_1.get_Left().get_CodeNodeType() != 26 || V_1.get_Right().get_CodeNodeType() != 26 || !this.initializationsToRemove.ContainsKey((V_1.get_Right() as VariableReferenceExpression).get_Variable())) { return(false); } if (theIf.get_Then().get_Statements().get_Item(1).get_CodeNodeType() != 5) { return(false); } V_2 = theIf.get_Then().get_Statements().get_Item(2) as ExpressionStatement; if (V_2 == null) { return(false); } V_3 = V_2.get_Expression() as BinaryExpression; if (V_3 == null) { return(false); } if (!V_3.get_IsAssignmentExpression() || V_3.get_Left().get_CodeNodeType() != 30 || V_3.get_Right().get_CodeNodeType() != 26 || !this.initializationsToRemove.ContainsKey((V_3.get_Right() as VariableReferenceExpression).get_Variable())) { return(false); } this.cachingVersion = 1; return(true); } } return(false); }
private bool CheckVariableCaching(IfStatement theIf) { V_0 = theIf.get_Condition() as BinaryExpression; if (V_0.get_Operator() != 9 || V_0.get_Right().get_CodeNodeType() != 22 || (V_0.get_Right() as LiteralExpression).get_Value() != null) { return(false); } V_1 = (V_0.get_Left() as VariableReferenceExpression).get_Variable(); if (!this.initializationsToRemove.ContainsKey(V_1)) { return(false); } if (this.cachingVersion == RemoveDelegateCachingStep.DelegateCachingVersion.V1) { stackVariable25 = 0; } else { stackVariable25 = 1; } V_2 = stackVariable25; V_3 = (theIf.get_Then().get_Statements().get_Item(V_2) as ExpressionStatement).get_Expression() as BinaryExpression; if (V_3 == null || !V_3.get_IsAssignmentExpression() || V_3.get_Left().get_CodeNodeType() != 26 || (object)(V_3.get_Left() as VariableReferenceExpression).get_Variable() != (object)V_1) { return(false); } if (this.variableToReplacingExpressionMap.ContainsKey(V_1)) { throw new Exception("A caching variable cannot be assigned more than once."); } V_4 = V_1.get_VariableType().Resolve(); if (V_4 == null || V_4.get_BaseType() == null || String.op_Inequality(V_4.get_BaseType().get_FullName(), "System.MulticastDelegate")) { return(false); } this.variableToReplacingExpressionMap.set_Item(V_1, V_3.get_Right()); return(true); }
public override void VisitBoxExpression(BoxExpression node) { V_0 = new Stack <Expression>(); V_0.Push(this.parentExpressions.Pop()); if (this.parentExpressions.get_Count() > 0) { V_1 = this.parentExpressions.Peek(); if (V_1 as MemberReferenceExpresion == null) { if (V_1 as MethodInvocationExpression != null || V_1 as FieldReferenceExpression != null || V_1 as PropertyReferenceExpression != null) { node.set_IsAutoBox(true); } else { if (V_1 as BinaryExpression == null) { if (V_1 as ReturnExpression == null) { if (V_1 as YieldReturnExpression != null && (V_1 as YieldReturnExpression).get_Expression().Equals(node)) { node.set_IsAutoBox(true); } } else { if (!String.op_Equality(this.context.get_Method().get_ReturnType().get_FullName(), "System.Object")) { V_4 = node.get_BoxedExpression().get_ExpressionType().Resolve(); if (V_4 != null && V_4.get_IsValueType()) { node.set_IsAutoBox(true); } } else { node.set_IsAutoBox(true); } } } else { V_3 = V_1 as BinaryExpression; if (V_3.get_IsAssignmentExpression() && V_3.get_Right().Equals(node)) { node.set_IsAutoBox(true); } if (V_3.get_IsComparisonExpression() && node.get_BoxedAs().get_IsGenericParameter()) { if (V_3.get_Left() == node && V_3.get_Right() as LiteralExpression != null && (V_3.get_Right() as LiteralExpression).get_Value() == null) { node.set_IsAutoBox(true); } if (V_3.get_Right() == node && V_3.get_Left() as LiteralExpression != null && (V_3.get_Left() as LiteralExpression).get_Value() == null) { node.set_IsAutoBox(true); } } } } } else { V_2 = this.parentExpressions.Pop() as MemberReferenceExpresion; V_0.Push(V_2); if (V_2.get_Member() as MethodReference != null) { node.set_IsAutoBox(true); } } } while (V_0.get_Count() > 0) { this.parentExpressions.Push(V_0.Pop()); } this.VisitBoxExpression(node); return; }