Inheritance: DefaultVisitor
コード例 #1
0
ファイル: ReplaceJumpToGoTo.cs プロジェクト: scemino/nscumm
 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;
 }
コード例 #2
0
ファイル: ReplaceJumpToWhile.cs プロジェクト: scemino/nscumm
 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;
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }