Ejemplo n.º 1
0
 def __init__(self, left_variable, nodes, call_ir, rvalue):
     assert is_valid_lvalue(left_variable)
     assert isinstance(nodes, set)
     super(PhiCallback, self).__init__(left_variable, nodes)
     self._call_ir = call_ir
     self._rvalues = [rvalue]
     self._rvalue_no_callback = rvalue
Ejemplo n.º 2
0
    def __init__(self, destination, value, result):
        assert is_valid_lvalue(result)
        assert isinstance(destination, (Variable, SolidityVariable))
        super(Send, self).__init__()
        self._destination = destination
        self._lvalue = result

        self._call_value = value
Ejemplo n.º 3
0
    def points_to(self, points_to):
        # Can only be a rvalue of
        # Member or Index operator
        from slither.slithir.utils.utils import is_valid_lvalue
        assert is_valid_lvalue(points_to) \
            or isinstance(points_to, (SolidityVariable, Contract, Enum))

        self._points_to = points_to
Ejemplo n.º 4
0
 def __init__(self, left_variable, right_variable, variable_return_type):
     assert is_valid_lvalue(left_variable)
     assert is_valid_rvalue(right_variable) or isinstance(right_variable, (Function, TupleVariable))
     super(Assignment, self).__init__()
     self._variables = [left_variable, right_variable]
     self._lvalue = left_variable
     self._rvalue = right_variable
     self._variable_return_type = variable_return_type
Ejemplo n.º 5
0
 def __init__(self, lvalue, function, function_type):
     assert isinstance(function_type, FunctionType)
     assert isinstance(function, Variable)
     assert is_valid_lvalue(lvalue) or lvalue is None
     super(InternalDynamicCall, self).__init__()
     self._function = function
     self._function_type = function_type
     self._lvalue = lvalue
Ejemplo n.º 6
0
    def __init__(self, result, variable, variable_type):
        assert is_valid_rvalue(variable)
        assert is_valid_lvalue(result)
        assert isinstance(variable_type, Type)

        self._variable = variable
        self._type = variable_type
        self._lvalue = result
Ejemplo n.º 7
0
 def __init__(self, result, tuple_var, idx):
     assert is_valid_lvalue(result)
     assert isinstance(tuple_var, TupleVariable)
     assert isinstance(idx, int)
     super(Unpack, self).__init__()
     self._tuple = tuple_var
     self._idx = idx
     self._lvalue = result
Ejemplo n.º 8
0
 def __init__(self, contract_name, lvalue):
     assert isinstance(contract_name, Constant)
     assert is_valid_lvalue(lvalue)
     super(NewContract, self).__init__()
     self._contract_name = contract_name
     # todo create analyze to add the contract instance
     self._lvalue = lvalue
     self._callid = None  # only used if gas/value != 0
     self._call_value = None
Ejemplo n.º 9
0
    def __init__(self, result, variable, variable_type):
        super().__init__()
        assert is_valid_rvalue(variable) or isinstance(variable, Contract)
        assert is_valid_lvalue(result)
        assert isinstance(variable_type, Type)

        self._variable = variable
        self._type = variable_type
        self._lvalue = result
Ejemplo n.º 10
0
 def __init__(self, result, left_variable, right_variable, index_type):
     super().__init__()
     assert is_valid_lvalue(
         left_variable) or left_variable == SolidityVariableComposed(
             "msg.data")
     assert is_valid_rvalue(right_variable)
     assert isinstance(result, ReferenceVariable)
     self._variables = [left_variable, right_variable]
     self._type = index_type
     self._lvalue = result
Ejemplo n.º 11
0
 def __init__(self, result, left_variable, right_variable, operation_type):
     assert is_valid_rvalue(left_variable)
     assert is_valid_rvalue(right_variable)
     assert is_valid_lvalue(result)
     super(Binary, self).__init__()
     self._variables = [left_variable, right_variable]
     self._type = operation_type
     self._lvalue = result
     if BinaryType.return_bool(operation_type):
         result.set_type(ElementaryType('bool'))
     else:
         result.set_type(left_variable.type)
Ejemplo n.º 12
0
 def __init__(self, left_variable, nodes):
     # When Phi operations are created the
     # correct indexes of the variables are not yet computed
     # We store the nodes where the variables are written
     # so we can update the rvalues of the Phi operation
     # after its instantiation
     assert is_valid_lvalue(left_variable)
     assert isinstance(nodes, set)
     super().__init__()
     self._lvalue = left_variable
     self._rvalues = []
     self._nodes = nodes
Ejemplo n.º 13
0
 def __init__(self, result, left_variable, right_variable, operation_type: BinaryType):
     assert is_valid_rvalue(left_variable) or isinstance(left_variable, Function)
     assert is_valid_rvalue(right_variable) or isinstance(right_variable, Function)
     assert is_valid_lvalue(result)
     assert isinstance(operation_type, BinaryType)
     super().__init__()
     self._variables = [left_variable, right_variable]
     self._type = operation_type
     self._lvalue = result
     if BinaryType.return_bool(operation_type):
         result.set_type(ElementaryType("bool"))
     else:
         result.set_type(left_variable.type)
Ejemplo n.º 14
0
    def __init__(self, destination, function_name, nbr_arguments, result, type_call):
        assert isinstance(function_name, Constant)
        assert is_valid_lvalue(result) or result is None
        self._check_destination(destination)
        super(HighLevelCall, self).__init__()
        self._destination = destination
        self._function_name = function_name
        self._nbr_arguments = nbr_arguments
        self._type_call = type_call
        self._lvalue = result
        self._callid = None  # only used if gas/value != 0
        self._function_instance = None

        self._call_value = None
        self._call_gas = None
Ejemplo n.º 15
0
 def __init__(self, value, lvalue):
     assert is_valid_rvalue(value)
     assert is_valid_lvalue(lvalue)
     self._value = value
     self._lvalue = lvalue
     lvalue.set_type(ElementaryType('uint256'))
Ejemplo n.º 16
0
 def __init__(self, array, value):
     assert is_valid_rvalue(value) or isinstance(value, Function)
     assert is_valid_lvalue(array)
     self._value = value
     self._lvalue = array
Ejemplo n.º 17
0
 def __init__(self, lvalue, variable):
     assert is_valid_lvalue(variable)
     super(Delete, self).__init__()
     self._variable = variable
     self._lvalue = lvalue
Ejemplo n.º 18
0
 def __init__(self, new_type, lvalue):
     assert isinstance(new_type, ElementaryType)
     assert is_valid_lvalue(lvalue)
     super(NewElementaryType, self).__init__()
     self._type = new_type
     self._lvalue = lvalue
Ejemplo n.º 19
0
 def __init__(self, array, value):
     assert is_valid_rvalue(value)
     assert is_valid_lvalue(array)
     self._value = value
     self._lvalue = array