slither.slithir.operations.internal_call
1from typing import Any 2from slither.core.declarations import Modifier 3from slither.core.declarations.function import Function 4from slither.core.declarations.function_contract import FunctionContract 5from slither.slithir.operations.call import Call 6from slither.slithir.operations.lvalue import OperationWithLValue 7from slither.slithir.variables.constant import Constant 8from slither.slithir.variables.temporary import TemporaryVariable 9from slither.slithir.variables.temporary_ssa import TemporaryVariableSSA 10from slither.slithir.variables.tuple import TupleVariable 11from slither.slithir.variables.tuple_ssa import TupleVariableSSA 12 13 14class InternalCall(Call, OperationWithLValue): 15 def __init__( 16 self, 17 function: Function | tuple[str, str], 18 nbr_arguments: int, 19 result: TupleVariableSSA | TemporaryVariableSSA | TupleVariable | TemporaryVariable | None, 20 type_call: str, 21 names: list[str] | None = 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 self._contract_name = "" 31 if isinstance(function, Function): 32 self._function: Function | None = function 33 self._function_name = function.name 34 if isinstance(function, FunctionContract): 35 self._contract_name = function.contract_declarer.name 36 else: 37 self._function = None 38 self._function_name, self._contract_name = function 39 # self._contract = contract 40 self._nbr_arguments = nbr_arguments 41 self._type_call = type_call 42 self._lvalue = result 43 # function_candidates is only used as an helper to retrieve the "function" object 44 # For top level function called through a import renamed 45 # See SolidityImportPlaceHolder usages 46 self.function_candidates: list[Function] | None = None 47 48 @property 49 def read(self) -> list[Any]: 50 return list(self._unroll(self.arguments)) 51 52 @property 53 def function(self) -> Function | None: 54 return self._function 55 56 @function.setter 57 def function(self, f): 58 self._function = f 59 60 @property 61 def function_name(self) -> Constant: 62 return self._function_name 63 64 @property 65 def contract_name(self) -> str: 66 return self._contract_name 67 68 @property 69 def nbr_arguments(self) -> int: 70 return self._nbr_arguments 71 72 @property 73 def type_call(self) -> str: 74 return self._type_call 75 76 @property 77 def is_modifier_call(self): 78 """ 79 Check if the destination is a modifier 80 :return: bool 81 """ 82 return isinstance(self.function, Modifier) 83 84 def __str__(self): 85 args = [str(a) for a in self.arguments] 86 if not self.lvalue: 87 lvalue = "" 88 elif isinstance(self.lvalue.type, (list,)): 89 lvalue = f"{self.lvalue}({','.join(str(x) for x in self.lvalue.type)}) = " 90 else: 91 lvalue = f"{self.lvalue}({self.lvalue.type}) = " 92 if self.is_modifier_call: 93 txt = "{}MODIFIER_CALL, {}({})" 94 else: 95 txt = "{}INTERNAL_CALL, {}({})" 96 return txt.format(lvalue, self.function.canonical_name, ",".join(args))
class
InternalCall(slither.slithir.operations.call.Call, slither.slithir.operations.lvalue.OperationWithLValue):
15class InternalCall(Call, OperationWithLValue): 16 def __init__( 17 self, 18 function: Function | tuple[str, str], 19 nbr_arguments: int, 20 result: TupleVariableSSA | TemporaryVariableSSA | TupleVariable | TemporaryVariable | None, 21 type_call: str, 22 names: list[str] | None = None, 23 ) -> None: 24 """ 25 #### Parameters 26 names - 27 For calls of the form f({argName1 : arg1, ...}), the names of parameters listed in call order. 28 Otherwise, None. 29 """ 30 super().__init__(names=names) 31 self._contract_name = "" 32 if isinstance(function, Function): 33 self._function: Function | None = function 34 self._function_name = function.name 35 if isinstance(function, FunctionContract): 36 self._contract_name = function.contract_declarer.name 37 else: 38 self._function = None 39 self._function_name, self._contract_name = function 40 # self._contract = contract 41 self._nbr_arguments = nbr_arguments 42 self._type_call = type_call 43 self._lvalue = result 44 # function_candidates is only used as an helper to retrieve the "function" object 45 # For top level function called through a import renamed 46 # See SolidityImportPlaceHolder usages 47 self.function_candidates: list[Function] | None = None 48 49 @property 50 def read(self) -> list[Any]: 51 return list(self._unroll(self.arguments)) 52 53 @property 54 def function(self) -> Function | None: 55 return self._function 56 57 @function.setter 58 def function(self, f): 59 self._function = f 60 61 @property 62 def function_name(self) -> Constant: 63 return self._function_name 64 65 @property 66 def contract_name(self) -> str: 67 return self._contract_name 68 69 @property 70 def nbr_arguments(self) -> int: 71 return self._nbr_arguments 72 73 @property 74 def type_call(self) -> str: 75 return self._type_call 76 77 @property 78 def is_modifier_call(self): 79 """ 80 Check if the destination is a modifier 81 :return: bool 82 """ 83 return isinstance(self.function, Modifier) 84 85 def __str__(self): 86 args = [str(a) for a in self.arguments] 87 if not self.lvalue: 88 lvalue = "" 89 elif isinstance(self.lvalue.type, (list,)): 90 lvalue = f"{self.lvalue}({','.join(str(x) for x in self.lvalue.type)}) = " 91 else: 92 lvalue = f"{self.lvalue}({self.lvalue.type}) = " 93 if self.is_modifier_call: 94 txt = "{}MODIFIER_CALL, {}({})" 95 else: 96 txt = "{}INTERNAL_CALL, {}({})" 97 return txt.format(lvalue, self.function.canonical_name, ",".join(args))
Operation with a lvalue
InternalCall( function: slither.core.declarations.function.Function | tuple[str, str], nbr_arguments: int, result: slither.slithir.variables.tuple_ssa.TupleVariableSSA | slither.slithir.variables.temporary_ssa.TemporaryVariableSSA | slither.slithir.variables.tuple.TupleVariable | slither.slithir.variables.temporary.TemporaryVariable | None, type_call: str, names: list[str] | None = None)
16 def __init__( 17 self, 18 function: Function | tuple[str, str], 19 nbr_arguments: int, 20 result: TupleVariableSSA | TemporaryVariableSSA | TupleVariable | TemporaryVariable | None, 21 type_call: str, 22 names: list[str] | None = None, 23 ) -> None: 24 """ 25 #### Parameters 26 names - 27 For calls of the form f({argName1 : arg1, ...}), the names of parameters listed in call order. 28 Otherwise, None. 29 """ 30 super().__init__(names=names) 31 self._contract_name = "" 32 if isinstance(function, Function): 33 self._function: Function | None = function 34 self._function_name = function.name 35 if isinstance(function, FunctionContract): 36 self._contract_name = function.contract_declarer.name 37 else: 38 self._function = None 39 self._function_name, self._contract_name = function 40 # self._contract = contract 41 self._nbr_arguments = nbr_arguments 42 self._type_call = type_call 43 self._lvalue = result 44 # function_candidates is only used as an helper to retrieve the "function" object 45 # For top level function called through a import renamed 46 # See SolidityImportPlaceHolder usages 47 self.function_candidates: list[Function] | None = None
Parameters
names - For calls of the form f({argName1 : arg1, ...}), the names of parameters listed in call order. Otherwise, None.
function_candidates: list[slither.core.declarations.function.Function] | None
function: slither.core.declarations.function.Function | None
function_name: slither.slithir.variables.constant.Constant
is_modifier_call
77 @property 78 def is_modifier_call(self): 79 """ 80 Check if the destination is a modifier 81 :return: bool 82 """ 83 return isinstance(self.function, Modifier)
Check if the destination is a modifier
Returns
bool