Inheritance: Statement, IWhileDoStatement
Exemple #1
0
 public override void TraverseChildren(IBlockStatement block) {
   Contract.Assume(block is BlockStatement);
   var decompiledBlock = (BlockStatement)block;
   var statements = decompiledBlock.Statements;
   for (int i = 0; i < statements.Count-3; i++) {
     var gotoCondition = statements[i] as GotoStatement;
     if (gotoCondition == null) continue;
     var gotosThatTarget = this.gotosThatTarget[(uint)gotoCondition.TargetStatement.Label.UniqueKey];
     Contract.Assume(gotosThatTarget != null && gotosThatTarget.Count >= 1);
     if (gotosThatTarget.Count != 1) continue;
     var conditionalGotoBody = LookForCondition(statements, i+1, gotoCondition.TargetStatement);
     if (conditionalGotoBody == null || !(conditionalGotoBody.FalseBranch is EmptyStatement)) continue;
     var gotoBody = conditionalGotoBody.TrueBranch as GotoStatement;
     if (gotoBody == null) continue;
     Contract.Assume(i < statements.Count-3);
     if (!IsOrContainsAsFirstStatement(statements[i+1], gotoBody.TargetStatement)) continue;
     gotosThatTarget.Remove(gotoCondition);
     gotosThatTarget = this.gotosThatTarget[(uint)gotoBody.TargetStatement.Label.UniqueKey];
     Contract.Assume(gotosThatTarget != null && gotosThatTarget.Count >= 1);
     gotosThatTarget.Remove(gotoBody);
     var loopBody = ExtractBlock(statements, i+1, gotoCondition.TargetStatement);
     var whileLoop = new WhileDoStatement() { Body = loopBody, Condition = conditionalGotoBody.Condition };
     Contract.Assume(i < statements.Count);
     statements[i] = whileLoop;
   }
   base.TraverseChildren(block);
 }
Exemple #2
0
 /// <summary>
 /// Visits the specified while do statement.
 /// </summary>
 /// <param name="whileDoStatement">The while do statement.</param>
 public override void Visit(IWhileDoStatement whileDoStatement)
 {
     WhileDoStatement mutableWhileDoStatement = new WhileDoStatement(whileDoStatement);
     this.resultStatement = this.myCodeCopier.DeepCopy(mutableWhileDoStatement);
 }
Exemple #3
0
 /// <summary>
 /// Visits the specified while do statement.
 /// </summary>
 /// <param name="whileDoStatement">The while do statement.</param>
 /// <returns></returns>
 protected virtual IStatement DeepCopy(WhileDoStatement whileDoStatement)
 {
     whileDoStatement.Condition = Substitute(whileDoStatement.Condition);
       whileDoStatement.Body = Substitute(whileDoStatement.Body);
       return whileDoStatement;
 }
Exemple #4
0
 /// <summary>
 /// Rewrites the children of the given while do statement.
 /// </summary>
 public virtual void RewriteChildren(WhileDoStatement whileDoStatement)
 {
     this.RewriteChildren((Statement)whileDoStatement);
       whileDoStatement.Condition = this.Rewrite(whileDoStatement.Condition);
       whileDoStatement.Body = this.Rewrite(whileDoStatement.Body);
 }
Exemple #5
0
 /// <summary>
 /// Visits the specified while do statement.
 /// </summary>
 /// <param name="whileDoStatement">The while do statement.</param>
 public override void Visit(IWhileDoStatement whileDoStatement)
 {
     WhileDoStatement mutableWhileDoStatement = whileDoStatement as WhileDoStatement;
     if (alwaysMakeACopy || mutableWhileDoStatement == null) mutableWhileDoStatement = new WhileDoStatement(whileDoStatement);
     this.resultStatement = this.myCodeMutator.Visit(mutableWhileDoStatement);
 }
Exemple #6
0
 /// <summary>
 /// Visits the specified while do statement.
 /// </summary>
 /// <param name="whileDoStatement">The while do statement.</param>
 /// <returns></returns>
 public virtual IStatement Visit(WhileDoStatement whileDoStatement)
 {
     whileDoStatement.Condition = Visit(whileDoStatement.Condition);
       whileDoStatement.Body = Visit(whileDoStatement.Body);
       return whileDoStatement;
 }