Fix incorrect handling of nested return values

pull/87/head
Josselin 6 years ago
parent 2f17fea1a5
commit 32ed2dfefd
  1. 9
      slither/slithir/operations/call.py
  2. 10
      slither/slithir/operations/init_array.py
  3. 9
      slither/slithir/operations/operation.py
  4. 12
      slither/slithir/operations/return_operation.py

@ -15,12 +15,3 @@ class Call(Operation):
def arguments(self, v):
self._arguments = v
# if array inside the parameters
def _unroll(self, l):
ret = []
for x in l:
if not isinstance(x, list):
ret += [x]
else:
ret += self._unroll(x)
return ret

@ -21,16 +21,6 @@ class InitArray(OperationWithLValue):
self._init_values = init_values
self._lvalue = lvalue
# if array inside the init values
def _unroll(self, l):
ret = []
for x in l:
if not isinstance(x, list):
ret += [x]
else:
ret += self._unroll(x)
return ret
@property
def read(self):
return self._unroll(self.init_values)

@ -29,3 +29,12 @@ class Operation(Context, ChildNode, AbstractOperation):
"""
return self.read
# if array inside the parameters
def _unroll(self, l):
ret = []
for x in l:
if not isinstance(x, list):
ret += [x]
else:
ret += self._unroll(x)
return ret

@ -18,14 +18,20 @@ class Return(Operation):
else:
values = [values]
else:
for value in values:
assert is_valid_rvalue(value) or isinstance(value, TupleVariable)
self._valid_value(values)
super(Return, self).__init__()
self._values = values
def _valid_value(self, value):
if isinstance(value, list):
assert all(self._valid_value(v) for v in value)
else:
assert is_valid_rvalue(value) or isinstance(value, TupleVariable)
return True
@property
def read(self):
return self.values
return self._unroll(self.values)
@property
def values(self):

Loading…
Cancel
Save