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.counter_slithir_tuple = 0
self.counter_slithir_temporary = 0
self.counter_slithir_reference = 0
###################################################################################
###################################################################################
# region Source code

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

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

@ -1,16 +1,19 @@
from typing import TYPE_CHECKING
from slither.core.children.child_node import ChildNode
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__()
if index is None:
self._index = TupleVariable.COUNTER
TupleVariable.COUNTER += 1
self._index = node.slither.counter_slithir_tuple
node.slither.counter_slithir_tuple += 1
else:
self._index = index

Loading…
Cancel
Save