Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
0
 def __init__(self, values):
     # Note: Can return None 
     # ex: return call()
     # where call() dont return
     if not isinstance(values, list):
         assert is_valid_rvalue(values) or isinstance(values, TupleVariable) or values == None
         if not values is None:
             values = [values]
     else:
         for value in values:
             assert is_valid_rvalue(value) or isinstance(value, TupleVariable)
     super(Return, self).__init__()
     self._values = values
    def __init__(self, variable_left, variable_right, result):
        # Function can happen for something like
        # library FunctionExtensions {
        #     function h(function() internal _t, uint8) internal {  }
        # }
        # contract FunctionMembers {
        #     using FunctionExtensions for function();
        #
        #     function f() public {
        #         f.h(1);
        #     }
        # }
        # Can be an ElementaryType because of bytes.concat, string.concat
        assert is_valid_rvalue(variable_left) or isinstance(
            variable_left,
            (Contract, Enum, Function, CustomError, SolidityImportPlaceHolder,
             ElementaryType),
        )

        assert isinstance(variable_right, Constant)
        assert isinstance(result, ReferenceVariable)
        super().__init__()
        self._variable_left = variable_left
        self._variable_right = variable_right
        self._lvalue = result
        self._gas = None
        self._value = None
Beispiel #5
0
 def __init__(self, value, lvalue):
     super().__init__()
     assert is_valid_rvalue(value)
     assert is_valid_lvalue(lvalue)
     self._value = value
     self._lvalue = lvalue
     lvalue.set_type(ElementaryType("uint256"))
Beispiel #6
0
 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, Function))
     return True
Beispiel #7
0
 def __init__(self, result, variable, operation_type):
     assert is_valid_rvalue(variable)
     assert is_valid_lvalue(result)
     super(Unary, self).__init__()
     self._variable = variable
     self._type = operation_type
     self._lvalue = result
    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
Beispiel #9
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
Beispiel #10
0
 def __init__(self, value):
     # Note: Can return None
     # ex: return call()
     # where call() dont return
     assert is_valid_rvalue(value) or isinstance(
         value, TupleVariable) or value == None
     super(Return, self).__init__()
     self._value = value
    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
Beispiel #12
0
 def __init__(self, variable_left, variable_right, result):
     assert is_valid_rvalue(variable_left) or isinstance(
         variable_left, (Contract, Enum))
     assert isinstance(variable_right, Constant)
     assert isinstance(result, ReferenceVariable)
     super(Member, self).__init__()
     self._variable_left = variable_left
     self._variable_right = variable_right
     self._lvalue = result
 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
Beispiel #14
0
 def __init__(self, values):
     # Note: Can return None
     # ex: return call()
     # where call() dont return
     if not isinstance(values, list):
         assert is_valid_rvalue(values) or isinstance(
             values, (TupleVariable, Function)) or values is None
         if values is None:
             values = []
         else:
             values = [values]
     else:
         # Remove None
         # Prior Solidity 0.5
         # return (0,)
         # was valid for returns(uint)
         values = [v for v in values if not v is None]
         self._valid_value(values)
     super(Return, self).__init__()
     self._values = values
Beispiel #15
0
 def __init__(self, variable_left, variable_right, result):
     # Function can happen for something like
     # library FunctionExtensions {
     #     function h(function() internal _t, uint8) internal {  }
     # }
     # contract FunctionMembers {
     #     using FunctionExtensions for function();
     #
     #     function f() public {
     #         f.h(1);
     #     }
     # }
     assert is_valid_rvalue(variable_left) or isinstance(
         variable_left, (Contract, Enum, Function)
     )
     assert isinstance(variable_right, Constant)
     assert isinstance(result, ReferenceVariable)
     super().__init__()
     self._variable_left = variable_left
     self._variable_right = variable_right
     self._lvalue = result
     self._gas = None
     self._value = None
Beispiel #16
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'))
Beispiel #17
0
 def check(elem):
     if isinstance(elem, (list,)):
         return reduce(elem)
     return is_valid_rvalue(elem)
Beispiel #18
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
Beispiel #19
0
 def __init__(self, value):
     assert is_valid_rvalue(value)
     super().__init__()
     self._value = value
Beispiel #20
0
 def __init__(self, value):
     assert is_valid_rvalue(value)
     super(Condition, self).__init__()
     self._value = value
Beispiel #21
0
 def __init__(self, array, value):
     assert is_valid_rvalue(value)
     assert is_valid_lvalue(array)
     self._value = value
     self._lvalue = array