示例#1
0
文件: MClassCode.py 项目: w495/acv
        def optimizeTree(tree):

            try:
                if ["comments"] == optimize:
                    # do a mere comment stripping
                    commentoptimizer.patch(tree)

                # "variants" prunes parts of the tree, so all subsequent optimizations benefit
                if "variants" in optimize:
                    variantoptimizer.search(tree, variantSet, self.id)

                # 'statics' has to come before 'privates', as it needs the original key names in tree
                # if features should be removed recursively, this has to be controlled on the calling
                # level.
                if "statics" in optimize:
                    if not featureMap:
                        console.warn("Empty feature map passed to static methods optimization; skipping")
                    elif self.type == "static" and self.id in featureMap:
                        featureoptimizer.patch(tree, self, featureMap)

                if "basecalls" in optimize:
                    basecalloptimizer.patch(tree)

                if "privates" in optimize:
                    privatesMap = load_privates()
                    privateoptimizer.patch(tree, id, privatesMap)
                    write_privates(privatesMap)

                if "strings" in optimize:
                    tree = self._stringOptimizer(tree)

                if "variables" in optimize:
                    variableoptimizer.search(tree)
            except Exception, e:
                raise RuntimeError("Problem optimizing %s; probably a syntax problem?!" % self.id)
示例#2
0
        def optimizeTree(tree):

            if "comments" in optimize:
                commentoptimizer.patch(tree)

            # "variants" prunes parts of the tree, so all subsequent optimizations benefit
            if "variants" in optimize:
                variantoptimizer.search(tree, variantSet, self.id)

            # 'statics' has to come before 'privates', as it needs the original key names in tree
            # if features should be removed recursively, this has to be controlled on the calling
            # level.
            if "statics" in optimize:
                if not featureMap:
                    console.warn(
                        "Empty feature map passed to static methods optimization; skipping"
                    )
                elif self.type == 'static' and self.id in featureMap:
                    featureoptimizer.patch(tree, self, featureMap)

            if "basecalls" in optimize:
                basecalloptimizer.patch(tree)

            if "privates" in optimize:
                privatesMap = load_privates()
                privateoptimizer.patch(tree, id, privatesMap)
                write_privates(privatesMap)

            if "strings" in optimize:
                tree = self._stringOptimizer(tree)

            if "variables" in optimize:
                variableoptimizer.search(tree)

            return tree
示例#3
0
        def optimizeTree(tree):

            if "comments" in optimize:
                commentoptimizer.patch(tree)

            # "variants" prunes parts of the tree, so all subsequent optimizations benefit
            if "variants" in optimize:
                variantoptimizer.search(tree, variantSet, self.id)

            # 'statics' has to come before 'privates', as it needs the original key names in tree
            # if features should be removed recursively, this has to be controlled on the calling
            # level.
            if "statics" in optimize:
                if not featureMap:
                    console.warn("Empty feature map passed to static methods optimization; skipping")
                elif self.type == 'static' and self.id in featureMap:
                    featureoptimizer.patch(tree, self, featureMap)

            if "basecalls" in optimize:
                basecalloptimizer.patch(tree)

            if "privates" in optimize:
                privatesMap = load_privates()
                privateoptimizer.patch(tree, id, privatesMap)
                write_privates(privatesMap)

            if "globals" in optimize:
                tree = globalsoptimizer.process(tree) # need to re-assign as this optimizer might change the root node

            if "strings" in optimize:
                tree = stringoptimizer.process(tree, self.id)

            if "variables" in optimize:
                variableoptimizer.search(tree)

            return tree
示例#4
0
        def optimizeTree(tree):

            if "comments" in optimize:
                commentoptimizer.patch(tree)

            # "variants" prunes parts of the tree, so all subsequent optimizations benefit
            if "variants" in optimize:
                variantoptimizer.search(tree, variantSet, self.id)

            # 'statics' has to come before 'privates', as it needs the original key names in tree
            # if features should be removed recursively, this has to be controlled on the calling
            # level.
            if "statics" in optimize:
                if not featureMap:
                    console.warn(
                        "Empty feature map passed to static methods optimization; skipping"
                    )
                elif self.type == 'static' and self.id in featureMap:
                    optimzed_features = featureoptimizer.patch(
                        tree, self, featureMap)
                    if optimzed_features:
                        optimized_statics_overall = load_features()
                        copy = optimized_statics_overall.copy()
                        copy.update(optimzed_features)
                        write_features(copy)

            if "basecalls" in optimize:
                basecalloptimizer.patch(tree)

            if "privates" in optimize:
                privatesMap = load_privates()
                privateoptimizer.patch(tree, id, privatesMap)
                write_privates(privatesMap)

            if "globals" in optimize:
                tree = globalsoptimizer.process(
                    tree
                )  # need to re-assign as this optimizer might change the root node

            if "strings" in optimize:
                tree = stringoptimizer.process(tree, self.id)

            if "variables" in optimize:
                variableoptimizer.search(tree)

            return tree
示例#5
0
 def _staticMethodsHelper(self, tree, id, variants):
     if self._classesObj[id].type == 'static':
         featureoptimizer.patch(tree, id, self._featureMap[id])
示例#6
0
 def _staticMethodsHelper(self, tree, id, variants):
     if self._classesObj[id].type == 'static':
         featureoptimizer.patch(tree, id, self._featureMap[id])