Refactored property/field names for improved accuracy.

pull/132/head
David Pokora 6 years ago
parent 4c1f5dde51
commit 1017903e46
No known key found for this signature in database
GPG Key ID: 3CED48D1BB21BDD7
  1. 29
      slither/core/declarations/contract.py
  2. 13
      slither/core/declarations/function.py
  3. 2
      slither/solc_parsing/declarations/function.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):

@ -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

@ -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):

Loading…
Cancel
Save