MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / process

Method process

src/dsql/BoolNodes.cpp:1698–1808  ·  view source on GitHub ↗

Replace NOT with an appropriately inverted condition, if possible. Get rid of redundant nested NOT predicates.

Source from the content-addressed store, hash-verified

1696// Replace NOT with an appropriately inverted condition, if possible.
1697// Get rid of redundant nested NOT predicates.
1698BoolExprNode* NotBoolNode::process(DsqlCompilerScratch* dsqlScratch, bool invert)
1699{
1700 MemoryPool& pool = dsqlScratch->getPool();
1701 NotBoolNode* notArg = nodeAs<NotBoolNode>(arg);
1702
1703 if (notArg)
1704 {
1705 // Recurse until different node is found (every even call means no inversion required).
1706 return notArg->process(dsqlScratch, !invert);
1707 }
1708
1709 if (!invert)
1710 return arg->dsqlPass(dsqlScratch);
1711
1712 ComparativeBoolNode* cmpArg = nodeAs<ComparativeBoolNode>(arg);
1713 BinaryBoolNode* binArg = nodeAs<BinaryBoolNode>(arg);
1714
1715 // Do not handle special case: <value> NOT IN <list>
1716
1717 if (cmpArg && (!cmpArg->dsqlSpecialArg || !nodeIs<ValueListNode>(cmpArg->dsqlSpecialArg)))
1718 {
1719 // Invert the given boolean.
1720 switch (cmpArg->blrOp)
1721 {
1722 case blr_eql:
1723 case blr_neq:
1724 case blr_lss:
1725 case blr_gtr:
1726 case blr_leq:
1727 case blr_geq:
1728 {
1729 UCHAR newBlrOp;
1730
1731 switch (cmpArg->blrOp)
1732 {
1733 case blr_eql:
1734 newBlrOp = blr_neq;
1735 break;
1736 case blr_neq:
1737 newBlrOp = blr_eql;
1738 break;
1739 case blr_lss:
1740 newBlrOp = blr_geq;
1741 break;
1742 case blr_gtr:
1743 newBlrOp = blr_leq;
1744 break;
1745 case blr_leq:
1746 newBlrOp = blr_gtr;
1747 break;
1748 case blr_geq:
1749 newBlrOp = blr_lss;
1750 break;
1751 default:
1752 fb_assert(false);
1753 return NULL;
1754 }
1755

Callers 2

executeMethod · 0.45
stringBooleanMethod · 0.45

Calls 4

NotBoolNodeClass · 0.85
ComparativeBoolNodeClass · 0.70
BinaryBoolNodeClass · 0.70
dsqlPassMethod · 0.45

Tested by

no test coverage detected