protected virtual bool CheckTheLoop(WhileStatement theWhile, VariableReference forVariable) { if (theWhile == null || theWhile.Body.Statements.Count < 2) { return false; } VariableFinder variableFinder = new VariableFinder(forVariable); if (!variableFinder.FindVariable(theWhile.Condition)) { return false; } ExpressionStatement incrementCandidate = theWhile.Body.Statements[theWhile.Body.Statements.Count - 1] as ExpressionStatement; VariableReference incrementVariable; if (incrementCandidate == null || !TryGetAssignedVariable(incrementCandidate, out incrementVariable) || forVariable != incrementVariable) { return false; } ContinueFinder continueFinder = new ContinueFinder(); return !continueFinder.FindContinue(theWhile.Body); }
private void FixExpression() { if (variableReference == null) { return; } VariableFinder finder = new VariableFinder(this.variableReference); BinaryExpression assignExpression = this.expression as BinaryExpression; if (assignExpression.Right.IsReferenceExpression() && !finder.FindVariable(theTry.Try)) { List<Instruction> instructions = new List<Instruction>(assignExpression.Left.UnderlyingSameMethodInstructions); instructions.AddRange(assignExpression.MappedInstructions); this.expression = assignExpression.Right.CloneAndAttachInstructions(instructions); } }