示例#1
0
        private static void TestRename()
        {
            Lexer  l = new Lexer();
            Parser p = new Parser(l.Lex("local a = 5; function c() print(a) end c()"));
            Chunk  c = p.Parse();

            c.Scope.RenameVariable("a", "b");
            c.Scope.RenameVariable("c", "testfunc");
            Visitors.BasicBeautifier e = new Visitors.BasicBeautifier();
            Console.WriteLine(e.Beautify(c));
            Visitors.ExactReconstruction e2 = new Visitors.ExactReconstruction();
            Console.WriteLine(e2.Reconstruct(c));
        }
示例#2
0
        static void TestInline()
        {
            Lexer  l = new Lexer();
            Parser p = new Parser(l.Lex("local b = function(a, ...) return a + 1, ... end"));
            Chunk  c = p.Parse();
            AssignmentStatement a = c.Body[0] as AssignmentStatement;

            a.Rhs[0] = Refactoring.InlineFunction(a.Rhs[0] as SharpLua.Ast.Expression.AnonymousFunctionExpr);
            Visitors.BasicBeautifier e = new Visitors.BasicBeautifier();
            a.ScannedTokens = null;
            Console.WriteLine(e.Beautify(c));
            Visitors.ExactReconstruction e2 = new Visitors.ExactReconstruction();
            Console.WriteLine(e2.Reconstruct(c));
        }
示例#3
0
 static void TestInline()
 {
     Lexer l = new Lexer();
     Parser p = new Parser(l.Lex("local b = function(a, ...) return a + 1, ... end"));
     Chunk c = p.Parse();
     AssignmentStatement a = c.Body[0] as AssignmentStatement;
     a.Rhs[0] = Refactoring.InlineFunction(a.Rhs[0] as SharpLua.Ast.Expression.AnonymousFunctionExpr);
     Visitors.BasicBeautifier e = new Visitors.BasicBeautifier();
     a.ScannedTokens = null;
     Console.WriteLine(e.Beautify(c));
     Visitors.ExactReconstruction e2 = new Visitors.ExactReconstruction();
     Console.WriteLine(e2.Reconstruct(c));
 }
示例#4
0
 private static void TestRename()
 {
     Lexer l = new Lexer();
     Parser p = new Parser(l.Lex("local a = 5; function c() print(a) end c()"));
     Chunk c = p.Parse();
     c.Scope.RenameVariable("a", "b");
     c.Scope.RenameVariable("c", "testfunc");
     Visitors.BasicBeautifier e = new Visitors.BasicBeautifier();
     Console.WriteLine(e.Beautify(c));
     Visitors.ExactReconstruction e2 = new Visitors.ExactReconstruction();
     Console.WriteLine(e2.Reconstruct(c));
 }