# 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/xml_loader/htm_loader.py
# class HtmLoader(object):
#     """ Load htm.xml information into a Python element"""
# 
#     def __init__(self):
#         self.htms = []
#         self.htms_include = []
#         self.__load_xml(HTM_FILE)
# 
#     def __load_xml(self, file_name):
#         """Load the contents of htm.xml into a Python element"""
#         tree = elemTree.parse(file_name)
#         self.root = tree.getroot()
#         for htm in self.root.iter('function'):
#             self.htms.append(htm.attrib)
#         for htm_header in self.root.iter('header'):
#             self.htms_include.append(htm_header.attrib)
# 
#     def get_functions(self):
#         """Populate a list of HTM names"""
#         for htm in self.root.findall('htmapi'):
#             if htm.get("type") == "function":
#                 self.htms.append(htm.get('target'))
#         return self.htms
# 
#     def get_includes(self):
#         """Populate a list of HTM includes in the header"""
#         for htm in self.root.findall('htmapi'):
#             if htm.get('type') == 'header':
#                 self.htms_include.append(htm.get('target'))
#         return self.htms_include
# 
#     def get_fixes(self):
#         '''Method to populate a list of htm fixes'''
#         suggestion_dict = {}
#         for sysc in self.root.findall('htmapi'):
#             if sysc.get("replacer"):
#                 suggestion_dict[sysc.get("target")] = (sysc.get("replacer"))
#         return suggestion_dict


from clang.cindex import CursorKind
from ma.checkers.checker import Checker
from ma.xml_loader.htm_loader import HtmLoader
# -*- coding: utf-8 -*-

"""
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:
        * Daniel Kreling <dbkreling@br.ibm.com>
"""



class HtmChecker(Checker):
    """ Checker for HTM calls. """

    def __init__(self):
        self.problem_type = "Hardware Transactional Memory (HTM)"
        self.problem_msg = "x86 specific HTM calls are not supported in Power Systems"
        self.htm_functions = HtmLoader().get_functions()

# 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/xml_loader/htm_loader.py
# class HtmLoader(object):
#     """ Load htm.xml information into a Python element"""
# 
#     def __init__(self):
#         self.htms = []
#         self.htms_include = []
#         self.__load_xml(HTM_FILE)
# 
#     def __load_xml(self, file_name):
#         """Load the contents of htm.xml into a Python element"""
#         tree = elemTree.parse(file_name)
#         self.root = tree.getroot()
#         for htm in self.root.iter('function'):
#             self.htms.append(htm.attrib)
#         for htm_header in self.root.iter('header'):
#             self.htms_include.append(htm_header.attrib)
# 
#     def get_functions(self):
#         """Populate a list of HTM names"""
#         for htm in self.root.findall('htmapi'):
#             if htm.get("type") == "function":
#                 self.htms.append(htm.get('target'))
#         return self.htms
# 
#     def get_includes(self):
#         """Populate a list of HTM includes in the header"""
#         for htm in self.root.findall('htmapi'):
#             if htm.get('type') == 'header':
#                 self.htms_include.append(htm.get('target'))
#         return self.htms_include
# 
#     def get_fixes(self):
#         '''Method to populate a list of htm fixes'''
#         suggestion_dict = {}
#         for sysc in self.root.findall('htmapi'):
#             if sysc.get("replacer"):
#                 suggestion_dict[sysc.get("target")] = (sysc.get("replacer"))
#         return suggestion_dict


# Path: ma/checkers/htm_checker.py
from clang.cindex import CursorKind
from ma.checkers.checker import Checker
from ma.xml_loader.htm_loader import HtmLoader

# -*- coding: utf-8 -*-

"""
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:
        * Daniel Kreling <dbkreling@br.ibm.com>
"""



class HtmChecker(Checker):
    """ Checker for HTM calls. """

    def __init__(self):
        self.problem_type = "Hardware Transactional Memory (HTM)"
        self.problem_msg = "x86 specific HTM calls are not supported in Power Systems"
        self.htm_functions = HtmLoader().get_functions()

        self.htm_includes = HtmLoader().get_includes()