| 772 | } |
| 773 | |
| 774 | Token *clangimport::AstNode::createTokens(TokenList &tokenList) |
| 775 | { |
| 776 | if (nodeType == ArraySubscriptExpr) { |
| 777 | Token *array = getChild(0)->createTokens(tokenList); |
| 778 | Token *bracket1 = addtoken(tokenList, "["); |
| 779 | Token *index = children[1]->createTokens(tokenList); |
| 780 | Token *bracket2 = addtoken(tokenList, "]"); |
| 781 | bracket1->astOperand1(array); |
| 782 | bracket1->astOperand2(index); |
| 783 | bracket1->link(bracket2); |
| 784 | bracket2->link(bracket1); |
| 785 | return bracket1; |
| 786 | } |
| 787 | if (nodeType == BinaryOperator) { |
| 788 | Token *tok1 = getChild(0)->createTokens(tokenList); |
| 789 | Token *binop = addtoken(tokenList, unquote(mExtTokens.back())); |
| 790 | Token *tok2 = children[1]->createTokens(tokenList); |
| 791 | binop->astOperand1(tok1); |
| 792 | binop->astOperand2(tok2); |
| 793 | return binop; |
| 794 | } |
| 795 | if (nodeType == BreakStmt) |
| 796 | return addtoken(tokenList, "break"); |
| 797 | if (nodeType == CharacterLiteral) { |
| 798 | const int c = static_cast<int>(MathLib::toBigNumber(mExtTokens.back())); |
| 799 | if (c == 0) |
| 800 | return addtoken(tokenList, "\'\\0\'"); |
| 801 | if (c == '\r') |
| 802 | return addtoken(tokenList, "\'\\r\'"); |
| 803 | if (c == '\n') |
| 804 | return addtoken(tokenList, "\'\\n\'"); |
| 805 | if (c == '\t') |
| 806 | return addtoken(tokenList, "\'\\t\'"); |
| 807 | if (c == '\\') |
| 808 | return addtoken(tokenList, "\'\\\\\'"); |
| 809 | if (c < ' ' || c >= 0x80) { |
| 810 | std::ostringstream hex; |
| 811 | hex << std::hex << ((c>>4) & 0xf) << (c&0xf); |
| 812 | return addtoken(tokenList, "\'\\x" + hex.str() + "\'"); |
| 813 | } |
| 814 | return addtoken(tokenList, std::string("\'") + char(c) + std::string("\'")); |
| 815 | } |
| 816 | if (nodeType == CallExpr) |
| 817 | return createTokensCall(tokenList); |
| 818 | if (nodeType == CaseStmt) { |
| 819 | Token *caseToken = addtoken(tokenList, "case"); |
| 820 | Token *exprToken = getChild(0)->createTokens(tokenList); |
| 821 | caseToken->astOperand1(exprToken); |
| 822 | addtoken(tokenList, ":"); |
| 823 | children.back()->createTokens(tokenList); |
| 824 | return nullptr; |
| 825 | } |
| 826 | if (nodeType == ClassTemplateDecl) { |
| 827 | for (const AstNodePtr& child: children) { |
| 828 | if (child->nodeType == ClassTemplateSpecializationDecl) |
| 829 | child->createTokens(tokenList); |
| 830 | } |
| 831 | return nullptr; |
no test coverage detected