Instruction.previous_instruction()
Returns a list of immediate previous instructions in the control flow graph.
previous_instruction() →
APISet
[
Instruction
]
The difference between the previous_instruction() function and previous_instructions() is that this function will return a list of immediate previous instructions of the current instruction in the CFG (control-flow-graph).
The function operates non-recursively, meaning it works intra-procedurally.
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:
uint256 c = a - b;
the function will return the instruction:
require(b <= a, errorMessage);
Query Example
from glider import *
def query():
instructions = Functions().with_name("sub").exec(1,1).instructions().exec(1,2)
return instructions + list(instructions[0].previous_instruction())
Output Example

Last updated