예제 #1
0
    def apply(self, tree):
        """
        Applies the configured optimizations to the given node tree.

        Modifies the tree in-place
        to be sure to have a deep copy if you need the original one. It raises an error instance
        whenever any optimization could not be applied to the given tree.

        """

        if self.has("wrap"):
            try:
                ClosureWrapper.optimize(tree)
            except CryptPrivates.Error as err:
                raise Error(err)

        if self.has("declarations"):
            try:
                CombineDeclarations.optimize(tree)
            except CombineDeclarations.Error as err:
                raise Error(err)

        if self.has("blocks"):
            try:
                BlockReducer.optimize(tree)
            except BlockReducer.Error as err:
                raise Error(err)

        if self.has("variables"):
            try:
                LocalVariables.optimize(tree)
            except LocalVariables.Error as err:
                raise Error(err)

        if self.has("privates"):
            try:
                CryptPrivates.optimize(tree, tree.fileId)
            except CryptPrivates.Error as err:
                raise Error(err)
예제 #2
0
    def apply(self, tree):
        """
        Applies the configured optimizations to the given node tree.

        Modifies the tree in-place
        to be sure to have a deep copy if you need the original one. It raises an error instance
        whenever any optimization could not be applied to the given tree.

        """

        if self.has("wrap"):
            try:
                ClosureWrapper.optimize(tree)
            except CryptPrivates.Error as err:
                raise Error(err)

        if self.has("declarations"):
            try:
                CombineDeclarations.optimize(tree)
            except CombineDeclarations.Error as err:
                raise Error(err)

        if self.has("blocks"):
            try:
                BlockReducer.optimize(tree)
            except BlockReducer.Error as err:
                raise Error(err)

        if self.has("variables"):
            try:
                LocalVariables.optimize(tree)
            except LocalVariables.Error as err:
                raise Error(err)

        if self.has("privates"):
            try:
                CryptPrivates.optimize(tree, tree.fileId)
            except CryptPrivates.Error as err:
                raise Error(err)
예제 #3
0
 def process(self, code):
     node = Parser.parse(code)
     ScopeScanner.scan(node)
     CombineDeclarations.optimize(node)
     return Compressor.Compressor().compress(node)
예제 #4
0
 def process(self, code):
     node = Parser.parse(code)
     ScopeScanner.scan(node)
     CombineDeclarations.optimize(node)
     return Compressor.Compressor().compress(node)