Ejemplo n.º 1
0
        private void CompressMembers()
        {
            var membersVisitor = new MinifyMembersAstVisitor(IgnoredIdentifiers, Options.ConsoleApp, Options.PublicCompressing, Options.ToStringMethodsRemoving);

            CompileAndAcceptVisitor(membersVisitor);
            var substitutor  = new Substitutor(new MinIdGenerator());
            var ignoredNames = new List <string>(IgnoredIdentifiers);

            ignoredNames.AddRange(membersVisitor.NotMembersIdNames);
            var substituton = substitutor.Generate(membersVisitor.TypesMembers, ignoredNames.ToArray());

            var astSubstitution = new Dictionary <string, List <Tuple <string, List <AstNode> > > >();

            foreach (var typeMembers in membersVisitor.TypesMembers)
            {
                var typeMembersAstNodes = new List <Tuple <string, List <AstNode> > >();
                astSubstitution[typeMembers.Key] = typeMembersAstNodes;
                var membersSubst = substituton[typeMembers.Key];
                foreach (NameNode member in typeMembers.Value)
                {
                    typeMembersAstNodes.Add(new Tuple <string, List <AstNode> >(membersSubst[member.Name], GetResolvedNodes(ResolveResultType.Member, member.Node)));
                }
            }

            RenameOrRemoveNodes(astSubstitution, true, Options.MembersCompressing);
        }
Ejemplo n.º 2
0
        private void CompressLocals()
        {
            var localsVisitor = new MinifyLocalsAstVisitor(IgnoredIdentifiers);

            CompileAndAcceptVisitor(localsVisitor);
            var substitutor  = new Substitutor(new MinIdGenerator());
            var ignoredNames = new List <string>(IgnoredIdentifiers);

            ignoredNames.AddRange(localsVisitor.NotLocalsIdNames);
            var substituton = substitutor.Generate(localsVisitor.MethodVars, ignoredNames.ToArray());

            var astSubstitution = new Dictionary <string, List <Tuple <string, List <AstNode> > > >();

            foreach (var method in localsVisitor.MethodVars)
            {
                var localVarsAstNodes = new List <Tuple <string, List <AstNode> > >();
                astSubstitution[method.Key] = localVarsAstNodes;
                var localsSubst = substituton[method.Key];
                foreach (NameNode localVar in method.Value)
                {
                    localVarsAstNodes.Add(new Tuple <string, List <AstNode> >(localsSubst[localVar.Name], GetResolvedNodes(ResolveResultType.Local, localVar.Node)));
                }
            }

            RenameOrRemoveNodes(astSubstitution, true, Options.LocalVarsCompressing);
        }
Ejemplo n.º 3
0
        private void CompressTypes()
        {
            var typesVisitor = new MinifyTypesAstVisitor(IgnoredIdentifiers, Options.PublicCompressing);

            CompileAndAcceptVisitor(typesVisitor);
            var substitutor  = new Substitutor(new MinIdGenerator());
            var ignoredNames = new List <string>(IgnoredIdentifiers);

            ignoredNames.AddRange(typesVisitor.NotTypesIdNames);
            var substitution = substitutor.Generate(typesVisitor.Types, ignoredNames.ToArray());

            var astSubstitution = new List <Tuple <string, List <AstNode> > >();

            foreach (var type in typesVisitor.Types)
            {
                astSubstitution.Add(new Tuple <string, List <AstNode> >(substitution[type.Name], GetResolvedNodes(ResolveResultType.Type, type.Node)));
            }

            RenameOrRemoveNodes(astSubstitution, false, Options.TypesCompressing);
        }
Ejemplo n.º 4
0
        private void CompressTypes()
        {
            var typesVisitor = new MinifyTypesAstVisitor(IgnoredIdentifiers, Options.PublicCompressing);
            CompileAndAcceptVisitor(typesVisitor);
            var substitutor = new Substitutor(new MinIdGenerator());
            var ignoredNames = new List<string>(IgnoredIdentifiers);
            ignoredNames.AddRange(typesVisitor.NotTypesIdNames);
            var substitution = substitutor.Generate(typesVisitor.Types, ignoredNames.ToArray());

            var astSubstitution = new List<Tuple<string, List<AstNode>>>();
            foreach (var type in typesVisitor.Types)
                astSubstitution.Add(new Tuple<string, List<AstNode>>(substitution[type.Name], GetResolvedNodes(ResolveResultType.Type, type.Node)));

            RenameOrRemoveNodes(astSubstitution, false, Options.TypesCompressing);
        }
Ejemplo n.º 5
0
        private void CompressMembers()
        {
            var membersVisitor = new MinifyMembersAstVisitor(IgnoredIdentifiers, Options.ConsoleApp, Options.PublicCompressing, Options.ToStringMethodsRemoving);
            CompileAndAcceptVisitor(membersVisitor);
            var substitutor = new Substitutor(new MinIdGenerator());
            var ignoredNames = new List<string>(IgnoredIdentifiers);
            ignoredNames.AddRange(membersVisitor.NotMembersIdNames);
            var substituton = substitutor.Generate(membersVisitor.TypesMembers, ignoredNames.ToArray());

            var astSubstitution = new Dictionary<string, List<Tuple<string, List<AstNode>>>>();
            foreach (var typeMembers in membersVisitor.TypesMembers)
            {
                var typeMembersAstNodes = new List<Tuple<string, List<AstNode>>>();
                astSubstitution[typeMembers.Key] = typeMembersAstNodes;
                var membersSubst = substituton[typeMembers.Key];
                foreach (NameNode member in typeMembers.Value)
                    typeMembersAstNodes.Add(new Tuple<string, List<AstNode>>(membersSubst[member.Name], GetResolvedNodes(ResolveResultType.Member, member.Node)));
            }

            RenameOrRemoveNodes(astSubstitution, true, Options.MembersCompressing);
        }
Ejemplo n.º 6
0
        private void CompressLocals()
        {
            var localsVisitor = new MinifyLocalsAstVisitor(IgnoredIdentifiers);
            CompileAndAcceptVisitor(localsVisitor);
            var substitutor = new Substitutor(new MinIdGenerator());
            var ignoredNames = new List<string>(IgnoredIdentifiers);
            ignoredNames.AddRange(localsVisitor.NotLocalsIdNames);
            var substituton = substitutor.Generate(localsVisitor.MethodVars, ignoredNames.ToArray());

            var astSubstitution = new Dictionary<string, List<Tuple<string, List<AstNode>>>>();
            foreach (var method in localsVisitor.MethodVars)
            {
                var localVarsAstNodes = new List<Tuple<string, List<AstNode>>>();
                astSubstitution[method.Key] = localVarsAstNodes;
                var localsSubst = substituton[method.Key];
                foreach (NameNode localVar in method.Value)
                    localVarsAstNodes.Add(new Tuple<string, List<AstNode>>(localsSubst[localVar.Name], GetResolvedNodes(ResolveResultType.Local, localVar.Node)));
            }

            RenameOrRemoveNodes(astSubstitution, true, Options.LocalVarsCompressing);
        }