| 253 | //--------------------------------------------------------------------------- |
| 254 | |
| 255 | Token *TokenList::copyTokens(Token *dest, const Token *first, const Token *last, bool one_line) |
| 256 | { |
| 257 | std::stack<Token *> links; |
| 258 | Token *tok2 = dest; |
| 259 | int linenr = dest->linenr(); |
| 260 | const int commonFileIndex = dest->fileIndex(); |
| 261 | for (const Token *tok = first; tok != last->next(); tok = tok->next()) { |
| 262 | tok2->insertToken(tok->str()); |
| 263 | tok2 = tok2->next(); |
| 264 | tok2->fileIndex(commonFileIndex); |
| 265 | tok2->linenr(linenr); |
| 266 | tok2->tokType(tok->tokType()); |
| 267 | tok2->flags(tok->flags()); |
| 268 | tok2->varId(tok->varId()); |
| 269 | tok2->setTokenDebug(tok->getTokenDebug()); |
| 270 | |
| 271 | // Check for links and fix them up |
| 272 | if (Token::Match(tok2, "(|[|{")) |
| 273 | links.push(tok2); |
| 274 | else if (Token::Match(tok2, ")|]|}")) { |
| 275 | if (links.empty()) |
| 276 | return tok2; |
| 277 | |
| 278 | Token * link = links.top(); |
| 279 | |
| 280 | tok2->link(link); |
| 281 | link->link(tok2); |
| 282 | |
| 283 | links.pop(); |
| 284 | } |
| 285 | if (!one_line && tok->next()) |
| 286 | linenr += tok->next()->linenr() - tok->linenr(); |
| 287 | } |
| 288 | return tok2; |
| 289 | } |
| 290 | |
| 291 | //--------------------------------------------------------------------------- |
| 292 | // InsertTokens - Copy and insert tokens |
nothing calls this directly
no test coverage detected