From 1017903e46d9f263f9f99fb8706843f99bf8a8b9 Mon Sep 17 00:00:00 2001 From: David Pokora Date: Tue, 22 Jan 2019 22:30:25 -0500 Subject: [PATCH] Refactored property/field names for improved accuracy. --- slither/core/declarations/contract.py | 29 ++++++------------- slither/core/declarations/function.py | 13 +++++---- slither/solc_parsing/declarations/function.py | 2 +- 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/slither/core/declarations/contract.py b/slither/core/declarations/contract.py index be026a1e3..a57a3fe3e 100644 --- a/slither/core/declarations/contract.py +++ b/slither/core/declarations/contract.py @@ -21,7 +21,7 @@ class Contract(ChildSlither, SourceMapping): self._id = None self._inheritance = [] self._immediate_inheritance = [] - self._base_constructor_contracts_called = [] + self._explicit_base_constructor_calls = [] self._enums = {} self._structures = {} @@ -79,7 +79,7 @@ class Contract(ChildSlither, SourceMapping): def setInheritance(self, inheritance, immediate_inheritance, called_base_constructor_contracts): self._inheritance = inheritance self._immediate_inheritance = immediate_inheritance - self._base_constructor_contracts_called = called_base_constructor_contracts + self._explicit_base_constructor_calls = called_base_constructor_contracts @property def derived_contracts(self): @@ -143,27 +143,16 @@ class Contract(ChildSlither, SourceMapping): return [f for f in self.functions if f.visibility in ['public', 'external']] @property - def base_constructors_called(self): + def explicit_base_constructor_calls(self): """ - list(Function): List of the base constructors invoked by this contract definition, not via - this contract's constructor definition. + list(Function): List of the base constructors called explicitly by this contract definition. - NOTE: Base constructors can also be called from the constructor definition! + Base constructors called by any constructor definition will not be included. + Base constructors implicitly called by the contract definition (without + parenthesis) will not be included. """ - return [c.constructor for c in self._base_constructor_contracts_called if c.constructor] - - @property - def all_base_constructors_called(self): - """ - list(Function): List of the base constructors invoked by this contract definition, or the - underlying constructor definition. They should be in order of declaration, - starting first with contract definition's base constructor calls, then the - constructor definition's base constructor calls. - - NOTE: Duplicates may occur if the same base contracts are called in both - the contract and constructor definition. - """ - return self.base_constructors_called + self.constructor.base_constructors_called + # This is a list of contracts internally, so we convert it to a list of constructor functions. + return [c.constructor for c in self._explicit_base_constructor_calls if c.constructor] @property def modifiers(self): diff --git a/slither/core/declarations/function.py b/slither/core/declarations/function.py index 9bc6678a9..ab4bbb06e 100644 --- a/slither/core/declarations/function.py +++ b/slither/core/declarations/function.py @@ -56,7 +56,7 @@ class Function(ChildContract, SourceMapping): self._expression_calls = [] self._expression_modifiers = [] self._modifiers = [] - self._base_constructor_contracts_called = [] + self._explicit_base_constructor_calls = [] self._payable = False self._contains_assembly = False @@ -200,14 +200,15 @@ class Function(ChildContract, SourceMapping): return list(self._modifiers) @property - def base_constructors_called(self): + def explicit_base_constructor_calls(self): """ - list(Function): List of the base constructors invoked by this presumed constructor by definition, not via - calls within the function body. + list(Function): List of the base constructors called explicitly by this presumed constructor definition. - NOTE: Base constructors can also be called from the contract definition! + Base constructors implicitly or explicitly called by the contract definition will not be + included. """ - return [c.constructor for c in self._base_constructor_contracts_called if c.constructor] + # This is a list of contracts internally, so we convert it to a list of constructor functions. + return [c.constructor for c in self._explicit_base_constructor_calls if c.constructor] def __str__(self): return self._name diff --git a/slither/solc_parsing/declarations/function.py b/slither/solc_parsing/declarations/function.py index 69451c073..4b6b7c42f 100644 --- a/slither/solc_parsing/declarations/function.py +++ b/slither/solc_parsing/declarations/function.py @@ -773,7 +773,7 @@ class FunctionSolc(Function): if isinstance(m, Function): self._modifiers.append(m) elif isinstance(m, Contract): - self._base_constructor_contracts_called.append(m) + self._explicit_base_constructor_calls.append(m) def analyze_params(self):