Remove COUNTER from slithir variables classes

pull/828/head
Josselin 4 years ago
parent 115066c643
commit 81bf2cce99
  1. 4
      slither/core/slither_core.py
  2. 12
      slither/slithir/variables/reference.py
  3. 12
      slither/slithir/variables/temporary.py
  4. 13
      slither/slithir/variables/tuple.py

@ -90,6 +90,10 @@ class SlitherCore(Context): # pylint: disable=too-many-instance-attributes,too-
self._show_ignored_findings = False self._show_ignored_findings = False
self.counter_slithir_tuple = 0
self.counter_slithir_temporary = 0
self.counter_slithir_reference = 0
################################################################################### ###################################################################################
################################################################################### ###################################################################################
# region Source code # region Source code

@ -1,17 +1,19 @@
from typing import TYPE_CHECKING
from slither.core.children.child_node import ChildNode from slither.core.children.child_node import ChildNode
from slither.core.declarations import Contract, Enum, SolidityVariable, Function from slither.core.declarations import Contract, Enum, SolidityVariable, Function
from slither.core.variables.variable import Variable from slither.core.variables.variable import Variable
if TYPE_CHECKING:
from slither.core.cfg.node import Node
class ReferenceVariable(ChildNode, Variable): class ReferenceVariable(ChildNode, Variable):
COUNTER = 0 def __init__(self, node: "Node", index=None):
def __init__(self, node, index=None):
super().__init__() super().__init__()
if index is None: if index is None:
self._index = ReferenceVariable.COUNTER self._index = node.slither.counter_slithir_reference
ReferenceVariable.COUNTER += 1 node.slither.counter_slithir_reference += 1
else: else:
self._index = index self._index = index
self._points_to = None self._points_to = None

@ -1,16 +1,18 @@
from typing import TYPE_CHECKING
from slither.core.children.child_node import ChildNode from slither.core.children.child_node import ChildNode
from slither.core.variables.variable import Variable from slither.core.variables.variable import Variable
if TYPE_CHECKING:
from slither.core.cfg.node import Node
class TemporaryVariable(ChildNode, Variable): class TemporaryVariable(ChildNode, Variable):
COUNTER = 0 def __init__(self, node: "Node", index=None):
def __init__(self, node, index=None):
super().__init__() super().__init__()
if index is None: if index is None:
self._index = TemporaryVariable.COUNTER self._index = node.slither.counter_slithir_temporary
TemporaryVariable.COUNTER += 1 node.slither.counter_slithir_temporary += 1
else: else:
self._index = index self._index = index
self._node = node self._node = node

@ -1,16 +1,19 @@
from typing import TYPE_CHECKING
from slither.core.children.child_node import ChildNode from slither.core.children.child_node import ChildNode
from slither.slithir.variables.variable import SlithIRVariable from slither.slithir.variables.variable import SlithIRVariable
if TYPE_CHECKING:
from slither.core.cfg.node import Node
class TupleVariable(ChildNode, SlithIRVariable):
COUNTER = 0 class TupleVariable(ChildNode, SlithIRVariable):
def __init__(self, node, index=None): def __init__(self, node: "Node", index=None):
super().__init__() super().__init__()
if index is None: if index is None:
self._index = TupleVariable.COUNTER self._index = node.slither.counter_slithir_tuple
TupleVariable.COUNTER += 1 node.slither.counter_slithir_tuple += 1
else: else:
self._index = index self._index = index

Loading…
Cancel
Save