slither.slithir.operations.new_structure
1from typing import List, Optional, Union 2 3from slither.slithir.operations.call import Call 4from slither.slithir.operations.lvalue import OperationWithLValue 5 6from slither.slithir.utils.utils import is_valid_lvalue 7 8from slither.core.declarations.structure import Structure 9from slither.core.declarations.structure_contract import StructureContract 10from slither.slithir.variables.constant import Constant 11from slither.slithir.variables.temporary import TemporaryVariable 12from slither.slithir.variables.temporary_ssa import TemporaryVariableSSA 13 14 15class NewStructure(Call, OperationWithLValue): 16 def __init__( 17 self, 18 structure: StructureContract, 19 lvalue: Union[TemporaryVariableSSA, TemporaryVariable], 20 names: Optional[List[str]] = None, 21 ) -> None: 22 """ 23 #### Parameters 24 names - 25 For calls of the form f({argName1 : arg1, ...}), the names of parameters listed in call order. 26 Otherwise, None. 27 """ 28 super().__init__(names=names) 29 assert isinstance(structure, Structure) 30 assert is_valid_lvalue(lvalue) 31 self._structure = structure 32 # todo create analyze to add the contract instance 33 self._lvalue = lvalue 34 35 @property 36 def read(self) -> List[Union[TemporaryVariableSSA, TemporaryVariable, Constant]]: 37 return self._unroll(self.arguments) 38 39 @property 40 def structure(self) -> StructureContract: 41 return self._structure 42 43 @property 44 def structure_name(self): 45 return self.structure.name 46 47 def __str__(self): 48 args = [str(a) for a in self.arguments] 49 lvalue = self.lvalue 50 return f"{lvalue}({lvalue.type}) = new {self.structure_name}({','.join(args)})"
class
NewStructure(slither.slithir.operations.call.Call, slither.slithir.operations.lvalue.OperationWithLValue):
16class NewStructure(Call, OperationWithLValue): 17 def __init__( 18 self, 19 structure: StructureContract, 20 lvalue: Union[TemporaryVariableSSA, TemporaryVariable], 21 names: Optional[List[str]] = None, 22 ) -> None: 23 """ 24 #### Parameters 25 names - 26 For calls of the form f({argName1 : arg1, ...}), the names of parameters listed in call order. 27 Otherwise, None. 28 """ 29 super().__init__(names=names) 30 assert isinstance(structure, Structure) 31 assert is_valid_lvalue(lvalue) 32 self._structure = structure 33 # todo create analyze to add the contract instance 34 self._lvalue = lvalue 35 36 @property 37 def read(self) -> List[Union[TemporaryVariableSSA, TemporaryVariable, Constant]]: 38 return self._unroll(self.arguments) 39 40 @property 41 def structure(self) -> StructureContract: 42 return self._structure 43 44 @property 45 def structure_name(self): 46 return self.structure.name 47 48 def __str__(self): 49 args = [str(a) for a in self.arguments] 50 lvalue = self.lvalue 51 return f"{lvalue}({lvalue.type}) = new {self.structure_name}({','.join(args)})"
Operation with a lvalue
NewStructure( structure: slither.core.declarations.structure_contract.StructureContract, lvalue: Union[slither.slithir.variables.temporary_ssa.TemporaryVariableSSA, slither.slithir.variables.temporary.TemporaryVariable], names: Union[List[str], NoneType] = None)
17 def __init__( 18 self, 19 structure: StructureContract, 20 lvalue: Union[TemporaryVariableSSA, TemporaryVariable], 21 names: Optional[List[str]] = None, 22 ) -> None: 23 """ 24 #### Parameters 25 names - 26 For calls of the form f({argName1 : arg1, ...}), the names of parameters listed in call order. 27 Otherwise, None. 28 """ 29 super().__init__(names=names) 30 assert isinstance(structure, Structure) 31 assert is_valid_lvalue(lvalue) 32 self._structure = structure 33 # todo create analyze to add the contract instance 34 self._lvalue = lvalue
Parameters
names - For calls of the form f({argName1 : arg1, ...}), the names of parameters listed in call order. Otherwise, None.
read: List[Union[slither.slithir.variables.temporary_ssa.TemporaryVariableSSA, slither.slithir.variables.temporary.TemporaryVariable, slither.slithir.variables.constant.Constant]]
36 @property 37 def read(self) -> List[Union[TemporaryVariableSSA, TemporaryVariable, Constant]]: 38 return self._unroll(self.arguments)
Return the list of variables READ