| 1229 | } |
| 1230 | |
| 1231 | void simplecpp::TokenList::constFoldAddSub(Token *tok) |
| 1232 | { |
| 1233 | for (; tok && tok->op != ')'; tok = tok->next) { |
| 1234 | if (!tok->previous || !tok->previous->number) |
| 1235 | continue; |
| 1236 | if (!tok->next || !tok->next->number) |
| 1237 | continue; |
| 1238 | |
| 1239 | long long result; |
| 1240 | if (tok->op == '+') |
| 1241 | result = stringToLL(tok->previous->str()) + stringToLL(tok->next->str()); |
| 1242 | else if (tok->op == '-') |
| 1243 | result = stringToLL(tok->previous->str()) - stringToLL(tok->next->str()); |
| 1244 | else |
| 1245 | continue; |
| 1246 | |
| 1247 | tok = tok->previous; |
| 1248 | tok->setstr(toString(result)); |
| 1249 | deleteToken(tok->next); |
| 1250 | deleteToken(tok->next); |
| 1251 | } |
| 1252 | } |
| 1253 | |
| 1254 | void simplecpp::TokenList::constFoldShift(Token *tok) |
| 1255 | { |
nothing calls this directly
no test coverage detected