SlithIR: fix minor bugs

pull/64/head
Josselin 6 years ago
parent cfc3988ed1
commit 545841659b
  1. 1
      slither/core/cfg/node.py
  2. 14
      slither/slithir/convert.py
  3. 2
      slither/slithir/operations/assignment.py

@ -367,7 +367,6 @@ class Node(SourceMapping, ChildFunction):
def is_slithir_var(var):
return isinstance(var, (Constant, ReferenceVariable, TemporaryVariable, TupleVariable))
for ir in self.irs:
self._vars_read += [v for v in ir.read if not is_slithir_var(v)]
if isinstance(ir, OperationWithLValue):

@ -357,7 +357,12 @@ def convert_type_of_high_level_call(ir, contract):
return_type = return_type[0]
else:
# otherwise its a variable (getter)
return_type = func.type
if isinstance(func.type, MappingType):
return_type = func.type.type_to
elif isinstance(func.type, ArrayType):
return_type = func.type.type
else:
return_type = func.type
if return_type:
ir.lvalue.set_type(return_type)
else:
@ -369,9 +374,12 @@ def propagate_types(ir, node):
# propagate the type
using_for = node.function.contract.using_for
if isinstance(ir, OperationWithLValue):
# Force assignment in case of missing previous correct type
if isinstance(ir, Assignment):
ir.lvalue.set_type(ir.rvalue.type)
if not ir.lvalue.type:
if isinstance(ir, Assignment):
ir.lvalue.set_type(ir.rvalue.type)
pass
elif isinstance(ir, Binary):
if BinaryType.return_bool(ir.type):
ir.lvalue.set_type(ElementaryType('bool'))
@ -451,7 +459,7 @@ def propagate_types(ir, node):
assert False
elif isinstance(ir, Member):
# TODO we should convert the reference to a temporary if the member is a length or a balance
if ir.variable_right == 'length' and isinstance(ir.variable_left.type, ElementaryType):
if ir.variable_right == 'length' and isinstance(ir.variable_left.type, (ElementaryType, ArrayType)):
return Length(ir.variable_left, ir.lvalue)
if ir.variable_right == 'balance' and isinstance(ir.variable_left.type, ElementaryType):
return Balance(ir.variable_left, ir.lvalue)

@ -36,4 +36,4 @@ class Assignment(OperationWithLValue):
return self._rvalue
def __str__(self):
return '{} := {}'.format(self.lvalue, self.rvalue)
return '{}({}) := {}({})'.format(self.lvalue, self.lvalue.type, self.rvalue, self.rvalue.type)

Loading…
Cancel
Save