Skip to content

Commit

Permalink
Merge pull request #2368 from crytic/dev-all-variables
Browse files Browse the repository at this point in the history
Add all variables read/written
  • Loading branch information
0xalpharush authored Apr 3, 2024
2 parents ef44825 + 58155bf commit 524a863
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions slither/core/declarations/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ def __init__(self, compilation_unit: "SlitherCompilationUnit") -> None:
self._all_library_calls: Optional[List["LibraryCallType"]] = None
self._all_low_level_calls: Optional[List["LowLevelCallType"]] = None
self._all_solidity_calls: Optional[List["SolidityFunction"]] = None
self._all_variables_read: Optional[List["Variable"]] = None
self._all_variables_written: Optional[List["Variable"]] = None
self._all_state_variables_read: Optional[List["StateVariable"]] = None
self._all_solidity_variables_read: Optional[List["SolidityVariable"]] = None
self._all_state_variables_written: Optional[List["StateVariable"]] = None
Expand Down Expand Up @@ -1153,6 +1155,18 @@ def _explore_functions(self, f_new_values: Callable[["Function"], List]) -> List

return list(set(values))

def all_variables_read(self) -> List["Variable"]:
"""recursive version of variables_read"""
if self._all_variables_read is None:
self._all_variables_read = self._explore_functions(lambda x: x.variables_read)
return self._all_variables_read

def all_variables_written(self) -> List["Variable"]:
"""recursive version of variables_written"""
if self._all_variables_written is None:
self._all_variables_written = self._explore_functions(lambda x: x.variables_written)
return self._all_variables_written

def all_state_variables_read(self) -> List["StateVariable"]:
"""recursive version of variables_read"""
if self._all_state_variables_read is None:
Expand Down

0 comments on commit 524a863

Please sign in to comment.