From 58155bf309c0ff0d6649ea6fdea1c01603b48214 Mon Sep 17 00:00:00 2001 From: Simone Date: Tue, 19 Mar 2024 18:31:43 +0100 Subject: [PATCH] Add all variables read/written --- slither/core/declarations/function.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index d2baaf7e7b..77aa21b790 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -175,6 +175,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 @@ -1108,6 +1110,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: