public CompilationUnit Replace(CompilationUnit cu) { var visitor = new JumpAstVisitor(); cu.Accept(visitor); var jumps = visitor.Jumps.Where(AcceptJump).ToList(); var newCu = cu.Accept(new JumpReplacer()); newCu.Accept(new LabelInserter(jumps)); return (CompilationUnit)newCu; }
public CompilationUnit Replace(CompilationUnit cu) { var visitor = new JumpAstVisitor(); cu.Accept(visitor); var jumps = visitor.Jumps.Where(jump => jump.JumpOffset < jump.StartOffset).OrderByDescending(jmp => jmp.JumpOffset).ThenByDescending(jmp => jmp.StartOffset).ToList(); foreach (var jump in jumps) { cu = new CompilationUnit().AddStatements(ReplaceJump(jump, cu.Statement)); } return cu; }
public CompilationUnit Replace(CompilationUnit cu) { var visitor = new JumpAstVisitor(); cu.Accept(visitor); var jumps = visitor.Jumps.Where(AcceptJump).ToList(); var newCu = cu.Accept(new JumpReplacer()); newCu.Accept(new LabelInserter(jumps)); return((CompilationUnit)newCu); }
public CompilationUnit Replace(CompilationUnit cu) { var visitor = new JumpAstVisitor(); cu.Accept(visitor); var jumps = visitor.Jumps.Where(jump => jump.JumpOffset > jump.StartOffset && !(jump.Condition is BooleanLiteralExpression)).OrderByDescending(jmp => jmp.JumpOffset).ThenByDescending(jmp => jmp.StartOffset).ToList(); foreach (var jump in jumps) { cu = new CompilationUnit().AddStatements(ReplaceJump(jump, cu.Statement)); } return(cu); }