The function is the recursive/inter-procedural variant of the instructions(), meaning that it works recursively. It returns a set of Instructions object representing all the instructions which are reachable from the target function, the differences between instructions_recursive() and instructions() the latter will only return instructions directly accessible from the function. At the same time, the recursive version will find all the instructions recursively, which are eventually called when executing the function.
Also, note that the return types of instructions_recursive() -> APISet[Instruction] and instructions() -> Instructions are different, the recursive version returns an APISet of Instruction objects, while the original one returns Instructions (queryable) object.
Query Example
from glider import*defquery():# Let's find a function with name transferFrom functions =Functions().with_name('transferOwnership').exec(1)# Print the code of the functionprint(functions[0].source_code())# Return the list of (recursive) instructions, as it return a set, we need to cast it to listreturnlist(functions[0].instructions_recursive().exec(10))
For the function:
functiontransferOwnership(addressnewOwner)publicvirtualonlyOwner{require(newOwner !=address(0),"Ownable: new owner is the zero address");_transferOwnership(newOwner);}