| 1420 | } |
| 1421 | |
| 1422 | void Token::astParent(Token* tok) |
| 1423 | { |
| 1424 | const Token* tok2 = tok; |
| 1425 | while (tok2) { |
| 1426 | if (this == tok2) |
| 1427 | throw InternalError(this, "Internal error. AST cyclic dependency."); |
| 1428 | tok2 = tok2->astParent(); |
| 1429 | } |
| 1430 | // Clear children to avoid nodes referenced twice |
| 1431 | if (this->astParent()) { |
| 1432 | Token* parent = this->astParent(); |
| 1433 | if (parent->astOperand1() == this) |
| 1434 | parent->mImpl->mAstOperand1 = nullptr; |
| 1435 | if (parent->astOperand2() == this) |
| 1436 | parent->mImpl->mAstOperand2 = nullptr; |
| 1437 | } |
| 1438 | mImpl->mAstParent = tok; |
| 1439 | } |
| 1440 | |
| 1441 | void Token::astOperand1(Token *tok) |
| 1442 | { |