| 1347 | |
| 1348 | static const std::string OR("or"); |
| 1349 | void simplecpp::TokenList::constFoldLogicalOp(Token *tok) |
| 1350 | { |
| 1351 | for (; tok && tok->op != ')'; tok = tok->next) { |
| 1352 | if (tok->name) { |
| 1353 | if (isAlternativeBinaryOp(tok,AND)) |
| 1354 | tok->setstr("&&"); |
| 1355 | else if (isAlternativeBinaryOp(tok,OR)) |
| 1356 | tok->setstr("||"); |
| 1357 | } |
| 1358 | if (tok->str() != "&&" && tok->str() != "||") |
| 1359 | continue; |
| 1360 | if (!tok->previous || !tok->previous->number) |
| 1361 | continue; |
| 1362 | if (!tok->next || !tok->next->number) |
| 1363 | continue; |
| 1364 | |
| 1365 | int result; |
| 1366 | if (tok->str() == "||") |
| 1367 | result = (stringToLL(tok->previous->str()) || stringToLL(tok->next->str())); |
| 1368 | else /*if (tok->str() == "&&")*/ |
| 1369 | result = (stringToLL(tok->previous->str()) && stringToLL(tok->next->str())); |
| 1370 | |
| 1371 | tok = tok->previous; |
| 1372 | tok->setstr(toString(result)); |
| 1373 | deleteToken(tok->next); |
| 1374 | deleteToken(tok->next); |
| 1375 | } |
| 1376 | } |
| 1377 | |
| 1378 | void simplecpp::TokenList::constFoldQuestionOp(Token *&tok1) |
| 1379 | { |
nothing calls this directly
no test coverage detected