diff options
Diffstat (limited to 'arch/arch.py')
| -rw-r--r-- | arch/arch.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/arch/arch.py b/arch/arch.py index a46439e..ba94631 100644 --- a/arch/arch.py +++ b/arch/arch.py @@ -1,7 +1,23 @@ +from typing import Iterable + class Arch(): - def __init__(self, archname: str, regnames: list[str]): + def __init__(self, archname: str, regnames: Iterable[str]): self.archname = archname self.regnames = set(regnames) + def to_regname(self, name: str) -> str | None: + """Transform a string into a standard register name. + + Override to implement things like name aliases etc. + + :param name: The possibly non-standard name to look up. + :return: The 'corrected' register name, or None if `name` cannot be + transformed into a register name. + """ + name = name.upper() + if name in self.regnames: + return name + return None + def __eq__(self, other): return self.regnames == other.regnames |