From 7c9ada78241e08bf36bd04d989f742a6de721575 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Wed, 5 May 2021 17:23:49 +0800 Subject: Add the ability to automatically create struct members --- python/architecture.py | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'python/architecture.py') diff --git a/python/architecture.py b/python/architecture.py index 19ef7831..e23f39d7 100644 --- a/python/architecture.py +++ b/python/architecture.py @@ -2808,3 +2808,107 @@ class ReferenceSource(object): @address.setter def address(self, value): self._address = value + + +class TypeFieldReference(object): + def __init__(self, func, arch, addr, size): + self._function = func + self._arch = arch + self._address = addr + self._size = size + + def __repr__(self): + if self._arch: + return "" % (self._arch.name, self._address, self._size) + else: + return "" % (self._address, self._size) + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return (self.function, self.arch, self.address, self._size) ==\ + (other.address, other.function, other.arch, other.size) + + def __ne__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return not (self == other) + + def __lt__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + if self.address < other.address: + return True + elif self.address > other.address: + return False + else: + return self.size < other.size + + def __gt__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + if self.address > other.address: + return True + elif self.address < other.address: + return False + else: + return self.size > other.size + + def __ge__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + if self.address > other.address: + return True + elif self.address < other.address: + return False + else: + return self.size >= other.size + + def __le__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + if self.address < other.address: + return True + elif self.address > other.address: + return False + else: + return self.size <= other.size + + def __hash__(self): + return hash((self._function, self._arch, self._address, self._size)) + + @property + def function(self): + """ """ + return self._function + + @function.setter + def function(self, value): + self._function = value + + @property + def arch(self): + """ """ + return self._arch + + @arch.setter + def arch(self, value): + self._arch = value + + @property + def address(self): + """ """ + return self._address + + @address.setter + def address(self, value): + self._address = value + + @property + def size(self): + """ """ + return self._size + + @size.setter + def address(self, value): + self._size = value \ No newline at end of file -- cgit v1.3.1