Predicate TwoOperands::getASet
Get a set of operands for the given operation, ordered (a, b) or (b, a).
Never mix getASet calls without binding the result, e.g.
...::getASet(e).someOperand().... and ...::getASet(e).otherOperand()...., or else the
getASet predicate may hold for two different orders of the two operands. The consequence of
this is that .someOperand() and otherOperand() may refer to the same operand. Always bind
the result of this predicate to a singular instance, e.g.
exists(TwoOperands<BinaryExpr>::Set set | ... ).
Example usage:
predicate myBinaryTest(TwoOperands<BinaryExpr>::Set set) {
set.someOperand().isInteger() and
set.otherOperand().isConstant()
}
from BinaryExpr e
where myBinaryTest(TwoOperands<BinaryExpr>::getASet(e))
select e, "found match"
For an alternative, more minimal API see the set predicate.
Import path
import qtil.ast.TwoOperands