# Path: disassembler/formats/common/inst.py
# class CommonInstFormat:
#     def __init__(self, address, mnemonic, op_str, bytes, comment=None):
#         self.address = address
#         self.mnemonic = mnemonic
#         self.op_str = op_str
#         self.bytes = bytes
#         self.function = None
#         self.comment = comment
# 
#     def getByteString(self, num_bytes):
#         string_size = num_bytes*3
#         unpadded = str(self.bytes).encode("hex")[0:num_bytes*2]
#         return ' '.join([unpadded[x:x+2] for x in xrange(0, len(unpadded), 2)]).ljust(string_size)
# 
#     @staticmethod
#     def length(inst):
#         return 1
# 
#     @staticmethod
#     def toString(inst):
#         pass
# 
# Path: disassembler/formats/helpers/exceptions.py
# class ImproperObjectType(Exception):
#     def __init__(self, message):
#         Exception.__init__(self, message)
# 
# Path: disassembler/formats/helpers/label.py
# class Label:
#     def __init__(self, address, name, item, xrefs=None):
#         self.address = address
#         self.name = name
#         self.item = item
#         self.xrefs = [] if xrefs is None else xrefs
# 
#     def __str__(self):
#     	return self.name


from disassembler.formats.common.inst import CommonInstFormat
from disassembler.formats.helpers.exceptions import ImproperObjectType
from disassembler.formats.helpers.label import Label
class AddressComparator(InstComparator):
    def equals(self, other):
        return self.inst.address == other.address

class MnemonicComparator(InstComparator):
    def equals(self, other):
        return self.inst.mnemonic == other.mnemonic

class OpStrComparator(InstComparator):
    def equals(self, other):
        return self.inst.op_str == other.op_str
    
class BytesComparator(InstComparator):
    def equals(self, other):
        return self.inst.bytes == other.bytes

class CommentComparator(InstComparator):
    def equals(self, other):
        return self.inst.comment == other.comment


class LabelComparator:
    '''
    Can be used to compare the passed in Label object with any other
    Label object. This class must be subclassed before it can be used
    and the child must implement the equals method for finding which fields to compare
    on.
    '''
    def __init__(self, label):
        if not isinstance(label, Label):

# Path: disassembler/formats/common/inst.py
# class CommonInstFormat:
#     def __init__(self, address, mnemonic, op_str, bytes, comment=None):
#         self.address = address
#         self.mnemonic = mnemonic
#         self.op_str = op_str
#         self.bytes = bytes
#         self.function = None
#         self.comment = comment
# 
#     def getByteString(self, num_bytes):
#         string_size = num_bytes*3
#         unpadded = str(self.bytes).encode("hex")[0:num_bytes*2]
#         return ' '.join([unpadded[x:x+2] for x in xrange(0, len(unpadded), 2)]).ljust(string_size)
# 
#     @staticmethod
#     def length(inst):
#         return 1
# 
#     @staticmethod
#     def toString(inst):
#         pass
# 
# Path: disassembler/formats/helpers/exceptions.py
# class ImproperObjectType(Exception):
#     def __init__(self, message):
#         Exception.__init__(self, message)
# 
# Path: disassembler/formats/helpers/label.py
# class Label:
#     def __init__(self, address, name, item, xrefs=None):
#         self.address = address
#         self.name = name
#         self.item = item
#         self.xrefs = [] if xrefs is None else xrefs
# 
#     def __str__(self):
#     	return self.name


# Path: disassembler/formats/helpers/comparators.py
from disassembler.formats.common.inst import CommonInstFormat
from disassembler.formats.helpers.exceptions import ImproperObjectType
from disassembler.formats.helpers.label import Label

class AddressComparator(InstComparator):
    def equals(self, other):
        return self.inst.address == other.address

class MnemonicComparator(InstComparator):
    def equals(self, other):
        return self.inst.mnemonic == other.mnemonic

class OpStrComparator(InstComparator):
    def equals(self, other):
        return self.inst.op_str == other.op_str
    
class BytesComparator(InstComparator):
    def equals(self, other):
        return self.inst.bytes == other.bytes

class CommentComparator(InstComparator):
    def equals(self, other):
        return self.inst.comment == other.comment


class LabelComparator:
    '''
    Can be used to compare the passed in Label object with any other
    Label object. This class must be subclassed before it can be used
    and the child must implement the equals method for finding which fields to compare
    on.
    '''
    def __init__(self, label):
        if not isinstance(label, Label):

            raise ImproperObjectType('LabelComparator must be constructed with a Label object')