<commit_before>
class Register(object):
    def __init__(self, name: str, size: int=1, special: bool=False):
        self._value = 0
        self._name = name
        self._size = size
        self._special = special

    @property
    def name(self) -> str:
        return self._name

    @property
    def size(self) -> int:
        return self._size

    @property
    def value(self) -> int:
        return self._value

    @property
    def special(self) -> bool:
        return self._special

    @value.setter
    def value(self, value: int):
        if value >= self.minValue and value <= self.maxValue:
            self._value = value
        else:
            raise ValueError("Register {name} cannot have a value of "
                             "0x{value:08X} - largest value is {max:08X}"
                             .format(name=self.name,
                                     value=value,
                                     max=self.maxValue))

    @property
    def maxValue(self) -> int:
        return 2**(self.size*8) - 1

    @property
    def minValue(self) -> int:
        return 0

    def clear(self):
        self._value = 0

    def setBit(self, pos: int):
        if pos >= 0 and pos < self.size * 8:
            self.value = (self.value | 2**pos)
        else:
            raise ValueError("Register {name} does not have a bit index of "
                             "{value} - largest bit index is {max}"
                             .format(name=self.name,
                                     value=pos,
                                     max=self.size * 8 - 1))

    def clearBit(self, pos: int):
        if pos >= 0 and pos < self.size * 8:
            self.value = (self.value & (self.maxValue - 2**pos))
        else:
            raise ValueError("Register {name} does not have a bit index of "
                             "{value} - largest bit index is {max}"
                             .format(name=self.name,
                                     value=pos,
                                     max=self.size * 8 - 1))

    def getBit(self, pos: int) -> int:
        if pos >= pos and pos < self.size * 8:
            self.value = 0 if (self.value & (self.maxValue - 2**)) == 0 else 1

    def setBits(self, poses: [int]) -> int:
        for pos in poses:
            self.setBit(pos)

    def clearBits(self, poses: [int]):
        for pos in poses:
            self.clearBit(pos)

    def getBits(self, poses: [int]) -> int:
        minPos = min(poses)

        for pos in poses:
            if pos < 0 or pos >= self.size * 8:
                raise ValueError("Register {name} does not have a bit index of "
                                 "{value} - largest bit index is {max}"
                                 .format(name=self.name,
                                         value=pos,
                                         max=self.size * 8 - 1))

        return sum([(2**pos | self.value) for pos in (set(poses))]) >> minPOs

class UnimplementedRegister(Register):
    def __init__(self, size: int=1):
        super().__init__("unimplemented", size=size, special=True)
        zero = lambda _, *args: 0
        none = lambda _, *args: None
        self.clear = none
        self.setBit = none
        self.clearBits = none
        self.getBit = zero
        self.setBits = none
        self.clearBits = none
        self.getBits = zero

    @property
    def value(self) -> int:
        return 0

    # The following functions are intensionally set as pass.

    @value.setter
    def value(self, _):
        pass<commit_msg>Added a named bit register class.  Fix syntax error.<commit_after>
class Register(object):
    def __init__(self, name: str, size: int=1, special: bool=False):
        self._value = 0
        self._name = name
        self._size = size
        self._special = special

    @property
    def name(self) -> str:
        return self._name

    @property
    def size(self) -> int:
        return self._size

    @property
    def value(self) -> int:
        return self._value

    @property
    def special(self) -> bool:
        return self._special

    @value.setter
    def value(self, value: int):
        if value >= self.minValue and value <= self.maxValue:
            self._value = value
        else:
            raise ValueError("Register {name} cannot have a value of "
                             "0x{value:08X} - largest value is {max:08X}"
                             .format(name=self.name,
                                     value=value,
                                     max=self.maxValue))

    @property
    def maxValue(self) -> int:
        return 2**(self.size*8) - 1

    @property
    def minValue(self) -> int:
        return 0

    def clear(self):
        self._value = 0

    def setBit(self, pos: int):
        if pos >= 0 and pos < self.size * 8:
            self.value = (self.value | 2**pos)
        else:
            raise ValueError("Register {name} does not have a bit index of "
                             "{value} - largest bit index is {max}"
                             .format(name=self.name,
                                     value=pos,
                                     max=self.size * 8 - 1))

    def clearBit(self, pos: int):
        if pos >= 0 and pos < self.size * 8:
            self.value = (self.value & (self.maxValue - 2**pos))
        else:
            raise ValueError("Register {name} does not have a bit index of "
                             "{value} - largest bit index is {max}"
                             .format(name=self.name,
                                     value=pos,
                                     max=self.size * 8 - 1))

    def getBit(self, pos: int) -> int:
        if pos >= pos and pos < self.size * 8:
            self.value = 0 if (self.value & (self.maxValue - 2**pos)) == 0 else 1

    def setBits(self, poses: [int]) -> int:
        for pos in poses:
            self.setBit(pos)

    def clearBits(self, poses: [int]):
        for pos in poses:
            self.clearBit(pos)

    def getBits(self, poses: [int]) -> int:
        minPos = min(poses)

        for pos in poses:
            if pos < 0 or pos >= self.size * 8:
                raise ValueError("Register {name} does not have a bit index of "
                                 "{value} - largest bit index is {max}"
                                 .format(name=self.name,
                                         value=pos,
                                         max=self.size * 8 - 1))

        return sum([(2**pos | self.value) for pos in (set(poses))]) >> minPOs

class UnimplementedRegister(Register):
    def __init__(self, size: int=1):
        super().__init__("unimplemented", size=size, special=True)
        zero = lambda _, *args: 0
        none = lambda _, *args: None
        self.clear = none
        self.setBit = none
        self.clearBits = none
        self.getBit = zero
        self.setBits = none
        self.clearBits = none
        self.getBits = zero

    @property
    def value(self) -> int:
        return 0

    # The following functions are intensionally set as pass.

    @value.setter
    def value(self, _):
        pass

class NamedBitRegister(Register):
    def __init__(self, name: str,
                 bitNames: [str],
                 size: int=1,
                 special: bool=True):
        super().__init__(name=name, size=size, special=special)

        self._nameMap = {}
        for i in range(bitNames):
            if bitNames[i] is not None:
                self._nameMap[bitNames[i]] = (self.size * 8 - i - 1)

    def setNamedBit(self, name: str):
        self.setBit(self._nameMap[name])

    def getNamedBit(self, name: str) -> int:
        return self.getBit(self._nameMap[name])

    def clearNamedBit(self, name: str):
        self.clearBit(self._nameMap[name])
{'fraction_non_alphanumeric': 0.10759654471544715, 'fraction_numerical': 0.009273373983739838, 'mean_word_length': 1.3937366980845243, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '714321', 'n_tokens_mistral': 2273, 'n_tokens_neox': 2155, 'n_words': 654}