Refactor: Deduplicate code for AND
and OR
handling in if()
command
Signed-off-by: Alex Turbov <i.zaufi@gmail.com>
This commit is contained in:
parent
95fc27cedd
commit
314538703a
@ -687,29 +687,22 @@ bool cmConditionEvaluator::HandleLevel4(cmArgumentList& newArgs,
|
|||||||
MessageType& status)
|
MessageType& status)
|
||||||
{
|
{
|
||||||
bool reducible;
|
bool reducible;
|
||||||
bool lhs;
|
|
||||||
bool rhs;
|
|
||||||
do {
|
do {
|
||||||
reducible = false;
|
reducible = false;
|
||||||
for (auto arg = newArgs.begin(), argP1 = arg, argP2 = arg;
|
for (auto arg = newArgs.begin(), argP1 = arg, argP2 = arg;
|
||||||
arg != newArgs.end(); argP1 = ++arg) {
|
arg != newArgs.end(); argP1 = ++arg) {
|
||||||
IncrementArguments(newArgs, argP1, argP2);
|
IncrementArguments(newArgs, argP1, argP2);
|
||||||
if (argP1 != newArgs.end() && this->IsKeyword(keyAND, *argP1) &&
|
if (argP1 != newArgs.end() &&
|
||||||
|
(this->IsKeyword(keyAND, *argP1) ||
|
||||||
|
this->IsKeyword(keyOR, *argP1)) &&
|
||||||
argP2 != newArgs.end()) {
|
argP2 != newArgs.end()) {
|
||||||
lhs =
|
const auto lhs =
|
||||||
this->GetBooleanValueWithAutoDereference(*arg, errorString, status);
|
this->GetBooleanValueWithAutoDereference(*arg, errorString, status);
|
||||||
rhs = this->GetBooleanValueWithAutoDereference(*argP2, errorString,
|
const auto rhs = this->GetBooleanValueWithAutoDereference(
|
||||||
status);
|
*argP2, errorString, status);
|
||||||
HandleBinaryOp((lhs && rhs), reducible, arg, newArgs, argP1, argP2);
|
HandleBinaryOp(this->IsKeyword(keyAND, *argP1) ? (lhs && rhs)
|
||||||
}
|
: (lhs || rhs),
|
||||||
|
reducible, arg, newArgs, argP1, argP2);
|
||||||
if (argP1 != newArgs.end() && this->IsKeyword(keyOR, *argP1) &&
|
|
||||||
argP2 != newArgs.end()) {
|
|
||||||
lhs =
|
|
||||||
this->GetBooleanValueWithAutoDereference(*arg, errorString, status);
|
|
||||||
rhs = this->GetBooleanValueWithAutoDereference(*argP2, errorString,
|
|
||||||
status);
|
|
||||||
HandleBinaryOp((lhs || rhs), reducible, arg, newArgs, argP1, argP2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (reducible);
|
} while (reducible);
|
||||||
|
Loading…
Reference in New Issue
Block a user