Additional memoization

pull/703/head
Josselin 4 years ago
parent 3368b52a24
commit 19ad2e9450
  1. 14
      slither/core/declarations/contract.py
  2. 6
      slither/core/declarations/function.py

@ -71,7 +71,7 @@ class Contract(ChildSlither, SourceMapping): # pylint: disable=too-many-public-
self._is_upgradeable: Optional[bool] = None self._is_upgradeable: Optional[bool] = None
self._is_upgradeable_proxy: Optional[bool] = None self._is_upgradeable_proxy: Optional[bool] = None
self._is_top_level = False self.is_top_level = False # heavily used, so no @property
self._initial_state_variables: List["StateVariable"] = [] # ssa self._initial_state_variables: List["StateVariable"] = [] # ssa
@ -1207,18 +1207,6 @@ class Contract(ChildSlither, SourceMapping): # pylint: disable=too-many-public-
for func in self.functions + self.modifiers: for func in self.functions + self.modifiers:
func.fix_phi(last_state_variables_instances, initial_state_variables_instances) func.fix_phi(last_state_variables_instances, initial_state_variables_instances)
@property
def is_top_level(self) -> bool:
"""
The "TopLevel" contract is used to hold structures and enums defined at the top level
ie. structures and enums that are represented outside of any contract
:return:
"""
return self._is_top_level
@is_top_level.setter
def is_top_level(self, t: bool):
self._is_top_level = t
# endregion # endregion
################################################################################### ###################################################################################

@ -204,6 +204,7 @@ class Function(
self._solidity_signature: Optional[str] = None self._solidity_signature: Optional[str] = None
self._signature_str: Optional[str] = None self._signature_str: Optional[str] = None
self._canonical_name: Optional[str] = None self._canonical_name: Optional[str] = None
self._is_protected: Optional[bool] = None
################################################################################### ###################################################################################
################################################################################### ###################################################################################
@ -1427,11 +1428,14 @@ class Function(
(bool) (bool)
""" """
if self._is_protected is None:
if self.is_constructor: if self.is_constructor:
self._is_protected = True
return True return True
conditional_vars = self.all_conditional_solidity_variables_read(include_loop=False) conditional_vars = self.all_conditional_solidity_variables_read(include_loop=False)
args_vars = self.all_solidity_variables_used_as_args() args_vars = self.all_solidity_variables_used_as_args()
return SolidityVariableComposed("msg.sender") in conditional_vars + args_vars self._is_protected = SolidityVariableComposed("msg.sender") in conditional_vars + args_vars
return self._is_protected
# endregion # endregion
################################################################################### ###################################################################################

Loading…
Cancel
Save