Instruction.previous_instructions()
Returns a list of the previous instructions of the current node in the control flow graph.
previous_instructions() →
APISet
[
Instruction
]
The difference between the previous_instructions() function and previous_instruction() is that this function will return all previous instructions of the current instruction in the CFG (control-flow-graph).
The function is non-recursive (intra-procedural), and thus will not follow function calls; for the recursive (inter-procedural) variant of this function, use extended_previous_instructions().
For example, in the function:
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
for the instruction:
return c;
the function will return the instructions:
uint256 c = a - b;
require(b <= a, errorMessage);
*entry_point_instruction*
require(b <= a, errorMessage);
*entry_point_instruction*
{
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
Query Example
from glider import *
def query():
instructions = Functions().with_name("sub").exec(1,1).instructions().exec(1,3)
return instructions + list(instructions[0].previous_instructions())
Example Output

Last updated