Browse Source

Add type annotations

nosoop 10 tháng trước cách đây
mục cha
commit
f79354f6b5
1 tập tin đã thay đổi với 5 bổ sung4 xóa
  1. 5 4
      src/smgdc/angr/vtable_disamb.py

+ 5 - 4
src/smgdc/angr/vtable_disamb.py

@@ -6,13 +6,14 @@ from typing import Iterable
 
 import itanium_demangler as demangler
 from cle.backends.symbol import Symbol
+from cle.memory import Clemory
 
 import angr
 
 from .. import demangler_helpers as dh
 
 
-def read_cstring(mem, addr, encoding="utf-8", chunk=16, **kwargs):
+def read_cstring(mem: Clemory, addr: int, encoding="utf-8", chunk=16, **kwargs) -> str:
     """unpacks a variable-length, zero-terminated string from the binary"""
     try:
         unpacker = itertools.takewhile(
@@ -37,7 +38,7 @@ class VtableDisambiguator(angr.Analysis):
         self.memory = self.loader.memory
         self.analyze()
 
-    def analyze(self):
+    def analyze(self) -> None:
         self.syms_by_addr = collections.defaultdict(set)
         vtable_syms = set()
         for symbol in self.loader.symbols:
@@ -61,7 +62,7 @@ class VtableDisambiguator(angr.Analysis):
                 self.subclass_map[svtsym].add(vtsym)
                 self.superclass_map[vtsym].add(svtsym)
 
-    def dump_class_parents(self, typeinfo_ptr: int):
+    def dump_class_parents(self, typeinfo_ptr: int) -> Iterable[tuple[int, str]]:
         """
         Returns a list of mangled typenames in ascending order (towards base classes at the end).
         This takes a pointer to the class's typeinfo structure.
@@ -94,7 +95,7 @@ class VtableDisambiguator(angr.Analysis):
             raise ValueError("unknown typeinfo class", typeinfo_class_sym)
 
     def resolve_ambiguous_vfn(
-        self, vtidx, ambig_fnsyms, related_vtsyms: Iterable[Symbol]
+        self, vtidx: int, ambig_fnsyms: set[Symbol], related_vtsyms: Iterable[Symbol]
     ) -> Symbol | None:
         """
         Resolves an ambiguous virtual function by attempting to match against symbols in related