Exemplo n.º 1
0
def cleanup(node):
    """"""

    if not hasattr(node, "variables"):
        ScopeScanner.scan(node)

    # Re cleanup until nothing to remove is found
    x = 0
    cleaned = False

    Console.debug("Removing unused variables...")
    while True:
        x = x + 1
        #debug("Removing unused variables [Iteration: %s]...", x)
        Console.indent()

        if __cleanup(node):
            ScopeScanner.scan(node)
            cleaned = True
            Console.outdent()
        else:
            Console.outdent()
            break

    return cleaned
Exemplo n.º 2
0
    def __getOptimizedTree(self, permutation=None):
        """Returns an optimized tree with permutations applied."""

        field = "script:opt-tree[%s]-%s" % (self.id, permutation)
        tree = self.project.getCache().read(field, self.mtime)
        if not tree:
            tree = copy.deepcopy(self.__getTree())

            # Logging
            msg = "Optimizing class %s" % Console.colorize(self.id, "bold")
            if permutation:
                msg += Console.colorize(" (%s)" % permutation, "grey")

            Console.info("%s..." % msg)
            Console.indent()

            # Apply permutation
            if permutation:
                Console.debug("Patching tree with permutation: %s",
                              permutation)
                Console.indent()
                jasy.script.clean.Permutate.patch(tree, permutation)
                Console.outdent()

            # Cleanups
            jasy.script.clean.DeadCode.cleanup(tree)
            ScopeScanner.scan(tree)
            jasy.script.clean.Unused.cleanup(tree)

            self.project.getCache().store(field, tree, self.mtime, True)
            Console.outdent()

        return tree
Exemplo n.º 3
0
    def process(self, code):
        node = Parser.parse(code)
        ScopeScanner.scan(node)
        data = Data.ApiData("test")
        data.scanTree(node)

        return data
Exemplo n.º 4
0
    def process(self, code):
        node = Parser.parse(code)
        ScopeScanner.scan(node)
        data = Data.ApiData("test")
        data.scanTree(node)

        return data
Exemplo n.º 5
0
def cleanup(node):
    """"""

    if not hasattr(node, "variables"):
        ScopeScanner.scan(node)

    # Re cleanup until nothing to remove is found
    x = 0
    cleaned = False

    Console.debug("Removing unused variables...")
    while True:
        x = x + 1
        #debug("Removing unused variables [Iteration: %s]...", x)
        Console.indent()

        if __cleanup(node):
            ScopeScanner.scan(node)
            cleaned = True
            Console.outdent()
        else:
            Console.outdent()
            break

    return cleaned
Exemplo n.º 6
0
    def __getOptimizedTree(self, permutation=None):
        """Returns an optimized tree with permutations applied."""

        field = "script:opt-tree[%s]-%s" % (self.id, permutation)
        tree = self.project.getCache().read(field, self.mtime)
        if not tree:
            tree = copy.deepcopy(self.__getTree())

            # Logging
            msg = "Optimizing class %s" % Console.colorize(self.id, "bold")
            if permutation:
                msg += Console.colorize(" (%s)" % permutation, "grey")

            Console.info("%s..." % msg)
            Console.indent()

            # Apply permutation
            if permutation:
                Console.debug("Patching tree with permutation: %s", permutation)
                Console.indent()
                jasy.script.clean.Permutate.patch(tree, permutation)
                Console.outdent()

            # Cleanups
            jasy.script.clean.DeadCode.cleanup(tree)
            ScopeScanner.scan(tree)
            jasy.script.clean.Unused.cleanup(tree)

            self.project.getCache().store(field, tree, self.mtime, True)
            Console.outdent()

        return tree
Exemplo n.º 7
0
    def __getTree(self):
        """Returns the abstract syntax tree."""

        field = "script:tree[%s]" % self.id
        tree = self.project.getCache().read(field, self.mtime)
        if not tree:
            Console.info("Processing class %s...", Console.colorize(self.id, "bold"))

            Console.indent()
            tree = Parser.parse(self.getText(), self.id)
            ScopeScanner.scan(tree)
            Console.outdent()

            self.project.getCache().store(field, tree, self.mtime, True)

        return tree
Exemplo n.º 8
0
    def __getTree(self):
        """Returns the abstract syntax tree."""

        field = "script:tree[%s]" % self.id
        tree = self.project.getCache().read(field, self.mtime)
        if not tree:
            Console.info("Processing class %s...",
                         Console.colorize(self.id, "bold"))

            Console.indent()
            tree = Parser.parse(self.getText(), self.id)
            ScopeScanner.scan(tree)
            Console.outdent()

            self.project.getCache().store(field, tree, self.mtime, True)

        return tree
Exemplo n.º 9
0
 def process(self, code):
     node = Parser.parse(code)
     ScopeScanner.scan(node)
     LocalVariables.optimize(node)
     return Compressor.Compressor().compress(node)
Exemplo n.º 10
0
 def process(self, code):
     node = Parser.parse(code)
     ScopeScanner.scan(node)
     CombineDeclarations.optimize(node)
     return Compressor.Compressor().compress(node)
Exemplo n.º 11
0
 def process(self, code):
     node = Parser.parse(code)
     ScopeScanner.scan(node)
     LocalVariables.optimize(node)
     return Compressor.Compressor().compress(node)
Exemplo n.º 12
0
 def process(self, code):
     node = Parser.parse(code)
     ScopeScanner.scan(node)
     CombineDeclarations.optimize(node)
     return Compressor.Compressor().compress(node)