- Add .used attributes to all operators, it returns all the variables used
 - Use ABC for Operation
pull/58/head
Josselin 6 years ago
parent f1a8677629
commit e4b010af8a
  1. 4
      slither/slithir/operations/high_level_call.py
  2. 2
      slither/slithir/operations/internal_dynamic_call.py
  3. 4
      slither/slithir/operations/low_level_call.py
  4. 4
      slither/slithir/operations/lvalue.py
  5. 26
      slither/slithir/operations/operation.py
  6. 2
      slither/slithir/operations/send.py
  7. 2
      slither/slithir/operations/transfer.py

@ -58,7 +58,9 @@ class HighLevelCall(Call, OperationWithLValue):
@property
def read(self):
return [self.destination]
all_read = [self.destination, self.call_gas, self.call_value] + self.arguments
# remove None
return [x for x in all_read if x]
@property
def destination(self):

@ -19,7 +19,7 @@ class InternalDynamicCall(Call, OperationWithLValue):
@property
def read(self):
return list(self.arguments)
return list(self.arguments) + [self.function]
@property
def function(self):

@ -50,7 +50,9 @@ class LowLevelCall(Call, OperationWithLValue):
@property
def read(self):
return [self.destination]
all_read = [self.destination, self.call_gas, self.call_value] + self.arguments
# remove None
return [x for x in all_read if x]
@property
def destination(self):

@ -14,6 +14,10 @@ class OperationWithLValue(Operation):
def lvalue(self):
return self._lvalue
@property
def used(self):
return self.read + [self.lvalue]
@lvalue.setter
def lvalue(self, lvalue):
self._lvalue = lvalue

@ -1,9 +1,29 @@
import abc
from slither.core.context.context import Context
class Operation(Context):
class AbstractOperation(abc.ABC):
@property
@abc.abstractmethod
def read(self):
"""
Must be ovveriden
Return the list of variables READ
"""
pass
@property
@abc.abstractmethod
def used(self):
"""
Return the list of variables used
"""
pass
class Operation(Context, AbstractOperation):
@property
def used(self):
"""
By default used is all the variables read
"""
raise Exception('Not overrided {}'.format(type(self)))
return self.read

@ -23,7 +23,7 @@ class Send(Call, OperationWithLValue):
@property
def read(self):
return [self.destination]
return [self.destination, self.call_value]
@property
def destination(self):

@ -18,7 +18,7 @@ class Transfer(Call):
@property
def read(self):
return [self.destination]
return [self.destination, self.call_value]
@property
def destination(self):

Loading…
Cancel
Save