# 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
"""
Copyright (C) 2017 IBM Corporation

Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
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", "\\|")

# 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

"""
Copyright (C) 2017 IBM Corporation

Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
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", "|")