From f6ac9bd2b2ad1b153d3f77cf58f2e312ad6ad26f Mon Sep 17 00:00:00 2001 From: Roberto Raggi <roberto.raggi@nokia.com> Date: Fri, 13 Aug 2010 15:16:13 +0200 Subject: [PATCH] Process switch statements and handle Q/D pointers. --- src/shared/cplusplus/Bind.cpp | 45 +++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/src/shared/cplusplus/Bind.cpp b/src/shared/cplusplus/Bind.cpp index f9c20e7ac95..7ee2d8cf1bf 100644 --- a/src/shared/cplusplus/Bind.cpp +++ b/src/shared/cplusplus/Bind.cpp @@ -1088,18 +1088,38 @@ FullySpecifiedType Bind::trailingReturnType(TrailingReturnTypeAST *ast, const Fu // StatementAST bool Bind::visit(QtMemberDeclarationAST *ast) { - // unsigned q_token = ast->q_token; - // unsigned lparen_token = ast->lparen_token; - ExpressionTy type_id = this->expression(ast->type_id); - // unsigned rparen_token = ast->rparen_token; + const Name *name = 0; + + if (tokenKind(ast->q_token) == T_Q_D) + name = control()->nameId(control()->identifier("d")); + else + name = control()->nameId(control()->identifier("q")); + + FullySpecifiedType declTy = this->expression(ast->type_id); + + if (tokenKind(ast->q_token) == T_Q_D) { + if (NamedType *namedTy = declTy->asNamedType()) { + if (const NameId *nameId = namedTy->name()->asNameId()) { + std::string privateClass; + privateClass += nameId->identifier()->chars(); + privateClass += "Private"; + + const Name *privName = control()->nameId(control()->identifier(privateClass.c_str(), privateClass.size())); + declTy.setType(control()->namedType(privName)); + } + } + } + + Declaration *symbol = control()->newDeclaration(/*generated*/ 0, name); + symbol->setType(control()->pointerType(declTy)); + + _scope->addMember(symbol); return false; } bool Bind::visit(CaseStatementAST *ast) { - // unsigned case_token = ast->case_token; ExpressionTy expression = this->expression(ast->expression); - // unsigned colon_token = ast->colon_token; this->statement(ast->statement); return false; } @@ -1257,12 +1277,17 @@ bool Bind::visit(ReturnStatementAST *ast) bool Bind::visit(SwitchStatementAST *ast) { - // unsigned switch_token = ast->switch_token; - // unsigned lparen_token = ast->lparen_token; + Block *block = control()->newBlock(ast->firstToken()); + const unsigned startScopeToken = ast->lparen_token ? ast->lastToken() : ast->firstToken(); + block->setStartOffset(tokenAt(startScopeToken).end()); + block->setEndOffset(tokenAt(ast->lastToken() - 1).end()); + _scope->addMember(block); + ast->symbol = block; + + Scope *previousScope = switchScope(block); ExpressionTy condition = this->expression(ast->condition); - // unsigned rparen_token = ast->rparen_token; this->statement(ast->statement); - // Block *symbol = ast->symbol; + (void) switchScope(previousScope); return false; } -- GitLab