# Path: ma/checkers/checker.py
# class Checker(object):
#     """ Abstract class Checker """
#     __metaclass__ = abc.ABCMeta
# 
#     def check_node(self, node):
#         """ Check node from AST and return if it is a migration issue """
#         return False
# 
#     def check_include(self, include_name):
#         """ Check include from AST and return if it is a migration issue """
#         return False
# 
#     def check_file(self, file_name):
#         """ Check issues into file and return a list of lists, containing the
#         problem name and line number """
#         return []
# 
#     def get_solution(self, problem):
#         """ Get solution for the problem using the node from AST or the raw
#         node from file """
#         return ""
# 
#     @abc.abstractmethod
#     def get_pattern_hint(self):
#         """Return the pattern that should be used to get the
#         problematics files"""
#         raise NotImplementedError('users must define __get_pattern_hint__ to\
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_msg(self):
#         """Return the problem message of the checker"""
#         raise NotImplementedError('users must define __get_problem_msg__ to \
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_type(self):
#         """Return the problem type of the checker"""
#         raise NotImplementedError('users must define __get_problem_type__ to \
#         use this base class')
# 
# Path: ma/core.py
# X86_PATTERNS = ["amd64", "AMD64", "[xX]86", "[xX]86_64", "[iI]386", "[iI]486",
#                 "[iI]686"]
# PPC_PATTERNS = ["PPC", "ppc", "power[pP][cC]", "POWER[pP][cC]"]
# def get_supported_checkers():
# def get_supported_extensions():
# def execute(command):
# def execute_stdout(command):
# def cmdexists(command):
# def get_timestamp():
# def get_files(location, hint=''):
# def get_file_content(file_name, offset, length):
# def get_raw_node(node):
# def get_includes(file_path):
# def get_ifdefs(file_path):
# def get_ifdef_regex(arch, separator):


import re
from ma.checkers.checker import Checker
from ma import core
limitations under the License.

    Contributors:
        * Diego Fernandez-Merjildo <merjildo@br.ibm.com>
"""



class PerformanceDegradationChecker(Checker):
    """ This checker finds preprocessor ifs with architecture
    optimizations and without an optimization for Linux on Power"""

    def __init__(self):
        super(PerformanceDegradationChecker, self).__init__()
        self.problem_type = "Performance degradation"
        self.problem_msg = "This preprocessor can contain code without Power optimization"
        self.hint = core.get_ifdef_regex("x86", "\\|")
        self.ppc = core.get_ifdef_regex("ppc", "|")
        self.x86 = core.get_ifdef_regex("x86", "|")

    def get_pattern_hint(self):
        return self.hint

    def get_problem_msg(self):
        return self.problem_msg

    def get_problem_type(self):
        return self.problem_type

    def check_file(self, filename):

# Path: ma/checkers/checker.py
# class Checker(object):
#     """ Abstract class Checker """
#     __metaclass__ = abc.ABCMeta
# 
#     def check_node(self, node):
#         """ Check node from AST and return if it is a migration issue """
#         return False
# 
#     def check_include(self, include_name):
#         """ Check include from AST and return if it is a migration issue """
#         return False
# 
#     def check_file(self, file_name):
#         """ Check issues into file and return a list of lists, containing the
#         problem name and line number """
#         return []
# 
#     def get_solution(self, problem):
#         """ Get solution for the problem using the node from AST or the raw
#         node from file """
#         return ""
# 
#     @abc.abstractmethod
#     def get_pattern_hint(self):
#         """Return the pattern that should be used to get the
#         problematics files"""
#         raise NotImplementedError('users must define __get_pattern_hint__ to\
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_msg(self):
#         """Return the problem message of the checker"""
#         raise NotImplementedError('users must define __get_problem_msg__ to \
#         use this base class')
# 
#     @abc.abstractmethod
#     def get_problem_type(self):
#         """Return the problem type of the checker"""
#         raise NotImplementedError('users must define __get_problem_type__ to \
#         use this base class')
# 
# Path: ma/core.py
# X86_PATTERNS = ["amd64", "AMD64", "[xX]86", "[xX]86_64", "[iI]386", "[iI]486",
#                 "[iI]686"]
# PPC_PATTERNS = ["PPC", "ppc", "power[pP][cC]", "POWER[pP][cC]"]
# def get_supported_checkers():
# def get_supported_extensions():
# def execute(command):
# def execute_stdout(command):
# def cmdexists(command):
# def get_timestamp():
# def get_files(location, hint=''):
# def get_file_content(file_name, offset, length):
# def get_raw_node(node):
# def get_includes(file_path):
# def get_ifdefs(file_path):
# def get_ifdef_regex(arch, separator):


# Path: ma/checkers/performance_degradation_checker.py
import re
from ma.checkers.checker import Checker
from ma import core

limitations under the License.

    Contributors:
        * Diego Fernandez-Merjildo <merjildo@br.ibm.com>
"""



class PerformanceDegradationChecker(Checker):
    """ This checker finds preprocessor ifs with architecture
    optimizations and without an optimization for Linux on Power"""

    def __init__(self):
        super(PerformanceDegradationChecker, self).__init__()
        self.problem_type = "Performance degradation"
        self.problem_msg = "This preprocessor can contain code without Power optimization"
        self.hint = core.get_ifdef_regex("x86", "\\|")
        self.ppc = core.get_ifdef_regex("ppc", "|")
        self.x86 = core.get_ifdef_regex("x86", "|")

    def get_pattern_hint(self):
        return self.hint

    def get_problem_msg(self):
        return self.problem_msg

    def get_problem_type(self):
        return self.problem_type

    def check_file(self, filename):

        ifdef_lst = core.get_ifdefs(filename)